Skip to content

Commit 46da4d7

Browse files
maximcodingclaude
andcommitted
refactor(auth): replace manual boolean useState with useToggle
showPassword, emailFocused, passFocused all replaced by useToggle() from shared/hooks. Toggle handler is now a stable ref (toggleShowPassword) instead of an inline arrow. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 446e52e commit 46da4d7

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/features/auth/screens/AuthScreen.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import { ROUTES } from '@/navigation/routes'
4848
import { Button } from '@/shared/components/ui/Button'
4949
import { ScreenWrapper } from '@/shared/components/ui/ScreenWrapper'
5050
import { Text } from '@/shared/components/ui/Text'
51+
import { useToggle } from '@/shared/hooks/useToggle'
5152
import { useTheme } from '@/shared/theme'
5253
import { normalizeError } from '@/shared/utils/normalize-error'
5354
import { showErrorToast } from '@/shared/utils/toast'
@@ -352,9 +353,9 @@ export default function AuthScreen() {
352353
const [password, setPassword] = useState(() =>
353354
flags.USE_MOCK ? AUTH_MOCK_DEMO.password : '',
354355
)
355-
const [showPassword, setShowPassword] = useState(false)
356-
const [emailFocused, setEmailFocused] = useState(false)
357-
const [passFocused, setPassFocused] = useState(false)
356+
const [showPassword, toggleShowPassword] = useToggle(false)
357+
const [emailFocused, , setEmailFocused, clearEmailFocused] = useToggle(false)
358+
const [passFocused, , setPassFocused, clearPassFocused] = useToggle(false)
358359

359360
// Input focus — Reanimated shared values for color interpolation
360361
const emailFocus = useSharedValue(0)
@@ -692,11 +693,11 @@ export default function AuthScreen() {
692693
value={email}
693694
onChangeText={setEmail}
694695
onFocus={() => {
695-
setEmailFocused(true)
696+
setEmailFocused()
696697
animateFocus(emailFocus, true)
697698
}}
698699
onBlur={() => {
699-
setEmailFocused(false)
700+
clearEmailFocused()
700701
animateFocus(emailFocus, false)
701702
}}
702703
keyboardType="email-address"
@@ -742,11 +743,11 @@ export default function AuthScreen() {
742743
value={password}
743744
onChangeText={setPassword}
744745
onFocus={() => {
745-
setPassFocused(true)
746+
setPassFocused()
746747
animateFocus(passFocus, true)
747748
}}
748749
onBlur={() => {
749-
setPassFocused(false)
750+
clearPassFocused()
750751
animateFocus(passFocus, false)
751752
}}
752753
secureTextEntry={!showPassword}
@@ -756,7 +757,7 @@ export default function AuthScreen() {
756757
textContentType="password"
757758
/>
758759
<TouchableOpacity
759-
onPress={() => setShowPassword(!showPassword)}
760+
onPress={toggleShowPassword}
760761
activeOpacity={0.6}
761762
style={styles.eyeSlot}
762763
>

0 commit comments

Comments
 (0)