From 88f96eaf58bfcf458b971a1f2871d7ae6795371f Mon Sep 17 00:00:00 2001 From: kuraydev Date: Mon, 29 Jun 2026 16:03:05 +0300 Subject: [PATCH 1/7] refactor: modernize LoginScreen source and fix validator bugs - Move source from lib/ to src/. - Fix passwordValidator regex (\\d -> \d) so the digit rule actually applies. - Guard LayoutAnimation on Android via setLayoutAnimationEnabledExperimental. - Replace any-typed props (logoImageSource, children, TouchableComponent) and rewrite useStateWithCallback with real generics. - Wrap LoginScreen in React.memo; memoize render helpers and tooltip content. - Derive widths from useWindowDimensions instead of a module-load Dimensions read. - Add accessibilityRole/accessibilityLabel to buttons and inputs. - Export prop types and password pattern presets from the barrel. --- lib/helpers/passwordValidator.ts | 23 - {lib => src}/LoginScreen.style.ts | 11 +- {lib => src}/LoginScreen.tsx | 392 ++++++++++++------ .../social-button/SocialButton.style.ts | 11 +- .../components/social-button/SocialButton.tsx | 25 +- .../components/tooltip/Tooltip.style.ts | 0 {lib => src}/components/tooltip/Tooltip.tsx | 2 +- {lib => src}/helpers/emailValidator.ts | 4 +- src/helpers/passwordValidator.ts | 23 + {lib => src}/helpers/useStateWithCallback.ts | 16 +- {lib => src}/index.ts | 11 + {lib => src}/local-assets/apple.png | Bin {lib => src}/local-assets/discord.png | Bin {lib => src}/local-assets/eye-off.png | Bin {lib => src}/local-assets/eye.png | Bin {lib => src}/local-assets/facebook.png | Bin {lib => src}/local-assets/twitter.png | Bin tsconfig.json | 40 +- 18 files changed, 344 insertions(+), 214 deletions(-) delete mode 100644 lib/helpers/passwordValidator.ts rename {lib => src}/LoginScreen.style.ts (94%) rename {lib => src}/LoginScreen.tsx (51%) rename {lib => src}/components/social-button/SocialButton.style.ts (68%) rename {lib => src}/components/social-button/SocialButton.tsx (68%) rename {lib => src}/components/tooltip/Tooltip.style.ts (100%) rename {lib => src}/components/tooltip/Tooltip.tsx (93%) rename {lib => src}/helpers/emailValidator.ts (80%) create mode 100644 src/helpers/passwordValidator.ts rename {lib => src}/helpers/useStateWithCallback.ts (53%) rename {lib => src}/index.ts (54%) rename {lib => src}/local-assets/apple.png (100%) rename {lib => src}/local-assets/discord.png (100%) rename {lib => src}/local-assets/eye-off.png (100%) rename {lib => src}/local-assets/eye.png (100%) rename {lib => src}/local-assets/facebook.png (100%) rename {lib => src}/local-assets/twitter.png (100%) diff --git a/lib/helpers/passwordValidator.ts b/lib/helpers/passwordValidator.ts deleted file mode 100644 index 3bd19ae..0000000 --- a/lib/helpers/passwordValidator.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Credits: https://stackoverflow.com/a/52093032/2247055 -//Minimum six characters, at least one letter and one number: -export const patternNormal = /^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{6,}$/; - -//Minimum eight characters, at least one letter, one number and one special character: -export const patternMedium = - /^(?=.*[A-Za-z])(?=.*\\d)(?=.*[@$!%*#?&])[A-Za-z\\d@$!%*#?&]{8,}$/; - -//Minimum eight characters, at least one uppercase letter, one lowercase letter and one number: -export const patternHigh = - /^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,}$/; - -// Password Validator -export default function ( - password: string, - passwordRegEx = patternNormal, -): boolean { - if (!password) { - return false; - } - - return passwordRegEx.test(password); -} diff --git a/lib/LoginScreen.style.ts b/src/LoginScreen.style.ts similarity index 94% rename from lib/LoginScreen.style.ts rename to src/LoginScreen.style.ts index eb6d099..f147d1a 100644 --- a/lib/LoginScreen.style.ts +++ b/src/LoginScreen.style.ts @@ -1,11 +1,4 @@ -import { - ViewStyle, - ImageStyle, - Dimensions, - StyleSheet, - TextStyle, -} from "react-native"; -const { width: ScreenWidth } = Dimensions.get("screen"); +import { ViewStyle, ImageStyle, StyleSheet, TextStyle } from "react-native"; interface Style { container: ViewStyle; @@ -61,7 +54,6 @@ export default StyleSheet.create