leon 1 год назад
Родитель
Сommit
275be4f9a6

+ 1 - 1
ios/AppDelegate.mm

@@ -119,7 +119,7 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
 - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
 {
 //  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
-#if DEBUGAA
+#if DEBUG
   return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
 #else
   return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

+ 1 - 1
ios/hola.xcodeproj/project.pbxproj

@@ -661,7 +661,7 @@
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_TESTABILITY = YES;
 				EXCLUDED_ARCHS = "";
-				"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
+				"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
 				GCC_C_LANGUAGE_STANDARD = gnu99;
 				GCC_DYNAMIC_NO_PIC = NO;
 				GCC_NO_COMMON_BLOCKS = YES;

+ 3 - 3
src/app.tsx

@@ -36,9 +36,9 @@ const App: React.FC<PropsWithChildren> = ({ children }) => {
   if (process.env.TARO_ENV == 'rn') {
     global.language = 'en'
 
-    messaging().setBackgroundMessageHandler(async remoteMessage => {
-      console.log('Message is handled in the background!', remoteMessage);
-    });
+    // messaging().setBackgroundMessageHandler(async remoteMessage => {
+    //   console.log('Message is handled in the background!', remoteMessage);
+    // });
     // alert(Intl.DateTimeFormat().resolvedOptions().timeZone)
   }
   if (process.env.TARO_ENV == 'weapp') {

+ 1 - 0
src/features/daynight/DayNightRing.tsx

@@ -133,6 +133,7 @@ export default function DayNightRing(props: {
         if (authInfo && authInfo.timezone && authInfo.timezone.id) {
             var current1 = dayjs()
             var current = TimeFormatter.tzLocalTime(new Date().getTime(),authInfo.timezone.id)//dayjs().tz(authInfo.timezone.id)
+            debugger
             var offset = current.date() * 24 * 60 + current.hour() * 60 + current.minute() - current1.date() * 24 * 60 - current1.hour() * 60 - current1.minute()
             currentDot.offset = offset
         }

+ 1 - 1
src/pages/clock/ChooseScenario.scss

@@ -8,7 +8,7 @@
 }
 
 .item_sel1{
-    border-width: 1px;
+    border-width: 2px;
     border-color: $fastColor;
     border-style: solid;
     margin: 46px;

+ 14 - 11
src/pages/clock/ChooseScenario.tsx

@@ -9,6 +9,7 @@ import { chooseMode, initTarget, updateStep } from "@/store/set_target";
 import { useDispatch } from "react-redux";
 import { useDidShow } from "@tarojs/taro";
 import { TimeFormatter } from "@/utils/time_format";
+import Footer from "@/components/layout/Footer";
 
 export default function ChooseScenario() {
     const [selected, setSelected] = useState(0);
@@ -28,8 +29,6 @@ export default function ChooseScenario() {
                 }
             })
             dispatch(initTarget(targets))
-            // Taro.setStorage({ key: 'scenarios', data: JSON.stringify(data.scenarios as any) })
-            // setScenarios(data.scenarios)
         })
     }, [])
 
@@ -37,7 +36,7 @@ export default function ChooseScenario() {
         dispatch(updateStep({ step: 0 }))
     })
 
