Leon hai 1 ano
pai
achega
1c16e34383

+ 23 - 0
android/app/src/main/java/com/hola/AlarmReceiver.java

@@ -87,6 +87,29 @@ public class AlarmReceiver extends BroadcastReceiver {
             builder.addAction(0, "Pick an earlier end", openAppPendingIntent2);
         }
 
+        if (categoryId.equals("REMINDER_FS_START_FAST_T2")||
+                categoryId.equals("REMINDER_FS_START_FAST_T3")||
+                categoryId.equals("REMINDER_FS_START_FAST_T4")||
+                categoryId.equals("REMINDER_FS_START_SLEEP_T3")){
+            reminderId = 5;
+            if (categoryId.equals("REMINDER_FS_START_FAST_T3")){
+                reminderId = 6;
+            }
+            else if (categoryId.equals("REMINDER_FS_START_FAST_T4")){
+                reminderId = 7;
+            }
+            else if (categoryId.equals("REMINDER_FS_START_SLEEP_T3")){
+                reminderId = 8;
+            }
+
+            Intent openAppIntent = new Intent(context, MainActivity.class);
+            openAppIntent.setAction("LOG_MY_TIMES");
+            openAppIntent.putExtra("id",strId);
+            openAppIntent.putExtra("category_id",categoryId);
+            PendingIntent openAppPendingIntent = PendingIntent.getActivity(context, 0, openAppIntent, flags);
+            builder.addAction(0, "Log my times", openAppPendingIntent);
+        }
+
 
         // 显示通知
         NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);

+ 12 - 1
ios/AppDelegate.mm

@@ -312,6 +312,17 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
   }
 }
 
+- (void)jumpNotificationSettingPage{
+  if (self.rnLoaded){
+    [self.timer invalidate];
+    self.timer = nil;
+    [self.nativeBridge.bridge.eventDispatcher sendAppEventWithName:@"openNotificationSetting" body:@{}];
+  }
+  else {
+    
+  }
+}
+
 - (void)makeNetworkRequest{
   //https://api.fast.dev.liveplus.fun/api/static-resource-urls
   NSURL *url = [NSURL URLWithString:@"https://api.fast.dev.liveplus.fun/api/static-resource-urls"];
@@ -386,7 +397,7 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
 }
 
 - (void)userNotificationCenter:(UNUserNotificationCenter *)center openSettingsForNotification:(nullable UNNotification *)notification{
-  NSLog(@"open setting");
+  self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(jumpNotificationSettingPage) userInfo:nil repeats:YES];
 }
 
 

+ 10 - 0
ios/NativeBridge.m

@@ -206,6 +206,16 @@ RCT_EXPORT_METHOD(addLocalPush:(id)array){
         
         actions = @[action1,action2,action3];
       }
+      else if ([category_id isEqualToString:@"REMINDER_FS_START_FAST_T2"]||
+               [category_id isEqualToString:@"REMINDER_FS_START_FAST_T3"]||
+               [category_id isEqualToString:@"REMINDER_FS_START_FAST_T4"]||
+               [category_id isEqualToString:@"REMINDER_FS_START_SLEEP_T3"]){
+        UNNotificationAction *action2 = [UNNotificationAction actionWithIdentifier:@"LOG_MY_TIMES" title:@"Log my times" options:UNNotificationActionOptionForeground];
+        
+        UNNotificationAction *action3 = [UNNotificationAction actionWithIdentifier:@"SKIP" title:@"Skip" options:UNNotificationActionOptionAuthenticationRequired];
+        
+        actions = @[action2,action3];
+      }
       
       UNNotificationCategory *categroy = [UNNotificationCategory categoryWithIdentifier:category_id actions:actions intentIdentifiers:@[] options:UNNotificationCategoryOptionCustomDismissAction];
       [list addObject:categroy];

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 1
ios/main.jsbundle


+ 2 - 1
src/app.config.ts

