|
@@ -18,6 +18,7 @@ import Taro from '@tarojs/taro';
|
|
|
import { IconInfo, IconMinus, IconPlus } from '@/components/basic/Icons';
|
|
import { IconInfo, IconMinus, IconPlus } from '@/components/basic/Icons';
|
|
|
|
|
|
|
|
export default function CircadianDetailPopup(props: { record: any, schedule?: any, onClose: Function, stageIndex?: number, onlyStage?: boolean }) {
|
|
export default function CircadianDetailPopup(props: { record: any, schedule?: any, onClose: Function, stageIndex?: number, onlyStage?: boolean }) {
|
|
|
|
|
+
|
|
|
const [tabIndex, setTabIndex] = useState(0)
|
|
const [tabIndex, setTabIndex] = useState(0)
|
|
|
const [diffTimeZone, setDiffTimeZone] = useState(false)
|
|
const [diffTimeZone, setDiffTimeZone] = useState(false)
|
|
|
const [multiTimeZone, setMultiTimeZone] = useState(false)
|
|
const [multiTimeZone, setMultiTimeZone] = useState(false)
|
|
@@ -26,6 +27,7 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
|
|
|
const [fastPickerValue, setFastPickerValue] = useState([0, 0])
|
|
const [fastPickerValue, setFastPickerValue] = useState([0, 0])
|
|
|
const [sleepPickerValue, setSleepPickerValue] = useState([0, 0])
|
|
const [sleepPickerValue, setSleepPickerValue] = useState([0, 0])
|
|
|
const [showEditPicker, setShowEditPicker] = useState(false)
|
|
const [showEditPicker, setShowEditPicker] = useState(false)
|
|
|
|
|
+ const [schedule, setSchedule] = useState(props.schedule)
|
|
|
const [isFast, setIsFast] = useState(true)
|
|
const [isFast, setIsFast] = useState(true)
|
|
|
const durationPickerRef = useRef(null)
|
|
const durationPickerRef = useRef(null)
|
|
|
const common = useSelector((state: any) => state.common);
|
|
const common = useSelector((state: any) => state.common);
|
|
@@ -332,18 +334,19 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
|
|
|
|
|
|
|
|
setFastPickerValue(durationIndex(detail.fast.target_start_time, detail.fast.target_end_time, common))
|
|
setFastPickerValue(durationIndex(detail.fast.target_start_time, detail.fast.target_end_time, common))
|
|
|
|
|
|
|
|
- if (props.record.status == 'WAIT_FOR_START' && props.schedule) {
|
|
|
|
|
- var start = props.schedule.fast.start_time
|
|
|
|
|
- var startCount = (parseInt(start.split(':')[0]) * 60 + parseInt(start.split(':')[1])) * 60 * 1000
|
|
|
|
|
- var endCount = startCount + count
|
|
|
|
|
- if (endCount >= 24 * 3600 * 1000) {
|
|
|
|
|
- endCount -= 24 * 3600 * 1000
|
|
|
|
|
- }
|
|
|
|
|
- endCount = endCount / 60000
|
|
|
|
|
- var endHour = Math.floor(endCount / 60)
|
|
|
|
|
- var endMinute = endCount % 60
|
|
|
|
|
- var endTime = TimeFormatter.padZero(endHour) + ':' + TimeFormatter.padZero(endMinute)
|
|
|
|
|
- console.log(endTime)
|
|
|
|
|
|
|
+ if (props.record.status == 'WAIT_FOR_START') {
|
|
|
|
|
+ // var start = props.schedule.fast.start_time
|
|
|
|
|
+ // var startCount = (parseInt(start.split(':')[0]) * 60 + parseInt(start.split(':')[1])) * 60 * 1000
|
|
|
|
|
+ // var endCount = startCount + count
|
|
|
|
|
+ // if (endCount >= 24 * 3600 * 1000) {
|
|
|
|
|
+ // endCount -= 24 * 3600 * 1000
|
|
|
|
|
+ // }
|
|
|
|
|
+ // endCount = endCount / 60000
|
|
|
|
|
+ // var endHour = Math.floor(endCount / 60)
|
|
|
|
|
+ // var endMinute = endCount % 60
|
|
|
|
|
+ // var endTime = TimeFormatter.padZero(endHour) + ':' + TimeFormatter.padZero(endMinute)
|
|
|
|
|
+ // console.log(endTime)
|
|
|
|
|
+ changeSchedule(count)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -390,18 +393,19 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
|
|
|
|
|
|
|
|
setFastPickerValue(durationIndex(detail.fast.target_start_time, detail.fast.target_end_time, common))
|
|
setFastPickerValue(durationIndex(detail.fast.target_start_time, detail.fast.target_end_time, common))
|
|
|
|
|
|
|
|
- if (props.record.status == 'WAIT_FOR_START' && props.schedule) {
|
|
|
|
|
- var start = props.schedule.fast.start_time
|
|
|
|
|
- var startCount = (parseInt(start.split(':')[0]) * 60 + parseInt(start.split(':')[1])) * 60 * 1000
|
|
|
|
|
- var endCount = startCount + count
|
|
|
|
|
- if (endCount >= 24 * 3600 * 1000) {
|
|
|
|
|
- endCount -= 24 * 3600 * 1000
|
|
|
|
|
- }
|
|
|
|
|
- endCount = endCount / 60000
|
|
|
|
|
- var endHour = Math.floor(endCount / 60)
|
|
|
|
|
- var endMinute = endCount % 60
|
|
|
|
|
- var endTime = TimeFormatter.padZero(endHour) + ':' + TimeFormatter.padZero(endMinute)
|
|
|
|
|
- console.log(endTime)
|
|
|
|
|
|
|
+ if (props.record.status == 'WAIT_FOR_START') {
|
|
|
|
|
+ changeSchedule(count)
|
|
|
|
|
+ // var start = props.schedule.fast.start_time
|
|
|
|
|
+ // var startCount = (parseInt(start.split(':')[0]) * 60 + parseInt(start.split(':')[1])) * 60 * 1000
|
|
|
|
|
+ // var endCount = startCount + count
|
|
|
|
|
+ // if (endCount >= 24 * 3600 * 1000) {
|
|
|
|
|
+ // endCount -= 24 * 3600 * 1000
|
|
|
|
|
+ // }
|
|
|
|
|
+ // endCount = endCount / 60000
|
|
|
|
|
+ // var endHour = Math.floor(endCount / 60)
|
|
|
|
|
+ // var endMinute = endCount % 60
|
|
|
|
|
+ // var endTime = TimeFormatter.padZero(endHour) + ':' + TimeFormatter.padZero(endMinute)
|
|
|
|
|
+ // console.log(endTime)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
@@ -430,6 +434,25 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
|
|
|
setDetail(JSON.parse(JSON.stringify(detail)))
|
|
setDetail(JSON.parse(JSON.stringify(detail)))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function changeSchedule(count: number) {
|
|
|
|
|
+ if (!schedule) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ var obj = JSON.parse(JSON.stringify(schedule))
|
|
|
|
|
+ var start = schedule.fast.start_time
|
|
|
|
|
+ var startCount = (parseInt(start.split(':')[0]) * 60 + parseInt(start.split(':')[1])) * 60 * 1000
|
|
|
|
|
+ var endCount = startCount + count
|
|
|
|
|
+ if (endCount >= 24 * 3600 * 1000) {
|
|
|
|
|
+ endCount -= 24 * 3600 * 1000
|
|
|
|
|
+ }
|
|
|
|
|
+ endCount = endCount / 60000
|
|
|
|
|
+ var endHour = Math.floor(endCount / 60)
|
|
|
|
|
+ var endMinute = endCount % 60
|
|
|
|
|
+ var endTime = TimeFormatter.padZero(endHour) + ':' + TimeFormatter.padZero(endMinute)
|
|
|
|
|
+ obj.fast.end_time = endTime
|
|
|
|
|
+ setSchedule(obj)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function sleepRealDuration() {
|
|
function sleepRealDuration() {
|
|
|
return getStageDuration(4)
|
|
return getStageDuration(4)
|
|
|
}
|
|
}
|
|
@@ -693,14 +716,14 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
|
|
|
}
|
|
}
|
|
|
return <View>
|
|
return <View>
|
|
|
<View className='pop_ring_bg'>
|
|
<View className='pop_ring_bg'>
|
|
|
- <Rings common={common} bgRing={bgRing} canvasId={'pre_sleep_ring'} realRing={preRing} currentDot={currentDot}/>
|
|
|
|
|
|
|
+ <Rings common={common} bgRing={bgRing} canvasId={'pre_sleep_ring'} realRing={preRing} currentDot={currentDot} />
|
|
|
<View className="pop_duration_bg">
|
|
<View className="pop_duration_bg">
|
|
|
<Text className="pop_duration_title">{t('feature.track_time_duration.stage.a')}</Text>
|
|
<Text className="pop_duration_title">{t('feature.track_time_duration.stage.a')}</Text>
|
|
|
<Text className="pop_duration_value" style={{ color: ColorType.fast }}>{getStageDuration(0)}</Text>
|
|
<Text className="pop_duration_value" style={{ color: ColorType.fast }}>{getStageDuration(0)}</Text>
|
|
|
</View>
|
|
</View>
|
|
|
</View>
|
|
</View>
|
|
|
<View className='pop_ring_bg'>
|
|
<View className='pop_ring_bg'>
|
|
|
- <Rings common={common} bgRing={bgRing} canvasId={'sleeping_ring'} realRing={sleepRing} currentDot={currentDot2}/>
|
|
|
|
|
|
|
+ <Rings common={common} bgRing={bgRing} canvasId={'sleeping_ring'} realRing={sleepRing} currentDot={currentDot2} />
|
|
|
<View className="pop_duration_bg">
|
|
<View className="pop_duration_bg">
|
|
|
<Text className="pop_duration_title">{t('feature.track_time_duration.stage.b')}</Text>
|
|
<Text className="pop_duration_title">{t('feature.track_time_duration.stage.b')}</Text>
|
|
|
<View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
|
|
<View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
|
|
@@ -713,7 +736,7 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
|
|
|
</View>
|
|
</View>
|
|
|
</View>
|
|
</View>
|
|
|
<View className='pop_ring_bg'>
|
|
<View className='pop_ring_bg'>
|
|
|
- <Rings common={common} bgRing={bgRing} canvasId={'later_sleep_ring'} realRing={wakeRing} currentDot={currentDot3}/>
|
|
|
|
|
|
|
+ <Rings common={common} bgRing={bgRing} canvasId={'later_sleep_ring'} realRing={wakeRing} currentDot={currentDot3} />
|
|
|
<View className="pop_duration_bg">
|
|
<View className="pop_duration_bg">
|
|
|
<Text className="pop_duration_title">{t('feature.track_time_duration.stage.c')}</Text>
|
|
<Text className="pop_duration_title">{t('feature.track_time_duration.stage.c')}</Text>
|
|
|
<View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
|
|
<View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
|
|
@@ -727,60 +750,12 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function stage2() {
|
|
|
|
|
- var bgRing = getBgRing()
|
|
|
|
|
- var common = getCommon(null, false)
|
|
|
|
|
- common.radius = bigRingRadius;
|
|
|
|
|
- common.lineWidth = ringWidth;
|
|
|
|
|
-
|
|
|
|
|
- var timestamp = TimeFormatter.transferTimestamp(props.record.fast.real_start_time, props.record.fast.real_end_time_zone)
|
|
|
|
|
- var timestamp2 = TimeFormatter.transferTimestamp(props.record.sleep.real_start_time, props.record.fast.real_end_time_zone)
|
|
|
|
|
- var timestamp3 = TimeFormatter.transferTimestamp(props.record.sleep.real_end_time, props.record.fast.real_end_time_zone)
|
|
|
|
|
- const preRing: RealRing = {
|
|
|
|
|
- color: global.fastColor ? global.fastColor : ColorType.fast,
|
|
|
|
|
- startArc: startArc(timestamp),
|
|
|
|
|
- durationArc: durationArc(props.record.fast.real_start_time, props.record.sleep.real_start_time)
|
|
|
|
|
- }
|
|
|
|
|
- const sleepRing: RealRing = {
|
|
|
|
|
- color: global.sleepColor ? global.sleepColor : ColorType.sleep,
|
|
|
|
|
- startArc: startArc(timestamp2),
|
|
|
|
|
- durationArc: durationArc(props.record.sleep.real_start_time, props.record.sleep.real_end_time)
|
|
|
|
|
- }
|
|
|
|
|
- const wakeRing: RealRing = {
|
|
|
|
|
- color: global.fastColor ? global.fastColor : ColorType.fast,
|
|
|
|
|
- startArc: startArc(timestamp3),
|
|
|
|
|
- durationArc: durationArc(props.record.sleep.real_end_time, props.record.fast.real_end_time)
|
|
|
|
|
- }
|
|
|
|
|
- return <View>
|
|
|
|
|
- <View className='pop_ring_bg'>
|
|
|
|
|
- <Rings common={common} bgRing={bgRing} canvasId={'pre_sleep_ring'} realRing={preRing} />
|
|
|
|
|
- <View className="pop_duration_bg">
|
|
|
|
|
- <Text className="pop_duration_title">{t('feature.track_time_duration.stage.a')}</Text>
|
|
|
|
|
- <Text className="pop_duration_value" style={{ color: ColorType.fast }}>{getStageDuration(0)}</Text>
|
|
|
|
|
- </View>
|
|
|
|
|
- </View>
|
|
|
|
|
- <View className='pop_ring_bg'>
|
|
|
|
|
- <Rings common={common} bgRing={bgRing} canvasId={'sleeping_ring'} realRing={sleepRing} />
|
|
|
|
|
- <View className="pop_duration_bg">
|
|
|
|
|
- <Text className="pop_duration_title">{t('feature.track_time_duration.stage.b')}</Text>
|
|
|
|
|
- <Text className="pop_duration_value" style={{ color: ColorType.sleep }}>{getStageDuration(1)}</Text>
|
|
|
|
|
- </View>
|
|
|
|
|
- </View>
|
|
|
|
|
- <View className='pop_ring_bg'>
|
|
|
|
|
- <Rings common={common} bgRing={bgRing} canvasId={'later_sleep_ring'} realRing={wakeRing} />
|
|
|
|
|
- <View className="pop_duration_bg">
|
|
|
|
|
- <Text className="pop_duration_title">{t('feature.track_time_duration.stage.c')}</Text>
|
|
|
|
|
- <Text className="pop_duration_value" style={{ color: ColorType.fast }}>{getStageDuration(2)}</Text>
|
|
|
|
|
- </View>
|
|
|
|
|
- </View>
|
|
|
|
|
- </View>
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
function events() {
|
|
function events() {
|
|
|
return <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'center' }}>
|
|
return <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'center' }}>
|
|
|
<TimelineFastSleep
|
|
<TimelineFastSleep
|
|
|
data={props.record}
|
|
data={props.record}
|
|
|
first_real_check_time={props.record.first_real_check_time ? props.record.first_real_check_time : 0}
|
|
first_real_check_time={props.record.first_real_check_time ? props.record.first_real_check_time : 0}
|
|
|
|
|
+ scenario={schedule ? { schedule: schedule } : null}
|
|
|
diffTimeZone={diffTimeZone} multiTimeZone={multiTimeZone} />
|
|
diffTimeZone={diffTimeZone} multiTimeZone={multiTimeZone} />
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
@@ -824,13 +799,16 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
|
|
|
|
|
|
|
|
function durationChange(e) {
|
|
function durationChange(e) {
|
|
|
global.pauseIndexTimer = false
|
|
global.pauseIndexTimer = false
|
|
|
- // debugger
|
|
|
|
|
var count = (e[0] + common.duration.min) * 60 + e[1] * common.duration.step
|
|
var count = (e[0] + common.duration.min) * 60 + e[1] * common.duration.step
|
|
|
// var count = (e[0] + 1) * 60 + e[1] * 5
|
|
// var count = (e[0] + 1) * 60 + e[1] * 5
|
|
|
if (showDurationPicker) {
|
|
if (showDurationPicker) {
|
|
|
// global.changeTargetDuration(count, isFast)
|
|
// global.changeTargetDuration(count, isFast)
|
|
|
if (isFast) {
|
|
if (isFast) {
|
|
|
detail.fast.target_end_time = detail.fast.target_start_time + count * 60 * 1000
|
|
detail.fast.target_end_time = detail.fast.target_start_time + count * 60 * 1000
|
|
|
|
|
+ if (props.record.status == 'WAIT_FOR_START'){
|
|
|
|
|
+ changeSchedule(count*1000*60)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
detail.sleep.target_end_time = detail.sleep.target_start_time + count * 60 * 1000
|
|
detail.sleep.target_end_time = detail.sleep.target_start_time + count * 60 * 1000
|
|
@@ -1081,7 +1059,7 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
|
|
|
if (process.env.TARO_ENV == 'weapp') {
|
|
if (process.env.TARO_ENV == 'weapp') {
|
|
|
e.stopPropagation()
|
|
e.stopPropagation()
|
|
|
}
|
|
}
|
|
|
- global.updateFastSleepData(detail)
|
|
|
|
|
|
|
+ global.updateFastSleepData(detail,schedule)
|
|
|
props.onClose();
|
|
props.onClose();
|
|
|
}}>{getBottomText()}</View>
|
|
}}>{getBottomText()}</View>
|
|
|
</View>
|
|
</View>
|