|
|
@@ -16,10 +16,16 @@ import { IconCheck } from "@/components/basic/Icons";
|
|
|
import Rings2, { BgRing, RingCommon, TargetRing } from '@/features/trackTimeDuration/components/Rings';
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
|
|
+
|
|
|
+let LinearGradient
|
|
|
+if (process.env.TARO_ENV == 'rn') {
|
|
|
+ LinearGradient = require('react-native-linear-gradient').default
|
|
|
+}
|
|
|
+
|
|
|
export default function ChooseScenario() {
|
|
|
const [selected, setSelected] = useState(0);
|
|
|
const ring = useSelector((state: any) => state.ring);
|
|
|
- const {t} = useTranslation();
|
|
|
+ const { t } = useTranslation();
|
|
|
const dispatch = useDispatch();
|
|
|
var navigation: any = null
|
|
|
|
|
|
@@ -65,8 +71,8 @@ export default function ChooseScenario() {
|
|
|
|
|
|
function goSuggestion() {
|
|
|
dispatch(updateStep({ step: 0 }))
|
|
|
- jumpPage(`/pages/clock/Suggest?trigger_event=`+router.params.trigger_event, 'Suggest', navigation, {
|
|
|
- trigger_event:router.params.trigger_event
|
|
|
+ jumpPage(`/pages/clock/Suggest?trigger_event=` + router.params.trigger_event, 'Suggest', navigation, {
|
|
|
+ trigger_event: router.params.trigger_event
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -112,7 +118,7 @@ export default function ChooseScenario() {
|
|
|
}
|
|
|
|
|
|
const targetRing2: TargetRing = {
|
|
|
- color:ColorType.sleep,
|
|
|
+ color: ColorType.sleep,
|
|
|
startArc: timeToArc(ring.schedule.sleep.start_time),
|
|
|
durationArc: durationToArc(ring.schedule.sleep.start_time, ring.schedule.sleep.end_time)
|
|
|
}
|
|
|
@@ -133,56 +139,95 @@ export default function ChooseScenario() {
|
|
|
return (end - start) / 1440 * 2 * Math.PI
|
|
|
}
|
|
|
|
|
|
+ let background: any = 'linear-gradient(to right, ' + ColorType.fast + ', ' + ColorType.sleep + ')';
|
|
|
+ if (selected == 0) {
|
|
|
+ background = ColorType.fast
|
|
|
+ }
|
|
|
+
|
|
|
return <View style={{
|
|
|
- color: '#fff', flexDirection: 'column', display: 'flex'
|
|
|
+ color: '#fff', flexDirection: 'column', display: 'flex',
|
|
|
+ flex: 1
|
|
|
}}>
|
|
|
<Text className="target_title">{t('feature.choose_scenario.title')}</Text>
|
|
|
<Text className="target_desc">{t('feature.choose_scenario.description')}</Text>
|
|
|
|
|
|
<View className={selected == 0 ? 'item1 item_sel1' : 'item1'} onClick={() => chooseType(0)}>
|
|
|
<View style={{ flexShrink: 0, display: 'flex', width: 74, height: 74, marginRight: rpxToPx(24) }}>
|
|
|
- <Rings2 common={common} bgRing={bgRing} targetRing={selected==0?targetRing:null} canvasId={new Date().getTime()} />
|
|
|
+ <Rings2 common={common} bgRing={bgRing} targetRing={selected == 0 ? targetRing : null} canvasId={new Date().getTime()} />
|
|
|
</View>
|
|
|
<View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
|
<Text className="choose_item_title">{t('feature.choose_scenario.fasting')}</Text>
|
|
|
<Text className="choose_item_desc">{t('feature.choose_scenario.fast_desc')}</Text>
|
|
|
- {
|
|
|
- selected == 0 && <View className="choose_item_check_bg">
|
|
|
- <IconCheck color={ColorType.fast} width={38} height={26} />
|
|
|
- </View>
|
|
|
- }
|
|
|
-
|
|
|
- <View className="choose_corner_tag">{t('feature.choose_scenario.free')}</View>
|
|
|
-
|
|
|
-
|
|
|
</View>
|
|
|
+ <View className="choose_corner_tag">{t('feature.choose_scenario.free')}</View>
|
|
|
+ {
|
|
|
+ selected == 0 && <View className="choose_item_check_bg">
|
|
|
+ <IconCheck color={ColorType.fast} width={24} height={24} />
|
|
|
+ </View>
|
|
|
+ }
|
|
|
</View>
|
|
|
<View className={selected == 1 ? 'item1 item_sel1' : 'item1'} onClick={() => chooseType(1)}>
|
|
|
<View style={{ flexShrink: 0, display: 'flex', width: 74, height: 74, marginRight: rpxToPx(24), position: 'relative', zIndex: 1 }}>
|
|
|
- <Rings2 common={common} bgRing={bgRing} targetRing={selected==1?targetRing:null} canvasId={new Date().getTime()+2} />
|
|
|
+ <Rings2 common={common} bgRing={bgRing} targetRing={selected == 1 ? targetRing : null} canvasId={new Date().getTime() + 2} />
|
|
|
<View style={{ display: 'flex', position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, alignItems: 'center', justifyContent: 'center' }}>
|
|
|
- <Rings2 common={common2} bgRing={bgRing} targetRing={selected==1?targetRing2:null} canvasId={new Date().getTime()+4} />
|
|
|
+ <Rings2 common={common2} bgRing={bgRing} targetRing={selected == 1 ? targetRing2 : null} canvasId={new Date().getTime() + 4} />
|
|
|
</View>
|
|
|
</View>
|
|
|
- <View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
|
+ <View style={{ display: 'flex', flexDirection: 'column', flex: 1 }}>
|
|
|
<Text className="choose_item_title">{t('feature.choose_scenario.fast_sleep')}</Text>
|
|
|
<Text className="choose_item_desc">{t('feature.choose_scenario.fast_sleep_desc')}</Text>
|
|
|
- {
|
|
|
- selected == 1 && <View className="choose_item_check_bg">
|
|
|
- <IconCheck color={ColorType.fast} width={38} height={26} />
|
|
|
- </View>
|
|
|
- }
|
|
|
- <View className="choose_corner_tag">{t('feature.choose_scenario.limit_time_offer')}</View>
|
|
|
+
|
|
|
+
|
|
|
</View>
|
|
|
+ {
|
|
|
+ process.env.TARO_ENV == 'weapp' ? <View className="choose_corner_tag limit_offer">{t('feature.choose_scenario.limit_time_offer')}</View> :
|
|
|
+ <LinearGradient className="choose_corner_tag"
|
|
|
+ colors={[ColorType.fast, ColorType.sleep]}
|
|
|
+ start={{ x: 0, y: 0 }}
|
|
|
+ end={{ x: 1, y: 0 }}
|
|
|
+ >
|
|
|
+ <Text style={{ fontSize: rpxToPx(20) }}>{t('feature.choose_scenario.limit_time_offer')}</Text>
|
|
|
+ </LinearGradient>
|
|
|
+ }
|
|
|
+ {
|
|
|
+ selected == 1 && <View className="choose_item_check_bg">
|
|
|
+ <IconCheck color={ColorType.fast} width={24} height={24} />
|
|
|
+ </View>
|
|
|
+ }
|
|
|
+
|
|
|
</View>
|
|
|
<View style={{ flex: 1 }} />
|
|
|
<Footer>
|
|
|
<View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
|
|
- <ChooseScenarioBtn
|
|
|
- onClick={goSuggestion}
|
|
|
- title="Start"
|
|
|
- background={ColorType.fast}
|
|
|
- />
|
|
|
+ {
|
|
|
+ (process.env.TARO_ENV == 'weapp' || selected == 0) && <ChooseScenarioBtn
|
|
|
+ onClick={goSuggestion}
|
|
|
+ title="Start"
|
|
|
+ background={background}
|
|
|
+ />
|
|
|
+ }
|
|
|
+ {
|
|
|
+ process.env.TARO_ENV == 'rn' && selected == 1 && <View onClick={goSuggestion}>
|
|
|
+ <LinearGradient
|
|
|
+ style={{
|
|
|
+ width: 300,
|
|
|
+ height: 50,
|
|
|
+ borderRadius: 25,
|
|
|
+ alignItems: 'center',
|
|
|
+ justifyContent: 'center',
|
|
|
+ }}
|
|
|
+ colors={[ColorType.fast, ColorType.sleep]}
|
|
|
+ start={{ x: 0, y: 0 }}
|
|
|
+ end={{ x: 1, y: 0 }}
|
|
|
+ >
|
|
|
+ <Text style={{ fontWeight: 'bold', fontSize: 20 }}>Start</Text>
|
|
|
+ </LinearGradient>
|
|
|
+ </View>
|
|
|
+ }
|
|
|
+ {
|
|
|
+ process.env.TARO_ENV == 'rn' && <View style={{ marginBottom: 40 }} />
|
|
|
+ }
|
|
|
+
|
|
|
</View>
|
|
|
</Footer>
|
|
|
|