2024-10-29 19:33:26 -04:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
@available(iOS 15.0, *)
|
|
|
|
struct CompactPriceView: View {
|
2024-11-20 02:57:42 -04:00
|
|
|
@Environment(\.colorScheme) var colorScheme
|
|
|
|
|
2024-10-29 19:33:26 -04:00
|
|
|
let price: String
|
|
|
|
let lastUpdated: String
|
2024-10-30 19:16:03 -04:00
|
|
|
let code: String
|
2024-10-29 19:33:26 -04:00
|
|
|
let dataSource: String
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
VStack(alignment: .center, spacing: 16) {
|
|
|
|
Text(price)
|
|
|
|
.font(.title)
|
|
|
|
.bold()
|
2024-11-20 02:57:42 -04:00
|
|
|
.foregroundColor(priceTextColor)
|
|
|
|
.shadow(color: Color.black.opacity(0.2), radius: 1, x: 0, y: 1)
|
2024-10-29 19:33:26 -04:00
|
|
|
.multilineTextAlignment(.center)
|
|
|
|
.dynamicTypeSize(.large ... .accessibility5)
|
|
|
|
.accessibilityLabel("Bitcoin price: \(price)")
|
|
|
|
|
2024-10-30 19:16:03 -04:00
|
|
|
VStack(alignment: .center, spacing: 8) {
|
2024-11-20 02:57:42 -04:00
|
|
|
Text(code)
|
|
|
|
Text(lastUpdated)
|
|
|
|
Text(dataSource)
|
2024-10-29 19:33:26 -04:00
|
|
|
}
|
|
|
|
.font(.subheadline)
|
2024-11-20 08:58:59 -04:00
|
|
|
.foregroundColor(secondaryTextColor)
|
2024-10-29 19:33:26 -04:00
|
|
|
.multilineTextAlignment(.center)
|
|
|
|
.accessibilityElement(children: .combine)
|
|
|
|
}
|
|
|
|
.padding()
|
|
|
|
.frame(maxWidth: .infinity)
|
|
|
|
}
|
2024-11-20 02:57:42 -04:00
|
|
|
|
|
|
|
// Adaptive color for the price text using system built-in colors
|
|
|
|
var priceTextColor: Color {
|
|
|
|
colorScheme == .dark ? .cyan : .blue
|
|
|
|
}
|
2024-11-20 08:58:59 -04:00
|
|
|
|
|
|
|
// Improved secondary text color for better readability
|
|
|
|
var secondaryTextColor: Color {
|
|
|
|
colorScheme == .dark ? .white : .black
|
|
|
|
}
|
|
|
|
}
|