leon 1 éve
szülő
commit
ce643edece
1 módosított fájl, 38 hozzáadás és 28 törlés
  1. 38 28
      src/features/trackTimeDuration/components/IndexConsole.tsx

+ 38 - 28
src/features/trackTimeDuration/components/IndexConsole.tsx

@@ -9,7 +9,7 @@ import ConsolePicker from './ConsolePicker';
 import LimitPickers from '@/components/input/LimitPickers';
 import LimitTimeoutPickers from '@/components/input/LimitTimeoutPickers';
 import { getColor, getTimePickerTitle } from '../hooks/Console';
-import {kIsIOS, rpxToPx, vibrate } from '@/utils/tools';
+import { kIsIOS, rpxToPx, vibrate } from '@/utils/tools';
 import { TimeFormatter } from '@/utils/time_format';
 import Modal from '@/components/layout/Modal.weapp';
 import Taro, { useDidShow } from '@tarojs/taro';
@@ -23,8 +23,8 @@ import IndexConsoleMuti from './IndexConsoleMuti';
 
 let useNavigation;
 
-let Linking,PushNotification;
-let  checkNotification;
+let Linking, PushNotification;
+let checkNotification;
 if (process.env.TARO_ENV == 'rn') {
     useNavigation = require("@react-navigation/native").useNavigation
     Linking = require('react-native').Linking;
@@ -80,7 +80,7 @@ export default function IndexConsole(props: { record: any, count: number }) {
         if (process.env.TARO_ENV == 'rn') {
             // console.error('current status',status)
             var NativeAppEventEmitter = require('react-native').NativeAppEventEmitter;
-            if (nativePushListener){
+            if (nativePushListener) {
                 (nativePushListener as any).remove()
             }
             if (kIsIOS) {
@@ -89,14 +89,14 @@ export default function IndexConsole(props: { record: any, count: number }) {
             }
             nativePushListener = NativeAppEventEmitter.addListener('notificationReceive', (data) => {
                 console.log('notification receive action', data)
-                const { category_id, action_id,id } = data
+                const { category_id, action_id, id } = data
                 uploadLocalPushInfo({
-                    messageId:id
+                    messageId: id
                 })
                 switch (action_id) {
                     case 'START_TIMER_NOW':
                         {
-                            if (category_id == 'REMINDER_FS_START_FAST'){
+                            if (category_id == 'REMINDER_FS_START_FAST') {
                                 operateType = 'startFast'
                             }
                             else {
@@ -108,7 +108,7 @@ export default function IndexConsole(props: { record: any, count: number }) {
                         break;
                     case 'PICK_EARLIER_START':
                         {
-                            if (category_id == 'REMINDER_FS_START_FAST'){
+                            if (category_id == 'REMINDER_FS_START_FAST') {
                                 tapStartFast(null)
                             }
                             else {
@@ -118,7 +118,7 @@ export default function IndexConsole(props: { record: any, count: number }) {
                         break;
                     case 'END_TIMER_NOW':
                         {
-                            if (category_id == 'REMINDER_FS_END_FAST'){
+                            if (category_id == 'REMINDER_FS_END_FAST') {
                                 operateType = 'endFast'
                             }
                             else {
@@ -130,7 +130,7 @@ export default function IndexConsole(props: { record: any, count: number }) {
                         break;
                     case 'PICK_EARLIER_END':
                         {
-                            if (category_id == 'REMINDER_FS_END_FAST'){
+                            if (category_id == 'REMINDER_FS_END_FAST') {
                                 tapEndFast(null)
                             }
                             else {
@@ -315,7 +315,7 @@ export default function IndexConsole(props: { record: any, count: number }) {
             return;
         }
 
-        if (status == 'ONGOING1'){
+        if (status == 'ONGOING1') {
             // showAlert({
             //     title:t('feature.heads_up.alert_title'),
             //     content:t('feature.heads_up.ongoing1_content'),
@@ -323,7 +323,7 @@ export default function IndexConsole(props: { record: any, count: number }) {
             //     confirmText:t('feature.heads_up.ongoing1_confirm'),
             //     showCancel:true,
             //     cancel:()=>{
-                    
+
             //     },
             //     confirm:()=>{
             //         tapEndFastOperate()
@@ -333,7 +333,7 @@ export default function IndexConsole(props: { record: any, count: number }) {
             setShowMutiPicker(true);
             return
         }
-        else if (status == 'ONGOING2'){
+        else if (status == 'ONGOING2') {
             setMutiEvent('end_fast')
             setShowMutiPicker(true);
             // showAlert({
@@ -343,7 +343,7 @@ export default function IndexConsole(props: { record: any, count: number }) {
             //     confirmText:t('feature.heads_up.ongoing2_confirm'),
             //     showCancel:true,
             //     cancel:()=>{
-                    
+
             //     },
             //     confirm:()=>{
             //         tapEndFastOperate()
@@ -351,11 +351,11 @@ export default function IndexConsole(props: { record: any, count: number }) {
             // })
             return
         }
-        
+
         tapEndFastOperate()
     }
 
-    function tapEndFastOperate(){
+    function tapEndFastOperate() {
         operateType = 'endFast'
         global.pauseIndexTimer = true
         global.set_time = new Date().getTime()
@@ -590,9 +590,9 @@ export default function IndexConsole(props: { record: any, count: number }) {
                         }
                     }
                     else {
-                        PushNotification.checkPermissions((res)=>{
+                        PushNotification.checkPermissions((res) => {
                             //允许授权
-                            if ((kIsIOS && res.authorizationStatus == 2) || (!kIsIOS && res.alert)){
+                            if ((kIsIOS && res.authorizationStatus == 2) || (!kIsIOS && res.alert)) {
                                 getLocalPush()
                                 // showAlert({
                                 //     title: t('feature.track_time_duration.reminders.fast_end_title'),
@@ -662,9 +662,9 @@ export default function IndexConsole(props: { record: any, count: number }) {
                         }
                     }
                     else {
-                        PushNotification.checkPermissions((res)=>{
+                        PushNotification.checkPermissions((res) => {
                             //允许授权
-                            if ((kIsIOS && res.authorizationStatus == 2) || (!kIsIOS && res.alert)){
+                            if ((kIsIOS && res.authorizationStatus == 2) || (!kIsIOS && res.alert)) {
                                 getLocalPush()
                                 // showAlert({
                                 //     title: t('feature.track_time_duration.reminders.wake_title'),
@@ -719,7 +719,7 @@ export default function IndexConsole(props: { record: any, count: number }) {
 
                     }
                 }).catch((e) => {
-                    
+
                     setBtnDisable(false)
                     var picker = limitPickerRef.current;
                     (picker as any).resetPickerData()
@@ -748,7 +748,7 @@ export default function IndexConsole(props: { record: any, count: number }) {
                     global.checkAccess((res as any).access)
                     // checkAccessProvisional((res as any).access,showFastAlert)
                 }).catch((e) => {
-                    
+
                     setBtnDisable(false)
                     var picker = limitPickerRef.current;
                     (picker as any).resetPickerData()
@@ -817,7 +817,7 @@ export default function IndexConsole(props: { record: any, count: number }) {
                 {
                     status == 'WAIT_FOR_START' &&
                     <View onClick={tapStartFast} className='console_btn'>
-                        <Text style={{ fontWeight: 'bold',color:ColorType.black }}>{t('feature.track_time_duration.common.start_fast')}</Text>
+                        <Text style={{ fontWeight: 'bold', color: ColorType.black }}>{t('feature.track_time_duration.common.start_fast')}</Text>
                     </View>
                 }
                 {/* {
@@ -825,7 +825,7 @@ export default function IndexConsole(props: { record: any, count: number }) {
                 } */}
                 {
                     status == 'ONGOING' && <View onClick={tapEndFast} className={status == 'ONGOING' ? 'console_btn' : 'console_btn btn_disable'}>
-                        <Text style={{ fontWeight: 'bold',color:ColorType.black }}>{t('feature.track_time_duration.common.end_fast')}</Text>
+                        <Text style={{ fontWeight: 'bold', color: ColorType.black }}>{t('feature.track_time_duration.common.end_fast')}</Text>
                     </View>
                 }
                 {
@@ -880,7 +880,7 @@ export default function IndexConsole(props: { record: any, count: number }) {
             {
                 status == 'WAIT_FOR_START' ?
                     <View onClick={tapStartFast} className='console_btn'>
-                        <Text style={{ fontWeight: 'bold', fontSize: rpxToPx(32),color:ColorType.black }}>{t('feature.track_time_duration.common.start_fast')}</Text>
+                        <Text style={{ fontWeight: 'bold', fontSize: rpxToPx(32), color: ColorType.black }}>{t('feature.track_time_duration.common.start_fast')}</Text>
                     </View> :
                     <View onClick={() => { tapStage(0) }} className='stage_btn'>
                         <Text style={{ flex: 1, color: '#fff' }}>{t('feature.track_time_duration.stage.a')}</Text>
@@ -893,11 +893,21 @@ export default function IndexConsole(props: { record: any, count: number }) {
                     </View>
             }
             <View className='btn_line' />
-            {
+            {/* {
                 (status == 'WAIT_FOR_START' || status == 'ONGOING1') &&
                 <View onClick={tapStartSleep} className={status == 'ONGOING1' ? 'console_btn btn_sleep' : 'console_btn btn_sleep btn_disable'}>
                     <Text style={{ fontWeight: 'bold', fontSize: rpxToPx(32),color:ColorType.black }}>{t('feature.track_time_duration.common.start_sleep')}</Text>
                 </View>
+            } */}
+            {
+                status == 'ONGOING1' && <View onClick={tapStartSleep} className='console_btn btn_sleep'>
+                    <Text style={{ fontWeight: 'bold', fontSize: rpxToPx(32), color: ColorType.black }}>{t('feature.track_time_duration.common.start_sleep')}</Text>
+                </View>
+            }
+            {
+                status == 'WAIT_FOR_START' && <View onClick={tapStartSleep} className='console_btn btn_sleep btn_disable'>
+                    <Text style={{ fontWeight: 'bold', fontSize: rpxToPx(32), color: ColorType.black }}>{t('feature.track_time_duration.common.start_sleep')}</Text>
+                </View>
             }
             {
                 (status != 'WAIT_FOR_START' && status != 'ONGOING1') &&
@@ -915,7 +925,7 @@ export default function IndexConsole(props: { record: any, count: number }) {
             {
                 (expand || (status != 'WAIT_FOR_START' && status != 'ONGOING1')) && (status == 'WAIT_FOR_START' || status == 'ONGOING1' || status == 'ONGOING2') &&
                 <View onClick={tapEndSleep} className={status == 'ONGOING2' ? 'console_btn btn_sleep' : 'console_btn btn_sleep btn_disable'}>
-                    <Text style={{ fontWeight: 'bold', fontSize: rpxToPx(32),color:ColorType.black }}>{t('feature.track_time_duration.common.end_sleep')}</Text>
+                    <Text style={{ fontWeight: 'bold', fontSize: rpxToPx(32), color: ColorType.black }}>{t('feature.track_time_duration.common.end_sleep')}</Text>
                 </View>
             }
             {
@@ -929,7 +939,7 @@ export default function IndexConsole(props: { record: any, count: number }) {
             {
                 (expand || status == 'ONGOING3' || status == 'ONGOING') &&
                 <View onClick={tapEndFast} className={status == 'ONGOING3' ? 'console_btn' : 'console_btn btn_disable'}>
-                    <Text style={{ fontWeight: 'bold', fontSize: rpxToPx(32),color:ColorType.black  }}>{t('feature.track_time_duration.common.end_fast')}</Text>
+                    <Text style={{ fontWeight: 'bold', fontSize: rpxToPx(32), color: ColorType.black }}>{t('feature.track_time_duration.common.end_fast')}</Text>
                 </View>
             }
             {