|
@@ -6,7 +6,7 @@ import MainSleepActiveCard from "./MainSleepActiveCard";
|
|
|
import { useState } from "react";
|
|
import { useState } from "react";
|
|
|
import { WindowType } from "@/utils/types";
|
|
import { WindowType } from "@/utils/types";
|
|
|
import { useDispatch, useSelector } from "react-redux";
|
|
import { useDispatch, useSelector } from "react-redux";
|
|
|
-import { setTab } from "@/store/health";
|
|
|
|
|
|
|
+import { setMode, setTab } from "@/store/health";
|
|
|
import { MainColorType } from "@/context/themes/color";
|
|
import { MainColorType } from "@/context/themes/color";
|
|
|
import { rpxToPx } from "@/utils/tools";
|
|
import { rpxToPx } from "@/utils/tools";
|
|
|
import dayjs from "dayjs";
|
|
import dayjs from "dayjs";
|
|
@@ -86,58 +86,58 @@ export default function MainSwiper(props: { count: number, pageChanged: Function
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- else if (x >= -pageWidth*2 && x <= pageWidth*2) {
|
|
|
|
|
|
|
+ else if (x >= -pageWidth * 2 && x <= pageWidth * 2) {
|
|
|
switch (scrollPage) {
|
|
switch (scrollPage) {
|
|
|
case 0:
|
|
case 0:
|
|
|
case 3:
|
|
case 3:
|
|
|
{
|
|
{
|
|
|
- scale1 = 1 - (Math.abs(x)-pageWidth) / pageWidth * 0.2
|
|
|
|
|
- scale2 = x > 0 ? 1 - (pageWidth - x+pageWidth) / pageWidth * 0.2 : 0.8
|
|
|
|
|
- scale0 = x < 0 ? 1 - (pageWidth + x+pageWidth) / pageWidth * 0.2 : 0.8
|
|
|
|
|
|
|
+ scale1 = 1 - (Math.abs(x) - pageWidth) / pageWidth * 0.2
|
|
|
|
|
+ scale2 = x > 0 ? 1 - (pageWidth - x + pageWidth) / pageWidth * 0.2 : 0.8
|
|
|
|
|
+ scale0 = x < 0 ? 1 - (pageWidth + x + pageWidth) / pageWidth * 0.2 : 0.8
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
case 1:
|
|
case 1:
|
|
|
case 4:
|
|
case 4:
|
|
|
{
|
|
{
|
|
|
- scale1 = x < 0 ? 1 - (pageWidth + x+pageWidth) / pageWidth * 0.2 : 0.8
|
|
|
|
|
- scale2 = 1 - (Math.abs(x)-pageWidth) / pageWidth * 0.2
|
|
|
|
|
- scale0 = x > 0 ? 1 - (pageWidth - x+pageWidth) / pageWidth * 0.2 : 0.8
|
|
|
|
|
|
|
+ scale1 = x < 0 ? 1 - (pageWidth + x + pageWidth) / pageWidth * 0.2 : 0.8
|
|
|
|
|
+ scale2 = 1 - (Math.abs(x) - pageWidth) / pageWidth * 0.2
|
|
|
|
|
+ scale0 = x > 0 ? 1 - (pageWidth - x + pageWidth) / pageWidth * 0.2 : 0.8
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
case 2:
|
|
case 2:
|
|
|
case 5:
|
|
case 5:
|
|
|
{
|
|
{
|
|
|
- scale1 = x > 0 ? 1 - (pageWidth - x+pageWidth) / pageWidth * 0.2 : 0.8
|
|
|
|
|
- scale2 = x < 0 ? 1 - (pageWidth + x+pageWidth) / pageWidth * 0.2 : 0.8
|
|
|
|
|
- scale0 = 1 - (Math.abs(x)-pageWidth) / pageWidth * 0.2
|
|
|
|
|
|
|
+ scale1 = x > 0 ? 1 - (pageWidth - x + pageWidth) / pageWidth * 0.2 : 0.8
|
|
|
|
|
+ scale2 = x < 0 ? 1 - (pageWidth + x + pageWidth) / pageWidth * 0.2 : 0.8
|
|
|
|
|
+ scale0 = 1 - (Math.abs(x) - pageWidth) / pageWidth * 0.2
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- else if (x >= -pageWidth*3 && x <= pageWidth*3) {
|
|
|
|
|
|
|
+ else if (x >= -pageWidth * 3 && x <= pageWidth * 3) {
|
|
|
switch (scrollPage) {
|
|
switch (scrollPage) {
|
|
|
case 0:
|
|
case 0:
|
|
|
case 3:
|
|
case 3:
|
|
|
{
|
|
{
|
|
|
- scale2 = 1 - (Math.abs(x)-pageWidth*2) / pageWidth * 0.2
|
|
|
|
|
- scale0 = x > 0 ? 1 - (pageWidth - x+pageWidth*2) / pageWidth * 0.2 : 0.8
|
|
|
|
|
- scale1 = x < 0 ? 1 - (pageWidth + x+pageWidth*2) / pageWidth * 0.2 : 0.8
|
|
|
|
|
|
|
+ scale2 = 1 - (Math.abs(x) - pageWidth * 2) / pageWidth * 0.2
|
|
|
|
|
+ scale0 = x > 0 ? 1 - (pageWidth - x + pageWidth * 2) / pageWidth * 0.2 : 0.8
|
|
|
|
|
+ scale1 = x < 0 ? 1 - (pageWidth + x + pageWidth * 2) / pageWidth * 0.2 : 0.8
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
case 1:
|
|
case 1:
|
|
|
case 4:
|
|
case 4:
|
|
|
{
|
|
{
|
|
|
- scale2 = x < 0 ? 1 - (pageWidth + x+pageWidth*2) / pageWidth * 0.2 : 0.8
|
|
|
|
|
- scale0 = 1 - (Math.abs(x)-pageWidth*2) / pageWidth * 0.2
|
|
|
|
|
- scale1 = x > 0 ? 1 - (pageWidth - x+pageWidth*2) / pageWidth * 0.2 : 0.8
|
|
|
|
|
|
|
+ scale2 = x < 0 ? 1 - (pageWidth + x + pageWidth * 2) / pageWidth * 0.2 : 0.8
|
|
|
|
|
+ scale0 = 1 - (Math.abs(x) - pageWidth * 2) / pageWidth * 0.2
|
|
|
|
|
+ scale1 = x > 0 ? 1 - (pageWidth - x + pageWidth * 2) / pageWidth * 0.2 : 0.8
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
case 2:
|
|
case 2:
|
|
|
case 5:
|
|
case 5:
|
|
|
{
|
|
{
|
|
|
- scale2 = x > 0 ? 1 - (pageWidth - x+pageWidth*2) / pageWidth * 0.2 : 0.8
|
|
|
|
|
- scale0 = x < 0 ? 1 - (pageWidth + x+pageWidth*2) / pageWidth * 0.2 : 0.8
|
|
|
|
|
- scale1 = 1 - (Math.abs(x)-pageWidth*2) / pageWidth * 0.2
|
|
|
|
|
|
|
+ scale2 = x > 0 ? 1 - (pageWidth - x + pageWidth * 2) / pageWidth * 0.2 : 0.8
|
|
|
|
|
+ scale0 = x < 0 ? 1 - (pageWidth + x + pageWidth * 2) / pageWidth * 0.2 : 0.8
|
|
|
|
|
+ scale1 = 1 - (Math.abs(x) - pageWidth * 2) / pageWidth * 0.2
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -149,10 +149,34 @@ export default function MainSwiper(props: { count: number, pageChanged: Function
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function onTransitionend(){
|
|
|
|
|
|
|
+ function onTransitionend() {
|
|
|
scrollPage = current
|
|
scrollPage = current
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function switchMode() {
|
|
|
|
|
+ switch (health.mode) {
|
|
|
|
|
+ case 'FAST':
|
|
|
|
|
+ dispatch(setMode('EAT'));
|
|
|
|
|
+ break
|
|
|
|
|
+ case 'EAT':
|
|
|
|
|
+ dispatch(setMode('FAST'));
|
|
|
|
|
+ break
|
|
|
|
|
+ case 'DAY':
|
|
|
|
|
+ dispatch(setMode('NIGHT'));
|
|
|
|
|
+ break
|
|
|
|
|
+ case 'NIGHT':
|
|
|
|
|
+ dispatch(setMode('DAY'));
|
|
|
|
|
+ break
|
|
|
|
|
+ case 'SLEEP':
|
|
|
|
|
+ dispatch(setMode('ACTIVE'));
|
|
|
|
|
+ break
|
|
|
|
|
+ case 'ACTIVE':
|
|
|
|
|
+ dispatch(setMode('SLEEP'));
|
|
|
|
|
+ break
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return <View style={{ flexDirection: 'column', display: 'flex', alignItems: 'center' }}>
|
|
return <View style={{ flexDirection: 'column', display: 'flex', alignItems: 'center' }}>
|
|
|
<Text className="today">Today</Text>
|
|
<Text className="today">Today</Text>
|
|
|
<Text className="main_date">{global.language == 'en' ? dayjs().format('dddd, MMM D') : dayjs().format('MMMD日, dddd')}</Text>
|
|
<Text className="main_date">{global.language == 'en' ? dayjs().format('dddd, MMM D') : dayjs().format('MMMD日, dddd')}</Text>
|
|
@@ -172,18 +196,34 @@ export default function MainSwiper(props: { count: number, pageChanged: Function
|
|
|
onChange={pageChanged}
|
|
onChange={pageChanged}
|
|
|
current={current}>
|
|
current={current}>
|
|
|
<SwiperItem>
|
|
<SwiperItem>
|
|
|
- <MainDayNightCard scale={current==0?1:0.8} count={props.count} typeChanged={typeChanged} id={1} onClick={() => {
|
|
|
|
|
- setCurrent(0)
|
|
|
|
|
|
|
+ <MainDayNightCard scale={current == 0 ? 1 : 0.8} count={props.count} typeChanged={typeChanged} id={1} onClick={() => {
|
|
|
|
|
+
|
|
|
|
|
+ if (current == 0) {
|
|
|
|
|
+ switchMode()
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ setCurrent(0)
|
|
|
|
|
+ }
|
|
|
}} />
|
|
}} />
|
|
|
</SwiperItem>
|
|
</SwiperItem>
|
|
|
<SwiperItem>
|
|
<SwiperItem>
|
|
|
- <MainFastEatCard scale={current==1?1:0.8} count={props.count} typeChanged={typeChanged} id={2} onClick={() => {
|
|
|
|
|
- setCurrent(1)
|
|
|
|
|
|
|
+ <MainFastEatCard scale={current == 1 ? 1 : 0.8} count={props.count} typeChanged={typeChanged} id={2} onClick={() => {
|
|
|
|
|
+ if (current == 1) {
|
|
|
|
|
+ switchMode()
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ setCurrent(1)
|
|
|
|
|
+ }
|
|
|
}} />
|
|
}} />
|
|
|
</SwiperItem>
|
|
</SwiperItem>
|
|
|
<SwiperItem>
|
|
<SwiperItem>
|
|
|
- <MainSleepActiveCard scale={current==2?1:0.8} count={props.count} typeChanged={typeChanged} id={3} onClick={() => {
|
|
|
|
|
- setCurrent(2)
|
|
|
|
|
|
|
+ <MainSleepActiveCard scale={current == 2 ? 1 : 0.8} count={props.count} typeChanged={typeChanged} id={3} onClick={() => {
|
|
|
|
|
+ if (current == 2) {
|
|
|
|
|
+ switchMode()
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ setCurrent(2)
|
|
|
|
|
+ }
|
|
|
}} />
|
|
}} />
|
|
|
</SwiperItem>
|
|
</SwiperItem>
|
|
|
{/* <SwiperItem>
|
|
{/* <SwiperItem>
|