@@ -26,7 +26,8 @@ const appConfig = defineAppConfig({
     'pages/workout/History',
     'pages/account/Member',
     'pages/explore/Index',
-    'pages/clock/StreakDetail'
+    'pages/clock/StreakDetail',
+    'pages/notification/setting'
   ],
   entryPagePath: 'pages/clock/Clock',
   subPackages: [

+ 25 - 0
src/features/trackTimeDuration/components/IndexConsole.tsx

@@ -117,6 +117,31 @@ export default function IndexConsole(props: { record: any, count: number }) {
                             }
                         }
                         break;
+                    case 'LOG_MY_TIMES':
+                        {
+                            if (category_id == 'REMINDER_FS_START_FAST_T2') {
+                                if (props.record.scenario.name == 'FAST_SLEEP') {
+                                    tapStartSleep(null)
+                                }
+                                else {
+                                    tapEndFast(null)
+                                }
+
+                            }
+                            if (props.record.scenario.name == 'FAST') {
+                                return
+                            }
+                            if (category_id == 'REMINDER_FS_START_FAST_T3') {
+                                tapEndSleep(null)
+                            }
+                            else if (category_id == 'REMINDER_FS_START_FAST_T4') {
+                                tapEndFast(null)
+                            }
+                            else if (category_id == 'REMINDER_FS_START_SLEEP_T3') {
+                                tapEndSleep(null)
+                            }
+                        }
+                        break;
                     case 'END_TIMER_NOW':
                         {
                             if (category_id == 'REMINDER_FS_END_FAST') {

+ 126 - 30
src/features/trackTimeDuration/components/IndexConsoleMuti.tsx

@@ -6,10 +6,12 @@ import { ColorType } from "@/context/themes/color";
 import "@/components/layout/Modal.scss";
 import './IndexConsoleMuti.scss';
 import { useRef, useState } from "react";
-import { batchClocks, getLocalPush } from "../actions/TrackTimeActions";
+import { batchClocks, endFast, getLocalPush } from "../actions/TrackTimeActions";
 import dayjs from "dayjs";
 import Modal from "@/components/layout/Modal.weapp";
 import ConsolePicker from "./ConsolePicker";
+import Taro from "@tarojs/taro";
+import { TimeFormatter } from "@/utils/time_format";
 
 let min = 0
 let max = 0
@@ -19,10 +21,10 @@ export default function IndexConsoleMuti(props: { status: string, event: string,
     const isLoading = false;
     var color = ColorType.fast;
     var alpha = alphaToHex(0.4)
-    const [fastStart, setFastStart] = useState<any>(0)
-    const [fastEnd, setFastEnd] = useState<any>(0)
-    const [sleepStart, setSleepStart] = useState<any>(0)
-    const [sleepEnd, setSleepEnd] = useState<any>(0)
+    const [fastStart, setFastStart] = useState<any>(null)
+    const [fastEnd, setFastEnd] = useState<any>(null)
+    const [sleepStart, setSleepStart] = useState<any>(null)
+    const [sleepEnd, setSleepEnd] = useState<any>(null)
     const [showPicker, setShowPicker] = useState(false)
     const [operateType, setOperateType] = useState('startFast')
     const pickerRef = useRef(null)
@@ -37,38 +39,108 @@ export default function IndexConsoleMuti(props: { status: string, event: string,
         var sleep: any = {}
         switch (props.event) {
             case 'start_sleep':
-                fast.real_start_time = new Date().getTime() - 100 * 1000
-                fast.real_start_date = dayjs().format('YYYYMMDD')
-                sleep.real_start_time = new Date().getTime() - 50
-                sleep.real_start_date = dayjs().format('YYYYMMDD')
+                if (!fastStart) {
+                    Taro.showToast({
+                        icon: 'none',
+                        title: '请选择开始断食时间'
+                    })
+                    return
+                }
+                if (!sleepStart) {
+                    Taro.showToast({
+                        icon: 'none',
+                        title: '请选择开始睡眠时间'
+                    })
+                    return
+                }
+                fast.real_start_time = fastStart.time
+                fast.real_start_date = fastStart.date
+                sleep.real_start_time = sleepStart.time
+                sleep.real_start_date = sleepStart.date
                 break;
             case 'end_sleep':
                 if (props.status == 'WAIT_FOR_START') {
-                    fast.real_start_time = new Date().getTime() - 100 * 1000
-                    fast.real_start_date = dayjs().format('YYYYMMDD')
+                    if (!fastStart) {
+                        Taro.showToast({
+                            icon: 'none',
+                            title: '请选择开始断食时间'
+                        })
+                        return
+                    }
+                    fast.real_start_time = fastStart.time
+                    fast.real_start_date = fastStart.date
+                }
+                if (!sleepStart) {
+                    Taro.showToast({
+                        icon: 'none',
+                        title: '请选择开始睡眠时间'
+                    })
+                    return
+                }
+                if (!sleepEnd) {
+                    Taro.showToast({
+                        icon: 'none',
+                        title: '请选择结束睡眠时间'
+                    })
+                    return
                 }
-                sleep.real_start_time = new Date().getTime() - 50 * 1000
-                sleep.real_start_date = dayjs().format('YYYYMMDD')
-                sleep.real_end_time = new Date().getTime()
-                sleep.real_end_date = dayjs().format('YYYYMMDD')
+                sleep.real_start_time = sleepStart.time
+                sleep.real_start_date = sleepStart.date
+                sleep.real_end_time = sleepEnd.time
+                sleep.real_end_date = sleepEnd.date
                 break;
             case 'end_fast':
                 if (props.status == 'WAIT_FOR_START') {
-                    fast.real_start_time = new Date().getTime() - 100 * 1000
-                    fast.real_start_date = dayjs().format('YYYYMMDD')
+                    if (!fastStart) {
+                        Taro.showToast({
+                            icon: 'none',
+                            title: '请选择开始断食时间'
+                        })
+                        return
+                    }
+                    if (!sleepStart) {
+                        Taro.showToast({
+                            icon: 'none',
+                            title: '请选择开始睡眠时间'
+                        })
+                        return
+                    }
+                    fast.real_start_time = fastStart.time
+                    fast.real_start_date =  fastStart.date
 
-                    sleep.real_start_time = new Date().getTime() - 50 * 1000
-                    sleep.real_start_date = dayjs().format('YYYYMMDD')
+                    sleep.real_start_time = sleepStart.time
+                    sleep.real_start_date = sleepStart.date
 
                 }
                 else if (props.status == 'ONGOING1') {
-                    sleep.real_start_time = new Date().getTime() - 50 * 1000
-                    sleep.real_start_date = dayjs().format('YYYYMMDD')
+                    if (!sleepStart) {
+                        Taro.showToast({
+                            icon: 'none',
+                            title: '请选择开始睡眠时间'
+                        })
+                        return
+                    }
+                    sleep.real_start_time = sleepStart.time
+                    sleep.real_start_date = sleepStart.date
                 }
-                sleep.real_end_time = new Date().getTime() - 20 * 1000
-                sleep.real_end_date = dayjs().format('YYYYMMDD')
-                fast.real_end_time = new Date().getTime()
-                fast.real_end_date = dayjs().format('YYYYMMDD')
+                if (!sleepEnd) {
+                    Taro.showToast({
+                        icon: 'none',
+                        title: '请选择结束睡眠时间'
+                    })
+                    return
+                }
+                if (!fastEnd) {
+                    Taro.showToast({
+                        icon: 'none',
+                        title: '请选择结束断食时间'
+                    })
+                    return
+                }
+                sleep.real_end_time = sleepEnd.time
+                sleep.real_end_date = sleepEnd.date
+                fast.real_end_time = fastEnd.time
+                fast.real_end_date = fastEnd.date
                 break;
         }
         batchClocks({
@@ -110,7 +182,7 @@ export default function IndexConsoleMuti(props: { status: string, event: string,
         return <View className="new_item_cell" onClick={() => tapItem(0)}>
             <Text className="new_item_cell_title">{t('feature.track_time_duration.common.start_fast')}</Text>
             <View style={{ flex: 1 }} />
-            <Text className="new_item_cell_desc">Pick Time</Text>
+            <Text className="new_item_cell_desc">{fastStart?TimeFormatter.dateTimeFormate(fastStart.time,true):'Pick Time'}</Text>
             <Image className="cell_arrow" src={require('@/assets/images/arrow3.png')} />
         </View>
     }
@@ -119,7 +191,7 @@ export default function IndexConsoleMuti(props: { status: string, event: string,
         return <View className="new_item_cell" onClick={() => tapItem(1)}>
             <Text className="new_item_cell_title">{t('feature.track_time_duration.common.start_sleep')}</Text>
             <View style={{ flex: 1 }} />
-            <Text className="new_item_cell_desc">Pick Time</Text>
+            <Text className="new_item_cell_desc">{sleepStart?TimeFormatter.dateTimeFormate(sleepStart.time,true):'Pick Time'}</Text>
             <Image className="cell_arrow" src={require('@/assets/images/arrow3.png')} />
         </View>
     }
@@ -128,7 +200,7 @@ export default function IndexConsoleMuti(props: { status: string, event: string,
         return <View className="new_item_cell" onClick={() => tapItem(2)}>
             <Text className="new_item_cell_title">{t('feature.track_time_duration.common.end_sleep')}</Text>
             <View style={{ flex: 1 }} />
-            <Text className="new_item_cell_desc">Pick Time</Text>
+            <Text className="new_item_cell_desc">{sleepEnd?TimeFormatter.dateTimeFormate(sleepEnd.time,true):'Pick Time'}</Text>
             <Image className="cell_arrow" src={require('@/assets/images/arrow3.png')} />
         </View>
     }
@@ -137,7 +209,7 @@ export default function IndexConsoleMuti(props: { status: string, event: string,
         return <View className="new_item_cell" onClick={() => tapItem(3)}>
             <Text className="new_item_cell_title">{t('feature.track_time_duration.common.end_fast')}</Text>
             <View style={{ flex: 1 }} />
-            <Text className="new_item_cell_desc">Pick Time</Text>
+            <Text className="new_item_cell_desc">{fastEnd?TimeFormatter.dateTimeFormate(fastEnd.time,true):'Pick Time'}</Text>
             <Image className="cell_arrow" src={require('@/assets/images/arrow3.png')} />
         </View>
     }
@@ -207,8 +279,32 @@ export default function IndexConsoleMuti(props: { status: string, event: string,
                 isLoading={false}
                 hidenEndTime={true}
                 onChange={(e) => {
-
+                    setShowPicker(false)
                     global.pauseIndexTimer = false
+                    if (operateType == 'startFast') {
+                        setFastStart({
+                            time: e,
+                            date: dayjs(e).format('YYYYMMDD')
+                        })
+                    }
+                    else if (operateType == 'endFast') {
+                        setFastEnd({
+                            time: e,
+                            date: dayjs(e).format('YYYYMMDD')
+                        })
+                    }
+                    else if (operateType == 'startSleep') {
+                        setSleepStart({
+                            time: e,
+                            date: dayjs(e).format('YYYYMMDD')
+                        })
+                    }
+                    else {
+                        setSleepEnd({
+                            time: e,
+                            date: dayjs(e).format('YYYYMMDD')
+                        })
+                    }
                 }}
             />
 

+ 16 - 0
src/pages/clock/ClockMain.tsx

@@ -136,6 +136,15 @@ export default function Page() {
         console.log('计时器开始')
         pauseTimer = false;
         mainTimer()
+
+        if (process.env.TARO_ENV=='rn'){
+            NativeAppEventEmitter.addListener('openNotificationSetting', (data) => {
+                console.log('aaaa')
+                debugger
+                jumpPage('/pages/account/ChooseAuth', 'NotificationSetting', navigation)
+            })
+        }
+        
     }, [])
 
     function mainTimer() {
@@ -801,6 +810,12 @@ export default function Page() {
 
     var timestamp = new Date().getTime()
 
+    function goSetting(){
+        Taro.navigateTo({
+            url:'/pages/notification/setting'
+        })
+    }
+
     function render() {
         var smallTitle = ''
         const weekday = TimeFormatter.getDayOfWeek(new Date().getDay(), true);
@@ -837,6 +852,7 @@ export default function Page() {
                     </View>
                 </Box>
 
+                <Text style={{color:'#fff',fontSize:30}} onClick={goSetting}>notification setting</Text>
                 {
                     user.isLogin && records && records.length > 0 && <View className="index_section" style={{ marginTop: -rpxToPx(25 - 12), marginBottom: -rpxToPx(20) }}>
                         <Text className="index_section_title">{t('feature.track_time_duration.record_fast_sleep.header.latest_record')}</Text>

+ 7 - 0
src/pages/notification/setting.config.ts

@@ -0,0 +1,7 @@
+export default definePageConfig({
+    usingComponents: {
+        // 'ec-canvas': '../../lib/ec-canvas/ec-canvas',
+        // 'demo':'../../components/demo'
+    },
+    "navigationBarTitleText": "Notification Setting"
+})

+ 86 - 0
src/pages/notification/setting.scss

@@ -0,0 +1,86 @@
+.setting_container {
+    display: flex;
+    flex-direction: column;
+}
+
+.setting_segment {
+    margin-left: 46px;
+    margin-right: 46px;
+    margin-bottom: 20px;
+}
+
+.setting_section {
+    height: 120px;
+    display: flex;
+    flex-direction: row;
+    align-items: center;
+}
+
+.setting_section_title {
+    color: #fff;
+    margin-left: 46px;
+    font-weight: bold;
+    font-size: 48px;
+}
+
+.setting_header {
+    font-size: 28px;
+    margin-bottom: 20px;
+    color: #fff;
+    opacity: 0.4;
+    margin-left: 86px;
+    margin-right: 86px;
+    letter-spacing: 0;
+}
+
+.setting_footer {
+    font-size: 28px;
+    margin-bottom: 40px;
+    color: #fff;
+    opacity: 0.2;
+    margin-left: 86px;
+    margin-right: 86px;
+    letter-spacing: 0;
+    margin-top: 20px;
+}
+
+.setting_cell{
+    display: flex;
+    flex-direction: row;
+    align-items: center;
+    margin-left: 46px;
+    margin-right: 46px;
+    background-color: #1c1c1c;
+    border-radius: 24px;
+    height: 96px;
+    padding-left: 40px;
+    padding-right: 40px;
+}
+
+.setting_cell_title{
+    color: #fff;
+    font-size: 28px;
+}
+
+.setting_cell_value1{
+    color: #fff;
+    opacity: 0.8;
+    font-size: 28px;
+}
+
+/* #ifdef weapp */
+.myswitch{
+    // width: 100px !important;
+    // height: 50px !important;
+    transform: scale(0.85);
+    transform-origin: right center;
+    margin-right: -10px;
+
+}
+
+/* #endif */
+
+/* #ifdef rn */
+.myswitch{
+}
+/* #endif */

+ 60 - 2
src/pages/notification/setting.tsx

@@ -1,11 +1,69 @@
-import { View, Text } from "@tarojs/components";
+import { View, Text, Switch } from "@tarojs/components";
 import Metric from "@/features/trackSomething/components/Metric";
 import { useDidShow, usePullDownRefresh, useShareAppMessage } from "@tarojs/taro";
-import Tabbar from "@/components/navigation/TabBar";
 import { useTranslation } from "react-i18next";
+import Segment from '@/components/navigation/Segment'
+import { useState } from "react";
+import { rpxToPx } from "@/utils/tools";
+import './setting.scss'
 
 export default function Page() {
     const { t } = useTranslation()
+    const [segmentIndex, setSegmentIndex] = useState(0)
+
+    function free() {
+        return <View className="setting_container">
+            <View className="setting_section">
+                <Text className="setting_section_title">Fasting</Text>
+            </View>
+            <Text className="setting_header">Reminders</Text>
+            <View className="setting_cell">
+                <Text className="setting_cell_title" style={{flex:1}}>At your scheduled time</Text>
+                <Text className="setting_cell_value1">On</Text>
+            </View>
+            <Text className="setting_footer">A timely reminder so you never miss your scheduled time for fasting.</Text>
+        </View>
+    }
+
+    function pro() {
+        return <View className="setting_container">
+            <View className="setting_section">
+                <Text className="setting_section_title">Fasting with Sleep</Text>
+            </View>
+            <Text className="setting_header">Reminders</Text>
+            <View className="setting_cell">
+                <Text className="setting_cell_title" style={{flex:1}}>At your scheduled time</Text>
+                <Text className="setting_cell_value1">On</Text>
+            </View>
+            <Text className="setting_footer">A timely reminder so you never miss your scheduled time for fasting or sleep.</Text>
+            <Text className="setting_header">Extra Reminders</Text>
+            <View className="setting_cell">
+                <Text className="setting_cell_title" style={{flex:1}}>At your scheduled time</Text>
+                <Switch className="myswitch" />
+            </View>
+            <Text className="setting_footer">In cases when you missed a previous action, you receive another reminder to log it together with the current action. This gives you extra protection against any streak loss.</Text>
+            <View className="setting_section">
+                <Text className="setting_section_title">Follow the Sun</Text>
+            </View>
+            <Text className="setting_header">Reminders for Your Daily Local Sun Schedule</Text>
+            <Text className="setting_footer">Note if live in polar region, during time of Polar Day (Midnight Sun) when the Sun is up all day and during time of Polar Night when the Sun is down all day, the only reminder available is for daily Solar Noon.</Text>
+        </View>
+    }
+
     return <View className="container">
+        <View className='setting_segment'>
+            <Segment titles={[
+                `Free`,
+                `Pro`,
+            ]}
+                changed={(e) => {
+                    setSegmentIndex(e);
+                    // global.segmentIndex = e
+                    // console.log('segment item click', e)
+                }} />
+        </View>
+        {
+            segmentIndex == 0 ? free() : pro()
+        }
     </View>
 }

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

@@ -23,6 +23,7 @@ import WorkoutDetail from '@/pages/workout/WorkoutDetail'
 import Explore from '../explore/Index';
 import StreakDetail from '@/pages/clock/StreakDetail';
 import H5 from '@/pages/common/H5';
+import NotificationSetting from '@/pages/notification/setting';
 import { Image, PixelRatio } from 'react-native';
 // import { View,Image } from '@tarojs/components';
 
@@ -231,6 +232,9 @@ export default function RNMain() {
         <Stack.Screen name='SetGoal' component={SetGoal} options={{
           headerBackTitle: ' '
         }} />
+        <Stack.Screen name='NotificationSetting' component={NotificationSetting} options={{
+          headerBackTitle: ' '
+        }} />
       </Stack.Navigator>
     </NavigationContainer>
   )

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio