diff --git a/app.json b/app.json index 7dd3883..4f5d0c5 100644 --- a/app.json +++ b/app.json @@ -50,7 +50,9 @@ "expo-font", { "fonts": [ - "./assets/font/english.otf" + "./assets/fonts/Quicksand.otf", + "./assets/fonts/SF-Pro.otf", + "./assets/fonts/Inter-Regular.otf" ] } ], diff --git a/app/(tabs)/_layout.tsx b/app/(tabs)/_layout.tsx index d91d08a..54c5796 100644 --- a/app/(tabs)/_layout.tsx +++ b/app/(tabs)/_layout.tsx @@ -60,7 +60,9 @@ export default function TabLayout() { // 加载字体 const [loaded, error] = useFonts({ - english: require('@/assets/font/english.otf'), + quicksand: require('@/assets/fonts/Quicksand.otf'), + sfPro: require('@/assets/fonts/SF-Pro.otf'), + inter: require('@/assets/fonts/Inter-Regular.otf'), }); useEffect(() => { diff --git a/app/(tabs)/login.tsx b/app/(tabs)/login.tsx index ccc6d0d..3c84020 100644 --- a/app/(tabs)/login.tsx +++ b/app/(tabs)/login.tsx @@ -74,9 +74,9 @@ const LoginScreen = () => { keyboardShouldPersistTaps="handled" bounces={false} > - + - {t('login:auth.login.titleText')} + {t('login:auth.login.titleText')} { { > {/* 错误提示 */} - + {error} @@ -161,22 +162,22 @@ const LoginScreen = () => { return components[status as keyof typeof components] || components.login; })()} - + {status == 'login' || !status && - + {status === 'login' || !status ? t('auth.agree.logintext', { ns: 'login' }) : t('auth.agree.singupText', { ns: 'login' })} { setModalVisible(true); setModalType('terms') }}> - + {t('auth.agree.terms', { ns: 'login' })} - + {t('auth.agree.join', { ns: 'login' })} { setModalVisible(true); setModalType('privacy') }}> - + {t('auth.agree.privacyPolicy', { ns: 'login' })} diff --git a/assets/fonts/Inter-Regular.otf b/assets/fonts/Inter-Regular.otf new file mode 100644 index 0000000..fdb121d Binary files /dev/null and b/assets/fonts/Inter-Regular.otf differ diff --git a/assets/font/english.otf b/assets/fonts/Quicksand.otf similarity index 100% rename from assets/font/english.otf rename to assets/fonts/Quicksand.otf diff --git a/assets/fonts/SF-Pro.otf b/assets/fonts/SF-Pro.otf new file mode 100644 index 0000000..025b25c Binary files /dev/null and b/assets/fonts/SF-Pro.otf differ diff --git a/components/ThemedText.tsx b/components/ThemedText.tsx index c09ca6c..683619f 100644 --- a/components/ThemedText.tsx +++ b/components/ThemedText.tsx @@ -1,16 +1,26 @@ import { StyleProp, StyleSheet, Text, TextStyle, type TextProps } from 'react-native'; -import { Fonts } from '@/constants/Fonts'; +import { Colors } from '@/constants/Colors'; +import { FontColor, Fonts } from '@/constants/Fonts'; import { useThemeColor } from '@/hooks/useThemeColor'; +export type ThemeColor = keyof typeof Colors.light & keyof typeof Colors.dark; +export type ColorValue = `#${string}` | `rgb(${string})` | `rgba(${string})` | string; + export type ThemedTextProps = TextProps & { lightColor?: string; darkColor?: string; - type?: 'default' | 'title' | 'defaultSemiBold' | 'subtitle' | 'link'; + type?: 'default' | 'title' | 'defaultSemiBold' | 'subtitle' | 'link' | 'sfPro' | 'inter'; weight?: 'regular' | 'medium' | 'semiBold' | 'bold'; - size?: 'xs' | 'sm' | 'base' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl'; + size?: 'xxs' | 'xs' | 'sm' | 'base' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl'; + radius?: 'xs' | 'sm' | 'base' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl'; + color?: ThemeColor | FontColor | ColorValue; }; +export function isFontColorKey(key: string): key is FontColor { + return ['bgPrimary', 'bgSecondary', 'textPrimary', 'textSecondary', 'textThird', 'textWhite'].includes(key); +} + export function ThemedText({ style, lightColor, @@ -18,20 +28,38 @@ export function ThemedText({ type = 'default', weight = 'regular', size, + radius, + color, ...rest }: ThemedTextProps) { - const color = useThemeColor({ light: lightColor, dark: darkColor }, 'text'); + + const themeColor = useThemeColor({ light: lightColor, dark: darkColor }, 'text'); + + const textColor = (() => { + if (!color) return themeColor; + + // 检查是否是主题颜色 + const themeColors = Object.keys(Colors.light) as ThemeColor[]; + if (themeColors.includes(color as ThemeColor)) { + return useThemeColor({ light: lightColor, dark: darkColor }, color as ThemeColor); + } + + // 检查是否是 Fonts 中定义的颜色 + if (isFontColorKey(color)) { + return Fonts[color as FontColor]; + } + + // 返回自定义颜色值 + return color; + })(); + const baseStyle: StyleProp = { - fontFamily: Fonts.primary, - color, - fontWeight: Fonts[weight as keyof typeof Fonts] as TextStyle['fontWeight'], + fontFamily: Fonts.quicksand, + color: textColor, + fontWeight: Number(Fonts[weight as keyof typeof Fonts]) as TextStyle['fontWeight'], }; - if (size) { - baseStyle.fontSize = Fonts[size as keyof typeof Fonts]; - } - return ( ; +export function ThemedView({ className, style, bgColor, ...props }: ThemedViewProps) { + const themeColor = useThemeColor({ light: bgColor, dark: bgColor }, 'background'); + + const bgColorValue = (() => { + if (!bgColor) return themeColor; + + // 检查是否是主题颜色 + const themeColors = Object.keys(Colors.light) as ThemeColor[]; + if (themeColors.includes(bgColor as ThemeColor)) { + return useThemeColor({ light: bgColor, dark: bgColor }, bgColor as ThemeColor); + } + // 检查是否是 Fonts 中定义的颜色 + if (isFontColorKey(bgColor)) { + return Fonts[bgColor]; + } + // 返回自定义颜色值 + return bgColor; + })(); + + return ; } diff --git a/components/login/forgetPwd.tsx b/components/login/forgetPwd.tsx index da377d2..e02278b 100644 --- a/components/login/forgetPwd.tsx +++ b/components/login/forgetPwd.tsx @@ -1,9 +1,12 @@ +import { Fonts } from "@/constants/Fonts"; import { fetchApi } from "@/lib/server-api-util"; import { User } from "@/types/user"; import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; -import { ActivityIndicator, StyleSheet, TextInput, TouchableOpacity, View } from "react-native"; +import { StyleSheet, TouchableOpacity, View } from "react-native"; import { ThemedText } from "../ThemedText"; +import Button from "./ui/Button"; +import TextInput from "./ui/TextInput"; interface LoginProps { setIsSignUp?: (isSignUp: string) => void; @@ -69,45 +72,29 @@ const ForgetPwd = ({ setIsSignUp, updateUrlParam, setError }: LoginProps) => { return ( - - - {t('auth.forgetPwd.title', { ns: 'login' })} - - - - - - {loading ? ( - - ) : ( - - {isDisabled - ? `${t("auth.forgetPwd.sendEmailBtnDisabled", { ns: "login" })} (${countdown}s)` - : t("auth.forgetPwd.sendEmailBtn", { ns: "login" })} - - )} - + {/* 邮箱 */} + + {/* 发送邮箱 */} +