leon 1 ano atrás
pai
commit
01b1ca09d6

+ 5 - 1
ios/AppDelegate.mm

@@ -142,7 +142,7 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
 - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
 {
 //  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
-#if DEBUGAAA
+#if DEBUG
   return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
 #else
   return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
@@ -226,6 +226,10 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
   completionHandler(UNNotificationPresentationOptionAlert);
 }
 
+- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
+  
+}
+
 //iOS 10 消息事件回调
 - (void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler: (void (^)(void))completionHandler {
   NSDictionary * userInfo = response.notification.request.content.userInfo;

+ 90 - 6
ios/NativeBridge.m

@@ -106,7 +106,7 @@ RCT_EXPORT_METHOD(addLocalPush2:(id)detail){
     
     UNNotificationCategory *categroy = [UNNotificationCategory categoryWithIdentifier:@"c1" actions:actions intentIdentifiers:@[] options:UNNotificationCategoryOptionCustomDismissAction];
     
-    [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObject:categroy]];
+    //    [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObject:categroy]];
     content.categoryIdentifier = @"c1";
     
     UNTimeIntervalNotificationTrigger * trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:10 repeats:NO];
@@ -132,22 +132,106 @@ RCT_EXPORT_METHOD(addLocalPush2:(id)detail){
     
     UNNotificationCategory *categroy2 = [UNNotificationCategory categoryWithIdentifier:@"c12" actions:actions2 intentIdentifiers:@[] options:UNNotificationCategoryOptionCustomDismissAction];
     
-    [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObject:categroy2]];
+    //    [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObject:categroy2]];
+    [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithArray:@[categroy,categroy2]]];
     content2.categoryIdentifier = @"c12";
-
+    
     UNTimeIntervalNotificationTrigger * trigger2 = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:15 repeats:NO];
     NSString * identifier2 = @"e12";
     UNNotificationRequest * request2 = [UNNotificationRequest requestWithIdentifier:identifier2 content:content2 trigger:trigger2];
     [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request2 withCompletionHandler:^(NSError * _Nullable error) {
-      
     }];
     
-    
   });
 }
 
 
