diff options
Diffstat (limited to 'ios/MullvadVPN/Views')
| -rw-r--r-- | ios/MullvadVPN/Views/MullvadPrimaryTextField.swift | 33 | ||||
| -rw-r--r-- | ios/MullvadVPN/Views/MullvadProgressViewStyle.swift | 8 |
2 files changed, 29 insertions, 12 deletions
diff --git a/ios/MullvadVPN/Views/MullvadPrimaryTextField.swift b/ios/MullvadVPN/Views/MullvadPrimaryTextField.swift index 0ee481afab..a170e17392 100644 --- a/ios/MullvadVPN/Views/MullvadPrimaryTextField.swift +++ b/ios/MullvadVPN/Views/MullvadPrimaryTextField.swift @@ -6,19 +6,22 @@ struct MullvadPrimaryTextField: View { @Binding private var text: String @Binding private var suggestion: String? private let validate: ((String) -> Bool)? + private let keyboardType: UIKeyboardType? init( label: String, placeholder: String, text: Binding<String>, suggestion: Binding<String?>? = nil, - validate: ((String) -> Bool)? = nil + validate: ((String) -> Bool)? = nil, + keyboardType: UIKeyboardType? = nil ) { self.label = label self.placeholder = placeholder self._text = text self._suggestion = suggestion ?? .constant(nil) self.validate = validate + self.keyboardType = keyboardType } var isValid: Bool { @@ -38,22 +41,30 @@ struct MullvadPrimaryTextField: View { return false } + private var textFieldComponent: some View { + TextField( + placeholder, + text: $text, + prompt: Text(placeholder) + .foregroundColor( + isEnabled ? .MullvadTextField.inputPlaceholder : .MullvadTextField.textDisabled + ) + ) + .focused($isFocused) + .padding(.vertical, 12) + } + var body: some View { VStack(alignment: .leading) { Text(label) .foregroundColor(.MullvadTextField.label) VStack(spacing: 0) { HStack(spacing: 4) { - TextField( - placeholder, - text: $text, - prompt: Text(placeholder) - .foregroundColor( - isEnabled ? .MullvadTextField.inputPlaceholder : .MullvadTextField.textDisabled - ) - ) - .focused($isFocused) - .padding(.vertical, 12) + if let keyboardType { + textFieldComponent.keyboardType(keyboardType) + } else { + textFieldComponent + } if !text.isEmpty && isEnabled { Button { withAnimation { diff --git a/ios/MullvadVPN/Views/MullvadProgressViewStyle.swift b/ios/MullvadVPN/Views/MullvadProgressViewStyle.swift index 80a3b4bbef..e12a791bb9 100644 --- a/ios/MullvadVPN/Views/MullvadProgressViewStyle.swift +++ b/ios/MullvadVPN/Views/MullvadProgressViewStyle.swift @@ -1,11 +1,17 @@ import SwiftUI struct MullvadProgressViewStyle: ProgressViewStyle { + let size: CGFloat + + init(size: CGFloat = 48) { + self.size = size + } + @State var isAnimating = false func makeBody(configuration: Configuration) -> some View { Image.mullvadIconSpinner .resizable() - .frame(maxWidth: 48, maxHeight: 48) + .frame(maxWidth: size, maxHeight: size) .rotationEffect(.degrees(isAnimating ? 360 : 0)) .onAppear { withAnimation( |
