|
|
@@ -5,7 +5,7 @@ import RecordItem from "@/features/common/RecordItem";
|
|
|
import { delRecord } from "@/services/trackTimeDuration";
|
|
|
import { ModalType } from "@/utils/types";
|
|
|
import { View, Text, Image, PageContainer } from "@tarojs/components";
|
|
|
-import Taro from "@tarojs/taro";
|
|
|
+import Taro, { usePageScroll } from "@tarojs/taro";
|
|
|
import { useEffect, useState, memo } from "react";
|
|
|
import TimelineFastSleep from "./TimelineFastSleep";
|
|
|
import { TimeFormatter } from "@/utils/time_format";
|
|
|
@@ -37,6 +37,8 @@ let stageCanvasId = new Date().getTime()
|
|
|
|
|
|
let startX = 0
|
|
|
let startY = 0
|
|
|
+
|
|
|
+// let disableDismiss = false
|
|
|
//https://www.php.cn/faq/629819.html
|
|
|
|
|
|
// export default function RecordFastSleep(props: { data: any, type: string, delSuccess?: Function, index: any }) {
|
|
|
@@ -50,6 +52,7 @@ const RecordFastSleep = memo((props: { data: any, type: string, index: number })
|
|
|
const [selIndex, setSelIndex] = useState(0)
|
|
|
const [showMoreModal, setShowMoreModal] = useState(false)
|
|
|
const [showDel, setShowDel] = useState(false)
|
|
|
+ const [disableDismiss, setDisableDismiss] = useState(false)
|
|
|
const { t } = useTranslation()
|
|
|
var canvasId = props.data.id
|
|
|
const record = props.data;
|
|
|
@@ -72,13 +75,13 @@ const RecordFastSleep = memo((props: { data: any, type: string, index: number })
|
|
|
|
|
|
}
|
|
|
|
|
|
- if (props.index==-20000){
|
|
|
- global.refreshRecent = ()=>{
|
|
|
- setCount((index)=>index+1)
|
|
|
+ if (props.index == -20000) {
|
|
|
+ global.refreshRecent = () => {
|
|
|
+ setCount((index) => index + 1)
|
|
|
}
|
|
|
- setTimeout(()=>{
|
|
|
- setCount((index)=>index+1)
|
|
|
- },100)
|
|
|
+ setTimeout(() => {
|
|
|
+ setCount((index) => index + 1)
|
|
|
+ }, 100)
|
|
|
}
|
|
|
// console.log(sqrt(-4).toString())
|
|
|
}, [props.data])
|
|
|
@@ -177,8 +180,15 @@ const RecordFastSleep = memo((props: { data: any, type: string, index: number })
|
|
|
</View>
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
function showDetail(e) {
|
|
|
- setShowDel(false);
|
|
|
+ if (showDel){
|
|
|
+ setShowDel(false);
|
|
|
+ return
|
|
|
+ }
|
|
|
+ dispatch(setSelID(-1))
|
|
|
+
|
|
|
if (props.type == 'latest') {
|
|
|
setSegmentIndex(0)
|
|
|
global.segmentIndex = 0
|
|
|
@@ -240,7 +250,7 @@ const RecordFastSleep = memo((props: { data: any, type: string, index: number })
|
|
|
(props.data.scenario == 'SLEEP' && props.data.sleep.status == "NOT_COMPLETED")) {
|
|
|
realRing.durationArc = 0.01
|
|
|
}
|
|
|
- if (props.data.scenario=='FAST_SLEEP' && props.data.fast.status == "NOT_COMPLETED"){
|
|
|
+ if (props.data.scenario == 'FAST_SLEEP' && props.data.fast.status == "NOT_COMPLETED") {
|
|
|
realRing.durationArc = 0.01
|
|
|
}
|
|
|
return <Rings common={common} bgRing={bgRing} canvasId={canvasId} realRing={realRing} />
|
|
|
@@ -470,7 +480,7 @@ const RecordFastSleep = memo((props: { data: any, type: string, index: number })
|
|
|
fastDuration = t('feature.common.wait_for_end')
|
|
|
}
|
|
|
|
|
|
- if (record.status == 'COMPLETED' && record.fast.status=='NOT_COMPLETED'){
|
|
|
+ if (record.status == 'COMPLETED' && record.fast.status == 'NOT_COMPLETED') {
|
|
|
fastDuration = t('feature.common.not_completed')
|
|
|
}
|
|
|
|
|
|
@@ -530,6 +540,8 @@ const RecordFastSleep = memo((props: { data: any, type: string, index: number })
|
|
|
function touchStart(e) {
|
|
|
startX = e.touches[0].clientX
|
|
|
startY = e.touches[0].clientY
|
|
|
+ setDisableDismiss(true)
|
|
|
+ // disableDismiss = true
|
|
|
}
|
|
|
|
|
|
function touchMove(e) {
|
|
|
@@ -540,12 +552,13 @@ const RecordFastSleep = memo((props: { data: any, type: string, index: number })
|
|
|
|
|
|
|
|
|
if (Math.abs(deltaX) > Math.abs(deltaY)) {
|
|
|
- if (deltaX < -60) {
|
|
|
+ if (deltaX < -80) {
|
|
|
setShowDel(true)
|
|
|
+
|
|
|
dispatch(setSelID(props.data.id))
|
|
|
global.selId = props.data.id
|
|
|
}
|
|
|
- else if (deltaX > 60) {
|
|
|
+ else if (deltaX > 80) {
|
|
|
setShowDel(false)
|
|
|
// global.selId = -1
|
|
|
}
|
|
|
@@ -556,8 +569,16 @@ const RecordFastSleep = memo((props: { data: any, type: string, index: number })
|
|
|
|
|
|
function touchEnd(e) {
|
|
|
startX = 0
|
|
|
+ setDisableDismiss(false)
|
|
|
}
|
|
|
|
|
|
+ usePageScroll((e) => {
|
|
|
+ if (showDel && !disableDismiss) {
|
|
|
+ console.log(disableDismiss)
|
|
|
+ // setShowDel(false)
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
function modalContent() {
|
|
|
if (process.env.TARO_ENV == 'weapp') {
|
|
|
return <Modal
|