leon 1 gadu atpakaļ
vecāks
revīzija
f7b6bfc89c

+ 1 - 0
package.json

@@ -49,6 +49,7 @@
 		"@react-native-clipboard/clipboard": "~1.11.1",
 		"@react-native-community/geolocation": "~3.0.2",
 		"@react-native-community/netinfo": "~9.3.0",
+		"@react-native-community/push-notification-ios": "^1.11.0",
 		"@react-native-community/slider": "~4.3.2",
 		"@react-native-firebase/app": "^19.2.2",
 		"@react-native-firebase/messaging": "^19.2.2",

+ 2 - 1
src/context/locales/en.js

@@ -182,10 +182,11 @@ export default {
             },
             lose_access:{
                 title:'Premium Access Lost',
-                desc:'You\'ve lost premium access to the \'Fasting with Sleep\' feature\nsince you lost your fasting streak. To regain access, become a PRO or achieve a new 3-day fasting streak.',
+                desc:'You\'ve lost premium access to the \'Fasting with Sleep\' feature\nsince you lost your {{type}} streak. To regain access, become a PRO or achieve a new 3-day fasting streak.',
                 confirm:'Become a PRO member',
                 cancel:'Achieve New Fasting Streak'
             },
+            
         },
         common: {
             prompt: 'Prompt',

+ 1 - 1
src/context/locales/zh.js

@@ -185,7 +185,7 @@ export default {
             },
             lose_access:{
                 title:'Premium Access Lost',
-                desc:'You\'ve lost premium access to the \'Fasting with Sleep\' feature\nsince you lost your fasting streak. To regain access, become a PRO or achieve a new 3-day fasting streak.',
+                desc:'You\'ve lost premium access to the \'Fasting with Sleep\' feature\nsince you lost your {{type}} streak. To regain access, become a PRO or achieve a new 3-day fasting streak.',
                 confirm:'Become a PRO member',
                 cancel:'Achieve New Fasting Streak'
             },

+ 11 - 5
src/features/trackTimeDuration/components/CheckAccess.tsx

@@ -67,6 +67,10 @@ export default function CheckAccess(props: { record: any, count: number }) {
                     }
                 }
             }
+
+            if (obj.current_record.status != 'WAIT_FOR_START') {
+                Taro.setStorage({ key: 'showedDisqualifiedAlert', data: false })
+            }
         }
     }, [props.count])
 
@@ -115,6 +119,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
 
             setSubConfirmText('')
             confirmAction = null
+            debugger
             // setAccess(acccessData)
 
             if (preStatus == 'NOT_QUALIFIED' && currentStatus == 'NOT_QUALIFIED') {
@@ -184,7 +189,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
 
                 setShowFastAlert(true)
                 setAlertTitle(t('feature.check_access.stay_qualified.title'))
-                setAlertContent(t('feature.check_access.stay_qualified.title', { fast_streak_day: streak_fast_current, sleep_streak_day: streak_sleep_current }))
+                setAlertContent(t('feature.check_access.stay_qualified.desc', { fast_streak_day: streak_fast_current, sleep_streak_day: streak_sleep_current }))
                 setShowCancel(false)
                 setConfirmText(t('feature.check_access.stay_qualified.btn'))
             }
