Leon il y a 1 an
Parent
commit
1ea1c4be9f

Fichier diff supprimé car celui-ci est trop grand
+ 1 - 1
android/app/src/main/assets/index.android.bundle


Fichier diff supprimé car celui-ci est trop grand
+ 0 - 0
android/app/src/main/assets/index.android.map


BIN
android/app/src/main/res/drawable-mdpi/src_assets_index_time_moon.png


+ 1 - 0
package.json

@@ -95,6 +95,7 @@
 		"intl": "^1.2.5",
 		"lodash": "^4.17.21",
 		"mathjs": "^12.3.0",
+		"moment": "^2.30.1",
 		"moment-timezone": "^0.5.45",
 		"react": "^18.1.0",
 		"react-dom": "^18.1.0",

+ 10 - 5
src/app/time_of_day/index_time.scss

@@ -16,6 +16,15 @@
     border-radius: 60px;
     box-shadow: 0px 8px 20px 0px rgba(0, 0, 0, 0.3);
     margin-top: 88px;
+    position: relative;
+}
+
+.more {
+    width: 48px;
+    height: 48px;
+    position: absolute;
+    right: 30px;
+    top: 36px;
 }
 
 .btn_text {
@@ -105,10 +114,7 @@
     color: #CACACA;
 }
 
