Skip to content

Commit

Permalink
Add CurrencyPicker
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanov91 committed Jul 15, 2023
1 parent e676db4 commit 3d352ee
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
49 changes: 49 additions & 0 deletions Sources/OversizeComponents/CurrencyPicker/CurrencyPicker.swift
Original file line number Diff line number Diff line change
@@ -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<Locale.Currency>
) {
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"))
}
}
6 changes: 3 additions & 3 deletions Sources/OversizeComponents/PhoneSheet/PhoneSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public struct PhoneSheetNumber: Hashable {
}
}

public struct PhoneSheet: View {
public struct PhoneCallSheet: View {
private let numbers: [PhoneSheetNumber]
private let title: String

Expand Down Expand Up @@ -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"),
])
Expand Down

0 comments on commit 3d352ee

Please sign in to comment.