|
|
@@ -18,6 +18,8 @@ import NewDurationPicker, { DurationPickerType } from "../base/new_durationpicke
|
|
|
import showAlert from "@/components/basic/Alert";
|
|
|
import NewDatePicker, { NewDatePickerType } from "../base/new_date_picker";
|
|
|
import ChooseDateTime from "../components/choose_date_time";
|
|
|
+import { TimeFormatter } from "@/utils/time_format";
|
|
|
+import StatusIndicator, { StatusType } from "../base/status_indicator";
|
|
|
|
|
|
let useRoute;
|
|
|
let useNavigation;
|
|
|
@@ -142,7 +144,7 @@ export default function LogTime() {
|
|
|
event_id: timeline.event_id,
|
|
|
schedule_id: timeline.schedule_id,
|
|
|
time: dayjs().format('HH:mm'),
|
|
|
- date:dayjs().format('YYYY-MM-DD'),
|
|
|
+ date: dayjs().format('YYYY-MM-DD'),
|
|
|
extra: {
|
|
|
set_time: enterTime,
|
|
|
confirm_time: enterTime
|
|
|
@@ -175,7 +177,7 @@ export default function LogTime() {
|
|
|
event_id: timeline.event_id,
|
|
|
schedule_id: timeline.schedule_id,
|
|
|
time: dayjs().format('HH:mm'),
|
|
|
- date:dayjs().format('YYYY-MM-DD'),
|
|
|
+ date: dayjs().format('YYYY-MM-DD'),
|
|
|
extra: {
|
|
|
set_time: enterTime,
|
|
|
confirm_time: enterTime
|
|
|
@@ -255,6 +257,9 @@ export default function LogTime() {
|
|
|
if (isSingle) {
|
|
|
return isFast ? MainColorType.fast : MainColorType.sleep
|
|
|
}
|
|
|
+ else {
|
|
|
+ if (tapIndex == '1' || tapIndex == '2') return MainColorType.sleep
|
|
|
+ }
|
|
|
return MainColorType.fast
|
|
|
}
|
|
|
|
|
|
@@ -263,7 +268,7 @@ export default function LogTime() {
|
|
|
// var hour = parseInt(time.split(':')[0])
|
|
|
// var minute = parseInt(time.split(':')[1])
|
|
|
// var date = obj.date
|
|
|
- var now = new Date(obj.date+'T'+time+':'+dayjs().format('ss'))
|
|
|
+ var now = new Date(obj.date + 'T' + time + ':' + dayjs().format('ss'))
|
|
|
// now.setHours(hour)
|
|
|
// now.setMinutes(minute)
|
|
|
// now.setSeconds(0)
|
|
|
@@ -449,7 +454,7 @@ export default function LogTime() {
|
|
|
var scheduleTime = parseInt(schedule_time.replace(':', ''))
|
|
|
var date = dayjs().format('YYYY-MM-DD')
|
|
|
if (scheduleTime > nowTime) {
|
|
|
- date = dayjs(new Date().getTime()-24*3600*1000).format('YYYY-MM-DD')
|
|
|
+ date = dayjs(new Date().getTime() - 24 * 3600 * 1000).format('YYYY-MM-DD')
|
|
|
}
|
|
|
var list = JSON.parse(JSON.stringify(array))
|
|
|
list[index].date = date
|
|
|
@@ -490,6 +495,20 @@ export default function LogTime() {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ function expectText() {
|
|
|
+ var obj = array[0]
|
|
|
+ var timestamp = getTimestamp(obj)
|
|
|
+ var duration = isFast ? data.fast.target.duration : data.sleep.target.duration
|
|
|
+ var time2 = timestamp + duration
|
|
|
+ var strTime = TimeFormatter.dayjsFormat(time2, false)
|
|
|
+ if (isFast) {
|
|
|
+ return 'Expect to end fast at ' + strTime
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return 'Expect to wake up at ' + strTime
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
function logItem(index: number, iFast: boolean, iStart: boolean, showLine: boolean) {
|
|
|
const { fast, sleep } = data
|
|
|
var schedule_time = ''
|
|
|
@@ -561,7 +580,13 @@ export default function LogTime() {
|
|
|
showError = true
|
|
|
}
|
|
|
return <ChooseDateTime
|
|
|
- title={isSingle ? null : title}
|
|
|
+ title={isSingle ? null : <StatusIndicator
|
|
|
+ type={StatusType.normal}
|
|
|
+ color={iFast ? MainColorType.fast : MainColorType.sleep}
|
|
|
+ fontSize={rpxToPx(34)}
|
|
|
+ text={title}
|
|
|
+ defaultSpace
|
|
|
+ />}
|
|
|
disable={array[index].disable}
|
|
|
showError={showError}
|
|
|
showLine={showLine}
|
|
|
@@ -706,36 +731,62 @@ export default function LogTime() {
|
|
|
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>
|
|
|
+ <View className="h34" style={{marginLeft:rpxToPx(12)}}>{isFast ? 'Fast Goal' : 'Sleep Goal'}</View>
|
|
|
<NewButton
|
|
|
type={NewButtonType.gray}
|
|
|
height={rpxToPx(84)}
|
|
|
title={durationTime()}
|
|
|
+ fontNormal
|
|
|
onClick={() => { setExpandIndex(-1) }}
|
|
|
/>
|
|
|
</View>
|
|
|
{
|
|
|
- expandIndex == -1 && <NewDurationPicker
|
|
|
- type={DurationPickerType.normal}
|
|
|
- value={isFast ? data.fast.target.duration : data.sleep.target.duration}
|
|
|
- onChange={e => {
|
|
|
- var temp = JSON.parse(JSON.stringify(data))
|
|
|
- if (isFast) {
|
|
|
- temp.fast.target.duration = e
|
|
|
- }
|
|
|
- else {
|
|
|
- temp.sleep.target.duration = e
|
|
|
- }
|
|
|
- setData(temp)
|
|
|
- }}
|
|
|
- color={isFast ? MainColorType.fast : MainColorType.sleep} />
|
|
|
+ expandIndex == -1 && <View style={{
|
|
|
+ display: 'flex',
|
|
|
+ flexDirection: 'column',
|
|
|
+ alignItems: 'center'
|
|
|
+ }}>
|
|
|
+ <NewDurationPicker
|
|
|
+ type={DurationPickerType.normal}
|
|
|
+ value={isFast ? data.fast.target.duration : data.sleep.target.duration}
|
|
|
+ onChange={e => {
|
|
|
+ var temp = JSON.parse(JSON.stringify(data))
|
|
|
+ if (isFast) {
|
|
|
+ temp.fast.target.duration = e
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ temp.sleep.target.duration = e
|
|
|
+ }
|
|
|
+ setData(temp)
|
|
|
+ }}
|
|
|
+ color={isFast ? MainColorType.fast : MainColorType.sleep} />
|
|
|
+ </View>
|
|
|
}
|
|
|
|
|
|
</View>
|
|
|
</Card>
|
|
|
}
|
|
|
+ {
|
|
|
+ isSingle && isStart && showGoal && <View className="h24 g02" style={{
|
|
|
+ width: rpxToPx(750), height: rpxToPx(84),
|
|
|
+ display: 'flex',
|
|
|
+ alignItems: 'center',
|
|
|
+ justifyContent: 'center'
|
|
|
+ }}>{expectText()}</View>
|
|
|
+ }
|
|
|
<View style={{ flex: 1 }} />
|
|
|
- <View style={{ marginBottom: rpxToPx(128), display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
|
|
+ {/* <View style={{ marginBottom: rpxToPx(128), display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
|
|
+ <NewButton
|
|
|
+ color={footerBtnColor()}
|
|
|
+ type={NewButtonType.fill}
|
|
|
+ title={'Log'}
|
|
|
+ width={rpxToPx(646)}
|
|
|
+ height={rpxToPx(96)}
|
|
|
+ disable={errors.length > 0}
|
|
|
+ bold={true}
|
|
|
+ onClick={() => tapCommit(false)} />
|
|
|
+ </View> */}
|
|
|
+ <View className="main_footer">
|
|
|
<NewButton
|
|
|
color={footerBtnColor()}
|
|
|
type={NewButtonType.fill}
|