From 3919bb346ffe1a5f0fee0588aa38532e00064698 Mon Sep 17 00:00:00 2001 From: Uruk Date: Mon, 1 Sep 2025 15:48:55 +0200 Subject: [PATCH] refactor: replace inline password inputs with reusable PasswordInput component Consolidates duplicate password input implementations across login and settings screens into a single reusable component. Improves code maintainability by eliminating redundant password visibility toggle logic and standardizing password input behavior throughout the application. Adds consistent accessibility support and test identifiers across all password input instances. --- app/login.tsx | 81 ++++++++--------------- components/PasswordInput.tsx | 101 +++++++++++++++++++++++++++++ components/settings/Jellyseerr.tsx | 53 ++++++--------- 3 files changed, 148 insertions(+), 87 deletions(-) create mode 100644 components/PasswordInput.tsx diff --git a/app/login.tsx b/app/login.tsx index dac7a55a..46144069 100644 --- a/app/login.tsx +++ b/app/login.tsx @@ -20,6 +20,7 @@ import { Button } from "@/components/Button"; import { Input } from "@/components/common/Input"; import { Text } from "@/components/common/Text"; import JellyfinServerDiscovery from "@/components/JellyfinServerDiscovery"; +import { PasswordInput } from "@/components/PasswordInput"; import { PreviousServersList } from "@/components/PreviousServersList"; import { Colors } from "@/constants/Colors"; import { apiAtom, useJellyfin } from "@/providers/JellyfinProvider"; @@ -276,33 +277,20 @@ const Login: React.FC = () => { /> {/* Password */} - - - setCredentials({ ...credentials, password: text }) - } - value={credentials.password} - secureTextEntry={!showPassword} - keyboardType='default' - returnKeyType='done' - autoCapitalize='none' - textContentType='password' - clearButtonMode='while-editing' - maxLength={500} - className='pr-12' - /> - setShowPassword(!showPassword)} - className='absolute right-3 top-4 p-1' - > - - - + + setCredentials({ ...credentials, password: text }) + } + onSubmitEditing={handleLogin} + placeholder={t("login.password_placeholder")} + className='mb-4' + showPassword={showPassword} + onShowPasswordChange={setShowPassword} + topPosition='4' + testID='tv-password-input' + accessibilityLabel={t("login.password_placeholder")} + /> @@ -417,33 +405,18 @@ const Login: React.FC = () => { maxLength={500} /> - - - setCredentials({ ...credentials, password: text }) - } - value={credentials.password} - secureTextEntry={!showPassword} - keyboardType='default' - returnKeyType='done' - autoCapitalize='none' - textContentType='password' - clearButtonMode='while-editing' - maxLength={500} - className='pr-12' - /> - setShowPassword(!showPassword)} - className='absolute right-3 top-3.5 p-1' - > - - - + + setCredentials({ ...credentials, password: text }) + } + placeholder={t("login.password_placeholder")} + showPassword={showPassword} + onShowPasswordChange={setShowPassword} + topPosition='3.5' + testID='mobile-password-input' + accessibilityLabel={t("login.password_placeholder")} + />