-    
+
 
     function goSuggestion() {
         var navigation: any = null
@@ -51,7 +50,7 @@ export default function ChooseScenario() {
 
     function chooseType(index: number) {
         setSelected(index)
-        
+
         dispatch(chooseMode({ isMixed: index == 1 }))
     }
 
@@ -63,13 +62,17 @@ export default function ChooseScenario() {
 
         <View className={selected == 0 ? 'item_sel1' : 'item1'} onClick={() => chooseType(0)}>Fasting</View>
         <View className={selected == 1 ? 'item_sel1' : 'item1'} onClick={() => chooseType(1)}>Fasting with Sleep</View>
-        <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
-            <ChooseScenarioBtn
-                onClick={goSuggestion}
-                title="Start"
-                background={ColorType.fast}
-            />
-        </View>
+        <View style={{flex:1}}/>
+        <Footer>
+            <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
+                <ChooseScenarioBtn
+                    onClick={goSuggestion}
+                    title="Start"
+                    background={ColorType.fast}
+                />
+            </View>
+        </Footer>
+
 
     </View>
 }

+ 0 - 68
src/pages/clock/Clock.tsx

@@ -52,8 +52,6 @@ import DayNightSwiper from "@/features/daynight/DayNightSwiper";
 import showAlert from "@/components/basic/Alert";
 import { APP_VERSION, WX_VERSION } from "@/services/http/api";
 
-// import {OneSignal} from 'react-native-onesignal';
-
 const utc = require('dayjs/plugin/utc')
 const timezone = require('dayjs/plugin/timezone')
 
@@ -128,72 +126,6 @@ export default function Page() {
     }
 
     useEffect(() => {
-        // if (process.env.TARO_ENV == 'rn' && Taro.getSystemInfoSync().platform == 'android') {
-        //     const LogLevel = require('react-native-onesignal').LogLevel
-        //     const OneSignal = require('react-native-onesignal').OneSignal
-
-        //     OneSignal.Debug.setLogLevel(LogLevel.Verbose);
-
-        //     // OneSignal Initialization
-        //     OneSignal.initialize("2bbf5339-7ab8-4c5c-9a66-c3a8eaea188e");
-
-        //     // requestPermission will show the native iOS or Android notification permission prompt.
-        //     // We recommend removing the following code and instead using an In-App Message to prompt for notification permission
-        //     OneSignal.Notifications.requestPermission(true);
-
-        //     // Method for listening for notification clicks
-        //     OneSignal.Notifications.addEventListener('click', (event) => {
-        //         console.log('OneSignal: notification clicked:', event);
-        //     });
-
-        //     OneSignal.User.getOnesignalId().then((id) => {
-        //         console.log('OneSignal: device id:', id);
-        //         showAlert({
-        //             title:'OneSignal',
-        //             content:'device id: ' + id
-        //         })
-        //     })
-
-        //     messaging()
-        //         .requestPermission()
-        //         .then(authStatus => {
-        //             console.log('APNs Status: ', authStatus);
-        //             if (
-        //                 authStatus === messaging.AuthorizationStatus.AUTHORIZED ||
-        //                 authStatus === messaging.AuthorizationStatus.PROVISIONAL
-        //             ) {
-        //                 messaging()
-        //                     .getToken()
-        //                     .then(token => {
-        //                         // showAlert({
-        //                         //     title: 'auth',
-        //                         //     content: token
-        //                         // })
-        //                         console.log('messaging.getToken: ', token);
-        //                     });
-        //                 messaging().onTokenRefresh(token => {
-        //                     console.log('messaging.onTokenRefresh: ', token);
-        //                 });
-        //                 fcmUnsubscribe = messaging().onMessage(async remoteMessage => {
-        //                     // showAlert({
-        //                     //     title:(remoteMessage as any).notification.title,
-        //                     //     content:(remoteMessage as any).notification.body,
-        //                     // })
-
-        //                 });
-        //             }
-        //         })
-        //         .catch(err => {
-        //             console.log('messaging.requestPermission Error: ', err);
-        //         });
-        // }
-
-        // if (process.env.TARO_ENV == 'weapp') {
-        //     showAlert({
-        //         title: 'date',
-        //         content: new Date().toString()
-        //     })
-        // }
         dispatch(staticResources() as any);
         timer = setInterval(() => {
             var now = new Date()

+ 95 - 17
src/pages/clock/SetGoal.tsx

@@ -12,8 +12,11 @@ import TimePicker from "@/features/common/TimePicker";
 import { useTranslation } from "react-i18next";
 import { updateFast, updateSleep } from "@/store/set_target";
 import { setPlan } from "@/services/trackTimeDuration";
+import showAlert from "@/components/basic/Alert";
+import Taro from "@tarojs/taro";
 
 export default function SetGoal() {
+    
     let router
     var navigation: any = null
     if (process.env.TARO_ENV === 'rn') {
@@ -156,28 +159,32 @@ export default function SetGoal() {
     }
 
     function confirm() {
-        var params:any = {}
+        var params: any = {
+            schedule: {
+                fast: {
+                    start_time: fastTarget.start_time,
+                    end_time: fastTarget.end_time,
+                    method: parseInt(router.params.isSelf + '') == 1 ? 'USER_SET' : 'SUGGEST'
+                },
+            }
+        }
+
         if (target.isMixed) {
             params.scenario = 'FAST_SLEEP'
+            params.schedule.sleep = {
+                start_time: sleepTarget.start_time,
+                end_time: sleepTarget.end_time,
+                method: parseInt(router.params.isSelf + '') == 1 ? 'USER_SET' : 'SUGGEST',
+                latency: {
+                    value: target.sleep.schedule.sleep.latency.default_value,
+                }
+            }
         }
         else {
             params.scenario = 'FAST'
         }
 
-        setPlan({
-            scenario: scenario.name,
-            schedule: {
-                fast: {
-                    start_time: isFastFirst ? scenario.schedule.fast.start_time : startTime,
-                    end_time: isFastFirst ? scenario.schedule.fast.end_time : endTime,
-                }, sleep: {
-                    start_time: !isFastFirst ? scenario.schedule.sleep.start_time : startTime,
-                    end_time: !isFastFirst ? scenario.schedule.sleep.end_time : endTime,
-                }
-            }
-        }).then(res => {
-            setBtnDisable(false)
-            dispatch(setStep('fast'))
+        setPlan(params).then(res => {
             if (global.checkData) {
                 global.checkData()
             }
@@ -185,13 +192,84 @@ export default function SetGoal() {
             if (global.indexPageRefresh) {
                 global.indexPageRefresh()
             }
-            popMixScheduleAlert(scenario.schedule.fast.start_time, startTime)
+            // popMixScheduleAlert(scenario.schedule.fast.start_time, startTime)
+
+            if (process.env.TARO_ENV === 'rn') {
+                popRNAlert()
+            }
+            else {
+                popAlert()
+            }
 
 
         }).catch(e => {
         })
     }
 
+    function popAlert() {
+        Taro.navigateBack({ delta: 6 }).then(res => {
+
+        })
+        if (target.isMixed) {
+            setTimeout(() => {
+                global.popMixScheduleAlert(fastTarget.start_time, sleepTarget.start_time)
+            }, 800)
+        }
+        else {
+            setTimeout(() => {
+                global.popScheduleAlert({
+                    name: 'FAST'
+                }, fastTarget.start_time)
+            }, 800)
+        }
+    }
+
+    function popRNAlert() {
+        // if (target.isMixed) {
+
+        // }
+        // else {
+        //     const JPush = require('jpush-react-native').default;
+        //     JPush.isNotificationEnabled((res) => {
+        //         if (res) {
+        //             showAlert({
+        //                 title: t('feature.track_time_duration.reminders.schedule_title'),
+        //                 content:
+        //                     t('feature.track_time_duration.reminders.enable_schedule_fast_content', { time: fastTarget.start_time }),
+        //                 showCancel: false,
+        //                 confirmText: t('feature.track_time_duration.reminders.ok'),
+        //                 cancel: () => {
+        //                     navigation.popToTop()
+        //                 },
+        //                 confirm: () => {
+        //                     navigation.popToTop()
+        //                 },
+        //             })
+        //         }
+        //         else {
+        //             showAlert({
+        //                 title: t('feature.track_time_duration.reminders.schedule_title'),
+        //                 content:
+        //                     t('feature.track_time_duration.reminders.schedule_fast_content', { time: fastTarget.start_time }),
+        //                 cancelText: t('feature.track_time_duration.reminders.later'),
+        //                 confirmText: t('feature.track_time_duration.reminders.open'),
+        //                 showCancel: true,
+        //                 cancel: () => {
+        //                     navigation.popToTop()
+        //                 },
+        //                 confirm: () => {
+        //                     // if (authStatus != 'not_determined') {
+        //                     //     navigation.popToTop()
+        //                     // }
+        //                     // checkNotification()
+        //                     // Linking.openURL('app-settings:notifications')
+        //                 }
+        //             })
+        //         }
+        //     })
+        // }
+    }
+
     return <View style={{ display: 'flex', flexDirection: 'column' }}>
         <Text className="target_title">{isSelf ? 'Set Action Plan' : 'Almost Done!'}</Text>
         {
@@ -282,7 +360,7 @@ export default function SetGoal() {
         <Footer>
             <ChooseScenarioBtn
                 onClick={confirm}
-                title={'Next'}
+                title={'Done'}
                 background={ColorType.fast}
             />
         </Footer>

+ 72 - 52
src/pages/clock/Suggest.tsx

@@ -1,7 +1,7 @@
 import { ColorType } from "@/context/themes/color";
 import { ChooseScenarioBtn } from "@/features/common/SpecBtns";
 import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
-import { View, Text, Picker } from "@tarojs/components";
+import { View, Text, Picker, ScrollView } from "@tarojs/components";
 import { useDidShow, useRouter } from "@tarojs/taro";
 import { useEffect, useState } from "react";
 import './ChooseScenario.scss';
@@ -10,7 +10,7 @@ import { useDispatch, useSelector } from "react-redux";
 import { rpxToPx } from "@/utils/tools";
 import { updateFast, updateSleep, updateStep } from "@/store/set_target";
 import { TimeFormatter } from "@/utils/time_format";
-import { set } from "lodash";
+import Footer from "@/components/layout/Footer";
 
 export default function Suggest() {
     let router: any = null
@@ -73,9 +73,20 @@ export default function Suggest() {
             var array: any = []
             for (var i = 0; i < sleep_cycle.numbers.length; i++) {
                 var count = sleep_cycle.numbers[i] * sleep_cycle.length + sleep_latency
+
+                var sleep = JSON.parse(JSON.stringify(target.sleep))
+                var startCount = sleep.schedule.sleep.end_time.split(':')[0] * 60 + sleep.schedule.sleep.end_time.split(':')[1] * 1 - count
+                if (startCount < 0) {
+                    startCount += 24 * 60
+                }
+                var start = TimeFormatter.padZero(Math.floor(startCount / 60)) + ':' + TimeFormatter.padZero(startCount % 60)
+
+
                 array.push({
                     hours: Math.floor(count / 60),
-                    minutes: count % 60
+                    minutes: count % 60,
+                    number: sleep_cycle.numbers[i],
+                    time: start
                 })
             }
             setSuggestItem(array)
@@ -100,7 +111,7 @@ export default function Suggest() {
             fast.schedule.fast.start_time = start
             dispatch(updateFast({ fast: fast }))
         }
-        else if (pageStep == 3){
+        else if (pageStep == 3) {
             var item = suggestItems[suggestIndex]
             var sleep = JSON.parse(JSON.stringify(target.sleep))
             var startCount = sleep.schedule.sleep.end_time.split(':')[0] * 60 + sleep.schedule.sleep.end_time.split(':')[1] * 1 - (item.hours * 60 + item.minutes)
@@ -172,12 +183,6 @@ export default function Suggest() {
         var min: number = 0
         var max: number = 23
         var step: number = 5
-
-        // if (common.duration) {
-        //     min = common.duration.min
-        //     max = common.duration.max
-        //     step = common.duration.step
-        // }
         var minutes: string[] = []
         for (let i = 0; i < 60; i += step) {
             minutes.push(TimeFormatter.padZero(i))
@@ -275,16 +280,19 @@ export default function Suggest() {
     }
 
     function timePicker() {
-        return <View style={{ marginTop: rpxToPx(56) }}>
-            <PickerViews ref={null}
-                onChange={timePickerChanged}
-                items={durationDatas()}
-                value={durationValues()} height={200}
-                title=''
-                themeColor={target.isMixed ? global.fastColor ? global.fastColor : ColorType.fast : global.sleepColor ? global.sleepColor : ColorType.sleep}
-                showBtns={false}
-                hideTitle={true}
-                onCancel={() => { }} />
+        return <View>
+            <View style={{ marginTop: rpxToPx(56), marginLeft: rpxToPx(46), marginRight: rpxToPx(46), borderRadius: rpxToPx(20), overflow: 'hidden' }}>
+                <PickerViews ref={null}
+                    onChange={timePickerChanged}
+                    items={durationDatas()}
+                    value={durationValues()} height={200}
+                    title=''
+                    themeColor={target.isMixed ? global.fastColor ? global.fastColor : ColorType.fast : global.sleepColor ? global.sleepColor : ColorType.sleep}
+                    showBtns={false}
+                    hideTitle={true}
+                    onCancel={() => { }} />
+
+            </View>
             <Text className="suggest_footer">If you plan to skip breakfast, pick a time for your first meal of the day.</Text>
         </View>
     }
@@ -298,47 +306,55 @@ export default function Suggest() {
     }
 
     function fallSleepPicker() {
-        return <View style={{ marginTop: rpxToPx(56) }}>
-            <PickerViews ref={null}
-                onChange={fallSleepChanged}
-                items={sleepLatency()}
-                value={sleepLatencyValue()} height={200}
-                title=''
-                themeColor={target.isMixed ? global.fastColor ? global.fastColor : ColorType.fast : global.sleepColor ? global.sleepColor : ColorType.sleep}
-                showBtns={false}
-                hideTitle={true}
-                onCancel={() => { }} />
+        return <View>
+            <View style={{ marginTop: rpxToPx(56), marginLeft: rpxToPx(46), marginRight: rpxToPx(46), borderRadius: rpxToPx(20), overflow: 'hidden' }}>
+                <PickerViews ref={null}
+                    onChange={fallSleepChanged}
+                    items={sleepLatency()}
+                    value={sleepLatencyValue()} height={200}
+                    title=''
+                    themeColor={target.isMixed ? global.fastColor ? global.fastColor : ColorType.fast : global.sleepColor ? global.sleepColor : ColorType.sleep}
+                    showBtns={false}
+                    hideTitle={true}
+                    onCancel={() => { }} />
+
+            </View>
             <Text className="suggest_footer">It takes 10 to 30 minutes for most people to fall asleep once they're in bed.</Text>
         </View>
     }
 
-
-
     function suggestList() {
         if (pageStep == 1) {
-            return <View>
-                {
-                    suggestItems.map((item: any, index: number) => {
-                        return <View onClick={() => {
-                            setSuggestIndex(index)
-                        }} key={index} className={index == suggestIndex ? 'item_sel1' : 'item1'}>{item.hours} hours {item.minutes} minutes</View>
-                    })
-                }
-            </View>
+            return <ScrollView scrollY style={{ height: 400 }}>
+                <View style={{ flexDirection: 'column', display: 'flex' }}>
+                    {
+                        suggestItems.map((item: any, index: number) => {
+                            return <View onClick={() => {
+                                setSuggestIndex(index)
+                            }} key={index} className={index == suggestIndex ? 'item_sel1' : 'item1'}>{item.hours} hours {item.minutes} minutes</View>
+                        })
+                    }
+                </View>
+            </ScrollView>
         }
-        return <View>
+        return <View style={{ flex: 1, overflow: 'scroll' }}>
             {
                 suggestItems.map((item: any, index: number) => {
                     return <View onClick={() => {
                         setSuggestIndex(index)
-                    }} key={index} className={index == suggestIndex ? 'item_sel1' : 'item1'}>{item.hours} hours {item.minutes} minutes</View>
+                    }} key={index} className={index == suggestIndex ? 'item_sel1' : 'item1'}>
+
+                        <View>{item.hours} hours {item.minutes} minutes</View>
+                        <View>{item.number} sleep cycles</View>
+                        <View style={{ color: ColorType.sleep }}>Go to bed at {item.time}</View>
+                    </View>
                 })
             }
         </View>
     }
 
     function content() {
-        return <View >
+        return <View style={{ flex: 1, display: 'flex', flexDirection: 'column' }}>
             {
                 (pageStep == 0 || pageStep == 2) && timePicker()
             }
@@ -359,13 +375,17 @@ export default function Suggest() {
             content()
         }
 
-        <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center' }}>
-            <ChooseScenarioBtn
-                onClick={next}
-                title={pageStep == 0 || pageStep == 2 ? 'Suggest Plan' : 'Next'}
-                background={ColorType.fast}
-            />
-            <Text style={{ color: '#fff', opacity: 0.4 }} onClick={myself}>Set It Myself</Text>
-        </View>
+        <Footer>
+            <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center' }}>
+                <ChooseScenarioBtn
+                    onClick={next}
+                    title={pageStep == 0 || pageStep == 2 ? 'Suggest Plan' : 'Next'}
+                    background={ColorType.fast}
+                />
+                <Text style={{ color: '#fff', opacity: 0.4 }} onClick={myself}>Set It Myself</Text>
+            </View>
+        </Footer>
+
+
     </View>
 }

+ 6 - 0
src/utils/push.tsx

@@ -5,6 +5,7 @@ import JPush from 'jpush-react-native';
 import { title } from 'process';
 import { uploadPermissions } from './native_permission_check';
 import {OneSignal} from 'react-native-onesignal'
+import Taro from '@tarojs/taro';
 
 export default function jgPush() {
     // const JPush = require('jpush-react-native')
@@ -56,6 +57,11 @@ export default function jgPush() {
         }, 3000)
     })
 
+    if (Taro.getSystemInfoSync().platform == 'ios'){
+        debugger
+        return;
+    }
+
     const LogLevel = require('react-native-onesignal').LogLevel
     // const OneSignal = require('react-native-onesignal').OneSignal