Bladeren bron

Change input fields to be masked instead of invisible in screenshots

codebymini 11 maanden geleden
bovenliggende
commit
6aa0239fa8
1 gewijzigde bestanden met toevoegingen van 23 en 21 verwijderingen
  1. 23 21
      LoopFollow/Helpers/Views/TogglableSecureInput.swift

+ 23 - 21
LoopFollow/Helpers/Views/TogglableSecureInput.swift

@@ -20,18 +20,22 @@ struct TogglableSecureInput: View {
             Group {
                 switch style {
                 case .singleLine:
-                    if isVisible {
-                        TextField(placeholder, text: $text)
-                            .multilineTextAlignment(.trailing)
-                            .textContentType(textContentType)
-                            .submitLabel(.done)
-                            .focused($isFocused)
-                    } else {
-                        SecureField(placeholder, text: $text)
-                            .multilineTextAlignment(.trailing)
-                            .textContentType(textContentType)
-                            .submitLabel(.done)
-                            .focused($isFocused)
+                    ZStack(alignment: .trailing) {
+                        if isVisible {
+                            TextField(placeholder, text: $text)
+                                .multilineTextAlignment(.trailing)
+                                .textContentType(textContentType)
+                                .submitLabel(.done)
+                                .focused($isFocused)
+                        } else {
+                            HStack {
+                                Spacer()
+                                Text(maskString)
+                                    .font(.body.monospaced())
+                                    .foregroundColor(.primary)
+                                    .allowsHitTesting(false)
+                            }
+                        }
                     }
 
                 case .multiLine:
@@ -53,15 +57,13 @@ struct TogglableSecureInput: View {
                             }
 
                         if !isVisible {
-                            Text(maskString)
-                                .font(.body.monospaced())
-                                .foregroundColor(.primary)
-                                .frame(maxWidth: .infinity,
-                                       maxHeight: .infinity,
-                                       alignment: .topLeading)
-                                .padding(.top, 8)
-                                .padding(.leading, 5)
-                                .allowsHitTesting(false)
+                            HStack {
+                                Spacer()
+                                Text(maskString)
+                                    .font(.body.monospaced())
+                                    .foregroundColor(.primary)
+                                    .allowsHitTesting(false)
+                            }
                         }
                     }
                     .frame(minHeight: 100)