-RCT_EXPORT_METHOD(addLocalPush:(id)detail){
+RCT_EXPORT_METHOD(addLocalPush:(id)array){
+  dispatch_async(dispatch_get_main_queue(), ^{
+    NSMutableArray *list = [NSMutableArray new];
+    for (int i=0;i<[array count];i++){
+      id detail = array[i];
+      //设置通知内容
+      UNMutableNotificationContent * content = [[UNMutableNotificationContent alloc] init];
+      content.title = detail[@"title"];
+      content.body = [NSString stringWithFormat:@"%@\nPress for actions >>",detail[@"body"]];
+      
+      NSString *category_id = detail[@"category_id"];
+      NSString *message_id = detail[@"id"];
+      NSString *mode = detail[@"mode"];
+      
+      NSArray *actions;
+      if ([category_id isEqualToString:@"REMINDER_FS_START_FAST"]||[category_id isEqualToString:@"REMINDER_FS_START_SLEEP"]){
+        //消息的处理按钮
+        UNNotificationAction *action1 = [UNNotificationAction actionWithIdentifier:@"START_TIMER_NOW" title:@"Start timer now with 1-tap" options:UNNotificationActionOptionForeground];
+        
+        UNNotificationAction *action2 = [UNNotificationAction actionWithIdentifier:@"PICK_EARLIER_START" title:@"Pick an earlier start" options:UNNotificationActionOptionForeground];
+        
+        UNNotificationAction *action3 = [UNNotificationAction actionWithIdentifier:@"SKIP" title:@"Skip" options:UNNotificationActionOptionAuthenticationRequired];
+        
+        actions = @[action1,action2,action3];
+      }
+      else if([category_id isEqualToString:@"REMINDER_FS_END_FAST"]||[category_id isEqualToString:@"REMINDER_FS_END_SLEEP"]){
+        //消息的处理按钮
+        UNNotificationAction *action1 = [UNNotificationAction actionWithIdentifier:@"END_TIMER_NOW" title:@"End timer now with 1-tap" options:UNNotificationActionOptionForeground];
+        
+        UNNotificationAction *action2 = [UNNotificationAction actionWithIdentifier:@"PICK_EARLIER_END" title:@"Pick an earlier end" options:UNNotificationActionOptionForeground];
+        
+        UNNotificationAction *action3 = [UNNotificationAction actionWithIdentifier:@"SKIP" title:@"Skip" options:UNNotificationActionOptionAuthenticationRequired];
+        
+        actions = @[action1,action2,action3];
+      }
+      
+      UNNotificationCategory *categroy = [UNNotificationCategory categoryWithIdentifier:category_id actions:actions intentIdentifiers:@[] options:UNNotificationCategoryOptionCustomDismissAction];
+      [list addObject:categroy];
+//      [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObject:categroy]];
+      content.categoryIdentifier = category_id;
+      
+      if ([mode isEqualToString:@"RECURRING"]){
+        //设置推送的触发机制
+        NSArray *timeArray = [detail[@"recurring"][@"time"] componentsSeparatedByString:@":"];
+        NSInteger hour = [[timeArray objectAtIndex:0] integerValue];
+        NSInteger minute = [[timeArray objectAtIndex:1] integerValue];
+        NSInteger second = [[timeArray objectAtIndex:2] integerValue];
+        
+        // 2. 设置触发条件
+        NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
+        dateComponents.hour = hour;
+        dateComponents.minute = minute;
+        dateComponents.second = second;
+        UNCalendarNotificationTrigger *trigger = [UNCalendarNotificationTrigger triggerWithDateMatchingComponents:dateComponents repeats:YES];
+        
+        
+        NSString * identifier = message_id;
+        UNNotificationRequest * request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:trigger];
+        [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
+          
+        }];
+      }
+      else {
+        NSTimeInterval timestamp = [detail[@"once"] doubleValue]/1000; // 毫秒级时间戳
+        // 获取当前时间
+        NSDate *currentDate = [NSDate date];
+        // 计算当前时间与给定时间戳之间的时间差(秒)
+        NSTimeInterval timeInterval = timestamp - [currentDate timeIntervalSince1970];
+        
+        UNTimeIntervalNotificationTrigger * trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:timeInterval repeats:NO];
+        NSString * identifier = message_id;
+        UNNotificationRequest * request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:trigger];
+        [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
+          
+        }];
+      }
+    }
+    
+    [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithArray:list]];
+    
+    
+    
+  });
+}
+
+RCT_EXPORT_METHOD(addLocalPush3:(id)detail){
   dispatch_async(dispatch_get_main_queue(), ^{
     //设置通知内容
     UNMutableNotificationContent * content = [[UNMutableNotificationContent alloc] init];

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 0
ios/main.jsbundle


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

@@ -463,7 +463,15 @@ export default {
                 countdown_title: 'Don\'t lose your streak. Keep it going!',
                 countdown_titles: 'Don\'t lose your streaks. Keep them going!',
                 countdown_fast: 'Current fast streak will reset to zero in {{time}}.',
-                countdown_sleep: 'Current sleep streak will reset to zero in {{time}}.'
+                countdown_sleep: 'Current sleep streak will reset to zero in {{time}}.',
+                last_reset:'Last Reset',
+                next_reset:'Next Reset',
+                not_determined: 'Not Determined',
+                faststreak:'Faststreak',
+                sleepstreak:'Sleepstreak',
+                alert_title:'Begin Your Sleepstreak',
+                alert_content:'Begin growing your sleepstreak \nalong with your faststreak.',
+                alert_confirm:'Got it!',
             },
             change_tz_alert: {
                 title: 'New Time Zone Detected',

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

@@ -465,7 +465,15 @@ export default {
                 countdown_title: '别让连续纪录终止, 将它一直保持下去!',
                 countdown_titles: '别让连续纪录终止, 将它们一直保持下去!',
                 countdown_fast: '当前断食连续天数将在 {{time}} 后重置归零。',
-                countdown_sleep: '当前睡眠连续天数将在 {{time}} 后重置归零。'
+                countdown_sleep: '当前睡眠连续天数将在 {{time}} 后重置归零。',
+                last_reset:'上次归零',
+                next_reset:'下次归零',
+                not_determined: '未确定',
+                faststreak:'断食连续',
+                sleepstreak:'睡眠连续',
+                alert_title:'开启睡眠连续纪录',
+                alert_content:'让你的睡眠连续纪录\n与断食连续纪录一起同步增长。',
+                alert_confirm:'我知道了',
             },
             change_tz_alert: {
                 title: '检测到新时区',

+ 11 - 16
src/features/trackTimeDuration/actions/TrackTimeActions.tsx

@@ -135,28 +135,23 @@ export const getLocalPush = () => {
             });
             PushNotification.cancelAllLocalNotifications()
 
+            if (messages.length == 0) {
+                return
+            }
+
+            if (Taro.getSystemInfoSync().platform == 'ios') {
+                var Jto = require('react-native').NativeModules.NativeBridge;
+                Jto.addLocalPush(messages)
+                return;
+            }
+
+
             messages.map((item, index) => {
                 if (Taro.getSystemInfoSync().platform == 'ios') {
-                    // if (index>0) return;
                     setTimeout(() => {
                         var Jto = require('react-native').NativeModules.NativeBridge;
                         Jto.addLocalPush(item)
                     }, index * 1000)
-
-                    // PushNotification.localNotificationSchedule({
-                    //     //... You can use all the options from localNotifications
-                    //     channelId: item.id,
-                    //     title: item.title,
-                    //     message: item.content + '  ', // (required)
-                    //     date: new Date(date + 'T' + time), // in 60 secs
-                    //     allowWhileIdle: true, // (optional) set notification to work while on doze, default: false
-                    //     messageId: item.id,
-                    //     repeatType: repeat_type,
-                    //     // repeatType:'minute',
-                    //     /* Android Only Properties */
-
-                    // })
-                    // }
                 }
                 else {
                     PushNotification.createChannel({

+ 51 - 5
src/features/trackTimeDuration/components/StreakItem.tsx

@@ -6,6 +6,8 @@ import { ColorType } from '@/context/themes/color'
 import { useTranslation } from 'react-i18next'
 import { jumpPage } from '../hooks/Common'
 import { useEffect, useState } from 'react'
+import { TimeFormatter } from '@/utils/time_format'
+import showAlert from '@/components/basic/Alert'
 
 let useNavigation;
 if (process.env.TARO_ENV == 'rn') {
@@ -60,11 +62,37 @@ export default function StreakItem(props: { isFast: boolean, data: any }) {
         }
         return '天'
     }
+
+    function getTime() {
+        if (props.data.current.reset_ts) {
+            var date = new Date(props.data.current.reset_ts - 1000)
+            var time = TimeFormatter.padZero(date.getHours()) + ':' + TimeFormatter.padZero(date.getMinutes())
+            if (TimeFormatter.dateDescription(props.data.current.reset_ts - 1000, false) == 'Today') {
+                return 'Tonight ' + time
+            }
+            return TimeFormatter.dateDescription(props.data.current.reset_ts - 1000, false) + ' ' + time
+        }
+        return '时间'
+    }
+
+    function tapDetail() {
+        showAlert({
+            title: t('feature.track_time_duration.streaks.alert_title'),
+            content: t('feature.track_time_duration.streaks.alert_content'),
+            showCancel: false,
+            confirmText: t('feature.track_time_duration.streaks.alert_confirm')
+        })
+    }
+
+
     return <View className='streaks_item' onClick={goDetail}>
         <View className='streaks_item_header'>
-            <Text className='streak_item_type'>{props.isFast ? t('feature.track_time_duration.record_fast_sleep.item.fast') : t('feature.track_time_duration.record_fast_sleep.item.sleep')}</Text>
+            <Text className='streak_item_type'>{props.isFast ? t('feature.track_time_duration.streaks.faststreak') : t('feature.track_time_duration.streaks.sleepstreak')}</Text>
             {/* <IconShare2 width={rpxToPx(32)} color={props.isFast ? ColorType.fast : ColorType.sleep} /> */}
         </View>
+        <Text className='streak_index'
+            style={{ color: props.data.current.num_days == 0 ? '#ffffff99' : props.isFast ? ColorType.fast : ColorType.sleep }}
+        >{props.data.current.num_days}</Text>
         {
             props.data.current.num_days < 7 ? <View className='streak_item_point_bg'>
                 {
@@ -101,8 +129,26 @@ export default function StreakItem(props: { isFast: boolean, data: any }) {
                     </View>
                 </ScrollView>
         }
+        <View className='streak_next'>
+            <View className='streak_line_left' />
+            <Text className='streak_next_text'>Next Reset</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) => {
+                    if (process.env.TARO_ENV == 'weapp')
+                        e.stopPropagation()
+                    tapDetail()
+                }}>
+                    <Text className='streak_bottom_info_text'>{TimeFormatter.countdown(props.data.current.reset_ts)}</Text>
+                </View>
+            }
 
-        <View style={{ flexDirection: 'row', height: rpxToPx(36), overflow: 'hidden',alignItems:'flex-end' }}>
+        </View>
+
+        {/* <View style={{ flexDirection: 'row', height: rpxToPx(36), overflow: 'hidden',alignItems:'flex-end' }}>
             <Text className='streak_item_note'>{t('feature.track_time_duration.streaks.current')}</Text>
             {
                 props.data.current.num_days == 0 ? <Text className='streak_item_value' style={{ color: '#fff', opacity: 0.4,marginBottom:-2 }}>{props.data.current.num_days}</Text> :
@@ -114,11 +160,11 @@ export default function StreakItem(props: { isFast: boolean, data: any }) {
             }
 
 
-        </View>
-        <View style={{ marginTop: rpxToPx(16), flexDirection: 'row', height: rpxToPx(36), overflow: 'hidden',alignItems:'flex-end' }}>
+        </View> */}
+        {/* <View style={{ marginTop: rpxToPx(16), flexDirection: 'row', height: rpxToPx(36), overflow: 'hidden',alignItems:'flex-end' }}>
             <Text className='streak_item_note'>{t('feature.track_time_duration.streaks.longest')}</Text>
             <Text className='streak_item_value' style={{ color: '#fff', opacity: 0.4,marginBottom:-2 }}>{props.data.longest.num_days}</Text>
             <Text className='streak_item_note' style={{ fontWeight: 'bold' }}>{day(props.data.longest.num_days)}</Text>
-        </View>
+        </View> */}
     </View>
 }

+ 75 - 2
src/features/trackTimeDuration/components/Streaks.scss

@@ -1,4 +1,5 @@
 @import '@/utils/common.scss';
+
 .streaks_title {
     display: flex;
     font-weight: bold;
@@ -27,6 +28,9 @@
     padding-right: 24px;
     padding-top: 20px;
     padding-bottom: 40px;
+    display: flex;
+    flex-direction: column;
+    align-items: center;
 }
 
 .streaks_item_header {
@@ -48,7 +52,7 @@
     flex-direction: row;
     align-items: center;
     margin-top: 24px;
-    margin-bottom: 58px;
+    // margin-bottom: 58px;
 }
 
 .scroll_point_bg {
@@ -56,7 +60,6 @@
     flex-direction: row;
     // align-items: center;
     margin-top: 26px;
-    margin-bottom: 52px;
     width: 270px;
     box-sizing: border-box;
     border-radius: 6px;
@@ -128,6 +131,22 @@
     color: transparent;
 }
 
+.streak_line_left{
+    height: 1px;
+    margin-right: 10px;
+    background: linear-gradient(270deg, #2F2F2F 0%, rgba(47, 47, 47, 0) 100%);
+    transform: scaleY(0.5);
+    flex: 1;
+}
+
+.streak_line_right{
+    height: 1px;
+    margin-left: 10px;
+    background: linear-gradient(90deg, #2F2F2F 0%, rgba(47, 47, 47, 0) 100%);
+    transform: scaleY(0.5);
+    flex: 1;
+}
+
 
 /* #endif */
 
@@ -149,4 +168,58 @@
     opacity: 0.4;
     font-size: 18px;
     letter-spacing: 0;
+}
+
+.streak_index {
+    margin-top: 12px;
+    font-weight: bold;
+    font-size: 48px;
+}
+
+.streak_next {
+    display: flex;
+    flex-direction: row;
+    margin-top: 24px;
+    width: 120%;
+    align-items: center;
+}
+
+.streak_next_text{
+    font-size: 16px;
+    color: #2F2F2F;
+}
+
+.streak_status {
+    margin-top: 24px;
+    display: flex;
+    flex-direction: row;
+    align-items: center;
+    justify-content: center;
+    color: #fff;
+    opacity: 0.3;
+}
+
+.streak_bottom{
+    margin-top: 12px;
+    display: flex;
+    flex-direction: row;
+    justify-content: center;
+    align-items: center;
+    height: 34px;
+}
+
+.streak_bottom_info{
+    height: 34px;
+    padding-left: 15px;
+    padding-right: 15px;
+    border-radius: 6px;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+}
+
+.streak_bottom_info_text{
+    font-size: 20px;
+    color: #fff;
+    font-weight: bold;
 }

+ 4 - 4
src/features/trackTimeDuration/components/Streaks.tsx

@@ -94,13 +94,13 @@ export default function Streaks(props: { count: number }) {
                             <GradientText style={{ fontSize: rpxToPx(18), fontWeight: 'bold' }}>{t('feature.track_time_duration.streaks.countdown_title', { name: (fastStreaks.current.reset_ts && sleepStreaks.current.reset_ts) ? 'streaks' : 'streak' })}</GradientText>
 
                     } */}
-                    {
+                    {/* {
                         process.env.TARO_ENV == 'weapp' ? <Text className='streak_countdown_title'>{(fastStreaks.current.reset_ts && sleepStreaks.current.reset_ts)?t('feature.track_time_duration.streaks.countdown_titles'):t('feature.track_time_duration.streaks.countdown_title')}</Text> :
                             <GradientText style={{ fontSize: rpxToPx(18), fontWeight: 'bold' }}>{(fastStreaks.current.reset_ts && sleepStreaks.current.reset_ts)?t('feature.track_time_duration.streaks.countdown_titles'):t('feature.track_time_duration.streaks.countdown_title')}</GradientText>
 
-                    }
+                    } */}
                 </View>
-                {
+                {/* {
                     fastStreaks.current.reset_ts && <View className='streak_countdown_item'>
                         <View className='streak_point' />
                         <Text className='streak_countdown_value'>{t('feature.track_time_duration.streaks.countdown_fast', { time: TimeFormatter.countdown(fastStreaks.current.reset_ts) })}</Text>
@@ -111,7 +111,7 @@ export default function Streaks(props: { count: number }) {
                         <View className='streak_point' />
                         <Text className='streak_countdown_value'>{t('feature.track_time_duration.streaks.countdown_sleep', { time: TimeFormatter.countdown(sleepStreaks.current.reset_ts) })}</Text>
                     </View>
-                }
+                } */}
             </View>
         }
 

+ 10 - 4
src/pages/clock/ChooseScenario.tsx

@@ -26,7 +26,7 @@ export default function ChooseScenario() {
     const [selected, setSelected] = useState(0);
     const ring = useSelector((state: any) => state.ring);
     const { t } = useTranslation();
-    const [count,setCount] = useState(0)
+    const [count, setCount] = useState(0)
     const dispatch = useDispatch();
     var navigation: any = null
 
@@ -64,7 +64,7 @@ export default function ChooseScenario() {
     }, [])
 
     useDidShow(() => {
-        setCount(count=>count+1)
+        setCount(count => count + 1)
         dispatch(updateStep({ step: 0 }))
         dispatch(chooseMode({ isMixed: selected == 1 }))
     })
@@ -154,7 +154,10 @@ export default function ChooseScenario() {
         <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) }}>
+            <View style={{
+                flexShrink: 0, display: 'flex', width: 74, height: 74,
+                marginRight: rpxToPx(24), alignItems: 'center', justifyContent: 'center'
+            }}>
                 <Rings2 common={common} bgRing={bgRing} targetRing={selected == 0 ? targetRing : null} canvasId={new Date().getTime()} />
             </View>
             <View style={{ display: 'flex', flexDirection: 'column' }}>
@@ -169,7 +172,10 @@ export default function ChooseScenario() {
             }
         </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 }}>
+            <View style={{
+                flexShrink: 0, display: 'flex', width: 74, height: 74, marginRight: rpxToPx(24),
+                position: 'relative', zIndex: 1, alignItems: 'center', justifyContent: 'center'
+            }}>
                 <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} />

+ 101 - 75
src/pages/clock/Suggest.tsx

@@ -3,7 +3,7 @@ import { ChooseScenarioBtn } from "@/features/common/SpecBtns";
 import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
 import { View, Text, Picker, ScrollView } from "@tarojs/components";
 import { useDidShow, useRouter } from "@tarojs/taro";
-import { useEffect, useState } from "react";
+import { useEffect, useRef, useState } from "react";
 import './ChooseScenario.scss';
 import PickerViews from "@/components/input/PickerViews";
 import { useDispatch, useSelector } from "react-redux";
@@ -15,6 +15,12 @@ import { IconCheck } from "@/components/basic/Icons";
 import Rings2, { BgRing, RingCommon, TargetRing } from '@/features/trackTimeDuration/components/Rings';
 import { useTranslation } from "react-i18next";
 
+let ScrollViewRN
+if (process.env.TARO_ENV === 'rn') {
+    ScrollViewRN = require('react-native').ScrollView
+}
+
+
 export default function Suggest() {
     let router: any = null
     var navigation: any = null
@@ -39,6 +45,7 @@ export default function Suggest() {
     const [fastRecommendIndex, setFastRecommendIndex] = useState(-1)
     const [fastLastIndex, setFastLastIndex] = useState(-1)
     const { t } = useTranslation()
+    const scrollViewRef = useRef(null);
 
 
     useEffect(() => {
@@ -105,7 +112,11 @@ export default function Suggest() {
             setSuggestItem(array)
             setSuggestIndex(currentIndex)
             setScrollTop(currentIndex * rpxToPx(244) + 50)
-            // setScrollTop(currentIndex * 100-30)
+            if (process.env.TARO_ENV=='rn'){
+                setTimeout(()=>{
+                    (scrollViewRef.current as any).scrollTo({x:0,y:currentIndex * rpxToPx(244)+20,animated:true})
+                },500)
+            }
         }
         else if (pageStep == 3) {
             var obj = target.sleep.schedule.sleep
@@ -459,85 +470,100 @@ export default function Suggest() {
         return (end - start) / 1440 * 2 * Math.PI
     }
 
-    function suggestList() {
-        if (pageStep == 1) {
-            return <ScrollView scrollY style={{ height: 400 }} scrollTop={scrollTop}>
-                <View style={{ flexDirection: 'column', display: 'flex' }}>
-                    {
-                        suggestItems.map((item: any, index: number) => {
-                            return <View key={index} className={suggestIndex == index ? 'item1 item_sel1' : 'item1'} onClick={() => setSuggestIndex(index)}>
-                                <View style={{ flexShrink: 0, display: 'flex', width: 74, height: 74, marginRight: rpxToPx(24) }}>
-                                    <Rings2 common={ringCommon()}
-                                        bgRing={bgRing}
-                                        targetRing={targetRing(item.time, target.fast.schedule.fast.end_time, true, suggestIndex == index)}
-                                        dotList={point(true, index == suggestIndex)}
-                                        canvasId={new Date().getTime() + index * 5} />
-                                </View>
-                                <View style={{flex:1}}>
-    
-                                        <View className="suggest_item_title">{item.hours} hours</View>
-
-                                    <View className="suggest_item_desc">{index == suggestIndex ?
-                                        t('feature.suggest.fast_desc', { start_time: item.hours, end_time: item.left }) :
-                                        t('feature.suggest.intermitent_fast', { data: `${item.hours}/${item.left}` })
-                                    }</View>
-                                    {
-                                        index == suggestIndex &&
-                                        <View className="suggest_choose">
-                                            <View style={{ color: ColorType.fast }}>{t('feature.suggest.start_fast_time', { time: item.time })}</View>
-
-                                        </View>
-                                    }
+    function scrollContent() {
+        return <View style={{ flexDirection: 'column', display: 'flex' }}>
+            {
+                suggestItems.map((item: any, index: number) => {
+                    return <View key={index} className={suggestIndex == index ? 'item1 item_sel1' : 'item1'} onClick={() => setSuggestIndex(index)}>
+                        <View style={{ flexShrink: 0, display: 'flex', width: 74, height: 74, marginRight: rpxToPx(24) }}>
+                            <Rings2 common={ringCommon()}
+                                bgRing={bgRing}
+                                targetRing={targetRing(item.time, target.fast.schedule.fast.end_time, true, suggestIndex == index)}
+                                dotList={point(true, index == suggestIndex)}
+                                canvasId={new Date().getTime() + index * 5} />
+                        </View>
+                        <View style={{ flex: 1 }}>
+
+                            <View className="suggest_item_title">{item.hours} hours</View>
+
+                            <View className="suggest_item_desc">{index == suggestIndex ?
+                                t('feature.suggest.fast_desc', { start_time: item.hours, end_time: item.left }) :
+                                t('feature.suggest.intermitent_fast', { data: `${item.hours}/${item.left}` })
+                            }</View>
+                            {
+                                index == suggestIndex &&
+                                <View className="suggest_choose">
+                                    <View style={{ color: ColorType.fast }}>{t('feature.suggest.start_fast_time', { time: item.time })}</View>
 
                                 </View>
-                                {
-                                    index == suggestIndex && <View className="choose_item_check_bg">
-                                        <IconCheck color={ColorType.fast} width={24} height={24} />
-                                    </View>
-                                }
-                                <View className='suggest_fast_tag_bg'>
-                                    {
-                                        index == fastRecommendIndex &&
-                                        <View className='suggest_fast_tag'>{t('feature.suggest.popular')}</View>
-                                    }
-                                    {
-                                        index == fastLastIndex &&
-                                        <View className='suggest_fast_tag'>{t('feature.suggest.recent')}</View>
-                                    }
-                                </View>
+                            }
+
+                        </View>
+                        {
+                            index == suggestIndex && <View className="choose_item_check_bg">
+                                <IconCheck color={ColorType.fast} width={24} height={24} />
                             </View>
+                        }
+                        <View className='suggest_fast_tag_bg'>
+                            {
+                                index == fastRecommendIndex &&
+                                <View className='suggest_fast_tag'>{t('feature.suggest.popular')}</View>
+                            }
+                            {
+                                index == fastLastIndex &&
+                                <View className='suggest_fast_tag'>{t('feature.suggest.recent')}</View>
+                            }
+                        </View>
+                    </View>
 
-                            // return <View onClick={() => {
-                            //     setSuggestIndex(index)
-                            // }} key={index} className={index == suggestIndex ? 'item_choose_selected' : 'item_choose'}>
-                            //     <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
-                            //         <View className="suggest_item_title">{item.hours} hours</View>
-                            //         <View style={{ flex: 1 }} />
-                            //         {
-                            //             index == fastRecommendIndex &&
-                            //             <View style={{ color: '#fff' }}>Popular</View>
-                            //         }
-                            //         {
-                            //             index == fastLastIndex &&
-                            //             <View style={{ color: '#fff', marginLeft: 5 }}>Recent</View>
-                            //         }
-                            //     </View>
-
-                            //     <View className="suggest_item_desc">{index == suggestIndex ? `${item.hours} hours fasting / ${item.left} hours eating` : `${item.hours}/${item.left} Intermittent Fasting`}</View>
-                            //     {
-                            //         index == suggestIndex &&
-                            //         <View className="suggest_choose">
-                            //             <View style={{ color: ColorType.fast }}>Start fasting at  {item.time}</View>
-                            //             <IconCheck color={ColorType.fast} width={38} height={26} />
-                            //         </View>
-                            //     }
-
-                            // </View>
-                        })
-                    }
-                </View>
+                    // return <View onClick={() => {
+                    //     setSuggestIndex(index)
+                    // }} key={index} className={index == suggestIndex ? 'item_choose_selected' : 'item_choose'}>
+                    //     <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
+                    //         <View className="suggest_item_title">{item.hours} hours</View>
+                    //         <View style={{ flex: 1 }} />
+                    //         {
+                    //             index == fastRecommendIndex &&
+                    //             <View style={{ color: '#fff' }}>Popular</View>
+                    //         }
+                    //         {
+                    //             index == fastLastIndex &&
+                    //             <View style={{ color: '#fff', marginLeft: 5 }}>Recent</View>
+                    //         }
+                    //     </View>
+
+                    //     <View className="suggest_item_desc">{index == suggestIndex ? `${item.hours} hours fasting / ${item.left} hours eating` : `${item.hours}/${item.left} Intermittent Fasting`}</View>
+                    //     {
+                    //         index == suggestIndex &&
+                    //         <View className="suggest_choose">
+                    //             <View style={{ color: ColorType.fast }}>Start fasting at  {item.time}</View>
+                    //             <IconCheck color={ColorType.fast} width={38} height={26} />
+                    //         </View>
+                    //     }
+
+                    // </View>
+                })
+            }
+        </View>
+    }
+
+    function suggestList() {
+        if (pageStep == 1 && process.env.TARO_ENV === 'weapp') {
+            return <ScrollView scrollY style={{ height: 400 }} scrollTop={scrollTop}>
+                {
+                    scrollContent()
+                }
             </ScrollView>
         }
+
+        if (pageStep == 1 && process.env.TARO_ENV === 'rn') {
+            return <ScrollViewRN style={{ height: 400 }} ref={scrollViewRef}>
+                {
+                    scrollContent()
+                }
+            </ScrollViewRN>
+        }
+
         return <View style={{ flex: 1, overflow: 'scroll' }}>
             {
                 suggestItems.map((item: any, index: number) => {

+ 1 - 1
src/utils/time_format.ts

@@ -113,6 +113,7 @@ export class TimeFormatter {
   static dateTimeFormate(timestamp: number, ignoreWeek?: boolean) {
     const currentDate = new Date();
     const inputDate = new Date(timestamp);
+    debugger
 
     // 判断是否是今天
     if (
@@ -330,7 +331,6 @@ export class TimeFormatter {
     const now = new Date();
     const diff = now.getTime() - dt.getTime();
     const day = 1000 * 60 * 60 * 24;
-
     if (diff < day && !showFullDate) {
       return TimeFormatter.getTodayUnit();
     } else if (diff < 2 * day && !showFullDate) {

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff