|
|
@@ -5,7 +5,7 @@ import Rings from '@components/view/Rings';
|
|
|
import Rings2, { BgRing, RingCommon, TargetRing } from './Rings';
|
|
|
import Footer from '@/components/layout/Footer';
|
|
|
import SingleSelect from '../../../components/input/SingleSelect';
|
|
|
-import { ComponentStatus, TextType } from "@utils/types";
|
|
|
+import { ComponentStatus, NaviBarTitleShowType, TemplateType, TextType } from "@utils/types";
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
|
|
import './ChooseScenario.scss'
|
|
|
@@ -16,6 +16,7 @@ import { useDispatch, useSelector } from "react-redux";
|
|
|
import { setScenario, setScenarioName, setStep } from "@/store/scenario";
|
|
|
import { getPlans } from "@/services/trackTimeDuration";
|
|
|
import { ChooseScenarioBtn } from "@/features/common/SpecBtns";
|
|
|
+import Layout from "@/components/layout/layout";
|
|
|
|
|
|
|
|
|
export default function Component() {
|
|
|
@@ -25,16 +26,16 @@ export default function Component() {
|
|
|
const [selIndex, setSelIndex] = useState(-1)
|
|
|
const [scenarios, setScenarios] = useState<any[]>([])
|
|
|
const selScenario = useSelector((state: any) => state.scenario);
|
|
|
- const [count,setCount] = useState(0)
|
|
|
+ const [count, setCount] = useState(0)
|
|
|
|
|
|
- useDidShow(()=>{
|
|
|
- setCount(count+1)
|
|
|
+ useDidShow(() => {
|
|
|
+ setCount(count + 1)
|
|
|
})
|
|
|
|
|
|
useReady(() => {
|
|
|
if (selScenario) {
|
|
|
if (selScenario.name == 'FAST_SLEEP') {
|
|
|
- dispatch(setStep(isFastFirst?'fast':'sleep'))
|
|
|
+ dispatch(setStep(isFastFirst ? 'fast' : 'sleep'))
|
|
|
setSelIndex(2)
|
|
|
}
|
|
|
else if (selScenario.name == 'SLEEP') {
|
|
|
@@ -46,14 +47,14 @@ export default function Component() {
|
|
|
setSelIndex(0)
|
|
|
}
|
|
|
}
|
|
|
- Taro.getStorage({key:'scenarios'}).then(res=>{
|
|
|
- if (res){
|
|
|
+ Taro.getStorage({ key: 'scenarios' }).then(res => {
|
|
|
+ if (res) {
|
|
|
setScenarios(JSON.parse(res.data as any))
|
|
|
}
|
|
|
})
|
|
|
getPlans().then(res => {
|
|
|
const data = res as { scenarios: any[] };
|
|
|
- Taro.setStorage({key:'scenarios', data:JSON.stringify(data.scenarios as any)})
|
|
|
+ Taro.setStorage({ key: 'scenarios', data: JSON.stringify(data.scenarios as any) })
|
|
|
setScenarios(data.scenarios)
|
|
|
})
|
|
|
})
|
|
|
@@ -84,7 +85,7 @@ export default function Component() {
|
|
|
break;
|
|
|
}
|
|
|
return <View>
|
|
|
- <ChooseScenarioBtn title='Next' onClick={next} background={background}/>
|
|
|
+ <ChooseScenarioBtn title='Next' onClick={next} background={background} />
|
|
|
{/* <Buttons title='Next' onClick={next} btnStyle={{ ...style, width: 320 }} /> */}
|
|
|
</View>
|
|
|
}
|
|
|
@@ -139,13 +140,13 @@ export default function Component() {
|
|
|
function getScheduleTarget(isFast: boolean) {
|
|
|
for (var i = 0; i < scenarios.length; i++) {
|
|
|
if (isFast && scenarios[i].name == 'FAST') {
|
|
|
- if (global.schedule_fast){
|
|
|
+ if (global.schedule_fast) {
|
|
|
return global.schedule_fast
|
|
|
}
|
|
|
return scenarios[i].schedule.fast
|
|
|
}
|
|
|
else if (!isFast && scenarios[i].name == 'SLEEP') {
|
|
|
- if (global.schedule_sleep){
|
|
|
+ if (global.schedule_sleep) {
|
|
|
return global.schedule_sleep
|
|
|
}
|
|
|
return scenarios[i].schedule.sleep
|
|
|
@@ -233,22 +234,39 @@ export default function Component() {
|
|
|
dispatch(setStep('sleep'))
|
|
|
}
|
|
|
else {
|
|
|
- dispatch(setStep(isFastFirst?'fast':'sleep'))
|
|
|
+ dispatch(setStep(isFastFirst ? 'fast' : 'sleep'))
|
|
|
}
|
|
|
// dispatch(setScenarioName(scenarios[index].scenario) as any)
|
|
|
}
|
|
|
|
|
|
- return <View className="container">
|
|
|
- <Texts text={t('page.choose_scenario.title')} type={TextType.primary}></Texts>
|
|
|
- <Texts text={t('page.choose_scenario.sub_title')} type={TextType.secondary}></Texts>
|
|
|
- <View style={{ height: 20 }} />
|
|
|
- {
|
|
|
- scenarios.length>0&&<View style={{ position: 'relative', zIndex: 1 }}>
|
|
|
- <SingleSelect items={items()} itemSelect={handleItemSelect} selIndex={selIndex} />
|
|
|
- </View>
|
|
|
- }
|
|
|
+ return <Layout title={t('page.choose_scenario.title')}
|
|
|
+ titleShowStyle={NaviBarTitleShowType.scrollToShow} type={TemplateType.flex}>
|
|
|
+ <View className="container">
|
|
|
+ {/* <Texts text={t('page.choose_scenario.title')} type={TextType.primary}></Texts> */}
|
|
|
+ <Texts text={t('page.choose_scenario.sub_title')} type={TextType.secondary}></Texts>
|
|
|
+ <View style={{ height: 20 }} />
|
|
|
+ {
|
|
|
+ scenarios.length > 0 && <View style={{ position: 'relative', zIndex: 1 }}>
|
|
|
+ <SingleSelect items={items()} itemSelect={handleItemSelect} selIndex={selIndex} />
|
|
|
+ </View>
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ <Footer children={footerContent()} />
|
|
|
+ </View>
|
|
|
+ </Layout>
|
|
|
+
|
|
|
+ // return <View className="container">
|
|
|
+ // <Texts text={t('page.choose_scenario.title')} type={TextType.primary}></Texts>
|
|
|
+ // <Texts text={t('page.choose_scenario.sub_title')} type={TextType.secondary}></Texts>
|
|
|
+ // <View style={{ height: 20 }} />
|
|
|
+ // {
|
|
|
+ // scenarios.length>0&&<View style={{ position: 'relative', zIndex: 1 }}>
|
|
|
+ // <SingleSelect items={items()} itemSelect={handleItemSelect} selIndex={selIndex} />
|
|
|
+ // </View>
|
|
|
+ // }
|
|
|
|
|
|
|
|
|
- <Footer children={footerContent()} />
|
|
|
- </View>;
|
|
|
+ // <Footer children={footerContent()} />
|
|
|
+ // </View>;
|
|
|
}
|