leon 1 tahun lalu
induk
melakukan
d951f98232

+ 4 - 1
ios/NativeBridge.m

@@ -148,6 +148,9 @@ RCT_EXPORT_METHOD(addLocalPush2:(id)detail){
 
 RCT_EXPORT_METHOD(addLocalPush:(id)array){
   dispatch_async(dispatch_get_main_queue(), ^{
+    UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
+    [center removeAllPendingNotificationRequests];
+    
     NSMutableArray *list = [NSMutableArray new];
     for (int i=0;i<[array count];i++){
       id detail = array[i];
@@ -184,7 +187,7 @@ RCT_EXPORT_METHOD(addLocalPush:(id)array){
       
       UNNotificationCategory *categroy = [UNNotificationCategory categoryWithIdentifier:category_id actions:actions intentIdentifiers:@[] options:UNNotificationCategoryOptionCustomDismissAction];
       [list addObject:categroy];
-//      [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObject:categroy]];
+      //      [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObject:categroy]];
       content.categoryIdentifier = category_id;
       
       if ([mode isEqualToString:@"RECURRING"]){

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

@@ -472,6 +472,7 @@ export default {
                 alert_title:'Begin Your Sleepstreak',
                 alert_content:'Begin growing your sleepstreak \nalong with your faststreak.',
                 alert_confirm:'Got it!',
+                heads_up:'Heads-up',
             },
             change_tz_alert: {
                 title: 'New Time Zone Detected',

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

@@ -474,6 +474,7 @@ export default {
                 alert_title:'开启睡眠连续纪录',
                 alert_content:'让你的睡眠连续纪录\n与断食连续纪录一起同步增长。',
                 alert_confirm:'我知道了',
+                heads_up:'提示',
             },
             change_tz_alert: {
                 title: '检测到新时区',

+ 36 - 9
src/features/trackTimeDuration/components/StreakItem.tsx

@@ -63,16 +63,38 @@ export default function StreakItem(props: { isFast: boolean, data: any }) {
         return '天'
     }
 
+    function nextStatus(){
+        const {status} = props.data.current
+        if (status == 'EXPIRED'){
+            return t('feature.track_time_duration.streaks.last_reset')
+        }
+        else {
+            return t('feature.track_time_duration.streaks.next_reset')
+        }
+    }
+
     function getTime() {
-        if (props.data.current.reset_ts) {
-            var date = new Date(props.data.current.reset_ts - 1000)
+        const {status} = props.data.current
+        var ts:any=null;
+        switch (status){
+            case 'EXPIRED':
+                ts = props.data.current.prev_reset_ts
+                break;
+            case 'ACTIVE':
+                ts = props.data.current.reset_ts
+                break;
+            case 'NOT_DETERMINED':
+            case 'HEADS_UP':
+                return t('feature.track_time_duration.streaks.not_determined');
+        }
+
+            var date = new Date(ts)
             var time = TimeFormatter.padZero(date.getHours()) + ':' + TimeFormatter.padZero(date.getMinutes())
-            if (TimeFormatter.dateDescription(props.data.current.reset_ts - 1000, false) == 'Today') {
+            if (TimeFormatter.dateDescription(ts, false) == 'Today') {
                 return 'Tonight ' + time
             }
-            return TimeFormatter.dateDescription(props.data.current.reset_ts - 1000, false) + ' ' + time
-        }
-        return '时间'
+            return TimeFormatter.dateDescription(ts, false) + ' ' + time
+   
     }
 
     function tapDetail() {
@@ -131,18 +153,23 @@ export default function StreakItem(props: { isFast: boolean, data: any }) {
         }
         <View className='streak_next'>
             <View className='streak_line_left' />
-            <Text className='streak_next_text'>Next Reset</Text>
+            <Text className='streak_next_text'>{nextStatus()}</Text>
             <View className='streak_line_right' />
         </View>
         <Text className='streak_status'>{getTime()}</Text>
         <View className='streak_bottom'>
             {
-                props.data.current.reset_ts && <View className='streak_bottom_info' style={{ backgroundColor: 'red' }} onClick={(e) => {
+                props.data.current.status=='ACTIVE' && <View className='streak_bottom_info' style={{ backgroundColor: 'red' }}>
+                    <Text className='streak_bottom_info_text'>{TimeFormatter.countdown(props.data.current.reset_ts)}</Text>
+                </View>
+            }
+            {
+                props.data.current.status=='HEADS_UP' && <View className='streak_bottom_info' style={{ backgroundColor: ColorType.sleep }} onClick={(e) => {
                     if (process.env.TARO_ENV == 'weapp')
                         e.stopPropagation()
                     tapDetail()
                 }}>
-                    <Text className='streak_bottom_info_text'>{TimeFormatter.countdown(props.data.current.reset_ts)}</Text>
+                    <Text className='streak_bottom_info_text'>{t('feature.track_time_duration.streaks.heads_up')}</Text>
                 </View>
             }
 

+ 1 - 1
src/pages/clock/Clock.tsx

@@ -451,7 +451,7 @@ export default function Page() {
     }
 
     function getCheckData() {
-
+        debugger
         Promise.all([getClocks(), getPlans()]).then((list) => {
             setErrorPage(false)
             setCheckData(list)

+ 1 - 0
src/services/trackTimeDuration.tsx

@@ -85,6 +85,7 @@ export const getClockRecords = (params: any) => {
 }
 
 export const recordCheck = (params: Record<string, any>) => {
+    debugger
     if (params.real_check_time) {
         var date = new Date((params as any).real_check_time)
         var month = date.getMonth() + 1