Mercurial > public > simoleon
diff Simoleon/ConversionView.swift @ 188:e4f5dcf4d596
add keyboard resign option
author | Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com> |
---|---|
date | Thu, 23 Dec 2021 16:23:16 +0100 |
parents | 13d5a8deb6c2 |
children |
line wrap: on
line diff
--- a/Simoleon/ConversionView.swift Thu Dec 23 16:12:22 2021 +0100 +++ b/Simoleon/ConversionView.swift Thu Dec 23 16:23:16 2021 +0100 @@ -26,6 +26,9 @@ // Update currency rates @State private var timer = Timer.publish(every: 3, on: .main, in: .common).autoconnect() + // CurrencyTextfield variables + @FocusState private var textfieldIsFocused: Bool + var body: some View { ScrollView(showsIndicators: false) { VStack(alignment: .leading, spacing: 20) { @@ -51,6 +54,7 @@ .fontWeight(.semibold) CurrencyTextfield(currencyCode: baseCurrency.code, amount: $amount) + .focused($textfieldIsFocused) Divider() Text("\(quoteCurrency.code) - \(quoteCurrency.name)") @@ -68,6 +72,15 @@ CurrencyList(baseCurrency: $baseCurrency, quoteCurrency: $quoteCurrency, selecting: selecting) } } + .toolbar { + ToolbarItem(placement: .confirmationAction) { + if textfieldIsFocused { + Button("Done") { + textfieldIsFocused = false + } + } + } + } .onAppear { getConversion() timer = Timer.publish(every: 3, on: .main, in: .common).autoconnect()