diff --git a/Sources/OversizeComponents/CurrencyPicker/CurrencyPicker.swift b/Sources/OversizeComponents/CurrencyPicker/CurrencyPicker.swift new file mode 100644 index 0000000..c763c04 --- /dev/null +++ b/Sources/OversizeComponents/CurrencyPicker/CurrencyPicker.swift @@ -0,0 +1,49 @@ +// +// Copyright © 2023 Alexander Romanov +// CurrencyPicker.swift, created on 14.07.2023 +// + +import OversizeCore +import OversizeUI +import SwiftUI + +@available(macOS 13, iOS 16, tvOS 16, watchOS 9, *) +public struct CurrencyPicker: View { + @Environment(\.theme) private var theme: ThemeSettings + @Binding private var selection: Locale.Currency + private let label: String + private let currencies: [Locale.Currency] + @State private var showModal = false + + public init( + _ sheetTitle: String = "Currency", + currencies: [Locale.Currency] = Locale.Currency.countryCurrencies, + selection: Binding + ) { + label = sheetTitle + _selection = selection + self.currencies = currencies + } + + public var body: some View { + Select(label, currencies, selection: $selection) { element, _ in + Row(element.dispalyName ?? element.identifier) { + ZStack { + RoundedRectangle(cornerRadius: .small, style: .continuous) + .fill(Color.surfaceSecondary) + .frame(width: 52, height: 36) + Text(element.dispalySymbol ?? element.identifier) + } + } + } selectionView: { element in + Text(element.dispalyName ?? label) + } + } +} + +@available(macOS 13, iOS 16, tvOS 16, watchOS 9, *) +struct CurrencyPicker_Previews: PreviewProvider { + static var previews: some View { + CurrencyPicker(selection: .constant("USD")) + } +} diff --git a/Sources/OversizeComponents/PhoneSheet/PhoneSheet.swift b/Sources/OversizeComponents/PhoneSheet/PhoneSheet.swift index 8433727..7a49a6e 100644 --- a/Sources/OversizeComponents/PhoneSheet/PhoneSheet.swift +++ b/Sources/OversizeComponents/PhoneSheet/PhoneSheet.swift @@ -16,7 +16,7 @@ public struct PhoneSheetNumber: Hashable { } } -public struct PhoneSheet: View { +public struct PhoneCallSheet: View { private let numbers: [PhoneSheetNumber] private let title: String @@ -49,9 +49,9 @@ public struct PhoneSheet: View { } } -struct PhoneSheet_Previews: PreviewProvider { +struct PhoneCallSheet_Previews: PreviewProvider { static var previews: some View { - PhoneSheet("Phones", numbers: [ + PhoneCallSheet("Phones", numbers: [ PhoneSheetNumber(name: "Mobile", phone: "+1 (342) 345 45 42"), PhoneSheetNumber(name: "Home", phone: "+1 (435) 234 34 23"), ])