|
@@ -11,10 +11,21 @@ import { MainColorType } from "@/context/themes/color";
|
|
|
import { rpxToPx } from "@/utils/tools";
|
|
import { rpxToPx } from "@/utils/tools";
|
|
|
import dayjs from "dayjs";
|
|
import dayjs from "dayjs";
|
|
|
import { useTranslation } from "react-i18next";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
|
+import { useRouter } from "@tarojs/taro";
|
|
|
|
|
|
|
|
|
|
|
|
|
let scrollPage = 0;
|
|
let scrollPage = 0;
|
|
|
let maxScale = 0.75
|
|
let maxScale = 0.75
|
|
|
|
|
+let useRoute;
|
|
|
|
|
+let useNavigation;
|
|
|
|
|
+let scenario = '';
|
|
|
|
|
+let AppState;
|
|
|
|
|
+if (process.env.TARO_ENV == 'rn') {
|
|
|
|
|
+ useRoute = require("@react-navigation/native").useRoute
|
|
|
|
|
+ useNavigation = require("@react-navigation/native").useNavigation
|
|
|
|
|
+ AppState = require("react-native").AppState
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
export default function MainSwiper(props: { count: number, pageChanged: Function, typeChanged: Function }) {
|
|
export default function MainSwiper(props: { count: number, pageChanged: Function, typeChanged: Function }) {
|
|
|
const [current, setCurrent] = useState(1)
|
|
const [current, setCurrent] = useState(1)
|
|
|
const [type, setType] = useState(WindowType.day)
|
|
const [type, setType] = useState(WindowType.day)
|
|
@@ -24,12 +35,51 @@ export default function MainSwiper(props: { count: number, pageChanged: Function
|
|
|
const [scale1, setScale1] = useState(maxScale)
|
|
const [scale1, setScale1] = useState(maxScale)
|
|
|
const [scale2, setScale2] = useState(maxScale)
|
|
const [scale2, setScale2] = useState(maxScale)
|
|
|
|
|
|
|
|
- const {t} = useTranslation()
|
|
|
|
|
|
|
+ const { t } = useTranslation()
|
|
|
const dispatch = useDispatch()
|
|
const dispatch = useDispatch()
|
|
|
|
|
|
|
|
- useEffect(()=>{
|
|
|
|
|
|
|
+ let router
|
|
|
|
|
+ let navigation;
|
|
|
|
|
+ if (useNavigation) {
|
|
|
|
|
+ navigation = useNavigation()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (process.env.TARO_ENV == 'rn') {
|
|
|
|
|
+ router = useRoute()
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ router = useRouter()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ // if (router.params && router.params.window) {
|
|
|
|
|
+ // switch (router.params.window) {
|
|
|
|
|
+ // case 'day':
|
|
|
|
|
+ // case 'night':
|
|
|
|
|
+ // console.log('a')
|
|
|
|
|
+ // dispatch(setTab(0))
|
|
|
|
|
+ // setCurrent(0)
|
|
|
|
|
+ // break
|
|
|
|
|
+ // case 'fast':
|
|
|
|
|
+ // case 'eat':
|
|
|
|
|
+ // console.log('b')
|
|
|
|
|
+ // dispatch(setTab(1))
|
|
|
|
|
+ // setCurrent(1)
|
|
|
|
|
+ // break
|
|
|
|
|
+ // case 'sleep':
|
|
|
|
|
+ // case 'active':
|
|
|
|
|
+ // console.log('c')
|
|
|
|
|
+ // dispatch(setTab(2))
|
|
|
|
|
+ // setCurrent(2)
|
|
|
|
|
+ // break
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // else {
|
|
|
dispatch(setTab(1))
|
|
dispatch(setTab(1))
|
|
|
- },[])
|
|
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ }, [])
|
|
|
|
|
|
|
|
function pageChanged(e) {
|
|
function pageChanged(e) {
|
|
|
const page = e.detail.current
|
|
const page = e.detail.current
|
|
@@ -161,12 +211,12 @@ export default function MainSwiper(props: { count: number, pageChanged: Function
|
|
|
scrollPage = current
|
|
scrollPage = current
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- global.switchTap = ()=>{
|
|
|
|
|
|
|
+ global.switchTap = () => {
|
|
|
switchMode()
|
|
switchMode()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function switchMode() {
|
|
function switchMode() {
|
|
|
- console.log('swiper switch',health.mode)
|
|
|
|
|
|
|
+ console.log('swiper switch', health.mode)
|
|
|
switch (health.mode) {
|
|
switch (health.mode) {
|
|
|
case 'FAST':
|
|
case 'FAST':
|
|
|
dispatch(setMode('EAT'));
|
|
dispatch(setMode('EAT'));
|
|
@@ -191,14 +241,14 @@ export default function MainSwiper(props: { count: number, pageChanged: Function
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return <View style={{ flexDirection: 'column', display: 'flex', alignItems: 'center' }}>
|
|
return <View style={{ flexDirection: 'column', display: 'flex', alignItems: 'center' }}>
|
|
|
- <Text className="h50 bold" style={{marginTop:rpxToPx(24)}}>{t('health.today')}</Text>
|
|
|
|
|
|
|
+ <Text className="h50 bold" style={{ marginTop: rpxToPx(24) }}>{t('health.today')}</Text>
|
|
|
<Text className="main_date g01" >{global.language == 'en' ? dayjs().format('dddd, MMM D') : dayjs().format('MMMD日 dddd')}</Text>
|
|
<Text className="main_date g01" >{global.language == 'en' ? dayjs().format('dddd, MMM D') : dayjs().format('MMMD日 dddd')}</Text>
|
|
|
<Swiper
|
|
<Swiper
|
|
|
onTransition={onTransition}
|
|
onTransition={onTransition}
|
|
|
onAnimationFinish={onTransitionend}
|
|
onAnimationFinish={onTransitionend}
|
|
|
style={{ height: rpxToPx(218), width: rpxToPx(634) }} circular
|
|
style={{ height: rpxToPx(218), width: rpxToPx(634) }} circular
|
|
|
- previousMargin={rpxToPx(634/3)}
|
|
|
|
|
- nextMargin={rpxToPx(634/3)}
|
|
|
|
|
|
|
+ previousMargin={rpxToPx(634 / 3)}
|
|
|
|
|
+ nextMargin={rpxToPx(634 / 3)}
|
|
|
onChange={pageChanged}
|
|
onChange={pageChanged}
|
|
|
current={current}>
|
|
current={current}>
|
|
|
<SwiperItem>
|
|
<SwiperItem>
|