Leon 1 rok temu
rodzic
commit
f774880b9b

+ 1 - 1
src/context/themes/color.tsx

@@ -2,7 +2,7 @@ export enum ColorType {
     fast = '#00ffff',//'#aaff00',
     sleep = '#8961F5',//'#00ffff'
     box = '#121212',
-    ring = '#1c1c1c',
+    ring = '#76767625',//'#1c1c1c',
     food = '#FF7B00',
     activity = '#EEC01F',
     workout = 'yellow',

+ 39 - 17
src/features/trackTimeDuration/components/DayLight.tsx

@@ -16,6 +16,7 @@ export default function DayLight() {
     const [authInfo, setAuthInfo] = useState(null)
     const [sunriseTime, setSunriseTime] = useState('06:00')
     const [sunsetTime, setSunsetTime] = useState('18:00')
+    const [showLocatin, setShowLocation] = useState(true)
     const dayNight = useSelector((state: any) => state.dayNight);
     const user = useSelector((state: any) => state.user);
     const dispatch = useDispatch();
@@ -27,13 +28,13 @@ export default function DayLight() {
         if (authInfo)
             dispatch(updateMember({ isMember: user.test_user, gpsInfo: authInfo }))
         if (user.test_user && authInfo) {
-            if ((authInfo as any).daylights.length==1){
+            if ((authInfo as any).daylights.length == 1) {
                 setSunriseTime((authInfo as any).daylights[0].sunrise)
             }
             else {
                 setSunriseTime((authInfo as any).daylights[1].sunrise)
             }
-            
+
             setSunsetTime((authInfo as any).daylights[0].sunset)
         }
         else {
@@ -48,8 +49,8 @@ export default function DayLight() {
                 (data as any).latitude = (data as any).lat;
                 (data as any).longitude = (data as any).lng;
                 setAuthInfo(data as any)
-                
-                if ((data as any).daylights.length==1){
+
+                if ((data as any).daylights.length == 1) {
                     setSunriseTime((data as any).daylights[0].sunrise)
                 }
                 else {
@@ -84,6 +85,9 @@ export default function DayLight() {
         const isShow = await getStorage('showLightRing') || false
         setShowRing(isShow)
 
+        const hideLocation = await getStorage('hideLocation') || false
+        setShowLocation(!hideLocation)
+
         global.showNightRing = isShow
         global.refreshIndex()
 
@@ -212,20 +216,28 @@ export default function DayLight() {
                     <Text>Sunrise tomororow</Text>
                     <Text>{sunriseTime}</Text>
                 </View>
-                <Text className='daylight_note'>{isMember && authInfo ? 'Calculated based on your location.' : 'Sunset and sunrise times are global average. For actual times at your location, join our Pro program.'}</Text>
+                <Text className='daylight_note'>{
+                    !isMember ? 'Sunset and sunrise times are global average. For actual times at your location, join our Pro program.' :
+                        authInfo ? 'Calculated based on your location.' :
+                            'Sunset and sunrise times are global average. For actual times at your location, enter your location.'
+                }</Text>
+                {/* <Text className='daylight_note'>{isMember && authInfo ? 'Calculated based on your location.' : 'Sunset and sunrise times are global average. For actual times at your location, join our Pro program.'}</Text> */}
                 {
                     isMember ? <View>
-                        <View className='daylight_item' onClick={auth}>
-                            <Text style={{ flex: 1 }}>Location</Text>
-                            {
-                                authInfo ? <Text className='address'>{(authInfo as any).address.city}</Text> :
-                                    <Text>Enter</Text>
-                            }
-                            <Image className="daylight_arrow" src={require('@/assets/images/arrow3.png')} />
-                        </View>
+                        {
+                            showLocatin && <View className='daylight_item' onClick={auth}>
+                                <Text style={{ flex: 1 }}>Location</Text>
+                                {
+                                    authInfo ? <Text className='address'>{(authInfo as any).address.city}</Text> :
+                                        <Text>Enter</Text>
+                                }
+                                <Image className="daylight_arrow" src={require('@/assets/images/arrow3.png')} />
+                            </View>
+                        }
+
 
                         {
-                            authInfo && <View className='daylight_item' >
+                            authInfo && showLocatin && <View className='daylight_item' >
                                 <Text style={{ flex: 1 }}>Latitude</Text>
 
                                 <Text>{(authInfo as any).latitude}</Text>
@@ -234,7 +246,7 @@ export default function DayLight() {
                             </View>
                         }
                         {
-                            authInfo && <View className='daylight_item'>
+                            authInfo && showLocatin && <View className='daylight_item'>
                                 <Text style={{ flex: 1 }}>Longitude</Text>
 
                                 <Text>{(authInfo as any).longitude}</Text>
@@ -242,7 +254,7 @@ export default function DayLight() {
                             </View>
                         }
                         {
-                            authInfo && <View className='daylight_item'>
+                            authInfo && showLocatin && <View className='daylight_item'>
                                 <Text style={{ flex: 1 }}>Time zone</Text>
 
                                 <Text>{timezone}</Text>
@@ -250,7 +262,17 @@ export default function DayLight() {
                             </View>
                         }
                         {
-                            authInfo && <Text style={{ color: '#fff' }} onClick={clearData}>清除位置数据</Text>
+                            authInfo && <Text style={{ color: '#fff' }} onClick={() => {
+                                var enable = !showLocatin
+                                setShowLocation(enable)
+                                Taro.setStorage({
+                                    key: 'hideLocation',
+                                    data: !enable
+                                })
+                            }}>{showLocatin ? 'Hide my location' : 'Show my location'}</Text>
+                        }
+                        {
+                            authInfo && showLocatin && <Text style={{ color: '#fff' }} onClick={clearData}>清除位置数据</Text>
                         }
 
                     </View> :

+ 2 - 1
src/features/trackTimeDuration/components/IndexItem.tsx

@@ -70,7 +70,8 @@ export default function Component(props: { type: string, data: any, time: any })
 
             if (record.status == 'WAIT_FOR_START' || record.status == 'ONGOING1') {
                 var realRing1 = getSchedule(record, props.type != 'SLEEP', true)
-                return <Rings common={common} bgRing={bgRing} realRing={realRing1} canvasId={props.type + props.time + 'big'} />
+                var currentDot1 = getDot(record, true)
+                return <Rings common={common} bgRing={bgRing} realRing={realRing1} currentDot={currentDot1} canvasId={props.type + props.time + 'big'} />
             }
             if (props.data.status == 'ONGOING3') {
                 realRing.color = 'rgba(0,0,0,0)'

+ 1 - 1
src/features/trackTimeDuration/components/RecordFastSleep.tsx

@@ -32,7 +32,7 @@ export default function RecordFastSleep(props: { data: any, type: string, delSuc
     const [diffTimeZone, setDiffTimeZone] = useState(false)
     const [multiTimeZone, setMultiTimeZone] = useState(false)
     const { t } = useTranslation()
-    var canvasId = props.data.id+new Date().getTime()
+    var canvasId = props.data.id
     const record = props.data;
 
     const handleAppStateChange = (nextAppState) => {

+ 37 - 14
src/features/trackTimeDuration/components/Rings.weapp.tsx

@@ -145,6 +145,14 @@ export default function Rings(props: {
         });
     }
 
+    function calculateCoordinates(x, y, r, angle) {
+        const radians = angle * Math.PI / 180; // 将角度转换为弧度
+        const xPrime = x + r * Math.cos(radians);
+        const yPrime = y + r * Math.sin(radians);
+        return { x: xPrime, y: yPrime };
+      }
+      
+
     function drawContent(ctx){
         if (props.canvas){
             props.canvas.width = ((radius * 2 + lineWidth)+6) * dpr;
@@ -205,24 +213,39 @@ export default function Rings(props: {
             var time = new Date();
             var seconds = time.getHours() * 3600 + time.getMinutes() * 60 + time.getSeconds();
             var arc = seconds / 86400 * 2 * Math.PI - Math.PI / 2.0;
+            const radians = arc;//angle * Math.PI / 180; // 将角度转换为弧度
+            const xPrime = center + r * Math.cos(radians);
+            const yPrime = center + r * Math.sin(radians);
+
             ctx.beginPath();
-            ctx.arc(center, center, radius, arc,
-                arc + 0.001);
-            ctx.lineWidth = lineWidth+6;
-            ctx.strokeStyle = props.currentDot!.borderColor;
+            var dotLineWidth = 2
+            if (lineWidth==28){
+                dotLineWidth = 4
+                
+            }
+            ctx.arc(xPrime, yPrime, lineWidth/2.0+dotLineWidth/2.0, 0, 2 * Math.PI);
+            ctx.lineWidth = dotLineWidth;
+            ctx.strokeStyle = '#1C1C1C';
             ctx.lineCap = 'round'; // 设置为圆角
             ctx.stroke();
+        
+            // ctx.beginPath();
+            // ctx.arc(center, center, radius, arc,
+            //     arc + 0.001);
+            // ctx.lineWidth = lineWidth+6;
+            // ctx.strokeStyle = props.currentDot!.borderColor;
+            // ctx.lineCap = 'round'; // 设置为圆角
+            // ctx.stroke();
             
-            ctx.save()
-            ctx.beginPath();
-            ctx.arc(center, center, radius, arc,
-                arc + 0.001);
-            ctx.lineWidth = lineWidth;
-            ctx.strokeStyle = props.currentDot!.color;
-            ctx.lineCap = 'round'; // 设置为圆角
-            // ctx.globalAlpha = global.breathAlpha
-            ctx.stroke();
-            ctx.restore()
+            // ctx.save()
+            // ctx.beginPath();
+            // ctx.arc(center, center, radius, arc,
+            //     arc + 0.001);
+            // ctx.lineWidth = lineWidth;
+            // ctx.strokeStyle = props.currentDot!.color;
+            // ctx.lineCap = 'round'; // 设置为圆角
+            // ctx.stroke();
+            // ctx.restore()
         }
 
 

+ 0 - 1
src/features/trackTimeDuration/components/WeekCalendar.tsx

@@ -13,7 +13,6 @@ export default function WeekCalendar(props: { calendars: any }) {
     function onScroll(e) {
         var x = e.detail.scrollLeft
         var page = parseInt(x / rpxToPx(586) + '')
-        console.log(x)
         if (current != page) {
             setCurrent(page)
             setSummary(props.calendars[page].summary_stats)

+ 4 - 4
src/pages/clock/Index.tsx

@@ -164,7 +164,7 @@ export default function Page() {
             getClockRecords({
                 page: 1,
                 limit: 1,
-                part_completed: false
+                completed: true
             }).then(res => {
                 setRecords((res as any).data)
             })
@@ -352,10 +352,10 @@ export default function Page() {
     function render() {
         return <View className="index_container">
             <Text className="count">{count}</Text>
-            <IndexItem type="FAST" data={(homeData as any).fast} time={timestamp} />
-            <IndexItem type='SLEEP' data={(homeData as any).sleep} time={timestamp} />
+            {/* <IndexItem type="FAST" data={(homeData as any).fast} time={timestamp} /> */}
+            {/* <IndexItem type='SLEEP' data={(homeData as any).sleep} time={timestamp} /> */}
             <Text className="discovery">探索</Text>
-            <IndexItem type="FAST_SLEEP" data={(homeData as any).fast_sleep} time={timestamp} />
+            {/* <IndexItem type="FAST_SLEEP" data={(homeData as any).fast_sleep} time={timestamp} /> */}
             <Swiper className='swiper1' indicatorColor='#333'
                 indicatorActiveColor='#999'
                 current={0}