mirror of
https://github.com/ProtonMail/protoncore_ios.git
synced 2026-01-17 07:10:01 +00:00
fix(SSO): CP-9303 Change to upper case letters for confirmation code
Refs: https://gitlab.protontech.ch/apple/shared/protoncore/-/merge_requests/2052
This commit is contained in:
commit
6ee2b0d1d7
2 changed files with 4 additions and 6 deletions
|
|
@ -63,13 +63,14 @@ public struct PCCodeInput: View {
|
|||
TextField("", text: $content.code)
|
||||
.focused($isFocused)
|
||||
.keyboardType(.alphabet)
|
||||
.textInputAutocapitalization(content.autocapitalization)
|
||||
.textInputAutocapitalization(.characters)
|
||||
.autocorrectionDisabled()
|
||||
.onReceive(Just(content.code)) { _ in limitText(text: $content.code, limit: content.codeLength) }
|
||||
.opacity(.zero)
|
||||
}
|
||||
}
|
||||
.onChange(of: content.code, perform: { newValue in
|
||||
content.code = content.code.uppercased()
|
||||
for idx in 0..<codeArray.count {
|
||||
if idx < content.code.count {
|
||||
codeArray[idx] = String(content.code[idx])
|
||||
|
|
@ -125,7 +126,7 @@ public struct PCCodeInput: View {
|
|||
&& ( nextField || lastCharacterFilled )
|
||||
}
|
||||
|
||||
func limitText(text: Binding<String>, limit: Int) {
|
||||
private func limitText(text: Binding<String>, limit: Int) {
|
||||
if text.wrappedValue.count > limit {
|
||||
text.wrappedValue = String(text.wrappedValue.prefix(limit))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,16 +29,13 @@ public struct PCCodeInputContent {
|
|||
public var code: String = ""
|
||||
public var isFocused: Bool = false
|
||||
public var codeLength: Int
|
||||
public var autocapitalization: TextInputAutocapitalization
|
||||
|
||||
public init(
|
||||
title: String,
|
||||
length: Int = 4,
|
||||
autocapitalization: TextInputAutocapitalization = .characters
|
||||
length: Int = 4
|
||||
) {
|
||||
self.title = title
|
||||
self.codeLength = length
|
||||
self.autocapitalization = autocapitalization
|
||||
}
|
||||
|
||||
public mutating func focus() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue