|
|
@@ -41,7 +41,6 @@ if (process.env.TARO_ENV == 'rn') {
|
|
|
export default function MainConsole(props: { type: WindowType }) {
|
|
|
const health = useSelector((state: any) => state.health);
|
|
|
const user = useSelector((state: any) => state.user);
|
|
|
- const [showPicker, setShowPicker] = useState(false)
|
|
|
const [durationPicker, setDurationPicker] = useState(false)
|
|
|
const [btnDisable, setBtnDisable] = useState(false)
|
|
|
const [selItem, setSelItem] = useState<any>(null)
|
|
|
@@ -77,7 +76,6 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
}
|
|
|
console.log(item)
|
|
|
setSelItem(item)
|
|
|
- // setShowPicker(true)
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -178,7 +176,7 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
// if (item.action == 'END' && !scenario.real) {
|
|
|
// themeColor = MainColorType.g01
|
|
|
// }
|
|
|
- if (item.target.timestamp>=new Date().getTime()){
|
|
|
+ if (item.target.timestamp >= new Date().getTime()) {
|
|
|
themeColor = MainColorType.g02
|
|
|
}
|
|
|
if (health.mode == 'DAY' || health.mode == 'NIGHT') {
|
|
|
@@ -203,7 +201,7 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
// }
|
|
|
return <NewButton
|
|
|
color={themeColor}
|
|
|
- type={item.target.timestamp>=new Date().getTime()?NewButtonType.alpha2:NewButtonType.alpha}
|
|
|
+ type={item.target.timestamp >= new Date().getTime() ? NewButtonType.alpha2 : NewButtonType.alpha}
|
|
|
title={operateTitle(item)}
|
|
|
width={rpxToPx(128)}
|
|
|
height={rpxToPx(72)}
|
|
|
@@ -283,7 +281,8 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
if (time > timeline.target.timestamp) {
|
|
|
return <Image style={{ width: rpxToPx(24), height: rpxToPx(24) }} src={require('@assets/_health/checked.png')} />
|
|
|
}
|
|
|
- return <View style={{width:rpxToPx(26),height:rpxToPx(26),borderRadius:rpxToPx(13),backgroundColor:'#fff'}}/>
|
|
|
+ return <IconCircle width={rpxToPx(32)} color={MainColorType.g02} />
|
|
|
+ // return <View style={{width:rpxToPx(26),height:rpxToPx(26),borderRadius:rpxToPx(13),backgroundColor:'#fff'}}/>
|
|
|
}
|
|
|
// if (timeline.target.timestamp < new Date().getTime()) {
|
|
|
// return <IconMiss color="#fff" width={rpxToPx(24)} />
|
|
|
@@ -291,21 +290,39 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
if (timeline.real) {
|
|
|
return <Image style={{ width: rpxToPx(24), height: rpxToPx(24) }} src={require('@assets/_health/checked.png')} />
|
|
|
}
|
|
|
- return <View style={{width:rpxToPx(26),height:rpxToPx(26),borderRadius:rpxToPx(13),backgroundColor:'#fff'}}/>
|
|
|
+ return <View style={{ width: rpxToPx(26), height: rpxToPx(26), borderRadius: rpxToPx(13), backgroundColor: '#fff' }} />
|
|
|
// return timeline.reminder ? <IconNotification color="#fff" width={rpxToPx(24)} /> : <IconNotificationOff color="#fff" width={rpxToPx(24)} />
|
|
|
}
|
|
|
|
|
|
function timelineItem(item: any, index: number, count: number) {
|
|
|
+ var strColor = ''
|
|
|
+ if (item.real) {
|
|
|
+ strColor = getThemeColor(health.mode)
|
|
|
+ }
|
|
|
+ else if (health.mode == 'DAY' || health.mode == 'NIGHT') {
|
|
|
+ const time = new Date().getTime()
|
|
|
+ const scenario = getScenario(health.windows, health.mode)
|
|
|
+ const timeline = scenario.timeline[index]
|
|
|
+ if (time > timeline.target.timestamp) {
|
|
|
+ strColor = getThemeColor(health.mode)
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ strColor = 'transparent'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ strColor = 'transparent'
|
|
|
+ }
|
|
|
function statusView() {
|
|
|
return <StatusIndicator type={StatusType.console}
|
|
|
- color={item.real?getThemeColor(health.mode):'transparent' }
|
|
|
- fontColor={item.real?getThemeColor(health.mode):MainColorType.g01 }
|
|
|
- bold={item.real?true:false}
|
|
|
+ color={strColor}
|
|
|
+ fontColor={item.real ? getThemeColor(health.mode) : MainColorType.g01}
|
|
|
+ bold={item.real ? true : false}
|
|
|
// color={new Date().getTime()<item.target.timestamp?MainColorType.g02:getThemeColor(health.mode)}
|
|
|
text={itemTitle(item)}
|
|
|
fontSize={rpxToPx(24)}
|
|
|
>{
|
|
|
- item.real?processIcon(index):<IconCircle width={rpxToPx(32)} color={MainColorType.g02}/>
|
|
|
+ (item.real || (health.mode == 'DAY' || health.mode == 'NIGHT')) ? processIcon(index) : <IconCircle width={rpxToPx(32)} color={MainColorType.g02} />
|
|
|
}</StatusIndicator>
|
|
|
}
|
|
|
return <ConsoleCell
|
|
|
@@ -320,93 +337,6 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
/>
|
|
|
}
|
|
|
|
|
|
- function timeContent() {
|
|
|
- return <Modal
|
|
|
- testInfo={null}
|
|
|
- dismiss={() => {
|
|
|
- setShowPicker(false)
|
|
|
- }}
|
|
|
- confirm={() => { }}>
|
|
|
- {
|
|
|
- pickerContent()
|
|
|
- }
|
|
|
- </Modal>
|
|
|
- }
|
|
|
-
|
|
|
- function pickerContent() {
|
|
|
- const timestamp = selItem.target.timestamp
|
|
|
- const strTime = dayjs(timestamp).format('HH:mm')
|
|
|
-
|
|
|
- var title, color;
|
|
|
- switch (selItem.scenario) {
|
|
|
- case 'FAST':
|
|
|
- title = selItem.event == 'FAST_END' ? '结束断食' : '开始断食'
|
|
|
- color = MainColorType.fast
|
|
|
- break;
|
|
|
- case 'SLEEP':
|
|
|
- title = selItem.event == 'SLEEP_WAKE_UP' ? '结束睡眠' : '开始睡眠'
|
|
|
- color = MainColorType.sleep
|
|
|
- }
|
|
|
-
|
|
|
- return <TimePicker time={strTime}
|
|
|
- color={color}
|
|
|
- title={title}
|
|
|
- confirm={(e) => {
|
|
|
- confirmPickerTime(e)
|
|
|
- }}
|
|
|
- cancel={() => {
|
|
|
- setShowPicker(false)
|
|
|
- }} />
|
|
|
- }
|
|
|
-
|
|
|
- function confirmPickerTime(strTime) {
|
|
|
- if (selItem.event == 'FAST_END') {
|
|
|
- const obj = health.windows.fast_eat.fast.timeline[0]
|
|
|
- if (obj.action == 'POST_MOMENT' || obj.action == 'NA') {
|
|
|
- const format = dayjs(obj.target.timestamp).format(`YYYY-MM-DDT${strTime}:ss`)
|
|
|
- var t = new Date(format).getTime()
|
|
|
- if (t <= obj.target.timestamp) {
|
|
|
- t += 24 * 3600 * 1000
|
|
|
- }
|
|
|
- updateTarget(t, obj.event_id).then(res => {
|
|
|
- global.refreshWindow()
|
|
|
- global.refreshHistory()
|
|
|
- setShowPicker(false)
|
|
|
- })
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- else if (selItem.event == 'SLEEP_WAKE_UP') {
|
|
|
- const obj = health.windows.sleep_active.sleep.timeline[0]
|
|
|
- if (obj.action == 'POST_MOMENT' || obj.action == 'NA') {
|
|
|
- const format = dayjs(obj.target.timestamp).format(`YYYY-MM-DDT${strTime}:ss`)
|
|
|
- var t = new Date(format).getTime()
|
|
|
- if (t <= obj.target.timestamp) {
|
|
|
- t += 24 * 3600 * 1000
|
|
|
- }
|
|
|
- updateTarget(t, obj.event_id).then(res => {
|
|
|
- global.refreshWindow()
|
|
|
- global.refreshHistory()
|
|
|
- setShowPicker(false)
|
|
|
- })
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- updateSchedule({
|
|
|
- time: strTime,
|
|
|
- event: selItem.event,
|
|
|
- title: selItem.title,
|
|
|
- specific_time: true
|
|
|
- }, selItem.schedule_id).then(res => {
|
|
|
- global.refreshWindow()
|
|
|
- global.refreshHistory()
|
|
|
- setShowPicker(false)
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
function changeToIF() {
|
|
|
updateFast({ fast_type: 'IF' }).then(res => {
|
|
|
global.refreshWindow()
|
|
|
@@ -480,12 +410,12 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
}
|
|
|
|
|
|
var strTitle = ''
|
|
|
- if (health.mode == 'DAY' || health.mode == 'NIGHT'){
|
|
|
+ if (health.mode == 'DAY' || health.mode == 'NIGHT') {
|
|
|
strTitle = getLocation()
|
|
|
}
|
|
|
- else if (health.mode == 'EAT' || health.mode == 'ACTIVE'){
|
|
|
- const scenario = getScenario(health.windows,health.mode)
|
|
|
- if (scenario.archive_timestamp){
|
|
|
+ else if (health.mode == 'EAT' || health.mode == 'ACTIVE') {
|
|
|
+ const scenario = getScenario(health.windows, health.mode)
|
|
|
+ if (scenario.archive_timestamp) {
|
|
|
/*"Today's logs will be archived at 23:59."
|
|
|
"Today's logs will be archived at 03:10 tomorrow."
|
|
|
|
|
|
@@ -493,7 +423,7 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
"今日记录将于明天 23:59 归档"*/
|
|
|
var today = new Date().getDate()
|
|
|
var date = new Date(scenario.archive_timestamp).getDate()
|
|
|
- strTitle = `今日记录将于${today==date?'':'明天'} ${dayjs(scenario.archive_timestamp).format('HH:mm')} 归档`
|
|
|
+ strTitle = `今日记录将于${today == date ? '' : '明天'} ${dayjs(scenario.archive_timestamp).format('HH:mm')} 归档`
|
|
|
}
|
|
|
else {
|
|
|
strTitle = t('health.more_actions')
|
|
|
@@ -824,19 +754,19 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
var str = ''
|
|
|
switch (status) {
|
|
|
case 'OG1':
|
|
|
- str = 'Fast before Bedtime'
|
|
|
+ str = t('health.fast_before_bed')
|
|
|
break;
|
|
|
case 'OG2_NO1':
|
|
|
- str = 'Fast before Bedtime'
|
|
|
+ str = t('health.fast_missing')
|
|
|
break;
|
|
|
case 'OG2':
|
|
|
- str = 'Fast while Sleeping'
|
|
|
+ str = t('health.fast_while_sleep')
|
|
|
break;
|
|
|
case 'OG2_MISALIGNED':
|
|
|
- str = 'Misaligned/错位'
|
|
|
+ str = t('health.misaligned')
|
|
|
break;
|
|
|
case 'OG3':
|
|
|
- str = 'Fast after Wake Up'
|
|
|
+ str = t('health.fast_after_sleep')
|
|
|
break
|
|
|
}
|
|
|
return <View className="h26" style={{ color: MainColorType.g01 }}>{str}</View>
|
|
|
@@ -882,7 +812,7 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
style={{
|
|
|
color: getWindowStatus(health.windows, health.mode) == WindowStatusType.upcoming ? MainColorType.g02 : MainColorType.g01,
|
|
|
marginBottom: rpxToPx(30)
|
|
|
- }}>{getDuration(health.windows, health.mode)}{getScenario(health.windows,health.mode).status=='OG'?' ('+t('health.logging')+')':''}</Text>
|
|
|
+ }}>{getDuration(health.windows, health.mode)}{getScenario(health.windows, health.mode).status == 'OG' ? ' (' + t('health.logging') + ')' : ''}</Text>
|
|
|
<View className="border_footer_line" />
|
|
|
</View>
|
|
|
<View style={{ backgroundColor: '#fff', width: rpxToPx(750) }}>
|
|
|
@@ -982,7 +912,7 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
fastWithSleepStatus()
|
|
|
}
|
|
|
{
|
|
|
- health.fast_with_sleep.status == 'OG2_MISALIGNED' && <View style={{
|
|
|
+ (health.fast_with_sleep.status == 'OG2_MISALIGNED' || health.fast_with_sleep.status == 'OG2_NO1') && <View style={{
|
|
|
backgroundColor: MainColorType.error,
|
|
|
width: rpxToPx(12),
|
|
|
height: rpxToPx(12),
|
|
|
@@ -1010,9 +940,6 @@ export default function MainConsole(props: { type: WindowType }) {
|
|
|
/>
|
|
|
}
|
|
|
<View className="circle" />
|
|
|
- {
|
|
|
- showPicker && timeContent()
|
|
|
- }
|
|
|
{
|
|
|
durationPicker && <DurationPicker
|
|
|
done={(time) => {
|