RecordFastSleep.tsx 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. import Box from "@/components/layout/Box";
  2. import Header from "@/components/layout/Header";
  3. import Modal from "@/components/layout/Modal";
  4. import RecordItem from "@/features/common/RecordItem";
  5. import { delRecord } from "@/services/trackTimeDuration";
  6. import { ModalType } from "@/utils/types";
  7. import { View, Text, Image, PageContainer } from "@tarojs/components";
  8. import Taro from "@tarojs/taro";
  9. import { useEffect, useState, memo } from "react";
  10. import TimelineFastSleep from "./TimelineFastSleep";
  11. import { TimeFormatter } from "@/utils/time_format";
  12. import './RecordFastSleep.scss'
  13. import { getBgRing, getCommon, getDot, getReal, getTarget } from "../hooks/RingData";
  14. import Rings from "./Rings";
  15. import Segment from "@/components/navigation/Segment";
  16. import Stage from "./Stage";
  17. import CenterContentTitleModal from "@/features/common/CenterContentTitleModal";
  18. import { useTranslation } from "react-i18next";
  19. import { ColorType } from "@/context/themes/color";
  20. import TimelineStage from "./TimelineStage";
  21. import { jumpPage } from "../hooks/Common";
  22. import { RealRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
  23. import { rpxToPx } from "@/utils/tools";
  24. import { useDispatch, useSelector } from "react-redux";
  25. import { setSelID } from "@/store/common";
  26. import CircadianDetailPopup from "./CircadianDetailPopup";
  27. // import { sqrt } from 'mathjs'
  28. let AppState;
  29. if (process.env.TARO_ENV == 'rn') {
  30. AppState = require("react-native").AppState
  31. }
  32. let stageCanvasId = new Date().getTime()
  33. let startX = 0
  34. let startY = 0
  35. //https://www.php.cn/faq/629819.html
  36. // export default function RecordFastSleep(props: { data: any, type: string, delSuccess?: Function, index: any }) {
  37. const RecordFastSleep = memo((props: { data: any, type: string, index: number }) => {
  38. const [count, setCount] = useState(0)
  39. const [showDetailModal, setShowDetailModal] = useState(false)
  40. const [segmentIndex, setSegmentIndex] = useState(0)
  41. const [diffTimeZone, setDiffTimeZone] = useState(false)
  42. const [multiTimeZone, setMultiTimeZone] = useState(false)
  43. const [showMore, setShowMore] = useState(false)
  44. const [selIndex, setSelIndex] = useState(0)
  45. const [showMoreModal, setShowMoreModal] = useState(false)
  46. const [showDel, setShowDel] = useState(false)
  47. const { t } = useTranslation()
  48. var canvasId = props.data.id
  49. const record = props.data;
  50. const common = useSelector((state: any) => state.common);
  51. const dispatch = useDispatch();
  52. const handleAppStateChange = (nextAppState) => {
  53. checkTimezone()
  54. };
  55. useEffect(() => {
  56. checkTimezone()
  57. if (process.env.TARO_ENV == 'rn') {
  58. AppState.addEventListener('change', handleAppStateChange);
  59. }
  60. if (record.scenario != 'FAST_SLEEP') {
  61. setShowMore(false)
  62. setSelIndex(0)
  63. }
  64. // console.log(sqrt(-4).toString())
  65. }, [props.data])
  66. useEffect(() => {
  67. if (common.recordSelID != props.data.id) {
  68. setShowDel(false)
  69. }
  70. }, [common.recordSelID])
  71. function checkTimezone() {
  72. var split = new Date().toString().split(' ');
  73. var currentTZ = split[split.length - 2];
  74. var isDiff = false;
  75. var isMulti = false;
  76. var tempTZ = '';
  77. if (props.data.fast) {
  78. if (props.data.fast.real_start_time_zone) {
  79. tempTZ = props.data.fast.real_start_time_zone
  80. if (props.data.fast.real_start_time_zone != currentTZ) {
  81. isDiff = true
  82. }
  83. }
  84. if (props.data.fast.real_end_time_zone) {
  85. if (tempTZ != props.data.fast.real_end_time_zone) {
  86. isMulti = true
  87. }
  88. if (props.data.fast.real_end_time_zone != currentTZ) {
  89. isDiff = true
  90. }
  91. }
  92. }
  93. if (props.data.sleep) {
  94. if (props.data.sleep.real_start_time_zone) {
  95. if (tempTZ == '') {
  96. tempTZ = props.data.sleep.real_start_time_zone
  97. }
  98. else if (tempTZ != props.data.sleep.real_start_time_zone) {
  99. isMulti = true
  100. }
  101. if (props.data.sleep.real_start_time_zone != currentTZ) {
  102. isDiff = true
  103. }
  104. }
  105. if (props.data.sleep.real_end_time_zone) {
  106. if (tempTZ != props.data.sleep.real_end_time_zone) {
  107. isMulti = true
  108. }
  109. if (props.data.sleep.real_end_time_zone != currentTZ) {
  110. isDiff = true
  111. }
  112. }
  113. }
  114. setDiffTimeZone(isDiff)
  115. setMultiTimeZone(isMulti)
  116. }
  117. function del() {
  118. var id = props.data.id
  119. delRecord(id
  120. ).then(res => {
  121. // global.refreshTime()
  122. global.indexPageRefresh()
  123. Taro.showToast({
  124. title: t('page.records_history.del_success')
  125. })
  126. dispatch(setSelID(-1))
  127. if (global.delFastSleep)
  128. global.delFastSleep(props.data)
  129. // props.delSuccess && props.delSuccess(props.data)
  130. // Taro.navigateBack()
  131. })
  132. }
  133. function subTitle(timestamp) {
  134. if (multiTimeZone) {
  135. return t('feature.common.multi_timezones')
  136. }
  137. if (diffTimeZone) {
  138. return t('feature.common.different_timezone')
  139. }
  140. return TimeFormatter.getDateAndWeek(timestamp)
  141. }
  142. function schedules() {
  143. var timestamp = props.data.first_real_check_time
  144. return <View style={{ display: 'flex', flexDirection: 'column' }}>
  145. <TimelineStage data={props.data} title={t('feature.track_time_duration.record_fast_sleep.pop_title')}
  146. subTitle={subTitle(timestamp)} first_real_check_time={timestamp} diffTimeZone={diffTimeZone} multiTimeZone={multiTimeZone} />
  147. </View>
  148. }
  149. function showDetail(e) {
  150. if (props.type == 'latest') {
  151. setSegmentIndex(0)
  152. global.segmentIndex = 0
  153. setShowDetailModal(true)
  154. return;
  155. }
  156. setShowDetailModal(true)
  157. }
  158. function getDuration(obj) {
  159. if (!obj) {
  160. }
  161. if (obj.status == 'NOT_STARTED' || obj.status == 'NOT_COMPLETED') {
  162. return ''
  163. }
  164. var start = obj.real_start_time
  165. var end = obj.real_end_time
  166. if (!end) {
  167. end = (new Date()).getTime()
  168. }
  169. return TimeFormatter.durationFormate(start, end)
  170. // return TimeFormatter.calculateTimeDifference(start, end)
  171. }
  172. function getStageDuration() {
  173. var start, end;
  174. switch (selIndex) {
  175. case 0:
  176. start = record.fast.real_start_time
  177. end = record.sleep.real_start_time
  178. break
  179. case 1:
  180. start = record.sleep.real_start_time
  181. end = record.sleep.real_end_time
  182. break
  183. case 2:
  184. start = record.sleep.real_end_time
  185. end = record.fast.real_end_time
  186. break
  187. }
  188. return TimeFormatter.durationFormate(start, end)
  189. }
  190. function durationArc(start_time: number, end_time: number) {
  191. var duration = (end_time - start_time) / 1000;
  192. return duration / (24 * 3600) * 2 * Math.PI;
  193. }
  194. function bigRing() {
  195. var common = getCommon(null, true)
  196. common.radius = 42;
  197. common.lineWidth = 9;
  198. var bgRing = getBgRing()
  199. if (props.type == 'record' || props.type == 'latest') {
  200. var realRing = getReal(record, true, true)
  201. if (props.data.status == 'ONGOING3') {
  202. realRing.color = 'rgba(0,0,0,0)'
  203. }
  204. return <Rings common={common} bgRing={bgRing} canvasId={canvasId} realRing={realRing} />
  205. }
  206. else {
  207. var currentDot1 = getDot(record, true)
  208. var targetBigRing1 = getTarget(record, true)
  209. if (record.status == 'ONGOING') {
  210. var realRing1 = getReal(record, true, false)
  211. return <Rings common={common} bgRing={bgRing} currentDot={currentDot1} realRing={realRing1} targetRing={targetBigRing1} canvasId={canvasId} />
  212. }
  213. if (record.status == 'WAIT_FOR_START') {
  214. return <Rings common={common} bgRing={bgRing} currentDot={currentDot1} canvasId={canvasId} />
  215. }
  216. var realRing1 = getReal(record, true, false)
  217. return <Rings common={common} bgRing={bgRing} realRing={realRing1} currentDot={currentDot1} targetRing={targetBigRing1} canvasId={canvasId} />
  218. }
  219. }
  220. function bigMoreRing() {
  221. var common = getCommon(null, true)
  222. common.radius = 42;
  223. common.lineWidth = 9;
  224. var bgRing = getBgRing()
  225. var realRing = getReal(record, true, true)
  226. realRing.color = ColorType.fast + '66'
  227. var list: any = []
  228. if (record.scenario == 'FAST_SLEEP') {
  229. if (selIndex == 0) {
  230. const realRingBig: RealRing = {
  231. color: global.fastColor ? global.fastColor : ColorType.fast,
  232. startArc: startArc(record.fast.real_start_time),
  233. durationArc: durationArc(record.fast.real_start_time, record.sleep.real_start_time)
  234. }
  235. list.push(realRingBig)
  236. }
  237. if (selIndex == 1) {
  238. const realRingBig: RealRing = {
  239. color: global.fastColor ? global.fastColor : ColorType.fast,
  240. startArc: startArc(record.sleep.real_start_time),
  241. durationArc: durationArc(record.sleep.real_start_time, record.sleep.real_end_time)
  242. }
  243. list.push(realRingBig)
  244. }
  245. if (selIndex == 2) {
  246. const realRingBig: RealRing = {
  247. color: global.fastColor ? global.fastColor : ColorType.fast,
  248. startArc: startArc(record.sleep.real_end_time),
  249. durationArc: durationArc(record.sleep.real_end_time, record.fast.real_end_time)
  250. }
  251. list.push(realRingBig)
  252. }
  253. }
  254. return <Rings common={common} bgRing={bgRing} canvasId={stageCanvasId} stageList={list} realRing={realRing} />
  255. }
  256. const startArc = (time: number) => {
  257. var date = new Date(time);
  258. var hour = date.getHours();
  259. var minute = date.getMinutes();
  260. var second = date.getSeconds();
  261. return (hour * 3600 + minute * 60 + second) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
  262. }
  263. function smallRing() {
  264. if (record.scenario == 'FAST_SLEEP') {
  265. var common = getCommon(null, false)
  266. common.radius = 28;
  267. common.lineWidth = 9;
  268. var bgRing = getBgRing()
  269. var realRing = getReal(record, false, false)
  270. if (props.type == 'record' || props.type == 'latest') {
  271. var showReal = false;
  272. if (record.sleep.status == 'WAIT_FOR_END') {
  273. realRing.durationArc = durationArc(record.sleep.target_start_time, (new Date()).getTime())
  274. showReal = true
  275. // return <Rings common={common} bgRing={bgRing} canvasId={canvasId + 'small'} realRing={realRing} />
  276. }
  277. else if (record.sleep.status == 'NOT_COMPLETED') {
  278. realRing.durationArc = 0.01
  279. showReal = true
  280. // return <Rings common={common} bgRing={bgRing} canvasId={canvasId + 'small'} realRing={realRing} />
  281. }
  282. else if (record.sleep.status == 'COMPLETED') {
  283. realRing = getReal(record, false, true)
  284. showReal = true
  285. // return <Rings common={common} bgRing={bgRing} canvasId={canvasId + 'small'} realRing={realRing} />
  286. }
  287. return <Rings common={common} bgRing={bgRing} canvasId={canvasId + 'small'} realRing={showReal ? realRing : null} />
  288. // if (record.sleep.status == 'WAIT_FOR_END') {
  289. // realRing.durationArc = durationArc(record.sleep.target_start_time, (new Date()).getTime())
  290. // return <Rings common={common} bgRing={bgRing} canvasId={canvasId + 'small'} realRing={realRing} />
  291. // }
  292. // else if (record.sleep.status == 'NOT_COMPLETED') {
  293. // realRing.durationArc = 0.01
  294. // return <Rings common={common} bgRing={bgRing} canvasId={canvasId + 'small'} realRing={realRing} />
  295. // }
  296. // else if (record.sleep.status == 'COMPLETED') {
  297. // realRing = getReal(record, false, true)
  298. // return <Rings common={common} bgRing={bgRing} canvasId={canvasId + 'small'} realRing={realRing} />
  299. // }
  300. // return <Rings common={common} bgRing={bgRing} canvasId={canvasId + 'small'} />
  301. }
  302. else {
  303. var currentDot = getDot(record, false)
  304. var targetRing = getTarget(record, false)
  305. if (record.status == 'ONGOING2') {
  306. var realRing = getReal(record, false, false)
  307. return <Rings common={common} bgRing={bgRing} realRing={realRing} currentDot={currentDot} targetRing={targetRing} canvasId={canvasId + 'small'} />
  308. }
  309. if (record.status == 'ONGOING3') {
  310. currentDot.color = 'rgba(0, 255, 255, 0.5)'
  311. }
  312. return <Rings common={common} bgRing={bgRing} currentDot={currentDot} canvasId={canvasId + 'small'} />
  313. }
  314. }
  315. return null
  316. }
  317. function rings() {
  318. return <View style={{ position: 'relative', zIndex: 1 }}>
  319. {
  320. bigRing()
  321. }
  322. <View style={{ display: 'flex', position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, alignItems: 'center', justifyContent: 'center' }}>
  323. {
  324. smallRing()
  325. }
  326. </View>
  327. </View>
  328. }
  329. function recordTime() {
  330. var timestamp = props.data.first_real_check_time
  331. if (props.data.first_time_zone) {
  332. timestamp = TimeFormatter.transferTimestamp(timestamp, props.data.first_time_zone)
  333. }
  334. return TimeFormatter.dateDescription(timestamp, true)
  335. }
  336. function getArrowText() {
  337. if (multiTimeZone) {
  338. return t('feature.common.multi_timezones')
  339. }
  340. if (diffTimeZone) {
  341. return t('feature.common.different_timezone')
  342. }
  343. return recordTime()
  344. }
  345. function tapStage(e, index) {
  346. stageCanvasId = new Date().getTime()
  347. setSelIndex(index);
  348. // setCount(pre=>pre+1);
  349. e.stopPropagation()
  350. }
  351. // function moreCircle() {
  352. // return <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
  353. // <View style={{ position: 'relative', zIndex: 1 }}>
  354. // {
  355. // bigMoreRing()
  356. // }
  357. // <View style={{ display: 'flex', position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, alignItems: 'center', justifyContent: 'center' }}>
  358. // {
  359. // smallRing(123 + props.index)
  360. // }
  361. // </View>
  362. // </View>
  363. // <View style={{ flex: 1, marginLeft: -rpxToPx(46), marginRight: -rpxToPx(46) }}>
  364. // <View className={selIndex == 0 ? "single_check_sel" : "single_check_nor"} onClick={(e) => { tapStage(e, 0) }}>
  365. // <Text className={selIndex == 0 ? "single_check_text_sel" : "single_check_text_nor"}>睡前断食</Text>
  366. // {
  367. // selIndex == 0 && <Image src={require('@assets/images/check_black.png')} className="single_checked" />
  368. // }
  369. // </View>
  370. // <View className={selIndex == 1 ? "single_check_sel" : "single_check_nor"} onClick={(e) => { tapStage(e, 1) }}>
  371. // <Text className={selIndex == 1 ? "single_check_text_sel" : "single_check_text_nor"}>睡眠中断食</Text>
  372. // {
  373. // selIndex == 1 && <Image src={require('@assets/images/check_black.png')} className="single_checked" />
  374. // }
  375. // </View>
  376. // <View className={selIndex == 2 ? "single_check_sel" : "single_check_nor"} onClick={(e) => { tapStage(e, 2) }}>
  377. // <Text className={selIndex == 2 ? "single_check_text_sel" : "single_check_text_nor"}>起床后断食</Text>
  378. // {
  379. // selIndex == 2 && <Image src={require('@assets/images/check_black.png')} className="single_checked" />
  380. // }
  381. // </View>
  382. // </View>
  383. // </View>
  384. // }
  385. function moreStage() {
  386. var common = getCommon(null, false)
  387. common.radius = 28;
  388. common.lineWidth = 9;
  389. var bgRing = getBgRing()
  390. var realRing = getReal(record, false, true)
  391. return <View style={{ zIndex: 10000 }}>
  392. <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', position: 'relative' }}>
  393. {bigMoreRing()}
  394. <View style={{ display: 'flex', position: 'absolute', left: 0, width: 99, top: 0, height: 99, alignItems: 'center', justifyContent: 'center', zIndex: 10000 }}>
  395. <Rings common={common} bgRing={bgRing} canvasId={stageCanvasId + 'small'} realRing={realRing} />
  396. </View>
  397. <View className="duration_bg">
  398. {
  399. <Text className="duration_title">{t('feature.track_time_duration.record_fast_sleep.item.fast')}</Text>
  400. }
  401. {
  402. <Text className="duration_value" style={{ color: global.fastColor ? global.fastColor : ColorType.fast }}>{getStageDuration()}</Text>
  403. }
  404. {
  405. <Text className="duration_title">{t('feature.track_time_duration.record_fast_sleep.item.sleep')}</Text>
  406. }
  407. {
  408. <Text className="duration_value" style={{ color: global.sleepColor ? global.sleepColor : ColorType.sleep }}>{getDuration(record.sleep)}</Text>
  409. }
  410. </View>
  411. </View>
  412. <View style={{ flex: 1, marginLeft: -rpxToPx(46), marginRight: -rpxToPx(46), marginTop: 20 }}>
  413. <View className={selIndex == 0 ? "single_check_sel" : "single_check_nor"} onClick={(e) => { tapStage(e, 0) }}>
  414. <Text className={selIndex == 0 ? "single_check_text_sel" : "single_check_text_nor"}>睡前断食</Text>
  415. {
  416. selIndex == 0 && <Image src={require('@assets/images/check_black.png')} className="single_checked" />
  417. }
  418. </View>
  419. <View className={selIndex == 1 ? "single_check_sel" : "single_check_nor"} onClick={(e) => { tapStage(e, 1) }}>
  420. <Text className={selIndex == 1 ? "single_check_text_sel" : "single_check_text_nor"}>睡眠中断食</Text>
  421. {
  422. selIndex == 1 && <Image src={require('@assets/images/check_black.png')} className="single_checked" />
  423. }
  424. </View>
  425. <View className={selIndex == 2 ? "single_check_sel" : "single_check_nor"} onClick={(e) => { tapStage(e, 2) }}>
  426. <Text className={selIndex == 2 ? "single_check_text_sel" : "single_check_text_nor"}>起床后断食</Text>
  427. {
  428. selIndex == 2 && <Image src={require('@assets/images/check_black.png')} className="single_checked" />
  429. }
  430. </View>
  431. </View>
  432. </View>
  433. }
  434. function recordDetail() {
  435. var fastDuration = ''
  436. var sleepDuration = ''
  437. var showFast = false;
  438. var showSleep = false;
  439. if (record.scenario == 'FAST_SLEEP') {
  440. fastDuration = getDuration(record.fast)
  441. sleepDuration = getDuration(record.sleep)
  442. if (record.status == 'ONGOING3') {
  443. fastDuration = t('feature.common.wait_for_end')
  444. }
  445. if (record.sleep.status == "NOT_STARTED") {
  446. sleepDuration = t('feature.common.not_started')
  447. }
  448. else if (record.sleep.status == 'NOT_COMPLETED') {
  449. sleepDuration = t('feature.common.not_completed')
  450. }
  451. showFast = true
  452. showSleep = true
  453. }
  454. else if (record.scenario == 'FAST') {
  455. fastDuration = getDuration(record.fast)
  456. showFast = true
  457. }
  458. else {
  459. sleepDuration = getDuration(record.sleep)
  460. showSleep = true
  461. }
  462. return <View style={{ display: 'flex', flexDirection: 'column' }}>
  463. <View className="fast_sleep_item">
  464. {
  465. rings()
  466. }
  467. <View className="duration_bg">
  468. {
  469. showFast && <Text className="duration_title">{t('feature.track_time_duration.record_fast_sleep.item.fast')}</Text>
  470. }
  471. {
  472. showFast && <Text className="duration_value" style={{ color: global.fastColor ? global.fastColor : ColorType.fast }}>{fastDuration}</Text>
  473. }
  474. {
  475. showSleep && <Text className="duration_title">{t('feature.track_time_duration.record_fast_sleep.item.sleep')}</Text>
  476. }
  477. {
  478. showSleep && <Text className="duration_value" style={{ color: global.sleepColor ? global.sleepColor : ColorType.sleep }}>{sleepDuration}</Text>
  479. }
  480. </View>
  481. {/* <Image className="arrow1" src={require('@/assets/images/arrow.png')} /> */}
  482. <View className="record_arrow_bg" style={{ backgroundColor: global.isDebug ? 'red' : 'transparent' }}>
  483. <View style={{ flex: 1 }} />
  484. <Text className='recordTime'>{getArrowText()}</Text>
  485. <Image className="arrow2" src={require('@/assets/images/arrow3.png')} />
  486. </View>
  487. </View>
  488. </View>
  489. }
  490. function touchStart(e) {
  491. startX = e.touches[0].clientX
  492. startY = e.touches[0].clientY
  493. }
  494. function touchMove(e) {
  495. let x = startX
  496. let y = startY
  497. let deltaX = e.touches[0].clientX - x
  498. let deltaY = e.touches[0].clientY - y
  499. if (Math.abs(deltaX) > Math.abs(deltaY)) {
  500. if (deltaX < -60) {
  501. setShowDel(true)
  502. dispatch(setSelID(props.data.id))
  503. global.selId = props.data.id
  504. }
  505. else if (deltaX > 60) {
  506. setShowDel(false)
  507. // global.selId = -1
  508. }
  509. }
  510. }
  511. function touchEnd(e) {
  512. startX = 0
  513. }
  514. function modalContent() {
  515. if (process.env.TARO_ENV == 'weapp') {
  516. return <Modal
  517. testInfo={null}
  518. dismiss={() => {
  519. setShowDetailModal(false)
  520. }}
  521. confirm={() => { }}>
  522. {
  523. <CircadianDetailPopup
  524. record={record}
  525. onClose={() => setShowDetailModal(false)} />
  526. }
  527. </Modal>
  528. }
  529. else if (process.env.TARO_ENV == 'rn') {
  530. return <PageContainer style={{ backgroundColor: '#1c1c1c' }}
  531. // overlayStyle='background-color:rgba(0,0,0,0.9)'
  532. // custom-style='background-color:#1c1c1c'
  533. overlayStyle={{ backgroundColor: 'rgba(0,0,0,0.9)' }}
  534. customStyle={{ backgroundColor: '#1c1c1c' }}
  535. closeOnSlideDown={false}
  536. onBeforeEnter={() => {
  537. }}
  538. onBeforeLeave={() => {
  539. }}
  540. onClick={() => { alert('b') }}
  541. onClickOverlay={() => { alert('a') }}
  542. onAfterLeave={() => { setShowDetailModal(false) }}
  543. show={showDetailModal} round={true} overlay={true} position='bottom'
  544. >
  545. {
  546. <CircadianDetailPopup
  547. record={record}
  548. onClose={() => setShowDetailModal(false)} />
  549. }
  550. </PageContainer>
  551. }
  552. }
  553. return <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
  554. <View style={{ position: 'absolute', left: 0, top: 0, width: 0, height: 0, opacity: 0 }}>{count}</View>
  555. <View className='time_operate_item'
  556. onTouchStart={touchStart}
  557. onTouchMove={touchMove}
  558. onTouchEnd={touchEnd}
  559. >
  560. <RecordItem canDel={record.status == 'COMPLETED'} delete={del}
  561. onClick={showDetail}
  562. >{recordDetail()}
  563. </RecordItem>
  564. <View className={showDel ? 'btnDelete btnDeleteAni' : 'btnDelete'} onClick={del}>{t('feature.track_time_duration.record_fast_sleep.delete')}</View>
  565. </View>
  566. {/* {
  567. (props.type == 'record' || props.type == 'latest') &&
  568. record.scenario == 'FAST_SLEEP' &&
  569. record.sleep.status == 'COMPLETED' &&
  570. <View className="more_stage" onClick={(e) => {
  571. e.stopPropagation()
  572. setShowMoreModal(true)
  573. }}>
  574. <Text className="more_stage_text">{showMore ? '隐藏更多' : '显示更多'}</Text>
  575. </View>
  576. } */}
  577. {
  578. showDetailModal && modalContent()
  579. // showDetailModal && <Modal children={schedules()}
  580. // modalType={ModalType.center}
  581. // dismiss={() => setShowDetailModal(false)}
  582. // confirm={() => { }} />
  583. }
  584. {
  585. showMoreModal && <Modal children={moreStage()}
  586. modalType={ModalType.center}
  587. dismiss={() => setShowMoreModal(false)}
  588. confirm={() => { }} />
  589. }
  590. </View>
  591. })
  592. export default RecordFastSleep;