# HG changeset patch # User Dennis Concepcion Martin # Date 1640272996 -3600 # Node ID e4f5dcf4d59658bd7414dea6e77b33e8c23d7382 # Parent 13d5a8deb6c239baf506f631df1d7c6beaa23709 add keyboard resign option diff -r 13d5a8deb6c2 -r e4f5dcf4d596 Simoleon.xcodeproj/project.pbxproj --- a/Simoleon.xcodeproj/project.pbxproj Thu Dec 23 16:12:22 2021 +0100 +++ b/Simoleon.xcodeproj/project.pbxproj Thu Dec 23 16:23:16 2021 +0100 @@ -560,6 +560,7 @@ ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Simoleon/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = Simoleon; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; @@ -591,6 +592,7 @@ ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Simoleon/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = Simoleon; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; diff -r 13d5a8deb6c2 -r e4f5dcf4d596 Simoleon/ConversionView.swift --- 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() diff -r 13d5a8deb6c2 -r e4f5dcf4d596 Simoleon/Helpers/CurrencyTextfield.swift --- a/Simoleon/Helpers/CurrencyTextfield.swift Thu Dec 23 16:12:22 2021 +0100 +++ b/Simoleon/Helpers/CurrencyTextfield.swift Thu Dec 23 16:23:16 2021 +0100 @@ -12,7 +12,6 @@ @Binding var amount: String var body: some View { - VStack { TextField("Enter the amount", text: $amount) .keyboardType(.decimalPad) .font(.title2) @@ -22,7 +21,6 @@ .cornerRadius(15) .frame(height: 55) ) - } } }