The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 18:30 UTC
feat(mobile): secret field gets an eye toggle to show what you typed (#35783)
* feat(mobile): secret field gets an eye toggle to show what you typed
Theo Browne committed
Nov 12, 2026 at 18:35 UTC
7fb54eb0510df3e8effbdb403ab6cfe38a2e02bb
4 files changed
+74
-18
apps/mobile/modules/t3-native-controls/android/src/main/java/expo/modules/t3nativecontrols/T3SecretInputModule.kt
+14
@@ -7,6 +7,7 @@ import android.os.Build
7
import android.text.Editable
8
import android.text.InputType
9
import android.text.TextWatcher
10
+import android.text.method.PasswordTransformationMethod
11
import android.util.TypedValue
12
import android.view.Gravity
13
import android.view.KeyEvent
@@ -42,6 +43,7 @@ class T3SecretInputModule : Module() {
43
view.input.setTextSize(TypedValue.COMPLEX_UNIT_DIP, value)
44
}
45
Prop("editable") { view: T3SecretInputView, value: Boolean -> view.input.isEnabled = value }
46
+ Prop("revealed") { view: T3SecretInputView, value: Boolean -> view.setRevealed(value) }
47
Events("onChangeText", "onSubmit")
48
}
49
}
@@ -133,6 +135,18 @@ class T3SecretInputView(context: Context, appContext: AppContext) : ExpoView(con
135
applyingValue = false
136
}
137
138
+ /** Swapping the transformation re-sets the text, so it neither echoes to JS nor moves the caret. */
139
+ fun setRevealed(revealed: Boolean) {
140
+ val method = if (revealed) null else PasswordTransformationMethod.getInstance()
141
+ if (input.transformationMethod == method) return
142
+ val start = input.selectionStart
143
+ val end = input.selectionEnd
144
+ applyingValue = true
145
+ input.transformationMethod = method
146
+ if (start >= 0 && end >= 0) input.setSelection(start, end)
147
+ applyingValue = false
148
+ }
149
+
150
fun setCursorColor(color: Int) {
151
input.highlightColor = Color.argb(0x52, Color.red(color), Color.green(color), Color.blue(color))
152
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) return
apps/mobile/src/components/ui/SecretRevealButton.tsx
new
+25
@@ -0,0 +1,25 @@
1
+import { Pressable } from "react-native";
2
+
3
+import { SymbolView } from "./AppSymbol";
4
+
5
+/** Eye toggle that shows or hides a secret field's typed text. */
6
+export function SecretRevealButton(props: {
7
+ readonly revealed: boolean;
8
+ readonly onPress: () => void;
9
+}) {
10
+ return (
11
+ <Pressable
12
+ onPress={props.onPress}
13
+ hitSlop={6}
14
+ accessibilityRole="button"
15
+ accessibilityLabel={props.revealed ? "Hide secret" : "Show secret"}
16
+ className="size-10 items-center justify-center"
17
+ >
18
+ <SymbolView
19
+ name={props.revealed ? "eye.slash" : "eye"}
20
+ size={18}
21
+ tintColorClassName="accent-icon-muted"
22
+ />
23
+ </Pressable>
24
+ );
25
+}
apps/mobile/src/components/ui/SecretTextInput.android.tsx
+8
-2
@@ -1,8 +1,10 @@
1
import { requireNativeView } from "expo";
2
+import { useState } from "react";
3
import { processColor, View, type NativeSyntheticEvent, type ViewProps } from "react-native";
4
5
import { flattenThemeColor } from "../../lib/mobileTheme";
6
import { useUniwindTheme } from "../../lib/useUniwindTheme";
7
+import { SecretRevealButton } from "./SecretRevealButton";
8
import type { SecretTextInputProps } from "./SecretTextInput.types";
9
10
interface NativeSecretInputProps extends ViewProps {
@@ -14,6 +16,7 @@ interface NativeSecretInputProps extends ViewProps {
16
readonly cursorColor: number;
17
readonly fontSize: number;
18
readonly editable: boolean;
19
+ readonly revealed: boolean;
20
readonly onChangeText: (event: NativeSyntheticEvent<{ readonly value: string }>) => void;
21
readonly onSubmit: (event: NativeSyntheticEvent<{ readonly value: string }>) => void;
22
}
@@ -36,8 +39,9 @@ function nativeColor(value: string) {
39
export function SecretTextInput(props: SecretTextInputProps) {
40
const theme = useUniwindTheme();
41
const surface = theme["--color-input"];
42
+ const [revealed, setRevealed] = useState(false);
43
return (
40
- <View className="min-h-13.5 justify-center rounded-2xl border border-input-border bg-input px-3.5">
44
+ <View className="min-h-13.5 flex-row items-center gap-1 rounded-2xl border border-input-border bg-input pr-1.5 pl-3.5">
45
<NativeSecretInput
46
inputLabel={props.accessibilityLabel}
47
value={props.value}
@@ -47,10 +51,12 @@ export function SecretTextInput(props: SecretTextInputProps) {
51
cursorColor={nativeColor(flattenThemeColor(theme["--color-focus"], surface))}
52
fontSize={FONT_SIZE}
53
editable={props.editable}
54
+ revealed={revealed}
55
onChangeText={(event) => props.onChangeText(event.nativeEvent.value)}
56
onSubmit={(event) => props.onSubmitEditing(event.nativeEvent.value)}
52
- style={{ height: LINE_HEIGHT }}
57
+ style={{ flex: 1, height: LINE_HEIGHT }}
58
/>
59
+ <SecretRevealButton revealed={revealed} onPress={() => setRevealed(!revealed)} />
60
</View>
61
);
62
}
apps/mobile/src/components/ui/SecretTextInput.tsx
+27
-16
@@ -1,24 +1,35 @@
1
+import { useState } from "react";
2
+import { View } from "react-native";
3
+
4
import { AppTextInput } from "./AppText";
5
+import { SecretRevealButton } from "./SecretRevealButton";
6
import type { SecretTextInputProps } from "./SecretTextInput.types";
7
8
/** Masked field for a value that must stay out of password managers and suggestions. */
9
export function SecretTextInput(props: SecretTextInputProps) {
10
+ const [revealed, setRevealed] = useState(false);
11
return (
7
- <AppTextInput
8
- accessibilityLabel={props.accessibilityLabel}
9
- placeholder={props.placeholder}
10
- value={props.value}
11
- onChangeText={props.onChangeText}
12
- editable={props.editable}
13
- secureTextEntry
14
- autoCorrect={false}
15
- autoCapitalize="none"
16
- autoComplete="off"
17
- textContentType="none"
18
- importantForAutofill="no"
19
- spellCheck={false}
20
- returnKeyType="done"
21
- onSubmitEditing={(event) => props.onSubmitEditing(event.nativeEvent.text)}
22
- />
12
+ <View className="justify-center">
13
+ <AppTextInput
14
+ className="pr-12"
15
+ accessibilityLabel={props.accessibilityLabel}
16
+ placeholder={props.placeholder}
17
+ value={props.value}
18
+ onChangeText={props.onChangeText}
19
+ editable={props.editable}
20
+ secureTextEntry={!revealed}
21
+ autoCorrect={false}
22
+ autoCapitalize="none"
23
+ autoComplete="off"
24
+ textContentType="none"
25
+ importantForAutofill="no"
26
+ spellCheck={false}
27
+ returnKeyType="done"
28
+ onSubmitEditing={(event) => props.onSubmitEditing(event.nativeEvent.text)}
29
+ />
30
+ <View className="absolute right-1.5">
31
+ <SecretRevealButton revealed={revealed} onPress={() => setRevealed(!revealed)} />
32
+ </View>
33
+ </View>
34
);
35
}