diff options
| author | Bug Magnet <marco.nikic@mullvad.net> | 2025-02-07 09:52:27 +0100 |
|---|---|---|
| committer | Bug Magnet <marco.nikic@mullvad.net> | 2025-02-07 09:52:27 +0100 |
| commit | 7251f29a66ed7f25b7a0184d4e7bf0e3d7bfef84 (patch) | |
| tree | 0ec6098181d924e9906c231d8fab6553d9e03a87 | |
| parent | f278ba37d6aa88b0eaec80f1785938fb885c9eb6 (diff) | |
| parent | 3daaaf365334a5d68dfaa955430ae7a4f3624e2d (diff) | |
| download | mullvadvpn-7251f29a66ed7f25b7a0184d4e7bf0e3d7bfef84.tar.xz mullvadvpn-7251f29a66ed7f25b7a0184d4e7bf0e3d7bfef84.zip | |
Merge branch 'ios-1052-singlechoicelist-wonkiness'
| -rw-r--r-- | ios/MullvadVPN/View controllers/Settings/SwiftUI components/SingleChoiceList.swift | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/ios/MullvadVPN/View controllers/Settings/SwiftUI components/SingleChoiceList.swift b/ios/MullvadVPN/View controllers/Settings/SwiftUI components/SingleChoiceList.swift index 3560a870d6..df39f51bee 100644 --- a/ios/MullvadVPN/View controllers/Settings/SwiftUI components/SingleChoiceList.swift +++ b/ios/MullvadVPN/View controllers/Settings/SwiftUI components/SingleChoiceList.swift @@ -59,6 +59,8 @@ struct SingleChoiceList<Value>: View where Value: Equatable { let tableAccessibilityIdentifier: String let itemDescription: (Value) -> String let customFieldMode: CustomFieldMode + // a latch to keep the custom field selected through changes of focus until the user taps elsewhere + @State var customFieldSelected = false /// The configuration for the field for a custom value row enum CustomFieldMode { @@ -206,7 +208,7 @@ struct SingleChoiceList<Value>: View where Value: Equatable { // Construct a literal row for a specific literal value private func literalRow(_ item: Value) -> some View { row( - isSelected: value.wrappedValue == item && !customValueIsFocused + isSelected: value.wrappedValue == item && !customFieldSelected ) { Text(verbatim: itemDescription(item)) Spacer() @@ -215,6 +217,7 @@ struct SingleChoiceList<Value>: View where Value: Equatable { value.wrappedValue = item customValueIsFocused = false customValueInput = "" + customFieldSelected = false } } @@ -229,7 +232,7 @@ struct SingleChoiceList<Value>: View where Value: Equatable { fromValue: @escaping (Value) -> String? ) -> some View { row( - isSelected: value.wrappedValue == toValue(customValueInput) || customValueIsFocused + isSelected: value.wrappedValue == toValue(customValueInput) || customFieldSelected ) { Text(label) Spacer() @@ -304,6 +307,7 @@ struct SingleChoiceList<Value>: View where Value: Equatable { } } .onTapGesture { + customFieldSelected = true if let v = toValue(customValueInput) { value.wrappedValue = v } else { @@ -343,6 +347,7 @@ struct SingleChoiceList<Value>: View where Value: Equatable { switch opt.value { case let .literal(v): literalRow(v) + .listRowSeparator(.hidden) case let .custom( label, prompt, @@ -360,8 +365,10 @@ struct SingleChoiceList<Value>: View where Value: Equatable { toValue: toValue, fromValue: fromValue ) + .listRowSeparator(.hidden) if let legend { subtitleRow(legend) + .listRowSeparator(.hidden) } } } |
