|
|
@@ -12,12 +12,13 @@ import { getScenario, getThemeColor } from "./hooks/health_hooks";
|
|
|
import { TimeFormatter } from "@/utils/time_format";
|
|
|
import dayjs from "dayjs";
|
|
|
import { MainColorType } from "@/context/themes/color";
|
|
|
-import { IconArrow, IconCellArrow } from "@/components/basic/Icons";
|
|
|
+import { IconArrow, IconCellArrow, IconClose } from "@/components/basic/Icons";
|
|
|
import NoRecord from "@/_health/components/no_record";
|
|
|
import ListFooter from "@/_health/components/list_footer";
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
import { setActiveTip, setEatTip, setFirstActiveId, setFirstEatId } from "@/store/health";
|
|
|
import RightArrowRow from "@/_health/components/right_arrow_row";
|
|
|
+import NewButton, { NewButtonType } from "@/_health/base/new_button";
|
|
|
|
|
|
let lastMode = ''
|
|
|
let myScrollTop = 0
|
|
|
@@ -38,6 +39,12 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
|
|
|
const [activeList, setActiveList] = useState<any>([])
|
|
|
const [sleepList, setSleepList] = useState<any>([])
|
|
|
|
|
|
+
|
|
|
+ const [hideEatArchiveTip, setHideEatArchiveTip] = useState(false)
|
|
|
+ const [hideActiveArchiveTip, setHideActiveArchiveTip] = useState(false)
|
|
|
+ const [hideFastTip, setHideFastTip] = useState(false)
|
|
|
+ const [hideSleepTip, setHideSleepTip] = useState(false)
|
|
|
+
|
|
|
const dispatch = useDispatch()
|
|
|
const { t } = useTranslation()
|
|
|
|
|
|
@@ -71,7 +78,7 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
|
|
|
// }
|
|
|
// }
|
|
|
// else {
|
|
|
-
|
|
|
+
|
|
|
// }
|
|
|
}, [])
|
|
|
|
|
|
@@ -443,7 +450,7 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
|
|
|
setList(array)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
setTotal((res as any).total)
|
|
|
if (props.refreshSuccess) {
|
|
|
props.refreshSuccess()
|
|
|
@@ -512,51 +519,6 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
- function archiveContent() {
|
|
|
- if (health.mode != 'EAT' && health.mode != 'ACTIVE') {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- if (health.mode == 'EAT') {
|
|
|
- if (!showEatArchive || !health.eatArchived || !health.eatArchived.archived) {
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (health.mode == 'ACTIVE') {
|
|
|
- if (!showActiveArchive || !health.activeArchived || !health.activeArchived.archived) {
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return <View style={{
|
|
|
- display: 'flex',
|
|
|
- flexDirection: 'column',
|
|
|
- alignItems: 'center',
|
|
|
- paddingTop: rpxToPx(82),
|
|
|
- paddingBottom: rpxToPx(82),
|
|
|
- backgroundColor: '#fff',
|
|
|
- position: 'relative'
|
|
|
- }}>
|
|
|
- <View className="archived_bg" onClick={() => {
|
|
|
- jumpPage('/_health/pages/archive')
|
|
|
- setTimeout(() => {
|
|
|
- health.mode == 'EAT' ? setShowEatArchive(false) : setShowActiveArchive(false)
|
|
|
- }, 1000)
|
|
|
-
|
|
|
- }}>
|
|
|
- <Text className="archived_text bold" style={{ color: getThemeColor(health.mode) }}>[{health.eatArchived.real_count}/{health.eatArchived.target_count} Meals] Archived {TimeFormatter.dateDescription(new Date(health.eatArchived.timestamp).getTime(), true, false)}</Text>
|
|
|
- {
|
|
|
- health.eatArchived.images.map((item, index) => {
|
|
|
- return <Image src={item} key={index} className="archived_img" mode="aspectFill" />
|
|
|
- })
|
|
|
- }
|
|
|
- <IconArrow color={MainColorType.g02} width={rpxToPx(34)} />
|
|
|
- </View>
|
|
|
- <View className="border_footer_line" />
|
|
|
- </View>
|
|
|
- }
|
|
|
-
|
|
|
if (!loaded || health.mode == 'DAY' || health.mode == 'NIGHT')
|
|
|
return <View />
|
|
|
|
|
|
@@ -655,77 +617,124 @@ export default forwardRef((props: { type?: string, fast_type?: string, updateDat
|
|
|
return <View />
|
|
|
}
|
|
|
|
|
|
- return <View style={{ width: rpxToPx(750), marginTop: rpxToPx(60) }}>
|
|
|
+ function markDoneTip() {
|
|
|
+ if (health.mode == 'DAY' && health.mode != 'NIGHT') return
|
|
|
+ var scenario = getScenario(health.windows, health.mode)
|
|
|
+ if (scenario.status != 'OG') return
|
|
|
+
|
|
|
+ if (health.mode == 'EAT' && hideEatArchiveTip) return
|
|
|
+ if (health.mode == 'ACTIVE' && hideActiveArchiveTip) return
|
|
|
+ if (health.mode == 'FAST' && hideFastTip) return
|
|
|
+ if (health.mode == 'SLEEP' && hideSleepTip) return
|
|
|
+
|
|
|
+ function tipContent() {
|
|
|
+ var strTime = ''
|
|
|
+ var today = new Date().getDate()
|
|
|
+ var date = new Date(scenario.archive_timestamp).getDate()
|
|
|
+ var time = dayjs(scenario.archive_timestamp).format('HH:mm')
|
|
|
+ if (today == date) {
|
|
|
+ strTime = t('health.today_at', { time: time })
|
|
|
+ if (global.language == 'en'){
|
|
|
+ if (time == '23:59'){
|
|
|
+ strTime = 'at midnight'
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ strTime = `today at ${time}`
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ strTime = t('health.tomorrow_at', { time: time })
|
|
|
+ if (global.language == 'en'){
|
|
|
+ strTime = `tomorrow at ${time}`
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (health.mode) {
|
|
|
+ case 'FAST':
|
|
|
+ if (global.language == 'en') {
|
|
|
+ return <Text className="h26 g01"><Text className="bold">Today's Moments</Text> will appear in Recents when you <Text className="italic">log end fast</Text>.</Text>
|
|
|
+ }
|
|
|
+ return <Text className="h26 g01"><Text className="bold">今天的时刻</Text> 将在您 <Text className="italic">记录结束断食</Text> 之际,出现在最近记录中。</Text>
|
|
|
+ case 'SLEEP':
|
|
|
+ if (global.language == 'en') {
|
|
|
+ return <Text className="h26 g01"><Text className="bold">Today's Moments</Text> will appear in Recents when you <Text className="italic">log wake up</Text>.</Text>
|
|
|
+ }
|
|
|
+ return <Text className="h26 g01"><Text className="bold">今天的时刻</Text> 将在您 <Text className="italic">记录起床</Text> 之际,出现在最近记录中。</Text>
|
|
|
+ case 'EAT':
|
|
|
+ case 'ACTIVE':
|
|
|
+ if (global.language == 'en') {
|
|
|
+ return <Text className="h26 g01"><Text className="bold">Today's Moments</Text> will appear in Recents {strTime} or when you <Text className="italic">mark done</Text>.</Text>
|
|
|
+ }
|
|
|
+ return <Text className="h26 g01"><Text className="bold">今天的时刻</Text> 将在今夜或在您 <Text className="italic">标记完成</Text> 之际,出现在最近记录中。</Text>
|
|
|
+ }
|
|
|
+ return <Text className="h26">1</Text>
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return <View className="mark_done_tip" style={{
|
|
|
+ backgroundColor: getThemeColor(health.mode) + '1A'
|
|
|
+ }}>
|
|
|
+ <View style={{ display: 'flex', flexDirection: 'column', flex: 1 }}>
|
|
|
+ {
|
|
|
+ tipContent()
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ <NewButton type={NewButtonType.img} btnStyle={{
|
|
|
+ paddingLeft:20,
|
|
|
+ height: rpxToPx(32),
|
|
|
+ width: rpxToPx(32)
|
|
|
+ }} onClick={() => {
|
|
|
+ switch (health.mode) {
|
|
|
+ case 'FAST':
|
|
|
+ setHideFastTip(true)
|
|
|
+ break;
|
|
|
+ case 'EAT':
|
|
|
+ setHideEatArchiveTip(true)
|
|
|
+ break;
|
|
|
+ case 'SLEEP':
|
|
|
+ setHideSleepTip(true)
|
|
|
+ break
|
|
|
+ case 'ACTIVE':
|
|
|
+ setHideActiveArchiveTip(true)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }}>
|
|
|
+ <IconClose color={MainColorType.g01} width={rpxToPx(32)} height={rpxToPx(32)} />
|
|
|
+ </NewButton>
|
|
|
+ </View>
|
|
|
+ }
|
|
|
+
|
|
|
+ return <View style={{ width: rpxToPx(750) }}>
|
|
|
|
|
|
{
|
|
|
- (list.length >= 0 || health.mode == 'EAT') && <View className="new_header_bg">
|
|
|
- <Text className="h50 bold">{t('health.recents')}</Text>
|
|
|
- {
|
|
|
- false && (health.mode == 'EAT' || health.mode == 'ACTIVE') && <View onClick={() => {
|
|
|
- jumpPage('/pages/account/Journal?type=' + health.mode + `&show_tip=${showTipF() ? '1' : '0'}`)
|
|
|
- setTimeout(() => {
|
|
|
- health.mode == 'EAT' ? setShowEatArchive(false) : setShowActiveArchive(false)
|
|
|
- }, 1000)
|
|
|
- }} className="archive_bg" style={{ position: 'relative' }}>
|
|
|
- <Image className="archive_bg" src={require('@assets/_health/journal.png')} />
|
|
|
- {/* {
|
|
|
- ((health.mode == 'EAT' && health.eatArchivedTotal > 0) ||
|
|
|
- (health.mode == 'ACTIVE' && health.activeArchivedTotal > 0)) && <View style={{
|
|
|
- width: rpxToPx(12),
|
|
|
- height: rpxToPx(12),
|
|
|
- borderRadius: rpxToPx(6),
|
|
|
- backgroundColor: 'red',
|
|
|
- position: 'absolute',
|
|
|
- right: -6,
|
|
|
- top: 0
|
|
|
- }} />
|
|
|
- } */}
|
|
|
+ (list.length >= 0 || health.mode == 'EAT' || health.mode == 'ACTIVE') && <View className="new_header_bg2">
|
|
|
+ <Text className="h50 w500">{t('health.recents')}</Text>
|
|
|
|
|
|
+ {
|
|
|
+ (health.mode == 'EAT' || health.mode == 'ACTIVE') && <View style={{ marginTop: rpxToPx(0) }}><RightArrowRow
|
|
|
+ height={rpxToPx(50)}
|
|
|
+ title={t('health.my_journal')}
|
|
|
+ bgColor="transparent"
|
|
|
+ onClick={() => {
|
|
|
+ var showBadge = (health.mode == 'EAT' && health.eat_journal_tip) ||
|
|
|
+ (health.mode == 'ACTIVE' && health.active_journal_tip)
|
|
|
+ jumpPage('/pages/account/Journal?type=' + health.mode + `&show_tip=${showTipF() && false ? '1' : '0'}&show_badge=${showBadge ? 1 : 0}`)
|
|
|
+ }} />
|
|
|
</View>
|
|
|
}
|
|
|
+
|
|
|
</View>
|
|
|
}
|
|
|
- {/* {
|
|
|
- archiveContent()
|
|
|
- } */}
|
|
|
- {/* {
|
|
|
- newJournalTip()
|
|
|
- } */}
|
|
|
{
|
|
|
- (health.mode == 'EAT' || health.mode == 'ACTIVE') && <RightArrowRow title={health.mode == 'ACTIVE' ? t('health.title_active_journal') : t('health.title_food_journal')}
|
|
|
- // showBadge={(health.mode == 'EAT' && health.eat_journal_tip) ||
|
|
|
- // (health.mode == 'ACTIVE' && health.active_journal_tip)}
|
|
|
- onClick={() => {
|
|
|
- // if ((health.mode == 'EAT' && health.eat_journal_tip) ||
|
|
|
- // (health.mode == 'ACTIVE' && health.active_journal_tip)) {
|
|
|
- // getLatestJournal(false, {
|
|
|
- // id: health.mode == 'EAT' ? global.eatTipId : global.activeTipId,
|
|
|
- // user_confirmed: true
|
|
|
- // }).then(res => {
|
|
|
-
|
|
|
- // })
|
|
|
- // }
|
|
|
-
|
|
|
-
|
|
|
- // setTimeout(() => {
|
|
|
- // if (health.mode == 'EAT') {
|
|
|
- // dispatch(setEatTip(false))
|
|
|
- // }
|
|
|
- // else {
|
|
|
- // dispatch(setActiveTip(false))
|
|
|
- // }
|
|
|
- // }, 1000)
|
|
|
-
|
|
|
- var showBadge = (health.mode == 'EAT' && health.eat_journal_tip) ||
|
|
|
- (health.mode == 'ACTIVE' && health.active_journal_tip)
|
|
|
- jumpPage('/pages/account/Journal?type=' + health.mode + `&show_tip=${showTipF() && false ? '1' : '0'}&show_badge=${showBadge ? 1 : 0}`)
|
|
|
- }} />
|
|
|
+ markDoneTip()
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
{
|
|
|
list.length == 0 && <NoRecord />
|
|
|
}
|
|
|
{
|
|
|
- list.length > 0 && <View style={{ minHeight: rpxToPx(464), backgroundColor: '#fff' }}>
|
|
|
+ list.length > 0 && <View style={{ minHeight: rpxToPx(464), backgroundColor: '#fff', paddingTop: rpxToPx(60) }}>
|
|
|
{
|
|
|
list.map((item, index) => {
|
|
|
return <View id={`history-${index}`} key={index}>
|