-.more {
-    width: 48px;
-    height: 48px;
-}
+
 
 .modal_bg {
     background-color: #EBEBEB;
@@ -215,7 +221,6 @@
 
 .dst_note {
     color: #9E9E9E;
-    margin-top: 10px;
     font-size: 16px;
     line-height: 28px;
 }

+ 57 - 24
src/app/time_of_day/index_time.tsx

@@ -2,7 +2,7 @@ import { View, Text, Image } from "@tarojs/components";
 import './index_time.scss';
 import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
 import { getCommon, getDot } from "@/features/trackTimeDuration/hooks/RingData";
-import Rings, { RingCommon, BgRing,TargetRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
+import Rings, { RingCommon, BgRing, TargetRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
 import { useEffect, useState } from "react";
 import DeviceInfo from 'react-native-device-info';
 import dayjs from "dayjs";
@@ -13,6 +13,7 @@ import Taro from "@tarojs/taro";
 import { useTranslation } from "react-i18next";
 import 'dayjs/locale/zh-cn';
 import 'dayjs/locale/en';
+// import 'moment/locale/en';
 
 
 
@@ -46,12 +47,17 @@ export default function IndexTimePage() {
     }, [])
 
     async function getLanguage() {
+        var strLocation = await getStorage('lastLocation')
+        if (strLocation) {
+            setCurrent(JSON.parse(strLocation))
+        }
+
         var language = await getStorage('language') || 'en'
         global.language = language;
         i18n.changeLanguage(language)
         setIsEn(language == 'en')
         dayjs.locale(language == 'en' ? 'en' : 'zh-cn');
-        moment.locale(language == 'en' ? 'en' : 'zh-cn');
+        // moment.locale(language == 'en' ? 'en' : 'zh-cn');
     }
 
     async function getStorage(key: string) {
@@ -70,7 +76,7 @@ export default function IndexTimePage() {
         Taro.setStorage({ key: 'language', data: isEnglish ? 'en' : 'zh' })
         setShowLanguage(false)
         dayjs.locale(isEnglish ? 'en' : 'zh-cn');
-        moment.locale(isEnglish ? 'en' : 'zh-cn');
+        // moment.locale(isEnglish ? 'en' : 'zh-cn');
 
         if (current) {
             chooseLocation({
@@ -89,7 +95,19 @@ export default function IndexTimePage() {
     }
 
     function goMap() {
-        jumpPage('', 'map', navigation, { source: 'time_of_day', chooseLocation: chooseLocation })
+        jumpPage('', 'map', navigation, {
+            source: 'time_of_day',
+            lat: current ? current.geo.lat : null,
+            lng: current ? current.geo.lng : null,
+            chooseLocation: chooseLocation
+        })
+    }
+
+    function goRecords() {
+        if (!current) {
+            return
+        }
+        jumpPage('','MyPlaces',navigation)
     }
 
     function chooseLocation(res: any) {
@@ -103,7 +121,7 @@ export default function IndexTimePage() {
     }
 
     function saveLocation(location: any) {
-
+        Taro.setStorage({ key: 'lastLocation', data: JSON.stringify(location) })
     }
 
     function getLocation() {
@@ -137,7 +155,7 @@ export default function IndexTimePage() {
         color: '#EAE9E9'
     }
 
-    function getArc(){
+    function getArc() {
         var hour = new Date().getHours()
         var minute = new Date().getMinutes()
         var second = new Date().getSeconds()
@@ -150,23 +168,38 @@ export default function IndexTimePage() {
             second = parseInt(strSecond)
         }
 
-        return (hour*3600+minute*60+second)/(24*3600)*2*Math.PI
+        return (hour * 3600 + minute * 60 + second) / (24 * 3600) * 2 * Math.PI
     }
 
     function ring() {
+        var offset = 0
+
+        var hour = new Date().getHours()
+        var minute = new Date().getMinutes()
+        if (current) {
+            var strHour = moment().tz(current.time.timezone.id).format('H')
+            hour = parseInt(strHour)
+            var strMin = moment().tz(current.time.timezone.id).format('m')
+            minute = parseInt(strMin)
+        }
+
+        if (hour != new Date().getHours() || minute != new Date().getMinutes()) {
+            offset = hour * 60 + minute - new Date().getHours() * 60 - new Date().getMinutes()
+        }
+
         const currentDot: CurrentDot = {
             color: '#CACACA',
             lineWidth: 10,
             borderColor: '#ffffff',
-            offset: 0
+            offset: offset
         }
         const targetRing: TargetRing = {
             color: '#CACACA',
-            startArc: -Math.PI/2,
+            startArc: -Math.PI / 2,
             durationArc: getArc()
         }
 
-        return <Rings common={common} bgRing={bgRing} targetRing={targetRing}  currentDot={currentDot} canvasId={'smal11l'} />
+        return <Rings common={common} bgRing={bgRing} targetRing={targetRing} currentDot={currentDot} canvasId={'smal11l'} />
     }
 
     function languageModalContent() {
@@ -194,9 +227,9 @@ export default function IndexTimePage() {
         // var moment = require('moment-timezone');
         if (current) {
             if (timestamp) {
-                return dayjs(timestamp).tz(current.time.timezone.id).format(format)
+                return moment(timestamp).tz(current.time.timezone.id).format(format)
             }
-            return dayjs().tz(current.time.timezone.id).format(format)
+            return moment().tz(current.time.timezone.id).format(format)
         }
 
         return dayjs().format(format)
@@ -222,14 +255,6 @@ export default function IndexTimePage() {
         return t('time_of_day.index.winter_starts')
     }
 
-    function dstNote(item: any) {
-        var str = moment(item.timestamp).tz(current.time.timezone.id).format('YYYY-MM-DDTHH:mm:ss')
-        var str2 = moment(item.timestamp - 1).tz(current.time.timezone.id).format('YYYY-MM-DDTHH:mm:ss')
-        console.log(str, str2)
-        debugger
-        return 'Time was set forward 1 hour from 02:00 to 03:00.\nTime zone changed to UTC-7, Pacific Daylight Time (PDT).'
-    }
-
     function isNight() {
         var hour = new Date().getHours()
         if (current) {
@@ -258,8 +283,13 @@ export default function IndexTimePage() {
                         </View>
                         <View style={{ flex: 1 }}>
                             <Text className="dst_title">{dstTitle(index)}</Text>
-                            <Text className="dst_desc">{dstDesc(item, index)}</Text>
-                            <Text className="dst_note">{dstNote(item)}</Text>
+                            <Text className="dst_desc" style={{ marginBottom: 10 }}>{dstDesc(item, index)}</Text>
+                            {
+                                item.descriptions.map((desc, j) => {
+                                    return <Text className="dst_note" key={j * 100}>· {desc}</Text>
+                                })
+                            }
+
                         </View>
                     </View>
                 })
@@ -298,9 +328,12 @@ export default function IndexTimePage() {
         </View>
 
 
-        <View className="btn_bg" onClick={goMap}>
+        <View className="btn_bg" onClick={goMap} onLongClick={goRecords}>
             <Text className="btn_text">{t('time_of_day.index.pick_location')}</Text>
-            <Image className="more" src={require('@assets/index_time/more.png')} />
+            {
+                current && <Image className="more" onClick={goRecords} src={require('@assets/index_time/more.png')} />
+            }
+
         </View>
         <View className="footer" onClick={() => setShowLanguage(true)}>
             <Text className="footer_text">{isEn ? 'English' : '中文'}</Text>

+ 8 - 28
yarn.lock

@@ -14817,6 +14817,11 @@ moment@^2.29.4:
   resolved "https://registry.yarnpkg.com/moment/-/moment-2.30.1.tgz#f8c91c07b7a786e30c59926df530b4eac96974ae"
   integrity sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==
 
+moment@^2.30.1:
+  version "2.30.1"
+  resolved "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz#f8c91c07b7a786e30c59926df530b4eac96974ae"
+  integrity sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==
+
 ms@2.0.0:
   version "2.0.0"
   resolved "https://registry.npmmirror.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
@@ -18557,7 +18562,7 @@ string-hash-64@1.0.3:
   resolved "https://registry.yarnpkg.com/string-hash-64/-/string-hash-64-1.0.3.tgz#0deb56df58678640db5c479ccbbb597aaa0de322"
   integrity sha512-D5OKWKvDhyVWWn2x5Y9b+37NUllks34q1dCDhk/vYcso9fmhs+Tl3KR/gE4v5UNj2UA35cnX4KdVVGkG1deKqw==
 
-"string-width-cjs@npm:string-width@^4.2.0":
+"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
   version "4.2.3"
   resolved "https://registry.npmmirror.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
   integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -18574,15 +18579,6 @@ string-width@^2.1.0, string-width@^2.1.1:
     is-fullwidth-code-point "^2.0.0"
     strip-ansi "^4.0.0"
 
-string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
-  version "4.2.3"
-  resolved "https://registry.npmmirror.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
-  integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
-  dependencies:
-    emoji-regex "^8.0.0"
-    is-fullwidth-code-point "^3.0.0"
-    strip-ansi "^6.0.1"
-
 string-width@^5.0.1, string-width@^5.1.2:
   version "5.1.2"
   resolved "https://registry.npmmirror.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794"
@@ -18663,7 +18659,7 @@ stringify-entities@^1.0.1:
     is-alphanumerical "^1.0.0"
     is-hexadecimal "^1.0.0"
 
-"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
+"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
   version "6.0.1"
   resolved "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
   integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -18691,13 +18687,6 @@ strip-ansi@^5.0.0, strip-ansi@^5.2.0:
   dependencies:
     ansi-regex "^4.1.0"
 
-strip-ansi@^6.0.0, strip-ansi@^6.0.1:
-  version "6.0.1"
-  resolved "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
-  integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
-  dependencies:
-    ansi-regex "^5.0.1"
-
 strip-ansi@^7.0.1:
   version "7.1.0"
   resolved "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
@@ -20586,7 +20575,7 @@ wonka@^6.3.2:
   resolved "https://registry.npmmirror.com/wonka/-/wonka-6.3.4.tgz#76eb9316e3d67d7febf4945202b5bdb2db534594"
   integrity sha512-CjpbqNtBGNAeyNS/9W6q3kSkKE52+FjIj7AkFlLr11s/VWGUu6a2CdYSdGxocIhIVjaW/zchesBQUKPVU69Cqg==
 
-"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
+"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
   version "7.0.0"
   resolved "https://registry.npmmirror.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
   integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
@@ -20604,15 +20593,6 @@ wrap-ansi@^6.0.1, wrap-ansi@^6.2.0:
     string-width "^4.1.0"
     strip-ansi "^6.0.0"
 
-wrap-ansi@^7.0.0:
-  version "7.0.0"
-  resolved "https://registry.npmmirror.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
-  integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
-  dependencies:
-    ansi-styles "^4.0.0"
-    string-width "^4.1.0"
-    strip-ansi "^6.0.0"
-
 wrap-ansi@^8.1.0:
   version "8.1.0"
   resolved "https://registry.npmmirror.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff