|
|
@@ -10,6 +10,8 @@ import { IconCalendar } from "@/components/basic/Icons";
|
|
|
import dayjs from "dayjs";
|
|
|
import { useRouter } from "@tarojs/taro";
|
|
|
import Card from "../components/card";
|
|
|
+import { MainColorType } from "@/context/themes/color";
|
|
|
+import Taro from "@tarojs/taro";
|
|
|
|
|
|
let useRoute;
|
|
|
let useNavigation;
|
|
|
@@ -36,58 +38,178 @@ export default function LogTime() {
|
|
|
const isSingle = router.params.single == '1'
|
|
|
const isFast = router.params.window == 'FAST'
|
|
|
const isStart = router.params.is_start == '1'
|
|
|
+ const data = JSON.parse(router.params.data)
|
|
|
const health = useSelector((state: any) => state.health);
|
|
|
const [time, setTime] = useState(dayjs().format('HH:mm'))
|
|
|
const [isToday, setIsToday] = useState(true)
|
|
|
+ const [showGoal, setShowGoal] = useState(false)
|
|
|
+ const tapIndex = router.params.index ?? 0
|
|
|
+
|
|
|
+ const [expandIndex, setExpandIndex] = useState(0)
|
|
|
|
|
|
useEffect(() => {
|
|
|
+ if (isSingle) {
|
|
|
+ if (isFast) {
|
|
|
+ Taro.setNavigationBarTitle({
|
|
|
+ title: isStart ? '开始断食' : '结束断食'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Taro.setNavigationBarTitle({
|
|
|
+ title: isStart ? '就寝' : '起床'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}, [])
|
|
|
- return <View className="page_container">
|
|
|
- <Card>
|
|
|
- <View style={{ position: 'relative' }}>
|
|
|
- <View className="card_header">
|
|
|
- <View style={{ flex: 1 }} />
|
|
|
- <NewButton
|
|
|
- type={NewButtonType.gray}
|
|
|
- title={isToday ? "Today" : "Yesterday"}
|
|
|
- fontSize={rpxToPx(34)}
|
|
|
- width={rpxToPx(196)}
|
|
|
- height={rpxToPx(84)}
|
|
|
- onClick={() => {
|
|
|
- setIsToday(!isToday)
|
|
|
- }}
|
|
|
- />
|
|
|
- <View style={{ width: rpxToPx(12) }} />
|
|
|
- <NewButton
|
|
|
- type={NewButtonType.alpha}
|
|
|
- color={getThemeColor('FAST')}
|
|
|
- title={time}
|
|
|
- fontSize={rpxToPx(34)}
|
|
|
- width={rpxToPx(196)}
|
|
|
- height={rpxToPx(84)}
|
|
|
- onClick={() => {
|
|
|
|
|
|
- }}
|
|
|
- />
|
|
|
- <View style={{ flex: 1 }} />
|
|
|
- <View className='border_footer_line' />
|
|
|
- </View>
|
|
|
+ function footerBtnColor() {
|
|
|
+ if (isSingle) {
|
|
|
+ return isFast ? MainColorType.fast : MainColorType.sleep
|
|
|
+ }
|
|
|
+ return MainColorType.fast
|
|
|
+ }
|
|
|
|
|
|
- <NewTimePicker time={time} onChange={(e) => {
|
|
|
+ function logItem(index: number, iFast: boolean, iStart: boolean, showLine: boolean) {
|
|
|
+ const {fast,sleep} = data
|
|
|
+ var schedule_time = ''
|
|
|
+ if (iFast){
|
|
|
+ schedule_time = iStart?fast.period.start_time:fast.period.end_time
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ schedule_time = iStart?sleep.period.start_time:sleep.period.end_time
|
|
|
+ }
|
|
|
+ return <View style={{ position: 'relative' }}>
|
|
|
+ <View className="card_header">
|
|
|
+ <View style={{ flex: 1 }} />
|
|
|
+ <NewButton
|
|
|
+ type={NewButtonType.gray}
|
|
|
+ title={isToday ? "Today" : "Yesterday"}
|
|
|
+ fontSize={rpxToPx(34)}
|
|
|
+ width={rpxToPx(196)}
|
|
|
+ height={rpxToPx(84)}
|
|
|
+ onClick={() => {
|
|
|
+ setIsToday(!isToday)
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ <View style={{ width: rpxToPx(12) }} />
|
|
|
+ <NewButton
|
|
|
+ type={NewButtonType.alpha}
|
|
|
+ color={iFast?MainColorType.fast:MainColorType.sleep}
|
|
|
+ title={time}
|
|
|
+ fontSize={rpxToPx(34)}
|
|
|
+ width={rpxToPx(196)}
|
|
|
+ height={rpxToPx(84)}
|
|
|
+ onClick={() => {
|
|
|
+ setExpandIndex(index)
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ <View style={{ flex: 1 }} />
|
|
|
+ <View className='border_footer_line' />
|
|
|
+ </View>
|
|
|
+ {
|
|
|
+ expandIndex == index && <NewTimePicker time={time} onChange={(e) => {
|
|
|
setTime(e)
|
|
|
- }} color={getThemeColor(health.mode)} />
|
|
|
+ }} color={iFast?MainColorType.fast:MainColorType.sleep} />
|
|
|
+ }
|
|
|
|
|
|
- <View className='card_footer'>
|
|
|
+ {
|
|
|
+ expandIndex == index && <View className='card_footer'>
|
|
|
<IconCalendar width={rpxToPx(24)} color='#5C7099' />
|
|
|
- <Text style={{ color: '#5C7099', marginLeft: rpxToPx(12), fontSize: rpxToPx(26) }}>Scheduled for xxx today</Text>
|
|
|
+ <Text style={{ color: '#5C7099', marginLeft: rpxToPx(12), fontSize: rpxToPx(26) }}>Scheduled for {schedule_time} today</Text>
|
|
|
</View>
|
|
|
- </View>
|
|
|
+ }
|
|
|
+ {
|
|
|
+ showLine && <View className="border_footer_line" />
|
|
|
+ }
|
|
|
+
|
|
|
+ </View>
|
|
|
+ }
|
|
|
+
|
|
|
+ function multiContent() {
|
|
|
+ const { status } = data
|
|
|
+ switch (parseInt(tapIndex+'')) {
|
|
|
+ case 1:
|
|
|
+ return <View style={{ position: 'relative' }}>
|
|
|
+ {
|
|
|
+ logItem(0, true, true, true)
|
|
|
+ }
|
|
|
+ {
|
|
|
+ logItem(1, false, true, false)
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ case 2:
|
|
|
+ return <View style={{ position: 'relative' }}>
|
|
|
+ {
|
|
|
+ (status == 'WFS' || status == 'OG2_NO1') && logItem(0, true, true, true)
|
|
|
+ }
|
|
|
+ {
|
|
|
+ (status == 'WFS' || status == 'OG1') && logItem(1, false, true, true)
|
|
|
+ }
|
|
|
+ {
|
|
|
+ logItem(2, false, false, false)
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ case 3:
|
|
|
+ return <View style={{ position: 'relative' }}>
|
|
|
+ {
|
|
|
+ (status == 'WFS' || status == 'OG2_NO1') && logItem(0, true, true, true)
|
|
|
+ }
|
|
|
+ {
|
|
|
+ (status == 'WFS' || status == 'OG1') && logItem(1, false, true, true)
|
|
|
+ }
|
|
|
+ {
|
|
|
+ (status == 'WFS' || status == 'OG1' || status == 'OG2'|| status == 'OG2_NO1') && logItem(2, false, false, true)
|
|
|
+ }
|
|
|
+ {
|
|
|
+ logItem(3, true, false, false)
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ }
|
|
|
+ return <View style={{ position: 'relative' }}></View>
|
|
|
+ }
|
|
|
+ return <View className="page_container">
|
|
|
+ <Card>
|
|
|
+ {
|
|
|
+ isSingle ? <View style={{ position: 'relative' }}>
|
|
|
+ {
|
|
|
+ logItem(0, isFast, isStart, false)
|
|
|
+ }
|
|
|
+ </View> : multiContent()
|
|
|
+ }
|
|
|
+
|
|
|
</Card>
|
|
|
+ <View style={{ height: rpxToPx(36) }} />
|
|
|
+ {
|
|
|
+ isSingle && isStart && !showGoal && <View style={{ height: rpxToPx(72), marginTop: rpxToPx(18) }}>
|
|
|
+ <NewButton
|
|
|
+ type={NewButtonType.link}
|
|
|
+ title="Show More"
|
|
|
+ onClick={() => {
|
|
|
+ setShowGoal(true)
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ }
|
|
|
+ {
|
|
|
+ isSingle && isStart && showGoal && <Card>
|
|
|
+ <View style={{ position: 'relative' }}>
|
|
|
+ <View className="card_header" style={{ justifyContent: 'space-between' }}>
|
|
|
+ <View className="h34">{isFast ? 'Fast Goal' : 'Sleep Goal'}</View>
|
|
|
+ <NewButton
|
|
|
+ type={NewButtonType.gray}
|
|
|
+ height={rpxToPx(84)}
|
|
|
+ title="xxx"
|
|
|
+ onClick={() => { }}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ </Card>
|
|
|
+ }
|
|
|
<View style={{ flex: 1 }} />
|
|
|
<View style={{ marginBottom: rpxToPx(128), display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
|
|
<NewButton
|
|
|
- color={getThemeColor('FAST')}
|
|
|
+ color={footerBtnColor()}
|
|
|
type={NewButtonType.fill}
|
|
|
title={'Log'}
|
|
|
width={rpxToPx(670)}
|