11import { Icon , Toast } from '@ant-design/react-native' ;
22import AsyncStorage from '@react-native-async-storage/async-storage' ;
33import { LinearGradient } from 'expo-linear-gradient' ;
4- import { router } from 'expo-router' ;
4+ import { router , useFocusEffect } from 'expo-router' ;
55import * as React from 'react' ;
6- import { FC , useEffect , useState } from 'react' ;
6+ import { FC , useCallback , useEffect , useState } from 'react' ;
77import {
8+ BackHandler ,
89 Dimensions ,
910 Image ,
11+ Platform ,
1012 StyleSheet ,
1113 Text ,
1214 TouchableOpacity ,
@@ -23,12 +25,13 @@ import Animated, {
2325import AnimatedFade from '@/components/animatedView/AnimatedFade' ;
2426import AnimatedOpacity from '@/components/animatedView/AnimatedOpacity' ;
2527import Button from '@/components/button' ;
28+ import Modal from '@/components/modal' ;
2629import Pagination from '@/components/pagination' ;
2730
2831import useVisualScheme from '@/store/visualScheme' ;
2932
3033import { preloginGuide } from '@/constants/prelogin' ;
31- import { commonStyles } from '@/styles/common' ;
34+ import { commonColors , commonStyles } from '@/styles/common' ;
3235import { percent2px } from '@/utils' ;
3336
3437const PAGE_SWIPE_ANIMATION_DURATION = 450 ;
@@ -49,6 +52,41 @@ const GuidePage: FC = () => {
4952 } ;
5053 // 标题移动距离
5154 const titleShift = useSharedValue ( 0 ) ;
55+
56+ useFocusEffect (
57+ useCallback ( ( ) => {
58+ AsyncStorage . getItem ( 'agreement' ) . then ( agreement => {
59+ if ( agreement !== 'accepted' ) {
60+ Modal . show ( {
61+ children : < AgreementModal /> ,
62+ mode : 'middle' ,
63+ cancelText : '不同意' ,
64+ confirmText : '同意并接受' ,
65+ onConfirm : ( ) => {
66+ AsyncStorage . setItem ( 'agreement' , 'accepted' ) ;
67+ } ,
68+ onCancel ( ) {
69+ if ( Platform . OS === 'android' ) {
70+ router . replace ( '/auth/guide' ) ;
71+ BackHandler . exitApp ( ) ;
72+ } else if ( Platform . OS === 'ios' ) {
73+ router . replace ( '/auth/guide' ) ;
74+ }
75+ } ,
76+ onClose ( ) {
77+ if ( Platform . OS === 'android' ) {
78+ router . replace ( '/auth/guide' ) ;
79+ } else if ( Platform . OS === 'ios' ) {
80+ router . replace ( '/auth/guide' ) ;
81+ }
82+ } ,
83+ } ) ;
84+ }
85+ } ) ;
86+ return ( ) => { } ;
87+ } , [ ] )
88+ ) ;
89+
5290 useEffect ( ( ) => {
5391 'worklet' ;
5492 // 渐变条每次移动多少
@@ -67,16 +105,20 @@ const GuidePage: FC = () => {
67105 }
68106 ) ;
69107 } , [ gradientValue , activeIndex , titleShift ] ) ;
108+
70109 const gradientStyle = useAnimatedStyle ( ( ) => ( {
71110 transform : [ { translateX : gradientValue . value } ] ,
72111 } ) ) ;
112+
73113 const titleStyle = useAnimatedStyle ( ( ) => ( {
74114 transform : [ { translateX : titleShift . value } ] ,
75115 } ) ) ;
116+
76117 const handleStart = ( ) => {
77118 router . navigate ( '/auth/login' ) ;
78119 AsyncStorage . setItem ( 'firstLaunch' , 'true' ) ;
79120 } ;
121+
80122 // 跳转第几条内容
81123 const jump = ( pageNum : number ) => {
82124 if ( pageNum > preloginGuide . length - 1 || pageNum < 0 ) {
@@ -94,6 +136,7 @@ const GuidePage: FC = () => {
94136 setActiveContentIndex ( pageNum ) ;
95137 } , PAGE_SWIPE_ANIMATION_DURATION + 200 ) ;
96138 } ;
139+
97140 const onSwipe = Gesture . Pan ( )
98141 . minDistance ( 30 )
99142 . onEnd ( event => {
@@ -105,6 +148,7 @@ const GuidePage: FC = () => {
105148 const handleChange = ( current : number ) => {
106149 jump ( current ) ;
107150 } ;
151+
108152 return (
109153 < View style = { styles . guide_wrap } >
110154 < GestureDetector gesture = { onSwipe } >
@@ -184,6 +228,36 @@ const GuidePage: FC = () => {
184228
185229export default GuidePage ;
186230
231+ export const AgreementModal : FC = ( ) => {
232+ return (
233+ < Text
234+ style = { [ commonStyles . fontMedium , { textAlign : 'center' , lineHeight : 22 } ] }
235+ >
236+ 请你务必审慎阅读、充分理解“用户协议”和“隐私政策”各条款,包括但不限于:为了更好的向你提供服务,我们需要收集你的设备标识、操作日志等信息用于分析、优化应用性能。你可阅读
237+ < Text
238+ style = { { color : commonColors . purple , textDecorationLine : 'underline' } }
239+ onPress = { ( ) => {
240+ router . push ( '/(setting)/agreement' ) ;
241+ Modal . clear ( ) ;
242+ } }
243+ >
244+ 《用户协议》
245+ </ Text >
246+ 和
247+ < Text
248+ style = { { color : commonColors . purple , textDecorationLine : 'underline' } }
249+ onPress = { ( ) => {
250+ router . push ( '/(setting)/privacy' ) ;
251+ Modal . clear ( ) ;
252+ } }
253+ >
254+ 《隐私政策》
255+ </ Text >
256+ 了解详细信息。如果你同意,请点击下面按钮开始接受我们的服务。
257+ </ Text >
258+ ) ;
259+ } ;
260+
187261const styles = StyleSheet . create ( {
188262 skip_container : {
189263 flexDirection : 'row' ,
0 commit comments