@@ -222,6 +227,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
     }
 
     async function lose(condition) {
+        debugger
         var showedDisqualifiedAlert = await getStorage('showedDisqualifiedAlert') || false;
         if (showedDisqualifiedAlert) {
             return;
@@ -241,9 +247,9 @@ export default function CheckAccess(props: { record: any, count: number }) {
         setKeepContent(false)
         setAlertTitle(t('feature.check_access.lose_access.title'))
         setAlertContent(t('feature.check_access.lose_access.desc', { type: type }))
-        setShowCancel(true)
-        setCancelText('Achieve New Fasting Streak')
-        setConfirmText('Become a PRO member')
+        // setShowCancel(true)
+        setConfirmText(t('feature.check_access.lose_access.cancel'))
+        // setConfirmText('Become a PRO member')
         setSubConfirmText('')
         Taro.setStorage({ key: 'showedDisqualifiedAlert', data: true })
 
@@ -254,7 +260,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
         const { start_time, end_time } = global.ring.schedule.fast
         var params: any = {
             scenario: 'FAST',
-            trigger: 'POPUP_DISQUALIFIED_DISMISS',
+            trigger_event: 'POPUP_DISQUALIFIED_DISMISS',
             schedule: {
                 fast: {
                     start_time: start_time,

+ 7 - 7
src/pages/account/Setting.tsx

@@ -53,7 +53,7 @@ export default function Page() {
     }
 
     async function logoutF() {
-        var showDayRing = await getStorage('showedDisqualifiedAlert') || false;
+        // var showDayRing = await getStorage('showedDisqualifiedAlert') || false;
         showAlert({
             title: t('feature.common.modal.logout_title'),
             content: t('feature.common.modal.logout_content'),
@@ -69,12 +69,12 @@ export default function Page() {
                         })
                     }
 
-                    if (showDayRing) {
-                        Taro.setStorage({
-                            key: 'showedDisqualifiedAlert',
-                            data: true
-                        })
-                    }
+                    // if (showDayRing) {
+                    //     Taro.setStorage({
+                    //         key: 'showedDisqualifiedAlert',
+                    //         data: true
+                    //     })
+                    // }
                     
                     if (process.env.TARO_ENV == 'weapp') {
                         Taro.switchTab({

+ 16 - 4
src/pages/clock/ChooseScenario.scss

@@ -65,9 +65,11 @@
 }
 
 .choose_item_title {
-    font-size: 36px;
+    font-size: 40px;
     line-height: 48px;
     font-weight: bold;
+    color: #fff;
+    letter-spacing: 0;
 }
 
 .choose_item_desc {
@@ -171,8 +173,8 @@
 
 .choose_item_check_bg {
     position: absolute;
-    right: 20px;
-    bottom: 30px;
+    right: 40px;
+    bottom: 40px;
 }
 
 .choose_corner_tag {
@@ -229,4 +231,14 @@
     color: #000;
     margin-left: 20px;
     background-color: $fastColor;
-}
+}
+
+/* #ifdef weapp */
+.limit_offer{
+    background: linear-gradient(90deg, $fastColor 0%, $sleepColor 100%);
+}
+
+/* #endif */
+
+/* #ifdef rn */
+/* #endif */

+ 74 - 29
src/pages/clock/ChooseScenario.tsx

@@ -16,10 +16,16 @@ import { IconCheck } from "@/components/basic/Icons";
 import Rings2, { BgRing, RingCommon, TargetRing } from '@/features/trackTimeDuration/components/Rings';
 import { useTranslation } from "react-i18next";
 
+
+let LinearGradient
+if (process.env.TARO_ENV == 'rn') {
+    LinearGradient = require('react-native-linear-gradient').default
+}
+
 export default function ChooseScenario() {
     const [selected, setSelected] = useState(0);
     const ring = useSelector((state: any) => state.ring);
-    const {t} = useTranslation();
+    const { t } = useTranslation();
     const dispatch = useDispatch();
     var navigation: any = null
 
@@ -65,8 +71,8 @@ export default function ChooseScenario() {
 
     function goSuggestion() {
         dispatch(updateStep({ step: 0 }))
-        jumpPage(`/pages/clock/Suggest?trigger_event=`+router.params.trigger_event, 'Suggest', navigation, {
-            trigger_event:router.params.trigger_event
+        jumpPage(`/pages/clock/Suggest?trigger_event=` + router.params.trigger_event, 'Suggest', navigation, {
+            trigger_event: router.params.trigger_event
         })
     }
 
@@ -112,7 +118,7 @@ export default function ChooseScenario() {
     }
 
     const targetRing2: TargetRing = {
-        color:ColorType.sleep,
+        color: ColorType.sleep,
         startArc: timeToArc(ring.schedule.sleep.start_time),
         durationArc: durationToArc(ring.schedule.sleep.start_time, ring.schedule.sleep.end_time)
     }
@@ -133,56 +139,95 @@ export default function ChooseScenario() {
         return (end - start) / 1440 * 2 * Math.PI
     }
 
+    let background: any = 'linear-gradient(to right, ' + ColorType.fast + ', ' + ColorType.sleep + ')';
+    if (selected == 0) {
+        background = ColorType.fast
+    }
+
     return <View style={{
-        color: '#fff', flexDirection: 'column', display: 'flex'
+        color: '#fff', flexDirection: 'column', display: 'flex',
+        flex: 1
     }}>
         <Text className="target_title">{t('feature.choose_scenario.title')}</Text>
         <Text className="target_desc">{t('feature.choose_scenario.description')}</Text>
 
         <View className={selected == 0 ? 'item1 item_sel1' : 'item1'} onClick={() => chooseType(0)}>
             <View style={{ flexShrink: 0, display: 'flex', width: 74, height: 74, marginRight: rpxToPx(24) }}>
-                <Rings2 common={common} bgRing={bgRing} targetRing={selected==0?targetRing:null} canvasId={new Date().getTime()} />
+                <Rings2 common={common} bgRing={bgRing} targetRing={selected == 0 ? targetRing : null} canvasId={new Date().getTime()} />
             </View>
             <View style={{ display: 'flex', flexDirection: 'column' }}>
                 <Text className="choose_item_title">{t('feature.choose_scenario.fasting')}</Text>
                 <Text className="choose_item_desc">{t('feature.choose_scenario.fast_desc')}</Text>
-                {
-                    selected == 0 && <View className="choose_item_check_bg">
-                        <IconCheck color={ColorType.fast} width={38} height={26} />
-                    </View>
-                }
-
-                <View className="choose_corner_tag">{t('feature.choose_scenario.free')}</View>
-
-
             </View>
+            <View className="choose_corner_tag">{t('feature.choose_scenario.free')}</View>
+            {
+                selected == 0 && <View className="choose_item_check_bg">
+                    <IconCheck color={ColorType.fast} width={24} height={24} />
+                </View>
+            }
         </View>
         <View className={selected == 1 ? 'item1 item_sel1' : 'item1'} onClick={() => chooseType(1)}>
             <View style={{ flexShrink: 0, display: 'flex', width: 74, height: 74, marginRight: rpxToPx(24), position: 'relative', zIndex: 1 }}>
-                <Rings2 common={common} bgRing={bgRing} targetRing={selected==1?targetRing:null} canvasId={new Date().getTime()+2} />
+                <Rings2 common={common} bgRing={bgRing} targetRing={selected == 1 ? targetRing : null} canvasId={new Date().getTime() + 2} />
                 <View style={{ display: 'flex', position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, alignItems: 'center', justifyContent: 'center' }}>
-                    <Rings2 common={common2} bgRing={bgRing} targetRing={selected==1?targetRing2:null} canvasId={new Date().getTime()+4} />
+                    <Rings2 common={common2} bgRing={bgRing} targetRing={selected == 1 ? targetRing2 : null} canvasId={new Date().getTime() + 4} />
                 </View>
             </View>
-            <View style={{ display: 'flex', flexDirection: 'column' }}>
+            <View style={{ display: 'flex', flexDirection: 'column', flex: 1 }}>
                 <Text className="choose_item_title">{t('feature.choose_scenario.fast_sleep')}</Text>
                 <Text className="choose_item_desc">{t('feature.choose_scenario.fast_sleep_desc')}</Text>
-                {
-                    selected == 1 && <View className="choose_item_check_bg">
-                        <IconCheck color={ColorType.fast} width={38} height={26} />
-                    </View>
-                }
-                <View className="choose_corner_tag">{t('feature.choose_scenario.limit_time_offer')}</View>
+
+
             </View>
+            {
+                process.env.TARO_ENV == 'weapp' ? <View className="choose_corner_tag limit_offer">{t('feature.choose_scenario.limit_time_offer')}</View> :
+                    <LinearGradient className="choose_corner_tag"
+                        colors={[ColorType.fast, ColorType.sleep]}
+                        start={{ x: 0, y: 0 }}
+                        end={{ x: 1, y: 0 }}
+                    >
+                        <Text style={{ fontSize: rpxToPx(20) }}>{t('feature.choose_scenario.limit_time_offer')}</Text>
+                    </LinearGradient>
+            }
+            {
+                selected == 1 && <View className="choose_item_check_bg">
+                    <IconCheck color={ColorType.fast} width={24} height={24} />
+                </View>
+            }
+
         </View>
         <View style={{ flex: 1 }} />
         <Footer>
             <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
-                <ChooseScenarioBtn
-                    onClick={goSuggestion}
-                    title="Start"
-                    background={ColorType.fast}
-                />
+                {
+                    (process.env.TARO_ENV == 'weapp' || selected == 0) && <ChooseScenarioBtn
+                        onClick={goSuggestion}
+                        title="Start"
+                        background={background}
+                    />
+                }
+                {
+                    process.env.TARO_ENV == 'rn' && selected == 1 && <View onClick={goSuggestion}>
+                        <LinearGradient
+                            style={{
+                                width: 300,
+                                height: 50,
+                                borderRadius: 25,
+                                alignItems: 'center',
+                                justifyContent: 'center',
+                            }}
+                            colors={[ColorType.fast, ColorType.sleep]}
+                            start={{ x: 0, y: 0 }}
+                            end={{ x: 1, y: 0 }}
+                        >
+                            <Text style={{ fontWeight: 'bold', fontSize: 20 }}>Start</Text>
+                        </LinearGradient>
+                    </View>
+                }
+                {
+                    process.env.TARO_ENV == 'rn' && <View style={{ marginBottom: 40 }} />
+                }
+
             </View>
         </Footer>
 

+ 8 - 18
src/pages/clock/Clock.tsx

@@ -176,23 +176,6 @@ export default function Page() {
             PushNotification.configure({
                 onRegister: function (token) {
                     console.log('TOKEN:', token);
-                    PushNotification.localNotification({
-                        channelId: "channel-id-1",
-                        title: '推送通知',
-                        message: '这是一条本地推送通知',
-                        playSound: true,
-                        soundName: 'system',
-                    });
-
-                    PushNotification.localNotification({
-                        title: '通知栏推送',
-                        message: '这是一条通知栏推送通知',
-                        playSound: true,
-                        soundName: 'system',
-                        android: {
-                            priority: 'high',
-                        },
-                    });
                 },
 
                 onNotification: function (notification) {
@@ -212,7 +195,8 @@ export default function Page() {
 
             PushNotification.localNotificationSchedule({
                 //... You can use all the options from localNotifications
-                message: "My Notification Message444", // (required)
+                title: 'Leon test',
+                message: "Local notification push", // (required)
                 date: new Date(Date.now() + 10 * 1000), // in 60 secs
                 allowWhileIdle: true, // (optional) set notification to work while on doze, default: false
 
@@ -978,6 +962,12 @@ export default function Page() {
                 {
                     user.isLogin && <Streaks count={count} />
                 }
+                {
+                    user.isLogin && user.test_user && homeData && (homeData as any).access && <View style={{ display: 'flex', flexDirection: 'column' }}>
+                        <Text style={{ color: '#fff', fontSize: 15 }}>current status:{(homeData as any).access.current.qualification.status}</Text>
+                        <Text style={{ color: '#fff', fontSize: 15 }}>previous status:{(homeData as any).access.previous.qualification.status}</Text>
+                    </View>
+                }
 
                 {
                     process.env.TARO_ENV == 'weapp' && <View style={{ height: 100 }} />

+ 5 - 2
src/pages/clock/SetGoal.tsx

@@ -196,7 +196,7 @@ export default function SetGoal() {
             params.trigger_event = router.params.trigger_event
         }
         else {
-            params.trigger_event = router.params.trigger_event?router.params.trigger_event:'SET'
+            params.trigger_event = router.params.trigger_event ? router.params.trigger_event : 'SET'
         }
 
         setPlan(params).then(res => {
@@ -304,7 +304,7 @@ export default function SetGoal() {
         }
     }
 
-    return <View style={{ display: 'flex', flexDirection: 'column' }}>
+    return <View style={{ display: 'flex', flexDirection: 'column',flex:1 }}>
         <Text className="target_title">{isSelf ? t('feature.set_goal.set_action_plan') : t('feature.set_goal.almost_done')}</Text>
         {
             !isSelf && <Text className="target_desc">{t('feature.set_goal.header')}</Text>
@@ -401,5 +401,8 @@ export default function SetGoal() {
         {
             showTimePicker && modalContent()
         }
+        {
+            process.env.TARO_ENV == 'rn' && <View style={{ marginBottom: 40 }} />
+        }
     </View>
 }

+ 18 - 5
src/pages/clock/Suggest.tsx

@@ -491,11 +491,18 @@ export default function Suggest() {
                                         index == suggestIndex &&
                                         <View className="suggest_choose">
                                             <View style={{ color: ColorType.fast }}>{t('feature.suggest.start_fast_time', { time: item.time })}</View>
-                                            <IconCheck color={ColorType.fast} width={38} height={26} />
+
                                         </View>
                                     }
+
+                                </View>
+                                {
+                                index == suggestIndex && <View className="choose_item_check_bg">
+                                    <IconCheck color={ColorType.fast} width={24} height={24} />
                                 </View>
+                            }
                             </View>
+                            
                             // return <View onClick={() => {
                             //     setSuggestIndex(index)
                             // }} key={index} className={index == suggestIndex ? 'item_choose_selected' : 'item_choose'}>
@@ -530,7 +537,7 @@ export default function Suggest() {
         return <View style={{ flex: 1, overflow: 'scroll' }}>
             {
                 suggestItems.map((item: any, index: number) => {
-                    return <View key={index} className={suggestIndex == index ? 'item1 item_sel1' : 'item1'} onClick={() => setSuggestIndex(index)}>
+                    return <View key={index} className={suggestIndex == index ? 'item1 item_sel1' : 'item1'} style={{ borderColor: suggestIndex == index ? ColorType.sleep : '#00000000' }} onClick={() => setSuggestIndex(index)}>
                         <View style={{ flexShrink: 0, display: 'flex', width: 74, height: 74, marginRight: rpxToPx(24) }}>
                             <Rings2 common={ringCommon()}
                                 bgRing={bgRing}
@@ -545,11 +552,15 @@ export default function Suggest() {
                             {
                                 index == suggestIndex && <View className="suggest_choose">
                                     <View style={{ color: ColorType.sleep }}>{t('feature.suggest.go_to_bed_at', { time: item.time })}</View>
-                                    <IconCheck color={ColorType.sleep} width={38} height={26} />
                                 </View>
                             }
 
                         </View>
+                        {
+                            index == suggestIndex && <View className="choose_item_check_bg">
+                                <IconCheck color={ColorType.sleep} width={24} height={24} />
+                            </View>
+                        }
                         {
                             index == 0 && <View className='suggest_tag' style={{ backgroundColor: ColorType.sleep }}>{t('feature.suggest.popular')}</View>
                         }
@@ -577,7 +588,7 @@ export default function Suggest() {
     }
 
 
-    return <View style={{ display: 'flex', flexDirection: 'column' }}>
+    return <View style={{ display: 'flex', flexDirection: 'column', flex: 1 }}>
         <Text className="target_title">{suggestTitle()}</Text>
         <Text className="target_desc">{suggestDesc()}</Text>
         {
@@ -594,7 +605,9 @@ export default function Suggest() {
                 <Text className="suggest_footer_btn" onClick={myself}>{t('feature.suggest.set_myself')}</Text>
             </View>
         </Footer>
-
+        {
+            process.env.TARO_ENV == 'rn' && <View style={{ marginBottom: 40 }} />
+        }
 
     </View>
 }

+ 8 - 0
src/pages/rn/RNMain.tsx

@@ -12,6 +12,8 @@ import Auth from '@/pages/account/Auth'
 import Setting from '@/pages/account/Setting'
 import SetSchedule from '@/pages/clock/SetSchedule'
 import ChooseScenario from '@/pages/clock/ChooseScenario'
+import Suggest from '../clock/Suggest';
+import SetGoal from '../clock/SetGoal';
 import RecordsHistory from '@/pages/common/RecordsHistory'
 import ProfileSetting from '@/pages/account/ProfileSetting'
 import EditPage from '@/pages/account/EditPage'
@@ -223,6 +225,12 @@ export default function RNMain() {
         <Stack.Screen name='StreakDetail' component={StreakDetail} options={{
           headerBackTitle: ' '
         }} />
+        <Stack.Screen name='Suggest' component={Suggest} options={{
+          headerBackTitle: ' '
+        }} />
+        <Stack.Screen name='SetGoal' component={SetGoal} options={{
+          headerBackTitle: ' '
+        }} />
       </Stack.Navigator>
     </NavigationContainer>
   )

+ 7 - 0
yarn.lock

@@ -3653,6 +3653,13 @@
   resolved "https://registry.npmmirror.com/@react-native-community/netinfo/-/netinfo-9.3.11.tgz#3e449612def3d33873a93bcdd4204b73e71573b5"
   integrity sha512-zy47SjKuZVOlR+43rOVsD1BMLaHpeiICDye89YWUQKprFkI2AbnL0WrY/ezxL+n9nvoDJ2UTMpCUQe3tVu/ojQ==
 
+"@react-native-community/push-notification-ios@^1.11.0":
+  version "1.11.0"
+  resolved "https://registry.yarnpkg.com/@react-native-community/push-notification-ios/-/push-notification-ios-1.11.0.tgz#d8ec4acfb52260cb779ed0379b9e197db7841b83"
+  integrity sha512-nfkUs8P2FeydOCR4r7BNmtGxAxI22YuGP6RmqWt6c8EEMUpqvIhNKWkRSFF3pHjkgJk2tpRb9wQhbezsqTyBvA==
+  dependencies:
+    invariant "^2.2.4"
+
 "@react-native-community/slider@~4.3.2":
   version "4.3.3"
   resolved "https://registry.npmmirror.com/@react-native-community/slider/-/slider-4.3.3.tgz#281e90523ab3fac3463edf271ffe465cfd9932c9"