MainFastEatCard.tsx 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. import { View, Text, Image } from "@tarojs/components";
  2. import './MainCard.scss'
  3. import { useEffect, useRef, useState } from "react";
  4. import Modal from "@/components/layout/Modal.weapp";
  5. import { rpxToPx } from "@/utils/tools";
  6. import Rings, { RingCommon, BgRing, TargetRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
  7. import dayjs from "dayjs";
  8. import moment from 'moment-timezone'
  9. import { MainColorType } from "@/context/themes/color";
  10. import { fastWindow, setSchedule, updateRecord } from "@/services/trackTimeDuration";
  11. import { useDispatch, useSelector } from "react-redux";
  12. import { jumpPage } from "../trackTimeDuration/hooks/Common";
  13. import ConsolePicker from "../trackTimeDuration/components/ConsolePicker";
  14. import { endFast, startFast } from "../trackTimeDuration/actions/TrackTimeActions";
  15. import formatMilliseconds from "@/utils/format_time";
  16. import TimePicker from "@/features/common/TimePicker";
  17. import showAlert from "@/components/basic/Alert";
  18. import showActionSheet from "@/components/basic/ActionSheet";
  19. import { records } from "@/services/health";
  20. import MainHistory from "./MainHistory";
  21. import { WindowStatusType, WindowType } from "@/utils/types";
  22. import { durationArc, isCurrentTimeInRange, startArc } from "./util";
  23. import { setMode } from "@/store/health";
  24. import { IconSwitch1, IconSwitch2 } from "@/components/basic/Icons";
  25. import { getScenario, getWindowStatus } from "./hooks/health_hooks";
  26. let useNavigation;
  27. let Linking, PushNotification;
  28. let checkNotification;
  29. let min = 0
  30. let max = 0
  31. let defaultTimestamp = 0
  32. let useActionSheet;
  33. if (process.env.TARO_ENV == 'rn') {
  34. useNavigation = require("@react-navigation/native").useNavigation
  35. Linking = require('react-native').Linking;
  36. // JPush = require('jpush-react-native').default;
  37. PushNotification = require('react-native-push-notification')
  38. checkNotification = require('@/utils/native_permission_check').checkNotification;
  39. useActionSheet = require('@expo/react-native-action-sheet').useActionSheet
  40. }
  41. export default function MainFastEatCard(props: { count: any, typeChanged: Function, id: number, onClick: Function }) {
  42. const [isFastMode, setIsFastMode] = useState(true)
  43. const [showModal, setShowModal] = useState(false)
  44. const [showTimePicker, setShowTimePicker] = useState(false);
  45. const limitPickerRef = useRef(null)
  46. const [operateType, setOperateType] = useState('startFast')
  47. const [btnDisable, setBtnDisable] = useState(false)
  48. const [logEvent, setLogEvent] = useState('LOG_ONCE');
  49. const [eatData, setEatData] = useState<any>(null)
  50. const [fastData, setFastData] = useState<any>(null)
  51. const [startTime, setStartTime] = useState<any>(null)
  52. const [endTime, setEndTime] = useState<any>(null)
  53. const [status, setStatus] = useState<any>('upcoming')
  54. const [showPicker, setShowPicker] = useState(false)
  55. const [isStart, setIsStart] = useState(true)
  56. const user = useSelector((state: any) => state.user);
  57. const health = useSelector((state: any) => state.health);
  58. const dispatch = useDispatch()
  59. let navigation, showActionSheetWithOptions;
  60. if (useNavigation) {
  61. navigation = useNavigation()
  62. showActionSheetWithOptions = useActionSheet()
  63. }
  64. useEffect(() => {
  65. if (health.mode == 'FAST') {
  66. setIsFastMode(true)
  67. }
  68. else if (health.mode == 'EAT') {
  69. setIsFastMode(false)
  70. }
  71. }, [health.mode])
  72. useEffect(() => {
  73. const { fast, eat } = health.windows.fast_eat
  74. var now = new Date().getTime()
  75. if ((fast.status == 'WAIT_FOR_END' || fast.target.start_time <= now && fast.target.end_time >= now) || isCurrentTimeInRange(fast.period.start_time, fast.period.end_time)) {
  76. setIsFastMode(true)
  77. }
  78. else {
  79. setIsFastMode(false)
  80. }
  81. setEatData(eat)
  82. setFastData(fast)
  83. update(fast)
  84. }, [user.isLogin])
  85. useEffect(() => {
  86. if (fastData) {
  87. update(fastData)
  88. }
  89. }, [props.count])
  90. useEffect(() => {
  91. if (health.selTab == 1) {
  92. dispatch(setMode(isFastMode ? 'FAST' : 'EAT'))
  93. }
  94. }, [health.selTab, isFastMode])
  95. function update(fast) {
  96. var now = new Date().getTime()
  97. if (fast.status == 'WAIT_FOR_END') {
  98. setStatus('process')
  99. }
  100. else if ((fast.target.start_timestamp <= now && fast.target.end_timestamp >= now) || isCurrentTimeInRange(fast.period.start_time, fast.period.end_time)) {
  101. setStartTime(fast.period.start_time)
  102. setStatus('new')
  103. }
  104. else {
  105. setStatus('upcoming')
  106. }
  107. }
  108. const common: RingCommon = {
  109. useCase: 'ChooseScenario',
  110. radius: 37,
  111. lineWidth: 14,
  112. isFast: true,
  113. status: 'WAIT_FOR_START'
  114. }
  115. const bgRing: BgRing = {
  116. color: MainColorType.ringBg
  117. }
  118. function scheduleRing() {
  119. const { fast, eat } = health.windows.fast_eat
  120. var starts: any = fast.period.start_time.split(':')
  121. var ends: any = fast.period.end_time.split(':')
  122. const startSeconds: any = parseInt(starts[0] + '') * 60 + parseInt(starts[1] + '')
  123. const endSeconds: any = parseInt(ends[0] + '') * 60 + parseInt(ends[1] + '')
  124. const color = isFastMode ? MainColorType.fastLight : MainColorType.eatLight
  125. const startArc = isFastMode ? startSeconds / 1440 * 2 * Math.PI - Math.PI / 2 : endSeconds / 1440 * 2 * Math.PI - Math.PI / 2
  126. const fastCount = endSeconds - startSeconds > 0 ? endSeconds - startSeconds : endSeconds - startSeconds + 1440
  127. const eatCount = 1440 - fastCount
  128. const durationArc = isFastMode ? fastCount / 1440 * 2 * Math.PI : eatCount / 1440 * 2 * Math.PI
  129. return {
  130. color,
  131. startArc,
  132. durationArc
  133. }
  134. }
  135. function targetRing() {
  136. if (status != 'process') {
  137. return null
  138. }
  139. const { fast, eat } = health.windows.fast_eat
  140. var starts: any = fast.period.start_time.split(':')
  141. var ends: any = fast.period.end_time.split(':')
  142. const startSeconds: any = parseInt(starts[0] + '') * 60 + parseInt(starts[1] + '')
  143. const endSeconds: any = parseInt(ends[0] + '') * 60 + parseInt(ends[1] + '')
  144. const color = isFastMode ? '#9AE2FE' : '#FE810C66'
  145. var startArc = isFastMode ? startSeconds / 1440 * 2 * Math.PI - Math.PI / 2 : endSeconds / 1440 * 2 * Math.PI - Math.PI / 2
  146. const fastCount = endSeconds - startSeconds > 0 ? endSeconds - startSeconds : endSeconds - startSeconds + 1440
  147. const eatCount = 1440 - fastCount
  148. var durationArc = isFastMode ? fastCount / 1440 * 2 * Math.PI : eatCount / 1440 * 2 * Math.PI
  149. if (isFastMode) {
  150. var dt = new Date(fastData.target.start_time)
  151. var realSeconds = dt.getHours() * 3600 + dt.getMinutes() * 60 + dt.getSeconds()
  152. startArc = realSeconds / (1440 * 60) * 2 * Math.PI - Math.PI / 2
  153. durationArc = ((fastData.target.end_time - fastData.target.start_time) / 1000) / (1440 * 60) * 2 * Math.PI
  154. }
  155. return {
  156. color,
  157. startArc,
  158. durationArc,
  159. radius: isFastMode ? 90 : null,
  160. lineWidth: isFastMode ? 10 : null
  161. }
  162. }
  163. function getRealArc(time) {
  164. var date = new Date(time);
  165. var hour = date.getHours();
  166. var minute = date.getMinutes();
  167. var second = date.getSeconds();
  168. return (hour * 3600 + minute * 60 + second) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
  169. }
  170. function getRealDurationArc(start, end) {
  171. var duration = (end - start) / 1000;
  172. return duration / (24 * 3600) * 2 * Math.PI;
  173. }
  174. function realRing() {
  175. const status = getWindowStatus(health.windows, isFastMode ? 'FAST' : 'EAT')
  176. const scenario = getScenario(health.windows, isFastMode ? 'FAST' : 'EAT')
  177. if (status == WindowStatusType.upcoming) {
  178. return {
  179. color: '#cccccc',
  180. startArc: getRealArc(new Date().getTime()),
  181. durationArc: getRealDurationArc(new Date().getTime(), scenario.target.start_timestamp),
  182. }
  183. }
  184. return {
  185. color: isFastMode ? MainColorType.fast : MainColorType.eat,
  186. startArc: getRealArc(scenario.target.start_timestamp),
  187. durationArc: getRealDurationArc(scenario.target.start_timestamp, new Date().getTime())
  188. }
  189. }
  190. function getTimeToDestination(timeStr, isPasted) {
  191. // 获取当前时间
  192. const now = new Date();
  193. const currentHours = now.getHours();
  194. const currentMinutes = now.getMinutes();
  195. const currentSeconds = now.getSeconds();
  196. // 解析目标时间
  197. const [targetHours, targetMinutes] = timeStr.split(':').map(Number);
  198. // 计算时间差
  199. let hours = targetHours - currentHours;
  200. let minutes = targetMinutes - currentMinutes;
  201. let seconds = 60 - currentSeconds;
  202. if (minutes < 0) {
  203. minutes += 60;
  204. hours--;
  205. }
  206. if (hours < 0) {
  207. hours += 24;
  208. }
  209. if (seconds === 60) {
  210. seconds = 0;
  211. minutes++;
  212. }
  213. // 如果是过去的时间,则返回剩余时间
  214. if (isPasted) {
  215. hours = 24 - hours;
  216. minutes = 60 - minutes;
  217. seconds = 60 - seconds;
  218. }
  219. // 格式化输出
  220. return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
  221. }
  222. function ring() {
  223. var offset = 0
  224. var hour = new Date().getHours()
  225. var minute = new Date().getMinutes()
  226. if (hour != new Date().getHours() || minute != new Date().getMinutes()) {
  227. offset = hour * 60 + minute - new Date().getHours() * 60 - new Date().getMinutes()
  228. }
  229. // const currentDot: CurrentDot = {
  230. // color: isFastMode ? MainColorType.fast : MainColorType.eat,
  231. // lineWidth: 10,
  232. // borderColor: '#fff',
  233. // offset: offset,
  234. // whiteIcon: true
  235. // }
  236. return <Rings common={common} bgRing={bgRing} scheduleRing={scheduleRing()} targetRing={targetRing()} realRing={realRing()} canvasId={'smal11l' + props.id} />
  237. }
  238. function formatTime(format: string, timestamp?: number) {
  239. // var moment = require('moment-timezone');
  240. // if (current) {
  241. // if (timestamp) {
  242. // return moment(timestamp).tz(current.time.timezone.id).format(format)
  243. // }
  244. // return moment().tz(current.time.timezone.id).format(format)
  245. // }
  246. return dayjs().format(format)
  247. }
  248. function switchMode() {
  249. const mode = !isFastMode
  250. setIsFastMode(mode)
  251. props.typeChanged(mode ? WindowType.fast : WindowType.eat)
  252. }
  253. function getFastStatus() {
  254. switch (status) {
  255. case 'process':
  256. return 'Process'
  257. case 'new':
  258. return 'New Open'
  259. case 'upcoming':
  260. return 'Upcoming'
  261. }
  262. return ''
  263. }
  264. function getFastTime() {
  265. var milliSeconds = 0;
  266. switch (status) {
  267. case 'process':
  268. milliSeconds = new Date().getTime() - fastData.real_start_time
  269. break;
  270. case 'new':
  271. return getTimeToDestination(fastData.period.start_time, true)
  272. case 'upcoming':
  273. return getTimeToDestination(fastData.period.start_time, false)
  274. }
  275. var seconds = Math.floor(milliSeconds / 1000)
  276. const hours = Math.floor(seconds / 3600);
  277. const minutes = Math.floor((seconds % 3600) / 60);
  278. const remainingSeconds = seconds % 60;
  279. return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${remainingSeconds.toString().padStart(2, '0')}`;
  280. }
  281. function getEatTime() {
  282. return getTimeToDestination(eatData.period.start_time, isCurrentTimeInRange(eatData.period.start_time, eatData.period.end_time))
  283. }
  284. function tapFastStart() {
  285. setIsStart(true)
  286. setShowPicker(true)
  287. }
  288. function tapFastEnd() {
  289. setIsStart(false)
  290. setShowPicker(true)
  291. }
  292. function tapStartLog() {
  293. if (status == 'upcoming') {
  294. return;
  295. }
  296. if (!user.isLogin) {
  297. jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
  298. return
  299. }
  300. defaultTimestamp = new Date().getTime()
  301. min = defaultTimestamp - 1 * 24 * 3600 * 1000
  302. max = defaultTimestamp
  303. setOperateType('startFast')
  304. setShowTimePicker(true)
  305. }
  306. function tapEndLog() {
  307. if (status != 'process') {
  308. return
  309. }
  310. defaultTimestamp = new Date().getTime()
  311. // defaultTimestamp = e ? new Date().getTime() : logEventTimestamp
  312. min = defaultTimestamp - 1 * 24 * 3600 * 1000
  313. max = defaultTimestamp
  314. setOperateType('endFast')
  315. setShowTimePicker(true)
  316. }
  317. function modalContent() {
  318. global.set_time = new Date().getTime()
  319. return <Modal
  320. testInfo={null}
  321. dismiss={() => {
  322. setShowTimePicker(false)
  323. }}
  324. confirm={() => { }}>
  325. {
  326. timePickerContent()
  327. }
  328. </Modal>
  329. }
  330. function timeContent() {
  331. return <Modal
  332. testInfo={null}
  333. dismiss={() => {
  334. setShowPicker(false)
  335. }}
  336. confirm={() => { }}>
  337. {
  338. pickerContent()
  339. }
  340. </Modal>
  341. }
  342. function timePickerContent() {
  343. var title = operateType == 'endFast' ? '结束断食' : '开始断食'
  344. var color = MainColorType.fast
  345. var endTimestamp = 0
  346. if (operateType == 'endFast') {
  347. endTimestamp = fastData.target.end_time
  348. }
  349. var duration = fastData.target.duration
  350. return <View className="modal_content">
  351. <ConsolePicker ref={limitPickerRef}
  352. themeColor={color}
  353. title={title}
  354. onCancel={() => {
  355. setShowTimePicker(false)
  356. }}
  357. min={min}
  358. max={max}
  359. current={defaultTimestamp}
  360. duration={duration}
  361. endTimestamp={endTimestamp}
  362. isFast={true}
  363. isEnd={operateType == 'endFast'}
  364. isTimeout={false}
  365. isLoading={btnDisable}
  366. onChange={(e) => {
  367. pickerConfirm(e, null)
  368. global.pauseIndexTimer = false
  369. }}
  370. />
  371. </View>
  372. }
  373. function pickerContent() {
  374. const timestamp = isStart ? fastData.target.start_time : fastData.target.end_time
  375. const strTime = dayjs(timestamp).format('HH:mm')
  376. return <TimePicker time={strTime}
  377. color={MainColorType.fast}
  378. title={isStart ? '开始断食' : '结束断食'}
  379. confirm={(e) => {
  380. confirmPickerTime(e)
  381. }}
  382. cancel={() => {
  383. setShowPicker(false)
  384. }} />
  385. }
  386. function confirmPickerTime(strTime) {
  387. if (status != 'process') {
  388. setSchedule({
  389. code: isStart ? 'FAST_START' : 'FAST_END',
  390. time: strTime
  391. }).then(res => {
  392. setShowPicker(false)
  393. })
  394. }
  395. else {
  396. var startTime = dayjs(fastData.target.start_time).format('HH:mm:ss')
  397. var endTime = strTime + ':00'
  398. console.log(startTime, endTime)
  399. if (startTime == endTime) {
  400. showAlert({
  401. title: '',
  402. content: '开始时间不能与结束时间相同'
  403. })
  404. return;
  405. }
  406. updateRecord({
  407. fast: {
  408. target_duration: getIntervalSeconds(startTime, endTime) * 1000
  409. }
  410. }, fastData.id).then(res => {
  411. setShowPicker(false)
  412. })
  413. }
  414. }
  415. function getIntervalSeconds(time1, time2) {
  416. // 将时间字符串转换为 Date 对象
  417. const date1 = new Date(`2000-01-01T${time1}Z`);
  418. const date2 = new Date(`2000-01-01T${time2}Z`);
  419. // 计算两个 Date 对象之间的时间差
  420. let intervalMs = date2.getTime() - date1.getTime();
  421. // 如果 time2 比 time1 小, 说明跨天了, 需要加上一天的毫秒数
  422. if (date2 < date1) {
  423. intervalMs += 24 * 60 * 60 * 1000;
  424. }
  425. // 返回间隔秒数
  426. return Math.floor(intervalMs / 1000);
  427. }
  428. function pickerConfirm(t1: number, event: any) {
  429. if (btnDisable) {
  430. return
  431. }
  432. global.scenario = 'FAST'
  433. setBtnDisable(true)
  434. var date = new Date(t1)
  435. var setDate = new Date(global.set_time);
  436. date.setMilliseconds(setDate.getMilliseconds());
  437. date.setSeconds(setDate.getSeconds());
  438. t1 = date.getTime();
  439. if (operateType == 'startFast') {
  440. startFast(t1, fastData.target_duration, event ? event : logEvent).then(res => {
  441. setBtnDisable(false)
  442. setShowTimePicker(false)
  443. }).catch(e => {
  444. setBtnDisable(false)
  445. })
  446. }
  447. else {
  448. endFast(t1, event ? event : logEvent).then(res => {
  449. setBtnDisable(false)
  450. setShowTimePicker(false)
  451. }).catch(e => {
  452. setBtnDisable(false)
  453. })
  454. }
  455. }
  456. function goAddEat(meal, index) {
  457. if (!enableMeal(meal)) {
  458. return;
  459. }
  460. jumpPage('/pages/clock/AddEat?meal=' + JSON.stringify(eatData.meals[index]))
  461. }
  462. function enableMeal(meal) {
  463. if (meal.real_start_time > 0) {
  464. return true
  465. }
  466. if (meal.target.start_time > new Date().getTime()) {
  467. return true
  468. }
  469. return true
  470. }
  471. function more() {
  472. showActionSheet({
  473. showActionSheetWithOptions: showActionSheetWithOptions,
  474. title: 'Oprate Title',
  475. itemList: [
  476. 'Add Snack',
  477. '自定义餐次列表',
  478. ],
  479. success: (res) => {
  480. switch (res) {
  481. case 0:
  482. break;
  483. case 1:
  484. jumpPage('/_health/pages/edit_schedule')
  485. break;
  486. }
  487. }
  488. });
  489. }
  490. function switchIcon() {
  491. if (isFastMode) {
  492. if (status != 'upcoming') {
  493. return <IconSwitch1 color="#000" width={15} />
  494. }
  495. return <IconSwitch2 color="#fff" width={15} />
  496. }
  497. if (status != 'upcoming') {
  498. return <IconSwitch2 color="#fff" width={15} />
  499. }
  500. return <IconSwitch1 color="#000" width={15} />
  501. }
  502. function switchBtn() {
  503. var bgColor = ''
  504. if (isFastMode) {
  505. if (status != 'upcoming') {
  506. bgColor = '#fff'
  507. }
  508. else {
  509. bgColor = MainColorType.eat
  510. }
  511. }
  512. else {
  513. if (status != 'upcoming') {
  514. bgColor = MainColorType.fast
  515. }
  516. else {
  517. bgColor = '#fff'
  518. }
  519. }
  520. return <View className="switch_btn" style={{ backgroundColor: bgColor }} onClick={switchMode}>
  521. {
  522. switchIcon()
  523. }
  524. </View>
  525. }
  526. if (!fastData)
  527. return <View />
  528. return <View style={{ alignItems: 'center', display: 'flex', flexDirection: 'column', width: rpxToPx(750 / 3), flexShrink: 0 }} onClick={() => props.onClick()}>
  529. <View style={{ width: rpxToPx(750 / 3), }} />
  530. <View style={{ position: 'relative', }}>
  531. {
  532. ring()
  533. }
  534. <View className={health.selTab == 1 ? 'window_name window_name_sel' : 'window_name'}>{isFastMode ? 'Fast' : 'Eat'}</View>
  535. {/* <View className="ring_center">
  536. {
  537. isFastMode && <Text>{getFastStatus()}</Text>
  538. }
  539. <Text className="time1">{isFastMode ? getFastTime() : getEatTime()}</Text>
  540. <Text className="date1">{global.language == 'en' ? formatTime('dddd, MMM D') : formatTime('MMMD日 dddd')}</Text>
  541. </View> */}
  542. </View>
  543. {/* <View>{isFastMode ? formatMilliseconds(health.windows.fast_eat.fast.target.duration) : formatMilliseconds(health.windows.fast_eat.eat.target.duration)}</View> */}
  544. {/* {
  545. isFastMode && <View>
  546. <View className="log_row">
  547. {
  548. status == 'process' ? <View className="schedule_name">Fast starts</View> : <View className="schedule" onClick={tapFastStart}>
  549. <Text className="schedule_name">
  550. Fast starts:
  551. </Text>
  552. <Text className="schedule">
  553. {startScheduleTime}
  554. </Text>
  555. </View>
  556. }
  557. {
  558. status == 'process' ? <View className="schedule">{dayjs(fastData.target.start_time).format('HH:mm')}</View> :
  559. <View onClick={tapStartLog} className={status == 'new' ? "fast_log_btn" : "fast_log_btn fast_log_btn_disable"}>Log{status == 'new' && <View className="badge" />}</View>
  560. }
  561. </View>
  562. <View className="log_row">
  563. <View className="schedule" onClick={tapFastEnd}>
  564. <Text className="schedule_name">
  565. Fast ends:
  566. </Text>
  567. <Text className="schedule">
  568. {status == 'process' ? dayjs(fastData.target.end_time).format('HH:mm') : endScheduleTime}
  569. </Text>
  570. </View>
  571. <View onClick={tapEndLog} className={status == 'process' ? "fast_log_btn" : "fast_log_btn fast_log_btn_disable"}>Log</View>
  572. </View>
  573. </View>
  574. }
  575. {
  576. !isFastMode && <View>
  577. {
  578. eatData.meals.map((item, index) => {
  579. return <View className="log_row" style={{ justifyContent: 'flex-start' }} key={index}>
  580. {
  581. item.real_start_time && item.media && item.media.length > 0 && item.media[0].url && <Image src={item.media[0].url} style={{ width: 50, height: 50, marginRight: 10 }} />
  582. }
  583. <View className="schedule">
  584. <Text className="schedule_name">{item.name}</Text>
  585. <Text className="schedule">
  586. {item.real_start_time ? dayjs(item.real_start_time).format('HH:mm') + ' - ' + dayjs(item.real_end_time).format('HH:mm') : item.period.start_time}
  587. </Text>
  588. </View>
  589. <View style={{ flex: 1 }} />
  590. {
  591. item.real_start_time ? <View className="fast_log_btn fast_log_btn_disable">已记录</View> : <View onClick={() => goAddEat(item, index)} className={enableMeal(item) ? "fast_log_btn fast_log_eat_btn" : "fast_log_btn fast_log_btn_disable"}>Add</View>
  592. }
  593. </View>
  594. })
  595. }
  596. </View>
  597. } */}
  598. {/* {
  599. switchBtn()
  600. } */}
  601. {/* {
  602. !isFastMode && <Text onClick={more}>更多</Text>
  603. } */}
  604. {/* <MainHistory type={isFastMode ? 'FAST' : 'EAT'} /> */}
  605. {
  606. showModal && <Modal dismiss={() => setShowModal(false)}>
  607. <View style={{ width: 100, height: 100, backgroundColor: 'red' }}>{props.count}</View>
  608. </Modal>
  609. }
  610. {
  611. showTimePicker && modalContent()
  612. }
  613. {
  614. showPicker && timeContent()
  615. }
  616. </View>
  617. }