|
|
@@ -12,7 +12,7 @@ import MainHistory from "@/features/health/MainHistory";
|
|
|
import { useSelector } from "react-redux";
|
|
|
import showAlert from "@/components/basic/Alert";
|
|
|
import { clockTimes, delRecord, updateFast } from "@/services/health";
|
|
|
-import { useEffect, useState } from "react";
|
|
|
+import { useEffect, useRef, useState } from "react";
|
|
|
import { TimeFormatter } from "@/utils/time_format";
|
|
|
import dayjs from "dayjs";
|
|
|
import showActionSheet from "@/components/basic/ActionSheet";
|
|
|
@@ -21,6 +21,7 @@ import NewDurationPicker, { DurationPickerType } from "../base/new_durationpicke
|
|
|
import Taro from "@tarojs/taro";
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
import NewTimePicker from "../base/new_timepicker";
|
|
|
+import StickyDateList from "../components/sticky_date_list";
|
|
|
|
|
|
let useActionSheet;
|
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
|
@@ -36,6 +37,11 @@ export default function LongFast() {
|
|
|
const [duration, setDuration] = useState(0)
|
|
|
const [time, setTime] = useState(dayjs().format('HH:mm'))
|
|
|
const { t } = useTranslation()
|
|
|
+ const [isPulling, setIsPulling] = useState(false)
|
|
|
+ const [showDate, setShowDate] = useState(false)
|
|
|
+ const [date, setDate] = useState('')
|
|
|
+ const historyRef = useRef()
|
|
|
+
|
|
|
let showActionSheetWithOptions;
|
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
|
showActionSheetWithOptions = useActionSheet()
|
|
|
@@ -213,137 +219,140 @@ export default function LongFast() {
|
|
|
return <View />
|
|
|
}
|
|
|
|
|
|
- return <View className="page_container">
|
|
|
- <NewHeader type={NewHeaderType.left_subtitle}
|
|
|
- title="Long Fast "
|
|
|
- subtitle="Prolonged Fasting beyond 24 hours"
|
|
|
- />
|
|
|
- <Card>
|
|
|
- <View className="long_fast_card" >
|
|
|
- <View style={{ height: rpxToPx(96) }} />
|
|
|
- <View className="h50 bold" style={{ color: MainColorType.fast }}>{timeText()}</View>
|
|
|
- <View className="h24" style={{ color: MainColorType.g02, marginTop: rpxToPx(12) }}>Goal {goal()}</View>
|
|
|
- <View style={{ height: rpxToPx(44) }} />
|
|
|
- {
|
|
|
- long_fast.status == 'WFS' ? <NewButton
|
|
|
- type={NewButtonType.fill}
|
|
|
- width={rpxToPx(538)}
|
|
|
- height={rpxToPx(96)}
|
|
|
- color={getThemeColor('FAST')}
|
|
|
- title="Start fast"
|
|
|
- onClick={() => {
|
|
|
- tapStart()
|
|
|
- //
|
|
|
- }}
|
|
|
- /> :
|
|
|
- <NewButton
|
|
|
- type={NewButtonType.alpha}
|
|
|
+ return <StickyDateList
|
|
|
+ isPulling={isPulling}
|
|
|
+ showDate={showDate}
|
|
|
+ date={date}
|
|
|
+ onRefresherRefresh={() => {
|
|
|
+ (historyRef.current as any).refresh()
|
|
|
+ setIsPulling(true)
|
|
|
+ }}
|
|
|
+ onScroll={e => {
|
|
|
+ if (historyRef) {
|
|
|
+ (historyRef.current as any).onScroll(e)
|
|
|
+ }
|
|
|
+ }}><View className="page_container">
|
|
|
+ <NewHeader type={NewHeaderType.left_subtitle}
|
|
|
+ title="Long Fast "
|
|
|
+ subtitle="Prolonged Fasting beyond 24 hours"
|
|
|
+ />
|
|
|
+ <Card>
|
|
|
+ <View className="long_fast_card" >
|
|
|
+ <View style={{ height: rpxToPx(96) }} />
|
|
|
+ <View className="h50 bold" style={{ color: MainColorType.fast }}>{timeText()}</View>
|
|
|
+ <View className="h24" style={{ color: MainColorType.g02, marginTop: rpxToPx(12) }}>Goal {goal()}</View>
|
|
|
+ <View style={{ height: rpxToPx(44) }} />
|
|
|
+ {
|
|
|
+ long_fast.status == 'WFS' ? <NewButton
|
|
|
+ type={NewButtonType.fill}
|
|
|
width={rpxToPx(538)}
|
|
|
height={rpxToPx(96)}
|
|
|
color={getThemeColor('FAST')}
|
|
|
- title="How are you feeling?"
|
|
|
+ title="Start fast"
|
|
|
onClick={() => {
|
|
|
- tapLog()
|
|
|
+ tapStart()
|
|
|
+ //
|
|
|
}}
|
|
|
- />
|
|
|
- }
|
|
|
- {
|
|
|
- moment()
|
|
|
- }
|
|
|
+ /> :
|
|
|
+ <NewButton
|
|
|
+ type={NewButtonType.alpha}
|
|
|
+ width={rpxToPx(538)}
|
|
|
+ height={rpxToPx(96)}
|
|
|
+ color={getThemeColor('FAST')}
|
|
|
+ title="How are you feeling?"
|
|
|
+ onClick={() => {
|
|
|
+ tapLog()
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ }
|
|
|
+ {
|
|
|
+ moment()
|
|
|
+ }
|
|
|
|
|
|
- </View>
|
|
|
- </Card>
|
|
|
- {/* {
|
|
|
- long_fast.status == 'OG' && <View style={{ position: 'relative', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
|
|
- <NewButton
|
|
|
- type={NewButtonType.link}
|
|
|
- height={rpxToPx(96)}
|
|
|
- title='End fast'
|
|
|
- onClick={() => {
|
|
|
- tapEnd()
|
|
|
- }}
|
|
|
- />
|
|
|
- </View>
|
|
|
- }
|
|
|
- {
|
|
|
- long_fast.status == 'OG' && <Text onClick={tapMore}>More</Text>
|
|
|
- } */}
|
|
|
+ </View>
|
|
|
+ </Card>
|
|
|
|
|
|
- <View className="long_fast_footer" style={{ backgroundColor: 'transparent', marginBottom: -rpxToPx(35) }}>
|
|
|
- <View style={{ width: rpxToPx(316), height: rpxToPx(128), display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
|
|
+ <View className="long_fast_footer" style={{ backgroundColor: 'transparent', marginBottom: -rpxToPx(35) }}>
|
|
|
+ <View style={{ width: rpxToPx(316), height: rpxToPx(128), display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
|
|
+ {
|
|
|
+ long_fast.status == 'OG' ? <NewButton
|
|
|
+ type={NewButtonType.link}
|
|
|
+ title={'End longfast'}
|
|
|
+ onClick={tapEnd}
|
|
|
+ >
|
|
|
+ </NewButton> : <NewButton
|
|
|
+ type={NewButtonType.link}
|
|
|
+ title={'See Guidelines'}
|
|
|
+ onClick={() => { }}
|
|
|
+ >
|
|
|
+ </NewButton>
|
|
|
+ }
|
|
|
+ </View>
|
|
|
{
|
|
|
- long_fast.status == 'OG' ? <NewButton
|
|
|
- type={NewButtonType.link}
|
|
|
- title={'End longfast'}
|
|
|
- onClick={tapEnd}
|
|
|
- >
|
|
|
- </NewButton> : <NewButton
|
|
|
- type={NewButtonType.link}
|
|
|
- title={'See Guidelines'}
|
|
|
- onClick={() => { }}
|
|
|
- >
|
|
|
- </NewButton>
|
|
|
+ long_fast.status == 'OG' && <NewButton
|
|
|
+ btnStyle={{
|
|
|
+ position: 'absolute',
|
|
|
+ top: rpxToPx(42),
|
|
|
+ right: rpxToPx(26)
|
|
|
+ }}
|
|
|
+ type={NewButtonType.more}
|
|
|
+ onClick={tapMore}
|
|
|
+ />
|
|
|
}
|
|
|
- </View>
|
|
|
- {
|
|
|
- long_fast.status == 'OG' && <NewButton
|
|
|
- btnStyle={{
|
|
|
- position: 'absolute',
|
|
|
- top: rpxToPx(42),
|
|
|
- right: rpxToPx(26)
|
|
|
- }}
|
|
|
- type={NewButtonType.more}
|
|
|
- onClick={tapMore}
|
|
|
- />
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
- </View>
|
|
|
|
|
|
+ </View>
|
|
|
|
|
|
|
|
|
- <MainHistory type='FAST' fast_type="LF" />
|
|
|
|
|
|
- {
|
|
|
- editDuration && <NewModal
|
|
|
- title='长断食时长'
|
|
|
- dismiss={() => {
|
|
|
- setEditDuration(false)
|
|
|
- }}
|
|
|
- confirm={() => {
|
|
|
+ <MainHistory type='FAST' fast_type="LF" ref={historyRef} updateDate={(e) => {
|
|
|
+ setShowDate(e.show)
|
|
|
+ setDate(e.date)
|
|
|
+ }} refreshSuccess={() => {
|
|
|
+ setIsPulling(false)
|
|
|
+ }} />
|
|
|
|
|
|
- updateFast({ fast_type: 'LF', long_fast_goal: duration * 60 }).then(res => {
|
|
|
+ {
|
|
|
+ editDuration && <NewModal
|
|
|
+ title='长断食时长'
|
|
|
+ dismiss={() => {
|
|
|
setEditDuration(false)
|
|
|
- global.refreshWindow()
|
|
|
- })
|
|
|
- }}
|
|
|
- themeColor={getThemeColor(health.mode)}>
|
|
|
- <View style={{ flexDirection: 'column', display: 'flex', alignItems: 'center', marginBottom: 20 }}>
|
|
|
- <NewDurationPicker type={DurationPickerType.long}
|
|
|
- color={MainColorType.fast}
|
|
|
- value={duration}
|
|
|
- onChange={e => setDuration(e)} />
|
|
|
- </View>
|
|
|
- </NewModal>
|
|
|
- }
|
|
|
- {
|
|
|
- showPicker && <NewModal
|
|
|
- title='结束长断食'
|
|
|
- dismiss={() => {
|
|
|
- setShowPicker(false)
|
|
|
- }}
|
|
|
- confirm={() => {
|
|
|
+ }}
|
|
|
+ confirm={() => {
|
|
|
|
|
|
- save()
|
|
|
- }}
|
|
|
- themeColor={getThemeColor(health.mode)}>
|
|
|
- <View style={{ flexDirection: 'column', display: 'flex', alignItems: 'center', marginBottom: 20 }}>
|
|
|
- <NewTimePicker
|
|
|
- color={MainColorType.fast}
|
|
|
- time={dayjs().format('HH:mm')}
|
|
|
- onChange={e => setTime(e)} />
|
|
|
- </View>
|
|
|
- </NewModal>
|
|
|
- }
|
|
|
- </View>
|
|
|
+ updateFast({ fast_type: 'LF', long_fast_goal: duration * 60 }).then(res => {
|
|
|
+ setEditDuration(false)
|
|
|
+ global.refreshWindow()
|
|
|
+ })
|
|
|
+ }}
|
|
|
+ themeColor={getThemeColor(health.mode)}>
|
|
|
+ <View style={{ flexDirection: 'column', display: 'flex', alignItems: 'center', marginBottom: 20 }}>
|
|
|
+ <NewDurationPicker type={DurationPickerType.long}
|
|
|
+ color={MainColorType.fast}
|
|
|
+ value={duration}
|
|
|
+ onChange={e => setDuration(e)} />
|
|
|
+ </View>
|
|
|
+ </NewModal>
|
|
|
+ }
|
|
|
+ {
|
|
|
+ showPicker && <NewModal
|
|
|
+ title='结束长断食'
|
|
|
+ dismiss={() => {
|
|
|
+ setShowPicker(false)
|
|
|
+ }}
|
|
|
+ confirm={() => {
|
|
|
+
|
|
|
+ save()
|
|
|
+ }}
|
|
|
+ themeColor={getThemeColor(health.mode)}>
|
|
|
+ <View style={{ flexDirection: 'column', display: 'flex', alignItems: 'center', marginBottom: 20 }}>
|
|
|
+ <NewTimePicker
|
|
|
+ color={MainColorType.fast}
|
|
|
+ time={dayjs().format('HH:mm')}
|
|
|
+ onChange={e => setTime(e)} />
|
|
|
+ </View>
|
|
|
+ </NewModal>
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ </StickyDateList>
|
|
|
}
|