|
@@ -2,7 +2,7 @@ import { View, Text, Image, Switch } from "@tarojs/components";
|
|
|
import { bigRingRadius, dotIsOuterRange, getBgRing, getCommon, getDot, getReal, getSchedule, getTarget, ringWidth, smallRingRadius, thirdRingRadius } from "@/features/trackTimeDuration/hooks/RingData";
|
|
import { bigRingRadius, dotIsOuterRange, getBgRing, getCommon, getDot, getReal, getSchedule, getTarget, ringWidth, smallRingRadius, thirdRingRadius } from "@/features/trackTimeDuration/hooks/RingData";
|
|
|
import { RealRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
|
|
import { RealRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
|
|
|
import { ColorType } from "@/context/themes/color";
|
|
import { ColorType } from "@/context/themes/color";
|
|
|
-import { useSelector } from "react-redux";
|
|
|
|
|
|
|
+import { useDispatch, useSelector } from "react-redux";
|
|
|
import Rings from "@/features/trackTimeDuration/components/Rings";
|
|
import Rings from "@/features/trackTimeDuration/components/Rings";
|
|
|
import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
|
|
import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
|
|
|
import { rpxToPx } from "@/utils/tools";
|
|
import { rpxToPx } from "@/utils/tools";
|
|
@@ -15,6 +15,7 @@ import { getPerm, uploadPerm } from "@/services/user";
|
|
|
import Box from "@/components/layout/Box";
|
|
import Box from "@/components/layout/Box";
|
|
|
import { getPlans } from "@/services/trackTimeDuration";
|
|
import { getPlans } from "@/services/trackTimeDuration";
|
|
|
import DayNightCard from "@/features/trackSomething/components/DayNightCard";
|
|
import DayNightCard from "@/features/trackSomething/components/DayNightCard";
|
|
|
|
|
+import { clearDayStore } from "@/store/day";
|
|
|
|
|
|
|
|
|
|
|
|
|
let useNavigation;
|
|
let useNavigation;
|
|
@@ -26,10 +27,12 @@ let pauseTimer = false
|
|
|
|
|
|
|
|
export default function Discovery() {
|
|
export default function Discovery() {
|
|
|
const user = useSelector((state: any) => state.user);
|
|
const user = useSelector((state: any) => state.user);
|
|
|
- const dayNight = useSelector((state: any) => state.day);
|
|
|
|
|
|
|
+ const day = useSelector((state: any) => state.day);
|
|
|
|
|
+ const ring = useSelector((state: any) => state.ring);
|
|
|
const [schedule, setSchedule] = useState(null)
|
|
const [schedule, setSchedule] = useState(null)
|
|
|
const [count, setCount] = useState(0)
|
|
const [count, setCount] = useState(0)
|
|
|
- const [loaded,setLoaded] = useState(false)
|
|
|
|
|
|
|
+ const [loaded, setLoaded] = useState(false)
|
|
|
|
|
+ const dispatch = useDispatch();
|
|
|
const { t } = useTranslation()
|
|
const { t } = useTranslation()
|
|
|
|
|
|
|
|
let navigation;
|
|
let navigation;
|
|
@@ -37,12 +40,11 @@ export default function Discovery() {
|
|
|
if (useNavigation) {
|
|
if (useNavigation) {
|
|
|
navigation = useNavigation()
|
|
navigation = useNavigation()
|
|
|
}
|
|
}
|
|
|
- console.log('discovery')
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
setInterval(() => {
|
|
setInterval(() => {
|
|
|
- if (global.pauseIndexTimer || pauseTimer) {
|
|
|
|
|
|
|
+ if (global.pauseIndexTimer || pauseTimer) {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
setCount((prevCounter) => prevCounter + 1)
|
|
setCount((prevCounter) => prevCounter + 1)
|
|
@@ -51,15 +53,22 @@ export default function Discovery() {
|
|
|
}, [])
|
|
}, [])
|
|
|
|
|
|
|
|
useDidShow(() => {
|
|
useDidShow(() => {
|
|
|
|
|
+ setCount(pre=>pre+1)
|
|
|
//resume timer
|
|
//resume timer
|
|
|
pauseTimer = false
|
|
pauseTimer = false
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- useDidHide(()=>{
|
|
|
|
|
|
|
+ useDidHide(() => {
|
|
|
//pause timer
|
|
//pause timer
|
|
|
pauseTimer = true
|
|
pauseTimer = true
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ useEffect(()=>{
|
|
|
|
|
+ if (!user.isLogin) {
|
|
|
|
|
+ dispatch(clearDayStore());
|
|
|
|
|
+ }
|
|
|
|
|
+ },[user.isLogin])
|
|
|
|
|
+
|
|
|
// useEffect(() => {
|
|
// useEffect(() => {
|
|
|
// setSchedule(global.homeData.scenarios)
|
|
// setSchedule(global.homeData.scenarios)
|
|
|
// }, [global.homeData])
|
|
// }, [global.homeData])
|
|
@@ -69,9 +78,13 @@ export default function Discovery() {
|
|
|
setSchedule((res as any).scenarios)
|
|
setSchedule((res as any).scenarios)
|
|
|
setLoaded(true)
|
|
setLoaded(true)
|
|
|
})
|
|
})
|
|
|
|
|
+ setCount(pre=>pre+1)
|
|
|
}, [user.isLogin])
|
|
}, [user.isLogin])
|
|
|
|
|
|
|
|
function getFoodTime() {
|
|
function getFoodTime() {
|
|
|
|
|
+ if (ring.schedule) {
|
|
|
|
|
+ return [ring.schedule.fast.end_time, ring.schedule.fast.start_time]
|
|
|
|
|
+ }
|
|
|
var obj;
|
|
var obj;
|
|
|
(schedule as any).map(item => {
|
|
(schedule as any).map(item => {
|
|
|
if (item.name == 'FAST') {
|
|
if (item.name == 'FAST') {
|
|
@@ -86,6 +99,9 @@ export default function Discovery() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function getActivityTime() {
|
|
function getActivityTime() {
|
|
|
|
|
+ if (ring.schedule) {
|
|
|
|
|
+ return [ring.schedule.sleep.end_time, ring.schedule.sleep.start_time]
|
|
|
|
|
+ }
|
|
|
var obj;
|
|
var obj;
|
|
|
(schedule as any).map(item => {
|
|
(schedule as any).map(item => {
|
|
|
if (item.name == 'SLEEP') {
|
|
if (item.name == 'SLEEP') {
|
|
@@ -101,13 +117,36 @@ export default function Discovery() {
|
|
|
common.lineWidth = ringWidth;
|
|
common.lineWidth = ringWidth;
|
|
|
var bgRing = getBgRing()
|
|
var bgRing = getBgRing()
|
|
|
const targetRing: RealRing = {
|
|
const targetRing: RealRing = {
|
|
|
- color: ColorType.food + '66',
|
|
|
|
|
|
|
+ color: (ring.current_record && ring.current_record.scenario == 'SLEEP') ? ColorType.activity + '66' : ColorType.food + '66',
|
|
|
startArc: 0,
|
|
startArc: 0,
|
|
|
durationArc: 2
|
|
durationArc: 2
|
|
|
}
|
|
}
|
|
|
var list = getFoodTime()
|
|
var list = getFoodTime()
|
|
|
- var start = parseInt(list[0].split(':')[0]) * 60 + parseInt(list[0].split(':')[1])
|
|
|
|
|
- var end = parseInt(list[1].split(':')[0]) * 60 + parseInt(list[1].split(':')[1])
|
|
|
|
|
|
|
+ var start;
|
|
|
|
|
+ var end;
|
|
|
|
|
+
|
|
|
|
|
+ if (ring.current_record && ring.current_record.scenario == 'SLEEP') {
|
|
|
|
|
+ var list2 = getActivityTime()
|
|
|
|
|
+ start = parseInt(list2[0].split(':')[0]) * 60 + parseInt(list2[0].split(':')[1])
|
|
|
|
|
+ end = parseInt(list2[1].split(':')[0]) * 60 + parseInt(list2[1].split(':')[1])
|
|
|
|
|
+ if (ring.current_record.status != 'WAIT_FOR_START') {
|
|
|
|
|
+ var startDate = new Date(ring.current_record.sleep.target_start_time)
|
|
|
|
|
+ var endDate = new Date(ring.current_record.sleep.target_end_time)
|
|
|
|
|
+ end = startDate.getHours() * 60 + startDate.getMinutes()
|
|
|
|
|
+ start = endDate.getHours() * 60 + endDate.getMinutes()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ start = parseInt(list[0].split(':')[0]) * 60 + parseInt(list[0].split(':')[1])
|
|
|
|
|
+ end = parseInt(list[1].split(':')[0]) * 60 + parseInt(list[1].split(':')[1])
|
|
|
|
|
+ if (ring.current_record && ring.current_record.status != 'WAIT_FOR_START') {
|
|
|
|
|
+ var startDate = new Date(ring.current_record.fast.target_start_time)
|
|
|
|
|
+ var endDate = new Date(ring.current_record.fast.target_end_time)
|
|
|
|
|
+ end = startDate.getHours() * 60 + startDate.getMinutes()
|
|
|
|
|
+ start = endDate.getHours() * 60 + endDate.getMinutes()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (end < start) {
|
|
if (end < start) {
|
|
|
end += 24 * 60
|
|
end += 24 * 60
|
|
|
}
|
|
}
|
|
@@ -143,7 +182,11 @@ export default function Discovery() {
|
|
|
realRing = null
|
|
realRing = null
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return <Rings common={common} bgRing={bgRing} targetRing={targetRing} realRing={duration2 <= duration ? realRing : null} currentDot={currentDot} canvasId={timeStamp + '_big'} />
|
|
|
|
|
|
|
+ if (ring.current_record.status == 'ONGOING1') {
|
|
|
|
|
+ realRing = null
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return <Rings common={common} bgRing={bgRing} targetRing={targetRing} realRing={duration2 <= duration ? realRing : null} currentDot={currentDot} canvasId={'day_big'} />
|
|
|
}
|
|
}
|
|
|
function smallRing() {
|
|
function smallRing() {
|
|
|
var common = getCommon(null, false)
|
|
var common = getCommon(null, false)
|
|
@@ -158,6 +201,45 @@ export default function Discovery() {
|
|
|
var list = getActivityTime()
|
|
var list = getActivityTime()
|
|
|
var start = parseInt(list[0].split(':')[0]) * 60 + parseInt(list[0].split(':')[1])
|
|
var start = parseInt(list[0].split(':')[0]) * 60 + parseInt(list[0].split(':')[1])
|
|
|
var end = parseInt(list[1].split(':')[0]) * 60 + parseInt(list[1].split(':')[1])
|
|
var end = parseInt(list[1].split(':')[0]) * 60 + parseInt(list[1].split(':')[1])
|
|
|
|
|
+ if (ring.current_record) {
|
|
|
|
|
+ if (ring.current_record.scenario == 'SLEEP') {
|
|
|
|
|
+ if (ring.current_record.status == 'ONGOING') {
|
|
|
|
|
+ var startDate = new Date(ring.current_record.sleep.target_start_time)
|
|
|
|
|
+ var endDate = new Date(ring.current_record.sleep.target_end_time)
|
|
|
|
|
+ end = startDate.getHours() * 60 + startDate.getMinutes()
|
|
|
|
|
+ start = endDate.getHours() * 60 + endDate.getMinutes()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ if (ring.current_record.status == 'ONGOING2') {
|
|
|
|
|
+ var startDate = new Date(ring.current_record.sleep.target_start_time)
|
|
|
|
|
+ var endDate = new Date(ring.current_record.sleep.target_end_time)
|
|
|
|
|
+ end = startDate.getHours() * 60 + startDate.getMinutes()
|
|
|
|
|
+ start = endDate.getHours() * 60 + endDate.getMinutes()
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (ring.current_record.status == 'ONGOING3') {
|
|
|
|
|
+ //睡眠已完成时,睡眠小于24小时,使用真实的real_end_time-real_start_time
|
|
|
|
|
+ //大于24小时,使用real_end_time+sleep_duration
|
|
|
|
|
+ if (ring.current_record.sleep.real_end_time - ring.current_record.sleep.real_start_time < 24 * 3600 * 1000) {
|
|
|
|
|
+ var startDate = new Date(ring.current_record.sleep.real_start_time)
|
|
|
|
|
+ var endDate = new Date(ring.current_record.sleep.real_end_time)
|
|
|
|
|
+ end = startDate.getHours() * 60 + startDate.getMinutes()
|
|
|
|
|
+ start = endDate.getHours() * 60 + endDate.getMinutes()
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ var startDate = new Date(ring.current_record.sleep.real_end_time)
|
|
|
|
|
+ var durationTemp = end - start//ring.current_record.sleep.target_end_time-ring.current_record.sleep.target_start_time
|
|
|
|
|
+ if (durationTemp < 0) {
|
|
|
|
|
+ durationTemp += 24 * 60
|
|
|
|
|
+ }
|
|
|
|
|
+ var endDate = new Date(startDate.getTime() + durationTemp * 60 * 1000)
|
|
|
|
|
+ start = startDate.getHours() * 60 + startDate.getMinutes()
|
|
|
|
|
+ end = endDate.getHours() * 60 + endDate.getMinutes()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
if (end < start) {
|
|
if (end < start) {
|
|
|
end += 24 * 60
|
|
end += 24 * 60
|
|
|
}
|
|
}
|
|
@@ -192,7 +274,11 @@ export default function Discovery() {
|
|
|
realRing = null
|
|
realRing = null
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return <Rings common={common} bgRing={bgRing} targetRing={realRingBig} realRing={duration2 <= duration ? realRing : null} currentDot={currentDot} canvasId={timeStamp + '_small'} />
|
|
|
|
|
|
|
+ if (ring.current_record.status == 'ONGOING2') {
|
|
|
|
|
+ realRing = null
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return <Rings common={common} bgRing={bgRing} targetRing={realRingBig} realRing={duration2 <= duration ? realRing : null} currentDot={currentDot} canvasId={'day_small'} />
|
|
|
}
|
|
}
|
|
|
function dayRing() {
|
|
function dayRing() {
|
|
|
var common = getCommon(null, true)
|
|
var common = getCommon(null, true)
|
|
@@ -210,8 +296,8 @@ export default function Discovery() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- var sunRiseObj = dayNight.dayRingSunrise
|
|
|
|
|
- var sunSetObj = dayNight.dayRingSunset
|
|
|
|
|
|
|
+ var sunRiseObj = day.dayRingSunrise
|
|
|
|
|
+ var sunSetObj = day.dayRingSunset
|
|
|
sunRise = parseInt(sunRiseObj.split(':')[0]) * 60 + parseInt(sunRiseObj.split(':')[1])
|
|
sunRise = parseInt(sunRiseObj.split(':')[0]) * 60 + parseInt(sunRiseObj.split(':')[1])
|
|
|
sunSet = parseInt(sunSetObj.split(':')[0]) * 60 + parseInt(sunSetObj.split(':')[1])
|
|
sunSet = parseInt(sunSetObj.split(':')[0]) * 60 + parseInt(sunSetObj.split(':')[1])
|
|
|
|
|
|
|
@@ -242,8 +328,8 @@ export default function Discovery() {
|
|
|
startArc: (sunRise * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0,
|
|
startArc: (sunRise * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0,
|
|
|
durationArc: (duration2 * 60) / (24 * 3600) * 2 * Math.PI
|
|
durationArc: (duration2 * 60) / (24 * 3600) * 2 * Math.PI
|
|
|
}
|
|
}
|
|
|
- if (dayNight.dayRingDate) {
|
|
|
|
|
- if (new Date(dayNight.dayRingDate).getDate() != new Date().getDate()) {
|
|
|
|
|
|
|
+ if (day.dayRingDate) {
|
|
|
|
|
+ if (new Date(day.dayRingDate).getDate() != new Date().getDate()) {
|
|
|
realRing = null;
|
|
realRing = null;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -253,7 +339,7 @@ export default function Discovery() {
|
|
|
realRing = null
|
|
realRing = null
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return <Rings common={common} bgRing={bgRing} targetRing={realRingBig} realRing={duration2 <= duration ? realRing : null} currentDot={currentDot} canvasId={timeStamp + '_day'} />
|
|
|
|
|
|
|
+ return <Rings common={common} bgRing={bgRing} targetRing={realRingBig} realRing={duration2 <= duration ? realRing : null} currentDot={currentDot} canvasId={'day_day'} />
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function goAcitivity() {
|
|
function goAcitivity() {
|
|
@@ -273,8 +359,8 @@ export default function Discovery() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function dayDuration() {
|
|
function dayDuration() {
|
|
|
- var sunRiseObj = dayNight.dayRingSunrise
|
|
|
|
|
- var sunSetObj = dayNight.dayRingSunset
|
|
|
|
|
|
|
+ var sunRiseObj = day.dayRingSunrise
|
|
|
|
|
+ var sunSetObj = day.dayRingSunset
|
|
|
var sunRise = parseInt(sunRiseObj.split(':')[0]) * 60 + parseInt(sunRiseObj.split(':')[1])
|
|
var sunRise = parseInt(sunRiseObj.split(':')[0]) * 60 + parseInt(sunRiseObj.split(':')[1])
|
|
|
var sunSet = parseInt(sunSetObj.split(':')[0]) * 60 + parseInt(sunSetObj.split(':')[1])
|
|
var sunSet = parseInt(sunSetObj.split(':')[0]) * 60 + parseInt(sunSetObj.split(':')[1])
|
|
|
if (sunSetObj.indexOf('PM') != -1) {
|
|
if (sunSetObj.indexOf('PM') != -1) {
|
|
@@ -290,6 +376,12 @@ export default function Discovery() {
|
|
|
var list = getFoodTime()
|
|
var list = getFoodTime()
|
|
|
var start = parseInt(list[0].split(':')[0]) * 60 + parseInt(list[0].split(':')[1])
|
|
var start = parseInt(list[0].split(':')[0]) * 60 + parseInt(list[0].split(':')[1])
|
|
|
var end = parseInt(list[1].split(':')[0]) * 60 + parseInt(list[1].split(':')[1])
|
|
var end = parseInt(list[1].split(':')[0]) * 60 + parseInt(list[1].split(':')[1])
|
|
|
|
|
+ if (ring.current_record && ring.current_record.status != 'WAIT_FOR_START' && ring.current_record.scenario != 'SLEEP') {
|
|
|
|
|
+ var startDate = new Date(ring.current_record.fast.target_start_time)
|
|
|
|
|
+ var endDate = new Date(ring.current_record.fast.target_end_time)
|
|
|
|
|
+ end = startDate.getHours() * 60 + startDate.getMinutes()
|
|
|
|
|
+ start = endDate.getHours() * 60 + endDate.getMinutes()
|
|
|
|
|
+ }
|
|
|
if (end < start) {
|
|
if (end < start) {
|
|
|
end += 24 * 60
|
|
end += 24 * 60
|
|
|
}
|
|
}
|
|
@@ -299,32 +391,72 @@ export default function Discovery() {
|
|
|
|
|
|
|
|
function activityDuration() {
|
|
function activityDuration() {
|
|
|
var list = getActivityTime()
|
|
var list = getActivityTime()
|
|
|
- var start = parseInt(list[0].split(':')[0]) * 60 + parseInt(list[0].split(':')[1])
|
|
|
|
|
- var end = parseInt(list[1].split(':')[0]) * 60 + parseInt(list[1].split(':')[1])
|
|
|
|
|
|
|
+ var start = parseInt(list[0].split(':')[0]) * 3600 + parseInt(list[0].split(':')[1])*60
|
|
|
|
|
+ var end = parseInt(list[1].split(':')[0]) * 3600 + parseInt(list[1].split(':')[1])*60
|
|
|
|
|
+ if (ring.current_record) {
|
|
|
|
|
+ if (ring.current_record.scenario == 'SLEEP') {
|
|
|
|
|
+ if (ring.current_record.status == 'ONGOING') {
|
|
|
|
|
+ var startDate = new Date(ring.current_record.sleep.target_start_time)
|
|
|
|
|
+ var endDate = new Date(ring.current_record.sleep.target_end_time)
|
|
|
|
|
+ end = startDate.getHours() * 3600 + startDate.getMinutes()*60+startDate.getSeconds()
|
|
|
|
|
+ start = endDate.getHours() * 3600 + endDate.getMinutes()*60+endDate.getSeconds()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ if (ring.current_record.status == 'ONGOING2') {
|
|
|
|
|
+ var startDate = new Date(ring.current_record.sleep.target_start_time)
|
|
|
|
|
+ var endDate = new Date(ring.current_record.sleep.target_end_time)
|
|
|
|
|
+ end = startDate.getHours() * 3600 + startDate.getMinutes()*60+startDate.getSeconds()
|
|
|
|
|
+ start = endDate.getHours() * 3600 + endDate.getMinutes()*60+endDate.getSeconds()
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (ring.current_record.status == 'ONGOING3') {
|
|
|
|
|
+ //睡眠已完成时,睡眠小于24小时,使用真实的real_end_time-real_start_time
|
|
|
|
|
+ //大于24小时,使用real_end_time+sleep_duration
|
|
|
|
|
+ if (ring.current_record.sleep.real_end_time - ring.current_record.sleep.real_start_time < 24 * 3600 * 1000) {
|
|
|
|
|
+ var startDate = new Date(ring.current_record.sleep.real_start_time)
|
|
|
|
|
+ var endDate = new Date(ring.current_record.sleep.real_end_time)
|
|
|
|
|
+ end = startDate.getHours() * 3600 + startDate.getMinutes()*60+startDate.getSeconds()
|
|
|
|
|
+ start = endDate.getHours() * 3600 + endDate.getMinutes()*60+endDate.getSeconds()
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ var startDate = new Date(ring.current_record.sleep.real_end_time)
|
|
|
|
|
+ var durationTemp = start - end//ring.current_record.sleep.target_end_time-ring.current_record.sleep.target_start_time
|
|
|
|
|
+ if (durationTemp < 0) {
|
|
|
|
|
+ durationTemp += 24 * 3600
|
|
|
|
|
+ }
|
|
|
|
|
+ var endDate = new Date(startDate.getTime() + durationTemp )
|
|
|
|
|
+ end = startDate.getHours() * 3600 + startDate.getMinutes()*60+startDate.getSeconds()
|
|
|
|
|
+ start = endDate.getHours() * 3600 + endDate.getMinutes()*60+endDate.getSeconds()
|
|
|
|
|
+ console.log('active', end, start, durationTemp)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
if (end < start) {
|
|
if (end < start) {
|
|
|
- end += 24 * 60
|
|
|
|
|
|
|
+ end += 24 * 3600
|
|
|
}
|
|
}
|
|
|
- var duration = (end - start) * 60 * 1000
|
|
|
|
|
|
|
+ var duration = (end - start)*1000
|
|
|
return TimeFormatter.calculateTimeDifference(new Date().getTime(), new Date().getTime() + duration);
|
|
return TimeFormatter.calculateTimeDifference(new Date().getTime(), new Date().getTime() + duration);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function rings() {
|
|
function rings() {
|
|
|
return <View style={{
|
|
return <View style={{
|
|
|
position: 'relative', zIndex: 1,
|
|
position: 'relative', zIndex: 1,
|
|
|
- marginLeft: dayNight.showDayRing ? -6 : 0,
|
|
|
|
|
|
|
+ marginLeft: day.showDayRing ? -6 : 0,
|
|
|
}}>
|
|
}}>
|
|
|
{
|
|
{
|
|
|
bigRing()
|
|
bigRing()
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
- <View style={{ display: 'flex', position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, alignItems: 'center', justifyContent: 'center' }}>
|
|
|
|
|
|
|
+ ring.current_record && ring.current_record.scenario == 'FAST_SLEEP' && <View style={{ display: 'flex', position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, alignItems: 'center', justifyContent: 'center' }}>
|
|
|
{
|
|
{
|
|
|
smallRing()
|
|
smallRing()
|
|
|
}
|
|
}
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
- dayNight.showDayRing && <View style={{ display: 'flex', position: 'absolute', left: -14, top: -14, right: -14, bottom: -14 }}>
|
|
|
|
|
|
|
+ day.showDayRing && <View style={{ display: 'flex', position: 'absolute', left: -14, top: -14, right: -14, bottom: -14 }}>
|
|
|
{
|
|
{
|
|
|
dayRing()
|
|
dayRing()
|
|
|
}
|
|
}
|
|
@@ -334,7 +466,7 @@ export default function Discovery() {
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (!loaded){
|
|
|
|
|
|
|
+ if (!loaded) {
|
|
|
return <View />
|
|
return <View />
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -351,34 +483,34 @@ export default function Discovery() {
|
|
|
<View style={{
|
|
<View style={{
|
|
|
display: 'flex',
|
|
display: 'flex',
|
|
|
flexDirection: 'row',
|
|
flexDirection: 'row',
|
|
|
- marginTop: dayNight.showDayRing ? -6 : 0,
|
|
|
|
|
- marginBottom: dayNight.showDayRing ? -6 : 0,
|
|
|
|
|
- padding: dayNight.showDayRing ? 14 : 0,
|
|
|
|
|
|
|
+ marginTop: day.showDayRing ? -6 : 0,
|
|
|
|
|
+ marginBottom: day.showDayRing ? -6 : 0,
|
|
|
|
|
+ padding: day.showDayRing ? 14 : 0,
|
|
|
alignItems: 'center'
|
|
alignItems: 'center'
|
|
|
}}>
|
|
}}>
|
|
|
{
|
|
{
|
|
|
schedule && rings()
|
|
schedule && rings()
|
|
|
}
|
|
}
|
|
|
{schedule && <View className="duration_bg3"
|
|
{schedule && <View className="duration_bg3"
|
|
|
- style={{ marginLeft: dayNight.showDayRing ? rpxToPx(68) : rpxToPx(52), height: bigRingRadius * 2, overflow: 'visible' }}>
|
|
|
|
|
|
|
+ style={{ marginLeft: day.showDayRing ? rpxToPx(68) : rpxToPx(52), height: bigRingRadius * 2, overflow: 'visible' }}>
|
|
|
{
|
|
{
|
|
|
- dayNight.showDayRing && <Text className="duration_title2">{t('feature.common.day')}</Text>
|
|
|
|
|
|
|
+ day.showDayRing && <Text className="duration_title2">{t('feature.common.day')}</Text>
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
- dayNight.showDayRing &&
|
|
|
|
|
|
|
+ day.showDayRing &&
|
|
|
<Text className="duration_value2" style={{ color: ColorType.day }}>{dayDuration()}</Text>
|
|
<Text className="duration_value2" style={{ color: ColorType.day }}>{dayDuration()}</Text>
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
- <Text className="duration_title2">进食</Text>
|
|
|
|
|
|
|
+ ring.current_record && ring.current_record.scenario != 'SLEEP' && <Text className="duration_title2">进食</Text>
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
- <Text className="duration_value2" style={{ color: ColorType.food }}>{eatDuration()}</Text>
|
|
|
|
|
|
|
+ ring.current_record && ring.current_record.scenario != 'SLEEP' && <Text className="duration_value2" style={{ color: ColorType.food }}>{eatDuration()}</Text>
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
- <Text className="duration_title2">活动</Text>
|
|
|
|
|
|
|
+ ring.current_record && ring.current_record.scenario != 'FAST' && <Text className="duration_title2">活动</Text>
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
- <Text className="duration_value2" style={{ color: ColorType.activity, marginBottom: 0 }}>{activityDuration()}</Text>
|
|
|
|
|
|
|
+ ring.current_record && ring.current_record.scenario != 'FAST' && <Text className="duration_value2" style={{ color: ColorType.activity, marginBottom: 0 }}>{activityDuration()}</Text>
|
|
|
}
|
|
}
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
@@ -394,7 +526,7 @@ export default function Discovery() {
|
|
|
</View>
|
|
</View>
|
|
|
</Box>
|
|
</Box>
|
|
|
|
|
|
|
|
- <DayNightCard isNight={false} count={count}/>
|
|
|
|
|
|
|
+ <DayNightCard isNight={false} count={count} />
|
|
|
|
|
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|