leon 1 gadu atpakaļ
vecāks
revīzija
0629af2a51

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
android/app/src/main/assets/index.android.bundle


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 0
android/app/src/main/assets/index.android.map


+ 13 - 2
android/app/src/main/java/com/hola/MainActivity.java

@@ -24,6 +24,7 @@ import android.os.Bundle;
 import android.os.Handler;
 import android.os.SystemClock;
 import android.util.Log;
+import android.view.View;
 import android.widget.Toast;
 
 import androidx.annotation.NonNull;
@@ -87,6 +88,7 @@ public class MainActivity extends ReactActivity {
   protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(null);
     checkNotification(getIntent());
+
 //    demo2();
 //      try {
 //          demo();
@@ -218,10 +220,19 @@ public class MainActivity extends ReactActivity {
     @Override
     protected ReactRootView createRootView() {
       ReactRootView reactRootView = new ReactRootView(getContext());
-      reactRootView.setBackgroundColor(Color.rgb(0,0,0));
+      reactRootView.setBackgroundColor(Color.rgb(255,255,255));
       // If you opted-in for the New Architecture, we enable the Fabric Renderer.
       reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
-
+//      getWindow().getDecorView().setBackgroundColor(Color.rgb(255,255,255));
+//      getWindow().setNavigationBarColor(Color.rgb(255,255,255));
+      View decorView = getWindow().getDecorView();
+// Hide both the navigation bar and the status bar.
+// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
+// a general rule, you should design your app to hide the status bar whenever you
+// hide the navigation bar.
+      int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
+      decorView.setSystemUiVisibility(uiOptions);
+//      getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
 //      Intent intent = new Intent(getContext(), AlarmService.class);
 //      intent.putExtra("title", "My Notification");
 //      intent.putExtra("message", "This is a scheduled local notification.");

+ 2 - 2
android/build.gradle

@@ -3,9 +3,9 @@
 buildscript {
     ext {
         buildToolsVersion = "31.0.0"
-        minSdkVersion = 24
+        minSdkVersion = 21
         compileSdkVersion = 33
-        targetSdkVersion = 35
+        targetSdkVersion = 33
 //        compileSdkVersion = 33
 //        targetSdkVersion = 26
 

+ 3 - 0
src/app.tsx

@@ -8,6 +8,7 @@ import GlobalModal from './components/layout/GlobalModal'
 import Taro from '@tarojs/taro'
 import { getInfoSuccess } from './store/user'
 import { uploadLocalPushInfo } from './features/trackTimeDuration/actions/TrackTimeActions'
+import { kIsAndroid } from './utils/tools'
 
 
 // import { StatusBar } from 'react-native'
@@ -19,10 +20,12 @@ import { uploadLocalPushInfo } from './features/trackTimeDuration/actions/TrackT
 let LogBox;
 let StatusBar;
 let ActionSheetProvider;
+let SafeAreaView;
 let messaging;
 if (process.env.TARO_ENV == 'rn') {
   LogBox = require("react-native").LogBox
   StatusBar = require("react-native").StatusBar
+  SafeAreaView = require("react-native").SafeAreaView
   ActionSheetProvider = require('@expo/react-native-action-sheet').ActionSheetProvider
   messaging = require('@react-native-firebase/messaging').default
 }

+ 96 - 78
src/app/time_of_day/index_time.tsx

@@ -13,10 +13,11 @@ import Taro from "@tarojs/taro";
 import { useTranslation } from "react-i18next";
 import 'dayjs/locale/zh-cn';
 import 'dayjs/locale/en';
+import momentT from 'moment';
 
 import { getTimezone, getTimezoneName } from "@/utils/tools";
 
-import { AppState } from "react-native";
+import { AppState, SafeAreaView } from "react-native";
 // import 'moment/locale/en';
 
 
@@ -49,18 +50,18 @@ export default function IndexTimePage() {
         setInterval(() => {
             setCount(t => t + 1)
             const now = new Date()
-            const seconds = now.getHours()*3600+now.getMinutes()*60+now.getSeconds()
-            if (current && current.time && current.time.timezone.use_dst){
-                if (current.time_changes && current.time_changes.length>1){
+            const seconds = now.getHours() * 3600 + now.getMinutes() * 60 + now.getSeconds()
+            if (current && current.time && current.time.timezone.use_dst) {
+                if (current.time_changes && current.time_changes.length > 1) {
                     const date = new Date(current.time_changes[1].timestamp)
-                    const seconds2 = date.getHours()*3600+date.getMinutes()*60+date.getSeconds()
-                    if (seconds == seconds2){
+                    const seconds2 = date.getHours() * 3600 + date.getMinutes() * 60 + date.getSeconds()
+                    if (seconds == seconds2) {
                         refresh()
                     }
                 }
             }
-            
-            
+
+
         }, 1000)
     }, [])
 
@@ -96,6 +97,12 @@ export default function IndexTimePage() {
         i18n.changeLanguage(language)
         setIsEn(language == 'en')
         dayjs.locale(language == 'en' ? 'en' : 'zh-cn');
+        require('moment/locale/en-gb')
+        require('moment/locale/zh-cn')
+
+        momentT.locale(language == 'en' ? 'en-gb' : 'zh-cn')
+        moment.defineLocale(language == 'en' ? 'en-gb' : 'zh-cn', (momentT.localeData() as any)._config)
+        moment.locale(language == 'en' ? 'en-gb' : 'zh-cn')
         // moment.locale(language == 'en' ? 'en' : 'zh-cn');
     }
 
@@ -115,6 +122,13 @@ export default function IndexTimePage() {
         Taro.setStorage({ key: 'language', data: isEnglish ? 'en' : 'zh' })
         setShowLanguage(false)
         dayjs.locale(isEnglish ? 'en' : 'zh-cn');
+
+        require('moment/locale/en-gb')
+        require('moment/locale/zh-cn')
+
+        momentT.locale(isEnglish ? 'en-gb' : 'zh-cn')
+        moment.defineLocale(isEnglish ? 'en-gb' : 'zh-cn', (momentT.localeData() as any)._config)
+        moment.locale(isEnglish ? 'en-gb' : 'zh-cn')
         // moment.locale(isEnglish ? 'en' : 'zh-cn');
 
         if (current) {
@@ -199,6 +213,10 @@ export default function IndexTimePage() {
     function changeLocation(location) {
         setCurrent(location)
         Taro.setStorage({ key: 'lastLocation', data: JSON.stringify(location) })
+        chooseLocation({
+            lat: location.geo.lat,
+            lng: location.geo.lng
+        })
     }
 
     function getLocation() {
@@ -209,6 +227,7 @@ export default function IndexTimePage() {
             if (current.geo.country) {
                 return current.geo.country
             }
+            return `${Math.abs(parseInt(current.geo.lat))}°${parseInt(current.geo.lat) < 0 ? 'S' : 'N'} ${Math.abs(parseInt(current.geo.lng))}°${parseInt(current.geo.lng) < 0 ? 'W' : 'E'}`
         }
         return t('time_of_day.index.unknown')
     }
@@ -282,19 +301,13 @@ export default function IndexTimePage() {
     function languageModalContent() {
         return <View className="modal_bg">
             <View className="language_content">
-                <View className="language_item" onClick={() => changeLanguage(true)}>
-                    <Text className="language_text">English</Text>
-                    {
-                        isEn && <Image className="check" src={require('@assets/index_time/check.png')} />
-                    }
-
+                <View className="language_item" onClick={() => changeLanguage(isEn ? true : false)}>
+                    <Text className="language_text">{isEn ? 'English' : '中文'}</Text>
+                    <Image className="check" src={require('@assets/index_time/check.png')} />
                 </View>
                 <View className="line" />
-                <View className="language_item" onClick={() => changeLanguage(false)}>
-                    <Text className="language_text">中文</Text>
-                    {
-                        !isEn && <Image className="check" src={require('@assets/index_time/check.png')} />
-                    }
+                <View className="language_item" onClick={() => changeLanguage(isEn ? false : true)}>
+                    <Text className="language_text">{!isEn ? 'English' : '中文'}</Text>
                 </View>
             </View>
         </View>
@@ -375,72 +388,77 @@ export default function IndexTimePage() {
         </View>
     }
 
-    return <View className="page_container">
-        <View style={{ position: 'relative' }}>
-            {
-                ring()
-            }
-            <View className="ring_center">
-                <Image className="sun" src={isNight() ? require('@assets/index_time/moon.png') : require('@assets/index_time/sun.png')} />
-                <Text className="time">{formatTime('HH:mm:ss')}</Text>
-                <Text className="date">{global.language == 'en' ? formatTime('dddd, MMM DD') : formatTime('MMMD dddd')}</Text>
+    function detail() {
+        return <View className="page_container">
+            <View style={{ position: 'relative' }}>
+                {
+                    ring()
+                }
+                <View className="ring_center">
+                    <Image className="sun" src={isNight() ? require('@assets/index_time/moon.png') : require('@assets/index_time/sun.png')} />
+                    <Text className="time">{formatTime('HH:mm:ss')}</Text>
+                    <Text className="date">{global.language == 'en' ? formatTime('dddd, MMM D') : formatTime('MMMD日 dddd')}</Text>
+                </View>
             </View>
-        </View>
 
-        <View className="location">
-            <Image className="location_icon" src={require('@assets/index_time/pin.png')} />
-            <Text className="location_text">{current ? getLocation() : t('time_of_day.index.unknown')}</Text>
-        </View>
+            <View className="location">
+                <Image className="location_icon" src={require('@assets/index_time/pin.png')} />
+                <Text className="location_text">{current ? getLocation() : t('time_of_day.index.unknown')}</Text>
+            </View>
 
-        <View style={{ flexDirection: 'row', marginTop: 10, alignItems: 'center' }} onClick={() => {
-            if (current && current.time && current.time.timezone.use_dst) {
-                setShowDst(true)
-            }
-        }}>
-            <Text className="timezone">{current ? getTimezone1() : getTimezone()}</Text>
-            {
-                current && current.time && current.time.timezone.use_dst && <Image className="location_icon" src={require('@assets/index_time/arrow_right.png')} />
-            }
+            <View style={{ flexDirection: 'row', marginTop: 10, alignItems: 'center' }} onClick={() => {
+                if (current && current.time && current.time.timezone.use_dst) {
+                    setShowDst(true)
+                }
+            }}>
+                <Text className="timezone">{current ? getTimezone1() : getTimezone()}</Text>
+                {
+                    current && current.time && current.time.timezone.use_dst && <Image className="location_icon" src={require('@assets/index_time/arrow_right.png')} />
+                }
 
-        </View>
+            </View>
 
 
-        <View className="btn_bg" onClick={goMap} onLongClick={goRecords}>
-            <Text className="btn_text">{t('time_of_day.index.pick_location')}</Text>
+            <View className="btn_bg" onClick={goMap} onLongClick={goRecords} onLongPress={goRecords} onLongTap={goRecords}>
+                <Text className="btn_text">{!current ? t('time_of_day.index.pick_location') : t('time_of_day.index.change_location')}</Text>
+                {
+                    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>
+                <Image className="footer_icon" src={require('@assets/index_time/arrow.png')} />
+            </View>
             {
-                current && <Image className="more" onClick={goRecords} src={require('@assets/index_time/more.png')} />
+                showLanguage && <Modal
+                    testInfo={null}
+                    themeIsWhite={true}
+                    dismiss={() => {
+                        setShowLanguage(false)
+                    }}
+                    confirm={() => { }}>
+                    {
+                        languageModalContent()
+                    }
+                </Modal>
+            }
+            {
+                showDst && <Modal
+                    testInfo={null}
+                    themeIsWhite={true}
+                    dismiss={() => {
+                        setShowDst(false)
+                    }}
+                    confirm={() => { }}>
+                    {
+                        dstModalContent()
+                    }
+                </Modal>
             }
-
-        </View>
-        <View className="footer" onClick={() => setShowLanguage(true)}>
-            <Text className="footer_text">{isEn ? 'English' : '中文'}</Text>
-            <Image className="footer_icon" src={require('@assets/index_time/arrow.png')} />
         </View>
-        {
-            showLanguage && <Modal
-                testInfo={null}
-                themeIsWhite={true}
-                dismiss={() => {
-                    setShowLanguage(false)
-                }}
-                confirm={() => { }}>
-                {
-                    languageModalContent()
-                }
-            </Modal>
-        }
-        {
-            showDst && <Modal
-                testInfo={null}
-                themeIsWhite={true}
-                dismiss={() => {
-                    setShowDst(false)
-                }}
-                confirm={() => { }}>
-                {
-                    dstModalContent()
-                }
-            </Modal>
-        }
-    </View>
+    }
+
+    return detail()
+
 }

+ 20 - 7
src/app/time_of_day/my_places.tsx

@@ -15,20 +15,30 @@ export default function MyPlacesPage() {
 
     useEffect(() => {
         navigation.setOptions({
-            headerTitle: 'My Places',
+            headerTitle: t('time_of_day.index.my_places'),
         });
         getDatas()
     }, [])
 
     async function getDatas() {
         var strLocation = await getStorage('lastLocation')
+        var temp: any = null
         if (strLocation) {
-            setCurrent(JSON.parse(strLocation))
+            temp = JSON.parse(strLocation)
+            setCurrent(temp)
         }
 
         var locations = await getStorage('locations')
         if (locations) {
-            setList(JSON.parse(locations))
+            var array = JSON.parse(locations)
+            for (var i = 0; i < array.length; i++) {
+                var obj = array[i]
+                if (obj.geo.lat == temp.geo.lat && obj.geo.lng == temp.geo.lng){
+                    array.splice(i,1)
+                }
+            }
+            array.unshift(temp)
+            setList(array)
         }
     }
 
@@ -49,14 +59,17 @@ export default function MyPlacesPage() {
             if (current.geo.country) {
                 return current.geo.country
             }
+            return `${Math.abs(parseInt(current.geo.lat))}°${parseInt(current.geo.lat) < 0 ? 'S' : 'N'} ${Math.abs(parseInt(current.geo.lng))}°${parseInt(current.geo.lng) < 0 ? 'W' : 'E'}`
         }
         return t('time_of_day.index.unknown')
     }
 
     function clearAll() {
         showAlert({
-            title: 'clear',
-            content: 'clear all',
+            title: t('time_of_day.index.clear_title'),
+            content: t('time_of_day.index.clear_content'),
+            cancelText:t('time_of_day.index.clear_cancel'),
+            confirmText:t('time_of_day.index.clear_confirm'),
             showCancel: true,
             confirm: () => {
                 if ((router.params! as any).clearLocation) {
@@ -68,7 +81,7 @@ export default function MyPlacesPage() {
     }
 
     function isChecked(item) {
-        if (current && item.geo.lat == current.geo.lat && item.geo.lng == current.geo.lng){
+        if (current && item.geo.lat == current.geo.lat && item.geo.lng == current.geo.lng) {
             return true
         }
         return false
@@ -106,7 +119,7 @@ export default function MyPlacesPage() {
                         paddingLeft: 50,
                         paddingRight: 50
                     }}>
-                    <Text style={{ color: '#FA5151', fontWeight: 'bold' }}>Clear All</Text>
+                    <Text style={{ color: '#FA5151', fontWeight: 'bold' }}>{t('time_of_day.index.clear_all')}</Text>
                 </View>
             </View>
         </ScrollView>

+ 9 - 1
src/context/locales/en.js

@@ -835,7 +835,15 @@ export default {
             summer_started: 'Summer time started',
             winter_started: 'Winter time started',
             summer_starts: 'Summer time starts',
-            winter_starts: 'Winter time starts'
+            winter_starts: 'Winter time starts',
+            my_places:'My Places',
+            clear_all:'Clear All',
+            choose_location:'Choose Location',
+            done:'Done',
+            clear_title:'Confirmation',
+            clear_content:'Are you sure you want to clear all my places?',
+            clear_cancel:'Cancel',
+            clear_confirm:'Clear All'
         }
     }
 }

+ 10 - 2
src/context/locales/zh.js

@@ -825,14 +825,22 @@ export default {
     time_of_day: {
         index: {
             pick_location: '选择地点',
-            change_location: '选择地点',
+            change_location: '更改地点',
             unknown: '未知',
             last_change: '上次调整',
             next_change: '下次调整',
             summer_started: '夏令时生效',
             winter_started: '冬令时生效',
             summer_starts: '夏令时将生效',
-            winter_starts: '冬令时将生效'
+            winter_starts: '冬令时将生效',
+            my_places: '我的地点',
+            clear_all: '清空',
+            choose_location: '选择位置',
+            done: '确认',
+            clear_title: '确认操作',
+            clear_content: '确定要清空我常用的全部地点吗?',
+            clear_cancel: '取消',
+            clear_confirm: '清空'
         }
     }
 }

+ 20 - 6
src/pages/map/map.tsx

@@ -32,17 +32,21 @@ export default function map() {
             })
         }
         else {
+            setCenterLocation({
+                latitude: 37.4221,
+                longitude: -122.0853
+            })
             // getCurrent()
-            setTimeout(()=>{
-                getCurrent()
-            },100)
+            // setTimeout(()=>{
+            //     getCurrent()
+            // },100)
         }
 
         navigation.setOptions({
-            headerTitle: 'Choose Location',
+            headerTitle: t('time_of_day.index.choose_location'),
             headerRight: () => {
                 return <View>
-                    <Text onClick={confirmChoose} style={{ color: (router.params! as any).source == 'time_of_day'?'#000':'#fff', marginRight: 15 }}>Done</Text>
+                    <Text onClick={confirmChoose} style={{ color: (router.params! as any).source == 'time_of_day'?'#000':'#fff', marginRight: 15 }}>{t('time_of_day.index.done')}</Text>
                 </View>
             }
         });
@@ -135,12 +139,22 @@ export default function map() {
                         Jto.getLocation().then(result => {
                             var res = JSON.parse(result)
                             setCurrent(res)
+                            setCenterLocation(res)
                             location = {
                                 lat: (res as any).latitude, lng: (res as any).longitude
                             }
                             setIsLoading(false)
+                            // showAlert({
+                            //     title: 'location2',
+                            //     content: JSON.stringify(res)
+                            // })
                         }).catch(e => {
                             setIsLoading(false)
+
+                            showAlert({
+                                title: 'location failed',
+                                content: JSON.stringify(e)
+                            })
                         })
                     }
                     else {
@@ -190,7 +204,7 @@ export default function map() {
     return <View style={{ flex: 1 }}>
         <LeafletView
             style={{ flex: 1 }}
-            zoom={10}
+            zoom={12}
             mapCenterPosition={centerPosition()}
             mapMarkers={mapMarkers()}
             onMessageReceived={e => {

+ 2 - 2
src/pages/rn/RNMain.tsx

@@ -89,11 +89,11 @@ export default function RNMain() {
         primary: 'white',
         card: 'white',
         border: 'transparent',
-        background: 'black',
+        background: 'white',
         notification: 'red'
       }
     }}>
-      <StatusBar barStyle='dark-content' backgroundColor="#000" />
+      <StatusBar barStyle='dark-content' backgroundColor="#fff" />
       <Stack.Navigator screenOptions={({ route }) => ({
         headerStyle: {
           backgroundColor: 'white',

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels