Skip to content

Commit ae5917c

Browse files
authored
Merge pull request #458 from CodeByMiniOrg/no-invisible-input
Change input fields to be masked instead of invisible in screenshots
2 parents b98e26d + e0abc6b commit ae5917c

File tree

1 file changed

+35
-27
lines changed

1 file changed

+35
-27
lines changed

LoopFollow/Helpers/Views/TogglableSecureInput.swift

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,22 @@ struct TogglableSecureInput: View {
2020
Group {
2121
switch style {
2222
case .singleLine:
23-
if isVisible {
24-
TextField(placeholder, text: $text)
25-
.multilineTextAlignment(.trailing)
26-
.textContentType(textContentType)
27-
.submitLabel(.done)
28-
.focused($isFocused)
29-
} else {
30-
SecureField(placeholder, text: $text)
31-
.multilineTextAlignment(.trailing)
32-
.textContentType(textContentType)
33-
.submitLabel(.done)
34-
.focused($isFocused)
23+
ZStack(alignment: .trailing) {
24+
if isVisible {
25+
TextField(placeholder, text: $text)
26+
.multilineTextAlignment(.trailing)
27+
.textContentType(textContentType)
28+
.submitLabel(.done)
29+
.focused($isFocused)
30+
} else {
31+
HStack {
32+
Spacer()
33+
Text(maskString)
34+
.font(.body.monospaced())
35+
.foregroundColor(.primary)
36+
.allowsHitTesting(false)
37+
}
38+
}
3539
}
3640

3741
case .multiLine:
@@ -53,15 +57,13 @@ struct TogglableSecureInput: View {
5357
}
5458

5559
if !isVisible {
56-
Text(maskString)
57-
.font(.body.monospaced())
58-
.foregroundColor(.primary)
59-
.frame(maxWidth: .infinity,
60-
maxHeight: .infinity,
61-
alignment: .topLeading)
62-
.padding(.top, 8)
63-
.padding(.leading, 5)
64-
.allowsHitTesting(false)
60+
HStack {
61+
Spacer()
62+
Text(maskString)
63+
.font(.body.monospaced())
64+
.foregroundColor(.primary)
65+
.allowsHitTesting(false)
66+
}
6567
}
6668
}
6769
.frame(minHeight: 100)
@@ -80,13 +82,19 @@ struct TogglableSecureInput: View {
8082
}
8183
.contentShape(Rectangle())
8284
.onTapGesture {
83-
if style == .multiLine && !isVisible {
85+
if !isVisible {
8486
isVisible = true
85-
isMultilineFocused = true
86-
} else if style == .singleLine {
87-
isFocused = true
88-
} else if style == .multiLine && isVisible {
89-
isMultilineFocused = true
87+
if style == .singleLine {
88+
isFocused = true
89+
} else if style == .multiLine {
90+
isMultilineFocused = true
91+
}
92+
} else {
93+
if style == .singleLine {
94+
isFocused = true
95+
} else if style == .multiLine {
96+
isMultilineFocused = true
97+
}
9098
}
9199
}
92100
}

0 commit comments

Comments
 (0)