|
|
@@ -19,6 +19,7 @@ import { useTranslation } from "react-i18next";
|
|
|
import { ColorType } from "@/context/themes/color";
|
|
|
import TimelineStage from "./TimelineStage";
|
|
|
import { jumpPage } from "../hooks/Common";
|
|
|
+import { RealRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
|
|
|
// import { sqrt } from 'mathjs'
|
|
|
|
|
|
let AppState;
|
|
|
@@ -26,11 +27,15 @@ if (process.env.TARO_ENV == 'rn') {
|
|
|
AppState = require("react-native").AppState
|
|
|
}
|
|
|
|
|
|
-export default function RecordFastSleep(props: { data: any, type: string, delSuccess?: Function }) {
|
|
|
+let stageCanvasId = new Date().getTime()
|
|
|
+export default function RecordFastSleep(props: { data: any, type: string, delSuccess?: Function, index: number }) {
|
|
|
+ const [count, setCount] = useState(0)
|
|
|
const [showDetailModal, setShowDetailModal] = useState(false)
|
|
|
const [segmentIndex, setSegmentIndex] = useState(0)
|
|
|
const [diffTimeZone, setDiffTimeZone] = useState(false)
|
|
|
const [multiTimeZone, setMultiTimeZone] = useState(false)
|
|
|
+ const [showMore, setShowMore] = useState(false)
|
|
|
+ const [selIndex, setSelIndex] = useState(0)
|
|
|
const { t } = useTranslation()
|
|
|
var canvasId = props.data.id
|
|
|
const record = props.data;
|
|
|
@@ -44,6 +49,11 @@ export default function RecordFastSleep(props: { data: any, type: string, delSuc
|
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
|
AppState.addEventListener('change', handleAppStateChange);
|
|
|
}
|
|
|
+ if (record.scenario != 'FAST_SLEEP') {
|
|
|
+ setShowMore(false)
|
|
|
+ setSelIndex(0)
|
|
|
+
|
|
|
+ }
|
|
|
// console.log(sqrt(-4).toString())
|
|
|
}, [props.data])
|
|
|
|
|
|
@@ -171,9 +181,8 @@ export default function RecordFastSleep(props: { data: any, type: string, delSuc
|
|
|
var realRing = getReal(record, true, true)
|
|
|
if (props.data.status == 'ONGOING3') {
|
|
|
realRing.color = 'rgba(0,0,0,0)'
|
|
|
- // bgRing.color = 'rgba(0,0,0,0)'
|
|
|
}
|
|
|
- return <Rings common={common} bgRing={bgRing} canvasId={canvasId} realRing={realRing} />
|
|
|
+ return <Rings common={common} bgRing={bgRing} canvasId={props.index} realRing={realRing} />
|
|
|
}
|
|
|
else {
|
|
|
var currentDot1 = getDot(record, true)
|
|
|
@@ -191,7 +200,53 @@ export default function RecordFastSleep(props: { data: any, type: string, delSuc
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- function smallRing() {
|
|
|
+ function bigMoreRing() {
|
|
|
+ var common = getCommon(null, true)
|
|
|
+ common.radius = 42;
|
|
|
+ common.lineWidth = 9;
|
|
|
+ var bgRing = getBgRing()
|
|
|
+ var realRing = getReal(record, true, true)
|
|
|
+ realRing.color = ColorType.fast + '66'
|
|
|
+
|
|
|
+ var list: any = []
|
|
|
+ if (record.scenario == 'FAST_SLEEP') {
|
|
|
+ if (selIndex == 0) {
|
|
|
+ const realRingBig: RealRing = {
|
|
|
+ color: global.fastColor ? global.fastColor : ColorType.fast,
|
|
|
+ startArc: startArc(record.fast.real_start_time),
|
|
|
+ durationArc: durationArc(record.fast.real_start_time, record.sleep.real_start_time)
|
|
|
+ }
|
|
|
+ list.push(realRingBig)
|
|
|
+ }
|
|
|
+ if (selIndex == 1) {
|
|
|
+ const realRingBig: RealRing = {
|
|
|
+ color: global.fastColor ? global.fastColor : ColorType.fast,
|
|
|
+ startArc: startArc(record.sleep.real_start_time),
|
|
|
+ durationArc: durationArc(record.sleep.real_start_time, record.sleep.real_end_time)
|
|
|
+ }
|
|
|
+ list.push(realRingBig)
|
|
|
+ }
|
|
|
+ if (selIndex == 2) {
|
|
|
+ const realRingBig: RealRing = {
|
|
|
+ color: global.fastColor ? global.fastColor : ColorType.fast,
|
|
|
+ startArc: startArc(record.sleep.real_end_time),
|
|
|
+ durationArc: durationArc(record.sleep.real_end_time, record.fast.real_end_time)
|
|
|
+ }
|
|
|
+ list.push(realRingBig)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return <Rings common={common} bgRing={bgRing} canvasId={stageCanvasId} stageList={list} realRing={realRing} />
|
|
|
+ }
|
|
|
+
|
|
|
+ const startArc = (time: number) => {
|
|
|
+ var date = new Date(time);
|
|
|
+ var hour = date.getHours();
|
|
|
+ var minute = date.getMinutes();
|
|
|
+ var second = date.getSeconds();
|
|
|
+ return (hour * 3600 + minute * 60 + second) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
|
|
|
+ }
|
|
|
+
|
|
|
+ function smallRing(canvas_id = props.index) {
|
|
|
if (record.scenario == 'FAST_SLEEP') {
|
|
|
var common = getCommon(null, false)
|
|
|
common.radius = 28;
|
|
|
@@ -199,23 +254,39 @@ export default function RecordFastSleep(props: { data: any, type: string, delSuc
|
|
|
var bgRing = getBgRing()
|
|
|
var realRing = getReal(record, false, false)
|
|
|
if (props.type == 'record' || props.type == 'latest') {
|
|
|
+ var showReal = false;
|
|
|
if (record.sleep.status == 'WAIT_FOR_END') {
|
|
|
realRing.durationArc = durationArc(record.sleep.target_start_time, (new Date()).getTime())
|
|
|
- return <Rings common={common} bgRing={bgRing} canvasId={canvasId + 'small'} realRing={realRing} />
|
|
|
+ showReal = true
|
|
|
+ // return <Rings common={common} bgRing={bgRing} canvasId={canvasId + 'small'} realRing={realRing} />
|
|
|
}
|
|
|
else if (record.sleep.status == 'NOT_COMPLETED') {
|
|
|
realRing.durationArc = 0.01
|
|
|
- return <Rings common={common} bgRing={bgRing} canvasId={canvasId + 'small'} realRing={realRing} />
|
|
|
+ showReal = true
|
|
|
+ // return <Rings common={common} bgRing={bgRing} canvasId={canvasId + 'small'} realRing={realRing} />
|
|
|
}
|
|
|
else if (record.sleep.status == 'COMPLETED') {
|
|
|
realRing = getReal(record, false, true)
|
|
|
- return <Rings common={common} bgRing={bgRing} canvasId={canvasId + 'small'} realRing={realRing} />
|
|
|
+ showReal = true
|
|
|
+ // return <Rings common={common} bgRing={bgRing} canvasId={canvasId + 'small'} realRing={realRing} />
|
|
|
}
|
|
|
- return <Rings common={common} bgRing={bgRing} canvasId={canvasId + 'small'} />
|
|
|
+ return <Rings common={common} bgRing={bgRing} canvasId={canvas_id + 'small'} realRing={showReal ? realRing : null} />
|
|
|
+ // if (record.sleep.status == 'WAIT_FOR_END') {
|
|
|
+ // realRing.durationArc = durationArc(record.sleep.target_start_time, (new Date()).getTime())
|
|
|
+ // return <Rings common={common} bgRing={bgRing} canvasId={canvasId + 'small'} realRing={realRing} />
|
|
|
+ // }
|
|
|
+ // else if (record.sleep.status == 'NOT_COMPLETED') {
|
|
|
+ // realRing.durationArc = 0.01
|
|
|
+ // return <Rings common={common} bgRing={bgRing} canvasId={canvasId + 'small'} realRing={realRing} />
|
|
|
+ // }
|
|
|
+ // else if (record.sleep.status == 'COMPLETED') {
|
|
|
+ // realRing = getReal(record, false, true)
|
|
|
+ // return <Rings common={common} bgRing={bgRing} canvasId={canvasId + 'small'} realRing={realRing} />
|
|
|
+ // }
|
|
|
+ // return <Rings common={common} bgRing={bgRing} canvasId={canvasId + 'small'} />
|
|
|
}
|
|
|
else {
|
|
|
|
|
|
-
|
|
|
var currentDot = getDot(record, false)
|
|
|
var targetRing = getTarget(record, false)
|
|
|
if (record.status == 'ONGOING2') {
|
|
|
@@ -262,13 +333,56 @@ export default function RecordFastSleep(props: { data: any, type: string, delSuc
|
|
|
return recordTime()
|
|
|
}
|
|
|
|
|
|
+ function tapStage(e,index){
|
|
|
+ stageCanvasId = new Date().getTime()
|
|
|
+ setSelIndex(index);
|
|
|
+ // setCount(pre=>pre+1);
|
|
|
+ e.stopPropagation()
|
|
|
+ }
|
|
|
+
|
|
|
+ function moreCircle() {
|
|
|
+ return <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
|
|
|
+ <View style={{ position: 'relative', zIndex: 1 }}>
|
|
|
+ {
|
|
|
+ bigMoreRing()
|
|
|
+ }
|
|
|
+ <View style={{ display: 'flex', position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, alignItems: 'center', justifyContent: 'center' }}>
|
|
|
+ {
|
|
|
+ smallRing(123 + props.index)
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ <View style={{ flex: 1 }}>
|
|
|
+
|
|
|
+ <View className={selIndex == 0 ? "single_check_sel" : "single_check_nor"} onClick={(e) => { tapStage(e,0) }}>
|
|
|
+ <Text className={selIndex == 0 ? "single_check_text_sel" : "single_check_text_nor"}>睡前断食</Text>
|
|
|
+ {
|
|
|
+ selIndex == 0 && <Image src={require('@assets/images/check_black.png')} className="single_checked" />
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ <View className={selIndex == 1 ? "single_check_sel" : "single_check_nor"} onClick={(e) => { tapStage(e,1) }}>
|
|
|
+ <Text className={selIndex == 1 ? "single_check_text_sel" : "single_check_text_nor"}>睡眠中断食</Text>
|
|
|
+ {
|
|
|
+ selIndex == 1 && <Image src={require('@assets/images/check_black.png')} className="single_checked" />
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ <View className={selIndex == 2 ? "single_check_sel" : "single_check_nor"} onClick={(e) => { tapStage(e,2) }}>
|
|
|
+ <Text className={selIndex == 2 ? "single_check_text_sel" : "single_check_text_nor"}>起床后断食</Text>
|
|
|
+ {
|
|
|
+ selIndex == 2 && <Image src={require('@assets/images/check_black.png')} className="single_checked" />
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ }
|
|
|
+
|
|
|
function recordDetail() {
|
|
|
var fastDuration = ''
|
|
|
var sleepDuration = ''
|
|
|
var showFast = false;
|
|
|
var showSleep = false;
|
|
|
if (record.scenario == 'FAST_SLEEP') {
|
|
|
-
|
|
|
+
|
|
|
fastDuration = getDuration(record.fast)
|
|
|
sleepDuration = getDuration(record.sleep)
|
|
|
if (record.status == 'ONGOING3') {
|
|
|
@@ -292,35 +406,48 @@ export default function RecordFastSleep(props: { data: any, type: string, delSuc
|
|
|
sleepDuration = getDuration(record.sleep)
|
|
|
showSleep = true
|
|
|
}
|
|
|
- return <View className="fast_sleep_item">
|
|
|
- {
|
|
|
- rings()
|
|
|
- }
|
|
|
- <View className="duration_bg">
|
|
|
- {
|
|
|
- showFast && <Text className="duration_title">{t('feature.track_time_duration.record_fast_sleep.item.fast')}</Text>
|
|
|
- }
|
|
|
- {
|
|
|
- showFast && <Text className="duration_value" style={{ color: global.fastColor ? global.fastColor : ColorType.fast }}>{fastDuration}</Text>
|
|
|
- }
|
|
|
- {
|
|
|
- showSleep && <Text className="duration_title">{t('feature.track_time_duration.record_fast_sleep.item.sleep')}</Text>
|
|
|
- }
|
|
|
+ return <View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
|
+ <View className="fast_sleep_item">
|
|
|
{
|
|
|
- showSleep && <Text className="duration_value" style={{ color: global.sleepColor ? global.sleepColor : ColorType.sleep }}>{sleepDuration}</Text>
|
|
|
+ rings()
|
|
|
}
|
|
|
- </View>
|
|
|
- {/* <Image className="arrow1" src={require('@/assets/images/arrow.png')} /> */}
|
|
|
- <View className="record_arrow_bg" style={{ backgroundColor: global.isDebug ? 'red' : 'transparent' }}>
|
|
|
- <View style={{ flex: 1 }} />
|
|
|
- <Text className='recordTime'>{getArrowText()}</Text>
|
|
|
- <Image className="arrow2" src={require('@/assets/images/arrow3.png')} />
|
|
|
- </View>
|
|
|
+ <View className="duration_bg">
|
|
|
+ {
|
|
|
+ showFast && <Text className="duration_title">{t('feature.track_time_duration.record_fast_sleep.item.fast')}</Text>
|
|
|
+ }
|
|
|
+ {
|
|
|
+ showFast && <Text className="duration_value" style={{ color: global.fastColor ? global.fastColor : ColorType.fast }}>{fastDuration}</Text>
|
|
|
+ }
|
|
|
+ {
|
|
|
+ showSleep && <Text className="duration_title">{t('feature.track_time_duration.record_fast_sleep.item.sleep')}</Text>
|
|
|
+ }
|
|
|
+ {
|
|
|
+ showSleep && <Text className="duration_value" style={{ color: global.sleepColor ? global.sleepColor : ColorType.sleep }}>{sleepDuration}</Text>
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ {/* <Image className="arrow1" src={require('@/assets/images/arrow.png')} /> */}
|
|
|
+ <View className="record_arrow_bg" style={{ backgroundColor: global.isDebug ? 'red' : 'transparent' }}>
|
|
|
+ <View style={{ flex: 1 }} />
|
|
|
+ <Text className='recordTime'>{getArrowText()}</Text>
|
|
|
+ <Image className="arrow2" src={require('@/assets/images/arrow3.png')} />
|
|
|
+ </View>
|
|
|
|
|
|
+ </View>
|
|
|
+ {
|
|
|
+ (props.type == 'record' || props.type == 'latest') && record.scenario == 'FAST_SLEEP' &&
|
|
|
+ <Text style={{ color: '#fff', marginTop: 20 }} onClick={(e) => {
|
|
|
+ e.stopPropagation()
|
|
|
+ setShowMore(!showMore)
|
|
|
+ }}>{showMore ? '隐藏更多' : '显示更多'}</Text>
|
|
|
+ }
|
|
|
+ {
|
|
|
+ showMore && moreCircle()
|
|
|
+ }
|
|
|
</View>
|
|
|
}
|
|
|
|
|
|
return <View>
|
|
|
+ <View style={{ position: 'absolute', left: 0, top: 0, width: 0, height: 0, opacity: 0 }}>{count}</View>
|
|
|
<View className="time_operate_item">
|
|
|
<RecordItem canDel={record.status == 'COMPLETED'} delete={del}
|
|
|
onClick={showDetail}
|