fix: bug
This commit is contained in:
@@ -21,11 +21,12 @@ import { PointsIcon, SearchIcon, SettingsIcon } from '@/components/icon'
|
||||
import EditProfileDrawer from '@/components/drawer/EditProfileDrawer'
|
||||
import Dropdown from '@/components/ui/dropdown'
|
||||
import Toast from '@/components/ui/Toast'
|
||||
import { signOut , useSession } from '@/lib/auth'
|
||||
import { signOut, useSession } from '@/lib/auth'
|
||||
import { useTemplateGenerations, type TemplateGeneration } from '@/hooks'
|
||||
import { MySkeleton } from '@/components/skeleton/MySkeleton'
|
||||
|
||||
import { useUserBalance } from '@/hooks/use-user-balance'
|
||||
import { KeyboardAwareScrollView } from 'react-native-keyboard-controller'
|
||||
|
||||
const { width: screenWidth } = Dimensions.get('window')
|
||||
const GALLERY_GAP = 2
|
||||
@@ -182,6 +183,8 @@ export default function My() {
|
||||
|
||||
return (
|
||||
<SafeAreaView style={styles.container} edges={['top', 'bottom']}>
|
||||
<KeyboardAwareScrollView bottomOffset={50}>
|
||||
|
||||
<StatusBar style="light" />
|
||||
<RNStatusBar barStyle="light-content" />
|
||||
|
||||
@@ -223,7 +226,10 @@ export default function My() {
|
||||
</View>
|
||||
<Pressable
|
||||
style={styles.editButton}
|
||||
onPress={() => setEditDrawerVisible(true)}
|
||||
onPress={() => {
|
||||
console.log('[my.tsx] Edit Profile button pressed')
|
||||
setEditDrawerVisible(true)
|
||||
}}
|
||||
>
|
||||
<Text style={styles.editButtonText}>{t('my.editProfile')}</Text>
|
||||
</Pressable>
|
||||
@@ -335,6 +341,7 @@ export default function My() {
|
||||
)}
|
||||
|
||||
{/* 编辑资料抽屉 */}
|
||||
|
||||
<EditProfileDrawer
|
||||
visible={editDrawerVisible}
|
||||
onClose={() => setEditDrawerVisible(false)}
|
||||
@@ -344,6 +351,7 @@ export default function My() {
|
||||
setProfileName(data.name)
|
||||
}}
|
||||
/>
|
||||
</KeyboardAwareScrollView>
|
||||
</SafeAreaView>
|
||||
)
|
||||
}
|
||||
|
||||
16
app/auth.tsx
16
app/auth.tsx
@@ -4,6 +4,7 @@ import { StatusBar } from 'expo-status-bar'
|
||||
import { SafeAreaView } from 'react-native-safe-area-context'
|
||||
import { useRouter } from 'expo-router'
|
||||
import { LinearGradient } from 'expo-linear-gradient'
|
||||
import { KeyboardAwareScrollView } from 'react-native-keyboard-controller'
|
||||
import { AuthForm } from '@/components/blocks/AuthForm'
|
||||
import { useSession } from '@/lib/auth'
|
||||
|
||||
@@ -48,9 +49,15 @@ export default function Auth() {
|
||||
<StatusBar style="light" />
|
||||
<RNStatusBar barStyle="light-content" />
|
||||
|
||||
<KeyboardAwareScrollView
|
||||
style={styles.scrollView}
|
||||
contentContainerStyle={styles.scrollContent}
|
||||
bottomOffset={50}
|
||||
>
|
||||
<View style={styles.content}>
|
||||
<AuthForm onSuccess={handleSuccess} />
|
||||
</View>
|
||||
</KeyboardAwareScrollView>
|
||||
</SafeAreaView>
|
||||
</LinearGradient>
|
||||
)
|
||||
@@ -66,10 +73,17 @@ const styles = StyleSheet.create({
|
||||
flex: 1,
|
||||
backgroundColor: 'transparent',
|
||||
},
|
||||
content: {
|
||||
scrollView: {
|
||||
flex: 1,
|
||||
},
|
||||
scrollContent: {
|
||||
flexGrow: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
paddingHorizontal: 20,
|
||||
},
|
||||
content: {
|
||||
width: '100%',
|
||||
alignItems: 'center',
|
||||
},
|
||||
})
|
||||
|
||||
@@ -3,7 +3,6 @@ import {
|
||||
View,
|
||||
Text,
|
||||
StyleSheet,
|
||||
ScrollView,
|
||||
Pressable,
|
||||
Platform,
|
||||
TextInput,
|
||||
@@ -14,6 +13,7 @@ import { SafeAreaView } from 'react-native-safe-area-context'
|
||||
import { useRouter } from 'expo-router'
|
||||
import { StatusBar as RNStatusBar } from 'react-native'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { KeyboardAwareScrollView } from 'react-native-keyboard-controller'
|
||||
import { LeftArrowIcon } from '@/components/icon'
|
||||
import { LinearGradient } from 'expo-linear-gradient'
|
||||
import { useChangePassword } from '@/hooks/use-change-password'
|
||||
@@ -140,11 +140,10 @@ export default function ChangePasswordScreen() {
|
||||
<Text style={styles.headerTitle}>{t('changePassword.title')}</Text>
|
||||
<View style={styles.headerSpacer} />
|
||||
</View>
|
||||
<ScrollView
|
||||
<KeyboardAwareScrollView
|
||||
style={styles.scrollView}
|
||||
contentContainerStyle={styles.scrollContent}
|
||||
showsVerticalScrollIndicator={false}
|
||||
keyboardShouldPersistTaps="handled"
|
||||
bottomOffset={50}
|
||||
>
|
||||
<View style={styles.form}>
|
||||
<View style={styles.inputGroup}>
|
||||
@@ -257,7 +256,7 @@ export default function ChangePasswordScreen() {
|
||||
</LinearGradient>
|
||||
</Pressable>
|
||||
</View>
|
||||
</ScrollView>
|
||||
</KeyboardAwareScrollView>
|
||||
</SafeAreaView>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -8,13 +8,13 @@ import {
|
||||
Pressable,
|
||||
StatusBar as RNStatusBar,
|
||||
Platform,
|
||||
KeyboardAvoidingView,
|
||||
} from 'react-native'
|
||||
import { StatusBar } from 'expo-status-bar'
|
||||
import { SafeAreaView } from 'react-native-safe-area-context'
|
||||
import { Image } from 'expo-image'
|
||||
import { useRouter, useLocalSearchParams } from 'expo-router'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { KeyboardAwareScrollView } from 'react-native-keyboard-controller'
|
||||
|
||||
import { LeftArrowIcon, WhitePointsIcon } from '@/components/icon'
|
||||
import UploadReferenceImageDrawer from '@/components/drawer/UploadReferenceImageDrawer'
|
||||
@@ -95,16 +95,10 @@ export default function GenerateVideoScreen() {
|
||||
translucent
|
||||
/>
|
||||
)}
|
||||
<KeyboardAvoidingView
|
||||
style={styles.keyboardAvoidingView}
|
||||
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
|
||||
keyboardVerticalOffset={Platform.OS === 'ios' ? 0 : 0}
|
||||
>
|
||||
<ScrollView
|
||||
<KeyboardAwareScrollView
|
||||
style={styles.scrollView}
|
||||
contentContainerStyle={styles.scrollContent}
|
||||
showsVerticalScrollIndicator={false}
|
||||
keyboardShouldPersistTaps="handled"
|
||||
bottomOffset={50}
|
||||
>
|
||||
{/* 顶部导航栏 */}
|
||||
<View style={styles.header}>
|
||||
@@ -152,6 +146,7 @@ export default function GenerateVideoScreen() {
|
||||
loading={loading}
|
||||
onOpenDrawer={handleOpenDrawer}
|
||||
points={templateDetail?.price}
|
||||
disableScroll
|
||||
/>
|
||||
) : (
|
||||
<View style={styles.emptyContainer}>
|
||||
@@ -162,8 +157,7 @@ export default function GenerateVideoScreen() {
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
</KeyboardAvoidingView>
|
||||
</KeyboardAwareScrollView>
|
||||
|
||||
{/* 图片上传抽屉 */}
|
||||
<UploadReferenceImageDrawer
|
||||
@@ -197,9 +191,6 @@ const styles = StyleSheet.create({
|
||||
flex: 1,
|
||||
backgroundColor: '#090A0B',
|
||||
},
|
||||
keyboardAvoidingView: {
|
||||
flex: 1,
|
||||
},
|
||||
scrollView: {
|
||||
flex: 1,
|
||||
backgroundColor: '#090A0B',
|
||||
|
||||
@@ -6,12 +6,11 @@ import {
|
||||
StyleSheet,
|
||||
Platform,
|
||||
ActivityIndicator,
|
||||
ScrollView,
|
||||
KeyboardAvoidingView,
|
||||
} from 'react-native'
|
||||
import { Image } from 'expo-image'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import * as ImagePicker from 'expo-image-picker'
|
||||
import { KeyboardAwareScrollView } from 'react-native-keyboard-controller'
|
||||
|
||||
import { Button } from './ui/button'
|
||||
import Text from './ui/Text'
|
||||
@@ -81,10 +80,12 @@ interface DynamicFormProps {
|
||||
loading?: boolean
|
||||
onOpenDrawer?: (nodeId: string) => void
|
||||
points?: number
|
||||
/** 当外层已有滚动视图时,禁用内部滚动 */
|
||||
disableScroll?: boolean
|
||||
}
|
||||
|
||||
export const DynamicForm = forwardRef<DynamicFormRef, DynamicFormProps>(
|
||||
function DynamicForm({ formSchema, onSubmit, loading = false, onOpenDrawer, points }, ref) {
|
||||
function DynamicForm({ formSchema, onSubmit, loading = false, onOpenDrawer, points, disableScroll = false }, ref) {
|
||||
const { t } = useTranslation()
|
||||
const startNodes = formSchema.startNodes || []
|
||||
|
||||
@@ -456,18 +457,8 @@ export const DynamicForm = forwardRef<DynamicFormRef, DynamicFormProps>(
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<KeyboardAvoidingView
|
||||
style={styles.keyboardAvoidingView}
|
||||
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
|
||||
keyboardVerticalOffset={0}
|
||||
>
|
||||
<ScrollView
|
||||
style={styles.scrollView}
|
||||
contentContainerStyle={styles.scrollContent}
|
||||
showsVerticalScrollIndicator={false}
|
||||
keyboardShouldPersistTaps="handled"
|
||||
>
|
||||
const formContent = (
|
||||
<>
|
||||
{startNodes.map(renderField)}
|
||||
|
||||
<View style={styles.submitButtonContainer}>
|
||||
@@ -495,16 +486,31 @@ export const DynamicForm = forwardRef<DynamicFormRef, DynamicFormProps>(
|
||||
)}
|
||||
</Button>
|
||||
</View>
|
||||
</ScrollView>
|
||||
</KeyboardAvoidingView>
|
||||
</>
|
||||
)
|
||||
|
||||
// 当外层已有滚动视图时,不使用内部滚动
|
||||
if (disableScroll) {
|
||||
return (
|
||||
<View style={styles.scrollContent}>
|
||||
{formContent}
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<KeyboardAwareScrollView
|
||||
style={styles.scrollView}
|
||||
contentContainerStyle={styles.scrollContent}
|
||||
bottomOffset={50}
|
||||
>
|
||||
{formContent}
|
||||
</KeyboardAwareScrollView>
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
keyboardAvoidingView: {
|
||||
flex: 1,
|
||||
},
|
||||
scrollView: {
|
||||
flex: 1,
|
||||
},
|
||||
|
||||
@@ -4,21 +4,19 @@ import {
|
||||
Text,
|
||||
StyleSheet,
|
||||
Pressable,
|
||||
TextInput,
|
||||
Dimensions,
|
||||
Platform,
|
||||
Keyboard,
|
||||
ScrollView,
|
||||
ActivityIndicator,
|
||||
} from 'react-native'
|
||||
import { Image } from 'expo-image'
|
||||
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import BottomSheet, { BottomSheetModal, BottomSheetView, BottomSheetBackdrop, BottomSheetScrollView } from '@gorhom/bottom-sheet'
|
||||
import { BottomSheetModal, BottomSheetBackdrop, BottomSheetTextInput, BottomSheetView } from '@gorhom/bottom-sheet'
|
||||
import { CloseIcon, AvatarUploadIcon } from '@/components/icon'
|
||||
import { LinearGradient } from 'expo-linear-gradient'
|
||||
import { type ImagePickerAsset } from 'expo-image-picker'
|
||||
import { useUpdateProfile } from '@/hooks'
|
||||
import { KeyboardAwareScrollView, useKeyboardContext, useKeyboardState } from 'react-native-keyboard-controller'
|
||||
import { TextInput } from 'react-native-gesture-handler'
|
||||
|
||||
|
||||
interface EditProfileDrawerProps {
|
||||
@@ -41,13 +39,14 @@ export default function EditProfileDrawer({
|
||||
const [name, setName] = useState(initialName)
|
||||
const [avatar, setAvatar] = useState<string | undefined>(initialAvatar)
|
||||
const [selectedImage, setSelectedImage] = useState<ImagePickerAsset | null>(null)
|
||||
const insets = useSafeAreaInsets()
|
||||
|
||||
const keyboardState = useKeyboardState()
|
||||
|
||||
const { loading, pickImage, updateProfile } = useUpdateProfile()
|
||||
|
||||
// 增加高度以避免被底部 Tab 栏遮挡,考虑底部安全区域
|
||||
// 使用百分比让 BottomSheet 在键盘弹出时能够自动调整
|
||||
const snapPoints = useMemo(() => ['50%'], [])
|
||||
const snapPoints = useMemo(() => ['80%'], [])
|
||||
|
||||
useEffect(() => {
|
||||
if (visible) {
|
||||
@@ -56,11 +55,21 @@ export default function EditProfileDrawer({
|
||||
setName(initialName)
|
||||
setAvatar(initialAvatar)
|
||||
setSelectedImage(null)
|
||||
|
||||
} else {
|
||||
bottomSheetRef.current?.dismiss()
|
||||
}
|
||||
}, [visible, initialName, initialAvatar])
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (keyboardState && keyboardState.height) {
|
||||
bottomSheetRef.current?.expand()
|
||||
} else {
|
||||
bottomSheetRef.current?.collapse()
|
||||
}
|
||||
}, [keyboardState])
|
||||
|
||||
const handleSheetChanges = useCallback((index: number) => {
|
||||
if (index === -1) {
|
||||
onClose()
|
||||
@@ -132,13 +141,7 @@ export default function EditProfileDrawer({
|
||||
keyboardBlurBehavior="restore"
|
||||
android_keyboardInputMode="adjustResize"
|
||||
>
|
||||
<BottomSheetScrollView
|
||||
style={styles.scrollView}
|
||||
contentContainerStyle={styles.scrollContent}
|
||||
keyboardShouldPersistTaps="handled"
|
||||
showsVerticalScrollIndicator={false}
|
||||
>
|
||||
<View style={styles.container}>
|
||||
<BottomSheetView style={styles.container}>
|
||||
{/* 顶部关闭按钮 */}
|
||||
<Pressable
|
||||
style={styles.closeButton}
|
||||
@@ -173,7 +176,7 @@ export default function EditProfileDrawer({
|
||||
</View>
|
||||
|
||||
{/* 输入框 */}
|
||||
<TextInput
|
||||
{/* <BottomSheetTextInput
|
||||
style={styles.input}
|
||||
value={name}
|
||||
onChangeText={setName}
|
||||
@@ -181,9 +184,17 @@ export default function EditProfileDrawer({
|
||||
placeholderTextColor="#666666"
|
||||
returnKeyType="done"
|
||||
onSubmitEditing={handleSave}
|
||||
blurOnSubmit={true}
|
||||
editable={!loading}
|
||||
/>
|
||||
/> */}
|
||||
|
||||
<TextInput style={styles.input}
|
||||
value={name}
|
||||
onChangeText={setName}
|
||||
placeholder={t('editProfile.namePlaceholder')}
|
||||
placeholderTextColor="#666666"
|
||||
returnKeyType="done"
|
||||
onSubmitEditing={handleSave}
|
||||
editable={!loading}></TextInput>
|
||||
|
||||
{/* 保存按钮 */}
|
||||
<Pressable
|
||||
@@ -205,8 +216,8 @@ export default function EditProfileDrawer({
|
||||
)}
|
||||
</LinearGradient>
|
||||
</Pressable>
|
||||
</View>
|
||||
</BottomSheetScrollView>
|
||||
</BottomSheetView>
|
||||
|
||||
</BottomSheetModal>
|
||||
)
|
||||
}
|
||||
@@ -222,15 +233,8 @@ const styles = StyleSheet.create({
|
||||
flex: 1,
|
||||
backgroundColor: '#1C1E22',
|
||||
paddingHorizontal: 16,
|
||||
},
|
||||
scrollView: {
|
||||
flex: 1,
|
||||
},
|
||||
scrollContent: {
|
||||
paddingTop: 32,
|
||||
paddingBottom: Platform.OS === 'ios' ? 25 : 17,
|
||||
paddingHorizontal: 0,
|
||||
flexGrow: 1,
|
||||
},
|
||||
closeButton: {
|
||||
position: 'absolute',
|
||||
|
||||
@@ -110,17 +110,6 @@ export default function PointsDrawer({
|
||||
<View style={styles.balance}>
|
||||
<Text style={styles.balanceValue}>{totalPoints}</Text>
|
||||
</View>
|
||||
|
||||
{/* 积分类型细分 */}
|
||||
<View style={styles.breakdown}>
|
||||
<Text style={styles.breakdownText}>{t('pointsDrawer.subscriptionPoints')}
|
||||
<Text style={styles.breakdownTextValue}>{subscriptionPoints}</Text>
|
||||
</Text>
|
||||
<View style={styles.breakdownTextSeparator} />
|
||||
<Text style={styles.breakdownText}>{t('pointsDrawer.topUpPoints')}
|
||||
<Text style={styles.breakdownTextValue}>{topUpPoints}</Text>
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* 底部按钮 */}
|
||||
|
||||
@@ -103,7 +103,7 @@ export default function TopUpDrawer({
|
||||
// 获取余额 store 的方法
|
||||
const { load: loadBalance, restartPolling } = useUserBalanceStore()
|
||||
|
||||
const snapPoints = useMemo(() => [420], [])
|
||||
const snapPoints = useMemo(() => [500], [])
|
||||
|
||||
useEffect(() => {
|
||||
if (visible) {
|
||||
|
||||
@@ -222,7 +222,13 @@
|
||||
"agreementText": "I have read and agree to",
|
||||
"terms": "Terms of Service",
|
||||
"privacy": "Privacy Policy",
|
||||
"agreementAnd": "and"
|
||||
"agreementAnd": "and",
|
||||
"alipayNotInstalled": "Alipay SDK not installed",
|
||||
"createOrderFailed": "Failed to create order",
|
||||
"paymentSuccess": "Payment successful! Points are being credited...",
|
||||
"paymentCancelled": "Payment cancelled",
|
||||
"paymentFailed": "Payment failed, please try again",
|
||||
"paymentError": "Payment error"
|
||||
},
|
||||
"tabs": {
|
||||
"home": "Home",
|
||||
|
||||
@@ -222,7 +222,13 @@
|
||||
"agreementText": "我已阅读并同意",
|
||||
"terms": "服务条款",
|
||||
"privacy": "隐私协议",
|
||||
"agreementAnd": "与"
|
||||
"agreementAnd": "与",
|
||||
"alipayNotInstalled": "支付宝 SDK 未安装",
|
||||
"createOrderFailed": "创建订单失败",
|
||||
"paymentSuccess": "支付成功!积分正在到账中...",
|
||||
"paymentCancelled": "支付已取消",
|
||||
"paymentFailed": "支付失败,请重试",
|
||||
"paymentError": "支付出错"
|
||||
},
|
||||
"tabs": {
|
||||
"home": "首页",
|
||||
|
||||
41
stores/editProfileStore.ts
Normal file
41
stores/editProfileStore.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { create } from 'zustand'
|
||||
|
||||
interface EditProfileState {
|
||||
visible: boolean
|
||||
initialName: string
|
||||
initialAvatar?: string
|
||||
onSaveCallback?: (data: { name: string; avatar?: string }) => void
|
||||
}
|
||||
|
||||
interface EditProfileActions {
|
||||
open: (params: {
|
||||
initialName?: string
|
||||
initialAvatar?: string
|
||||
onSave?: (data: { name: string; avatar?: string }) => void
|
||||
}) => void
|
||||
close: () => void
|
||||
}
|
||||
|
||||
type EditProfileStore = EditProfileState & EditProfileActions
|
||||
|
||||
export const useEditProfileStore = create<EditProfileStore>((set) => ({
|
||||
visible: false,
|
||||
initialName: '',
|
||||
initialAvatar: undefined,
|
||||
onSaveCallback: undefined,
|
||||
|
||||
open: ({ initialName = '', initialAvatar, onSave }) => {
|
||||
set({
|
||||
visible: true,
|
||||
initialName,
|
||||
initialAvatar,
|
||||
onSaveCallback: onSave,
|
||||
})
|
||||
},
|
||||
|
||||
close: () => {
|
||||
set({
|
||||
visible: false,
|
||||
})
|
||||
},
|
||||
}))
|
||||
Reference in New Issue
Block a user