Suggest.tsx 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. import { ColorType } from "@/context/themes/color";
  2. import { ChooseScenarioBtn } from "@/features/common/SpecBtns";
  3. import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
  4. import { View, Text, Picker, ScrollView } from "@tarojs/components";
  5. import { useDidShow, useRouter } from "@tarojs/taro";
  6. import { useEffect, useState } from "react";
  7. import './ChooseScenario.scss';
  8. import PickerViews from "@/components/input/PickerViews";
  9. import { useDispatch, useSelector } from "react-redux";
  10. import { rpxToPx } from "@/utils/tools";
  11. import { updateFast, updateSleep, updateStep } from "@/store/set_target";
  12. import { TimeFormatter } from "@/utils/time_format";
  13. import Footer from "@/components/layout/Footer";
  14. import { IconCheck } from "@/components/basic/Icons";
  15. import Rings2, { BgRing, RingCommon, TargetRing } from '@/features/trackTimeDuration/components/Rings';
  16. import { useTranslation } from "react-i18next";
  17. export default function Suggest() {
  18. let router: any = null
  19. var navigation: any = null
  20. if (process.env.TARO_ENV === 'rn') {
  21. var useNavigation = require("@react-navigation/native").useNavigation
  22. navigation = useNavigation()
  23. const useRoute = require("@react-navigation/native").useRoute
  24. router = useRoute()
  25. }
  26. else {
  27. router = useRouter()
  28. }
  29. const common = useSelector((state: any) => state.common);
  30. const target = useSelector((state: any) => state.target);
  31. const [pageStep] = useState(target.step);
  32. const dispatch = useDispatch();
  33. const [suggestIndex, setSuggestIndex] = useState(-1)
  34. const [suggestItems, setSuggestItem] = useState<any>([])
  35. const [scrollTop, setScrollTop] = useState(0)
  36. const [fastRecommendIndex, setFastRecommendIndex] = useState(-1)
  37. const [fastLastIndex, setFastLastIndex] = useState(-1)
  38. const { t } = useTranslation()
  39. useEffect(() => {
  40. if (pageStep == 1) {
  41. var obj = target.fast.schedule.fast
  42. var array: any = []
  43. var currentIndex = -1;
  44. var recommendIndex = -1;
  45. var lastIndex = -1;
  46. for (var i = 0; i < obj.duration.options.length; i++) {
  47. if (obj.duration.options[i] == obj.duration.last_value) {
  48. lastIndex = i
  49. }
  50. if (obj.duration.options[i] == obj.duration.default_value) {
  51. recommendIndex = i
  52. }
  53. var fast = JSON.parse(JSON.stringify(target.fast))
  54. var startCount = fast.schedule.fast.end_time.split(':')[0] * 60 + fast.schedule.fast.end_time.split(':')[1] * 1 - obj.duration.options[i]
  55. if (startCount < 0) {
  56. startCount += 24 * 60
  57. }
  58. var start = TimeFormatter.padZero(Math.floor(startCount / 60)) + ':' + TimeFormatter.padZero(startCount % 60)
  59. array.push({
  60. hours: obj.duration.options[i] / 60,
  61. left: 24 - obj.duration.options[i] / 60,
  62. // minutes: obj.duration.minutes[i],
  63. // number: obj.duration.numbers[i],
  64. time: start
  65. })
  66. if (obj.duration.options[i] == obj.duration.init_value) {
  67. currentIndex = i
  68. }
  69. }
  70. // var duration = obj.end_time.split(':')[0] * 60 + obj.end_time.split(':')[1] * 1 - (obj.start_time.split(':')[0] * 60 + obj.start_time.split(':')[1] * 1)
  71. // if (duration <= 0) {
  72. // duration += 24 * 60
  73. // }
  74. // var durationHours = Math.floor(duration / 60)
  75. // var durationMinutes = duration % 60
  76. // var currentIndex = -1;
  77. // var array: any = []
  78. // for (var i = 12; i <= 23; i++) {
  79. // if (i != 23 || durationMinutes == 0) {
  80. // array.push({
  81. // hours: i,
  82. // minutes: durationMinutes
  83. // });
  84. // }
  85. // }
  86. // for (var i = 0; i < array.length; i++) {
  87. // if (array[i].hours == durationHours && array[i].minutes == durationMinutes) {
  88. // currentIndex = i
  89. // break
  90. // }
  91. // }
  92. setFastRecommendIndex(recommendIndex)
  93. setFastLastIndex(lastIndex)
  94. setSuggestItem(array)
  95. setSuggestIndex(currentIndex)
  96. setScrollTop(currentIndex * rpxToPx(244) + 50)
  97. // setScrollTop(currentIndex * 100-30)
  98. }
  99. else if (pageStep == 3) {
  100. var obj = target.sleep.schedule.sleep
  101. var sleep_cycle = obj.cycle
  102. var sleep_latency = obj.latency.init_value
  103. var array: any = []
  104. var index: number = 0;
  105. for (var i = 0; i < sleep_cycle.num.options.length; i++) {
  106. var count = sleep_cycle.num.options[i] * sleep_cycle.duration.init_value + sleep_latency
  107. //sleep.schedule.sleep.cycle.num.init_value = sleep.schedule.sleep.cycle.num.options[suggestIndex]
  108. if (sleep_cycle.num.options[i] == sleep_cycle.num.init_value) {
  109. index = i
  110. }
  111. var sleep = JSON.parse(JSON.stringify(target.sleep))
  112. var startCount = sleep.schedule.sleep.end_time.split(':')[0] * 60 + sleep.schedule.sleep.end_time.split(':')[1] * 1 - count
  113. if (startCount < 0) {
  114. startCount += 24 * 60
  115. }
  116. var start = TimeFormatter.padZero(Math.floor(startCount / 60)) + ':' + TimeFormatter.padZero(startCount % 60)
  117. array.push({
  118. hours: Math.floor(count / 60),
  119. minutes: count % 60,
  120. number: sleep_cycle.num.options[i],
  121. time: start
  122. })
  123. }
  124. setSuggestItem(array)
  125. setSuggestIndex(index)
  126. }
  127. }, [])
  128. useDidShow(() => {
  129. dispatch(updateStep({ step: pageStep }))
  130. })
  131. function next() {
  132. if (pageStep == 1) {
  133. var item = suggestItems[suggestIndex]
  134. var fast = JSON.parse(JSON.stringify(target.fast))
  135. // var startCount = fast.schedule.fast.end_time.split(':')[0] * 60 + fast.schedule.fast.end_time.split(':')[1] * 1 - (item.hours * 60 + item.minutes)
  136. // if (startCount < 0) {
  137. // startCount += 24 * 60
  138. // }
  139. // var start = TimeFormatter.padZero(Math.floor(startCount / 60)) + ':' + TimeFormatter.padZero(startCount % 60)
  140. fast.schedule.fast.start_time = item.time
  141. fast.schedule.fast.duration.init_value = fast.schedule.fast.duration.options[suggestIndex]
  142. dispatch(updateFast({ fast: fast }))
  143. }
  144. else if (pageStep == 3) {
  145. var item = suggestItems[suggestIndex]
  146. var sleep = JSON.parse(JSON.stringify(target.sleep))
  147. var startCount = sleep.schedule.sleep.end_time.split(':')[0] * 60 + sleep.schedule.sleep.end_time.split(':')[1] * 1 - (item.hours * 60 + item.minutes)
  148. if (startCount < 0) {
  149. startCount += 24 * 60
  150. }
  151. var start = TimeFormatter.padZero(Math.floor(startCount / 60)) + ':' + TimeFormatter.padZero(startCount % 60)
  152. sleep.schedule.sleep.start_time = start
  153. sleep.schedule.sleep.cycle.num.init_value = sleep.schedule.sleep.cycle.num.options[suggestIndex]
  154. dispatch(updateSleep({ sleep: sleep }))
  155. }
  156. var step: number = target.step + 1
  157. dispatch(updateStep({ step: step }))
  158. var url = '/pages/clock/Suggest?trigger_event=' + router.params.trigger_event
  159. var pageName = 'Suggest'
  160. if (!target.isMixed) {
  161. if (step == 2) {
  162. url = '/pages/clock/SetGoal?trigger_event=' + router.params.trigger_event
  163. pageName = 'SetGoal'
  164. }
  165. }
  166. else {
  167. if (step == 4) {
  168. url = '/pages/clock/SetGoal?trigger_event=' + router.params.trigger_event
  169. pageName = 'SetGoal'
  170. }
  171. }
  172. jumpPage(url, pageName, navigation, {
  173. trigger_event: router.params.trigger_event
  174. })
  175. }
  176. function myself() {
  177. jumpPage(`/pages/clock/SetGoal?isSelf=1&trigger_event=` + router.params.trigger_event, 'SetGoal', navigation, {
  178. isSelf: 1,
  179. trigger_event: router.params.trigger_event
  180. })
  181. }
  182. function suggestTitle() {
  183. switch (pageStep) {
  184. case 0:
  185. return t('feature.suggest.step_0_title')
  186. case 1:
  187. return t('feature.suggest.step_1_title')
  188. case 2:
  189. return t('feature.suggest.step_2_title')
  190. case 3:
  191. return t('feature.suggest.step_3_title')
  192. default:
  193. return ''
  194. }
  195. }
  196. function suggestDesc() {
  197. switch (pageStep) {
  198. case 0:
  199. return t('feature.suggest.end_fast_picker_header')
  200. case 1:
  201. return t('feature.suggest.fast_suggest_header', { time: target.fast.schedule.fast.end_time })
  202. case 2:
  203. return t('feature.suggest.end_sleep_picker_header')
  204. case 3:
  205. return t('feature.suggest.sleep_suggest_header', { time: target.sleep.schedule.sleep.end_time })
  206. default:
  207. return ''
  208. }
  209. }
  210. function durationDatas() {
  211. var min: number = 0
  212. var max: number = 23
  213. var step: number = 5
  214. var minutes: string[] = []
  215. for (let i = 0; i < 60; i += step) {
  216. minutes.push(TimeFormatter.padZero(i))
  217. }
  218. var hours: string[] = []
  219. for (let i = min; i <= max; i++) {
  220. hours.push(TimeFormatter.padZero(i))
  221. }
  222. return [hours, minutes]
  223. }
  224. function durationValues() {
  225. var eatTime = target.fast.schedule.fast.end_time
  226. if (pageStep == 2) {
  227. eatTime = target.sleep.schedule.sleep.end_time
  228. }
  229. var eatHour = eatTime.split(':')[0]
  230. var eatMin = eatTime.split(':')[1]
  231. var list = durationDatas()
  232. var hourIndex = 0
  233. var minIndex = 0
  234. for (let i = 0; i < list[0].length; i++) {
  235. if (list[0][i] == eatHour) {
  236. hourIndex = i
  237. break
  238. }
  239. }
  240. for (let i = 0; i < list[1].length; i++) {
  241. if (list[1][i] == eatMin) {
  242. minIndex = i
  243. break
  244. }
  245. }
  246. return [hourIndex, minIndex]
  247. }
  248. function sleepLatency() {
  249. var obj = target.sleep.schedule.sleep.latency
  250. var min: number = obj.min
  251. var max: number = obj.max
  252. var step: number = obj.step
  253. var minutes: string[] = []
  254. for (let i = min; i <= max; i += step) {
  255. minutes.push(i + '')
  256. }
  257. return [minutes]
  258. }
  259. function sleepLatencyValue() {
  260. var obj = target.sleep.schedule.sleep.latency
  261. var value: number = obj.init_value
  262. var min: number = obj.min
  263. var step: number = obj.step
  264. var index = (value - min) / step
  265. return [index]
  266. }
  267. function timePickerChanged(e: any) {
  268. var obj = target.fast.schedule.fast
  269. if (pageStep == 2) {
  270. obj = target.sleep.schedule.sleep
  271. }
  272. var duration = obj.end_time.split(':')[0] * 60 + obj.end_time.split(':')[1] * 1 - (obj.start_time.split(':')[0] * 60 + obj.start_time.split(':')[1] * 1)
  273. if (duration <= 0) {
  274. duration += 24 * 60
  275. }
  276. var endCount = duration - (e[0] * 60 + e[1] * 5)
  277. if (endCount < 0) {
  278. endCount += 24 * 60
  279. }
  280. var time = TimeFormatter.padZero(e[0]) + ':' + TimeFormatter.padZero(e[1] * 5)
  281. var start = TimeFormatter.padZero(Math.floor(endCount / 60)) + ':' + TimeFormatter.padZero(endCount % 60)
  282. if (pageStep == 0) {
  283. var fast = JSON.parse(JSON.stringify(target.fast))
  284. fast.schedule.fast.end_time = time
  285. fast.schedule.fast.start_time = start
  286. dispatch(updateFast({ fast: fast }))
  287. }
  288. else {
  289. var sleep = JSON.parse(JSON.stringify(target.sleep))
  290. sleep.schedule.sleep.end_time = time
  291. sleep.schedule.sleep.start_time = start
  292. dispatch(updateSleep({ sleep: sleep }))
  293. }
  294. }
  295. function timePicker() {
  296. return <View>
  297. <View style={{
  298. marginBottom: rpxToPx(40), marginLeft: rpxToPx(46),
  299. marginRight: rpxToPx(46), borderRadius: 10,
  300. overflow: 'hidden', backgroundColor: '#1c1c1c', paddingTop: 10, paddingBottom: 10
  301. }}>
  302. <PickerViews ref={null}
  303. onChange={timePickerChanged}
  304. items={durationDatas()}
  305. value={durationValues()} height={200}
  306. title=''
  307. themeColor={target.isMixed ? global.fastColor ? global.fastColor : ColorType.fast : global.sleepColor ? global.sleepColor : ColorType.sleep}
  308. showBtns={false}
  309. hideTitle={true}
  310. onCancel={() => { }} />
  311. </View>
  312. {
  313. pageStep == 0 && <Text className="suggest_footer_note">{t('feature.suggest.end_fast_picker_footer')}</Text>
  314. }
  315. {
  316. pageStep == 1 && <Text className="suggest_footer_note">If you plan to skip breakfast, pick a time for your first meal of the day.</Text>
  317. }
  318. </View>
  319. }
  320. function fallSleepChanged(e: any) {
  321. var value = target.sleep.schedule.sleep.latency
  322. var time = e[0] * value.step + value.min
  323. var sleep = JSON.parse(JSON.stringify(target.sleep))
  324. sleep.schedule.sleep.latency.init_value = time
  325. dispatch(updateSleep({ sleep: sleep }))
  326. }
  327. function fallSleepPicker() {
  328. return <View>
  329. <View className="target_desc">{t('feature.suggest.fall_sleep_picker_header')}</View>
  330. <View style={{
  331. marginLeft: rpxToPx(46), marginRight: rpxToPx(46),
  332. borderRadius: 10,
  333. overflow: 'hidden', backgroundColor: '#1c1c1c', paddingTop: 10, paddingBottom: 10
  334. }}>
  335. <PickerViews ref={null}
  336. onChange={fallSleepChanged}
  337. items={sleepLatency()}
  338. value={sleepLatencyValue()} height={200}
  339. title=''
  340. themeColor={target.isMixed ? global.fastColor ? global.fastColor : ColorType.fast : global.sleepColor ? global.sleepColor : ColorType.sleep}
  341. showBtns={false}
  342. hideTitle={true}
  343. onCancel={() => { }} />
  344. </View>
  345. <Text className="suggest_footer_note">{t('feature.suggest.fall_sleep_picker_footer')}</Text>
  346. </View>
  347. }
  348. // const common: RingCommon = {
  349. // useCase: 'ChooseScenario',
  350. // radius: 33,
  351. // lineWidth: 8,
  352. // isFast: true,
  353. // status: 'WAIT_FOR_START'
  354. // }
  355. const bgRing: BgRing = {
  356. color: '#262626'
  357. }
  358. // const targetRing: TargetRing = {
  359. // color: ColorType.fast,
  360. // startArc: timeToArc(ring.schedule.fast.start_time),
  361. // durationArc: durationToArc(ring.schedule.fast.start_time, ring.schedule.fast.end_time)
  362. // }
  363. function ringCommon() {
  364. return {
  365. useCase: 'ChooseScenario',
  366. radius: 33,
  367. lineWidth: 8,
  368. isFast: true,
  369. status: 'WAIT_FOR_START'
  370. }
  371. }
  372. function targetRing(start, end, isFast, isHighLight) {
  373. var color: any = isFast ? ColorType.fast + '66' : ColorType.sleep + '66'
  374. if (!isHighLight) {
  375. color = isFast ? ColorType.fast + '0D' : ColorType.sleep + '0D'
  376. }
  377. return {
  378. color: color,
  379. startArc: timeToArc(start),
  380. durationArc: durationToArc(start, end)
  381. }
  382. }
  383. function point(isFast: boolean, isShow: boolean) {
  384. if (!isShow) return null;
  385. var now = new Date()
  386. var t = suggestItems[suggestIndex].time
  387. now.setHours(parseInt(t.split(':')[0]))
  388. now.setMinutes(parseInt(t.split(':')[1]))
  389. return [{
  390. color: isFast ? ColorType.fast : ColorType.sleep,
  391. borderColor: 'transparent',
  392. timestamp: now.getTime()
  393. }]
  394. }
  395. function timeToArc(time: string) {
  396. var count: number = parseInt(time.split(':')[1]) + parseInt(time.split(':')[0]) * 60
  397. // count = count>720?count-720:count
  398. return (count as any) / 1440 * 2 * Math.PI - Math.PI / 2
  399. }
  400. function durationToArc(startTime: string, endTime: string) {
  401. var start: number = parseInt(startTime.split(':')[1]) + parseInt(startTime.split(':')[0]) * 60
  402. var end: number = parseInt(endTime.split(':')[1]) + parseInt(endTime.split(':')[0]) * 60
  403. if (end <= start) {
  404. end += 1440
  405. }
  406. return (end - start) / 1440 * 2 * Math.PI
  407. }
  408. function suggestList() {
  409. if (pageStep == 1) {
  410. return <ScrollView scrollY style={{ height: 400 }} scrollTop={scrollTop}>
  411. <View style={{ flexDirection: 'column', display: 'flex' }}>
  412. {
  413. suggestItems.map((item: any, index: number) => {
  414. return <View key={index} className={suggestIndex == index ? 'item1 item_sel1' : 'item1'} onClick={() => setSuggestIndex(index)}>
  415. <View style={{ flexShrink: 0, display: 'flex', width: 74, height: 74, marginRight: rpxToPx(24) }}>
  416. <Rings2 common={ringCommon()}
  417. bgRing={bgRing}
  418. targetRing={targetRing(item.time, target.fast.schedule.fast.end_time, true, suggestIndex == index)}
  419. dotList={point(true, index == suggestIndex)}
  420. canvasId={new Date().getTime() + index * 5} />
  421. </View>
  422. <View>
  423. <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
  424. <View className="suggest_item_title">{item.hours} hours</View>
  425. <View style={{ flex: 1 }} />
  426. <View className='suggest_fast_tag_bg'>
  427. {
  428. index == fastRecommendIndex &&
  429. <View className='suggest_fast_tag'>{t('feature.suggest.popular')}</View>
  430. }
  431. {
  432. index == fastLastIndex &&
  433. <View className='suggest_fast_tag'>{t('feature.suggest.recent')}</View>
  434. }
  435. </View>
  436. </View>
  437. <View className="suggest_item_desc">{index == suggestIndex ?
  438. t('feature.suggest.fast_desc', { start_time: item.hours, end_time: item.left }) :
  439. t('feature.suggest.intermitent_fast', { data: `${item.hours}/${item.left}` })
  440. }</View>
  441. {
  442. index == suggestIndex &&
  443. <View className="suggest_choose">
  444. <View style={{ color: ColorType.fast }}>{t('feature.suggest.start_fast_time', { time: item.time })}</View>
  445. </View>
  446. }
  447. </View>
  448. {
  449. index == suggestIndex && <View className="choose_item_check_bg">
  450. <IconCheck color={ColorType.fast} width={24} height={24} />
  451. </View>
  452. }
  453. </View>
  454. // return <View onClick={() => {
  455. // setSuggestIndex(index)
  456. // }} key={index} className={index == suggestIndex ? 'item_choose_selected' : 'item_choose'}>
  457. // <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
  458. // <View className="suggest_item_title">{item.hours} hours</View>
  459. // <View style={{ flex: 1 }} />
  460. // {
  461. // index == fastRecommendIndex &&
  462. // <View style={{ color: '#fff' }}>Popular</View>
  463. // }
  464. // {
  465. // index == fastLastIndex &&
  466. // <View style={{ color: '#fff', marginLeft: 5 }}>Recent</View>
  467. // }
  468. // </View>
  469. // <View className="suggest_item_desc">{index == suggestIndex ? `${item.hours} hours fasting / ${item.left} hours eating` : `${item.hours}/${item.left} Intermittent Fasting`}</View>
  470. // {
  471. // index == suggestIndex &&
  472. // <View className="suggest_choose">
  473. // <View style={{ color: ColorType.fast }}>Start fasting at {item.time}</View>
  474. // <IconCheck color={ColorType.fast} width={38} height={26} />
  475. // </View>
  476. // }
  477. // </View>
  478. })
  479. }
  480. </View>
  481. </ScrollView>
  482. }
  483. return <View style={{ flex: 1, overflow: 'scroll' }}>
  484. {
  485. suggestItems.map((item: any, index: number) => {
  486. return <View key={index} className={suggestIndex == index ? 'item1 item_sel1' : 'item1'} style={{ borderColor: suggestIndex == index ? ColorType.sleep : '#00000000' }} onClick={() => setSuggestIndex(index)}>
  487. <View style={{ flexShrink: 0, display: 'flex', width: 74, height: 74, marginRight: rpxToPx(24) }}>
  488. <Rings2 common={ringCommon()}
  489. bgRing={bgRing}
  490. dotList={point(false, index == suggestIndex)}
  491. targetRing={targetRing(item.time, target.sleep.schedule.sleep.end_time, false, suggestIndex == index)}
  492. canvasId={new Date().getTime() + index * 5} />
  493. </View>
  494. <View>
  495. <View className="suggest_item_title">{item.hours} hrs {item.minutes} mins</View>
  496. <View className="suggest_item_desc">{item.number} sleep cycles</View>
  497. {
  498. index == suggestIndex && <View className="suggest_choose">
  499. <View style={{ color: ColorType.sleep }}>{t('feature.suggest.go_to_bed_at', { time: item.time })}</View>
  500. </View>
  501. }
  502. </View>
  503. {
  504. index == suggestIndex && <View className="choose_item_check_bg">
  505. <IconCheck color={ColorType.sleep} width={24} height={24} />
  506. </View>
  507. }
  508. {
  509. index == 0 && <View className='suggest_tag' style={{ backgroundColor: ColorType.sleep }}>{t('feature.suggest.popular')}</View>
  510. }
  511. {
  512. index == 1 && <View className='suggest_tag' style={{ backgroundColor: ColorType.sleep }}>{t('feature.suggest.restorative')}</View>
  513. }
  514. </View>
  515. })
  516. }
  517. </View>
  518. }
  519. function content() {
  520. return <View style={{ flex: 1, display: 'flex', flexDirection: 'column' }}>
  521. {
  522. (pageStep == 0 || pageStep == 2) && timePicker()
  523. }
  524. {
  525. (pageStep == 1 || pageStep == 3) && suggestList()
  526. }
  527. {
  528. pageStep == 2 && fallSleepPicker()
  529. }
  530. {
  531. pageStep==2 && <View style={{height:200}}/>
  532. }
  533. </View>
  534. }
  535. return <View style={{ display: 'flex', flexDirection: 'column', flex: 1 }}>
  536. <Text className="target_title">{suggestTitle()}</Text>
  537. <Text className="target_desc">{suggestDesc()}</Text>
  538. {
  539. content()
  540. }
  541. <Footer>
  542. <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center' }}>
  543. <ChooseScenarioBtn
  544. onClick={next}
  545. title={pageStep == 0 || pageStep == 2 ? 'Suggest Plan' : 'Next'}
  546. background={pageStep < 2 ? ColorType.fast : ColorType.sleep}
  547. />
  548. <Text className="suggest_footer_btn" onClick={myself}>{t('feature.suggest.set_myself')}</Text>
  549. </View>
  550. </Footer>
  551. {
  552. process.env.TARO_ENV == 'rn' && <View style={{ marginBottom: 40 }} />
  553. }
  554. </View>
  555. }