|
|
@@ -39,7 +39,7 @@ if (process.env.TARO_ENV == 'rn') {
|
|
|
checkNotification = require('@/utils/native_permission_check').checkNotification;
|
|
|
useActionSheet = require('@expo/react-native-action-sheet').useActionSheet
|
|
|
}
|
|
|
-export default function MainFastEatCard(props: { count: any, typeChanged: Function }) {
|
|
|
+export default function MainFastEatCard(props: { count: any, typeChanged: Function,id:number }) {
|
|
|
const [isFastMode, setIsFastMode] = useState(true)
|
|
|
|
|
|
const [showModal, setShowModal] = useState(false)
|
|
|
@@ -49,8 +49,6 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
|
|
|
const [btnDisable, setBtnDisable] = useState(false)
|
|
|
const [logEvent, setLogEvent] = useState('LOG_ONCE');
|
|
|
|
|
|
- const [startScheduleTime, setStartScheduleTime] = useState('00:00')
|
|
|
- const [endScheduleTime, setEndScheduleTime] = useState('00:00')
|
|
|
const [eatData, setEatData] = useState<any>(null)
|
|
|
const [fastData, setFastData] = useState<any>(null)
|
|
|
const [startTime, setStartTime] = useState<any>(null)
|
|
|
@@ -81,8 +79,6 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
|
|
|
|
|
|
setEatData(eat)
|
|
|
setFastData(fast)
|
|
|
- setStartScheduleTime(fast.period.start_time)
|
|
|
- setEndScheduleTime(fast.period.end_time)
|
|
|
|
|
|
update(fast)
|
|
|
}, [user.isLogin])
|
|
|
@@ -97,25 +93,7 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
|
|
|
if (health.selTab == 1) {
|
|
|
dispatch(setMode(isFastMode ? 'FAST' : 'EAT'))
|
|
|
}
|
|
|
- }, [health.selTab,isFastMode])
|
|
|
-
|
|
|
-
|
|
|
- global.refreshFastEat = () => {
|
|
|
- refresh()
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- function refresh() {
|
|
|
- fastWindow().then(res => {
|
|
|
- const { eat_win, fast_win } = res
|
|
|
- const fast = fast_win.fast
|
|
|
- setEatData(eat_win)
|
|
|
- setFastData(fast_win)
|
|
|
- setStartScheduleTime(fast_win.fast.period.start_time)
|
|
|
- setEndScheduleTime(fast_win.fast.period.end_time)
|
|
|
- })
|
|
|
- }
|
|
|
+ }, [health.selTab, isFastMode])
|
|
|
|
|
|
function update(fast) {
|
|
|
var now = new Date().getTime()
|
|
|
@@ -134,8 +112,8 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
|
|
|
|
|
|
const common: RingCommon = {
|
|
|
useCase: 'ChooseScenario',
|
|
|
- radius: 115,
|
|
|
- lineWidth: 26,
|
|
|
+ radius: 50,
|
|
|
+ lineWidth: 15,
|
|
|
isFast: true,
|
|
|
status: 'WAIT_FOR_START'
|
|
|
}
|
|
|
@@ -145,8 +123,10 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
|
|
|
}
|
|
|
|
|
|
function scheduleRing() {
|
|
|
- var starts: any = startScheduleTime.split(':')
|
|
|
- var ends: any = endScheduleTime.split(':')
|
|
|
+ const { fast, eat } = health.windows.fast_eat
|
|
|
+
|
|
|
+ var starts: any = fast.period.start_time.split(':')
|
|
|
+ var ends: any = fast.period.end_time.split(':')
|
|
|
const startSeconds: any = parseInt(starts[0] + '') * 60 + parseInt(starts[1] + '')
|
|
|
const endSeconds: any = parseInt(ends[0] + '') * 60 + parseInt(ends[1] + '')
|
|
|
const color = isFastMode ? '#9AE2FE' : '#FE810C66'
|
|
|
@@ -168,8 +148,10 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
|
|
|
if (status != 'process') {
|
|
|
return null
|
|
|
}
|
|
|
- var starts: any = startScheduleTime.split(':')
|
|
|
- var ends: any = endScheduleTime.split(':')
|
|
|
+ const { fast, eat } = health.windows.fast_eat
|
|
|
+
|
|
|
+ var starts: any = fast.period.start_time.split(':')
|
|
|
+ var ends: any = fast.period.end_time.split(':')
|
|
|
const startSeconds: any = parseInt(starts[0] + '') * 60 + parseInt(starts[1] + '')
|
|
|
const endSeconds: any = parseInt(ends[0] + '') * 60 + parseInt(ends[1] + '')
|
|
|
const color = isFastMode ? '#9AE2FE' : '#FE810C66'
|
|
|
@@ -199,9 +181,16 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
|
|
|
|
|
|
|
|
|
function realRing() {
|
|
|
+ const { fast, eat } = health.windows.fast_eat
|
|
|
if (isFastMode) {
|
|
|
if (status != 'upcoming') {
|
|
|
- var starts: any = startTime ? startTime.split(':') : startScheduleTime.split(':')
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // var starts: any = fast.period.start_time.split(':')
|
|
|
+ // var ends: any = fast.period.end_time.split(':')
|
|
|
+
|
|
|
+ var starts: any = startTime ? startTime.split(':') : fast.period.start_time.split(':')
|
|
|
const startSeconds = parseInt(starts[0] + '') * 3600 + parseInt(starts[1] + '') * 60
|
|
|
|
|
|
const color = MainColorType.fast
|
|
|
@@ -231,8 +220,8 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
- if (isCurrentTimeInRange(endScheduleTime, startScheduleTime)) {
|
|
|
- var starts: any = endScheduleTime.split(':')
|
|
|
+ if (isCurrentTimeInRange(fast.period.end_time, fast.period.start_time)) {
|
|
|
+ var starts: any = fast.period.end_time.split(':')
|
|
|
const startSeconds = parseInt(starts[0] + '') * 60 + parseInt(starts[1] + '')
|
|
|
|
|
|
const color = MainColorType.eat
|
|
|
@@ -313,7 +302,7 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
|
|
|
whiteIcon: true
|
|
|
}
|
|
|
|
|
|
- return <Rings common={common} bgRing={bgRing} scheduleRing={scheduleRing()} targetRing={targetRing()} realRing={realRing()} currentDot={currentDot} canvasId={'smal11l'} />
|
|
|
+ return <Rings common={common} bgRing={bgRing} scheduleRing={scheduleRing()} targetRing={targetRing()} realRing={realRing()} currentDot={currentDot} canvasId={'smal11l'+props.id} />
|
|
|
}
|
|
|
|
|
|
function formatTime(format: string, timestamp?: number) {
|
|
|
@@ -490,7 +479,6 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
|
|
|
code: isStart ? 'FAST_START' : 'FAST_END',
|
|
|
time: strTime
|
|
|
}).then(res => {
|
|
|
- refresh()
|
|
|
setShowPicker(false)
|
|
|
})
|
|
|
}
|
|
|
@@ -511,7 +499,6 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
|
|
|
target_duration: getIntervalSeconds(startTime, endTime) * 1000
|
|
|
}
|
|
|
}, fastData.id).then(res => {
|
|
|
- refresh()
|
|
|
setShowPicker(false)
|
|
|
})
|
|
|
}
|
|
|
@@ -551,7 +538,6 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
|
|
|
if (operateType == 'startFast') {
|
|
|
startFast(t1, fastData.target_duration, event ? event : logEvent).then(res => {
|
|
|
setBtnDisable(false)
|
|
|
- refresh()
|
|
|
setShowTimePicker(false)
|
|
|
}).catch(e => {
|
|
|
setBtnDisable(false)
|
|
|
@@ -560,7 +546,6 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
|
|
|
else {
|
|
|
endFast(t1, event ? event : logEvent).then(res => {
|
|
|
setBtnDisable(false)
|
|
|
- refresh()
|
|
|
setShowTimePicker(false)
|
|
|
}).catch(e => {
|
|
|
setBtnDisable(false)
|
|
|
@@ -607,12 +592,12 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
|
|
|
|
|
|
function switchIcon() {
|
|
|
if (isFastMode) {
|
|
|
- if (status!='upcoming') {
|
|
|
+ if (status != 'upcoming') {
|
|
|
return <IconSwitch1 color="#000" width={15} />
|
|
|
}
|
|
|
return <IconSwitch2 color="#fff" width={15} />
|
|
|
}
|
|
|
- if (status!='upcoming') {
|
|
|
+ if (status != 'upcoming') {
|
|
|
return <IconSwitch2 color="#fff" width={15} />
|
|
|
}
|
|
|
return <IconSwitch1 color="#000" width={15} />
|
|
|
@@ -621,7 +606,7 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
|
|
|
function switchBtn() {
|
|
|
var bgColor = ''
|
|
|
if (isFastMode) {
|
|
|
- if (status!='upcoming') {
|
|
|
+ if (status != 'upcoming') {
|
|
|
bgColor = '#fff'
|
|
|
}
|
|
|
else {
|
|
|
@@ -630,7 +615,7 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
|
|
|
|
|
|
}
|
|
|
else {
|
|
|
- if (status!='upcoming') {
|
|
|
+ if (status != 'upcoming') {
|
|
|
bgColor = MainColorType.fast
|
|
|
}
|
|
|
else {
|
|
|
@@ -647,9 +632,9 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
|
|
|
if (!fastData)
|
|
|
return <View />
|
|
|
|
|
|
- return <View style={{ alignItems: 'center', display: 'flex', flexDirection: 'column', width: rpxToPx(750), flexShrink: 0 }}>
|
|
|
+ return <View style={{ alignItems: 'center', display: 'flex', flexDirection: 'column', width: rpxToPx(750/3), flexShrink: 0 }}>
|
|
|
|
|
|
- <View style={{ width: rpxToPx(750), }} />
|
|
|
+ <View style={{ width: rpxToPx(750/3), }} />
|
|
|
<View style={{ position: 'relative', }}>
|
|
|
{
|
|
|
ring()
|
|
|
@@ -662,7 +647,7 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
|
|
|
<Text className="date1">{global.language == 'en' ? formatTime('dddd, MMM D') : formatTime('MMMD日 dddd')}</Text>
|
|
|
</View>
|
|
|
</View>
|
|
|
- <View>{isFastMode ? formatMilliseconds(fastData.target.duration) : formatMilliseconds(eatData.target.end_timestamp - eatData.target.start_timestamp)}</View>
|
|
|
+ <View>{isFastMode ? formatMilliseconds(health.windows.fast_eat.fast.target.duration) : formatMilliseconds(health.windows.fast_eat.eat.target.duration)}</View>
|
|
|
{/* {
|
|
|
isFastMode && <View>
|
|
|
<View className="log_row">
|
|
|
@@ -727,10 +712,10 @@ export default function MainFastEatCard(props: { count: any, typeChanged: Functi
|
|
|
{
|
|
|
switchBtn()
|
|
|
}
|
|
|
- {
|
|
|
+ {/* {
|
|
|
!isFastMode && <Text onClick={more}>更多</Text>
|
|
|
- }
|
|
|
- <MainHistory type={isFastMode ? 'FAST' : 'EAT'} />
|
|
|
+ } */}
|
|
|
+ {/* <MainHistory type={isFastMode ? 'FAST' : 'EAT'} /> */}
|
|
|
{
|
|
|
showModal && <Modal dismiss={() => setShowModal(false)}>
|
|
|
<View style={{ width: 100, height: 100, backgroundColor: 'red' }}>{props.count}</View>
|