Leon %!s(int64=2) %!d(string=hai) anos
pai
achega
99f4463f0d

+ 3 - 0
src/components/layout/layout.scss

@@ -35,6 +35,9 @@
     margin-right: 46px;
 }
 
+.flex{
+}
+
 .scroll .wx-scroll-view {
     -webkit-overflow-scrolling: auto !important;
 }

+ 51 - 18
src/components/layout/layout.tsx

@@ -4,6 +4,10 @@ import { NaviBarTitleShowType, TemplateType } from "@/utils/types";
 import { useEffect, useState } from "react";
 import Taro, { usePageScroll } from "@tarojs/taro";
 
+let useNavigation;
+if (process.env.TARO_ENV == 'rn') {
+    useNavigation = require("@react-navigation/native").useNavigation
+}
 
 
 
@@ -22,14 +26,26 @@ export default function Layout(props: {
 }) {
     const { children, type, triggered } = props;
     const [showTitle, setShowTitle] = useState(props.titleShowStyle == NaviBarTitleShowType.alwayShow)
+    let navigation;
+    if (useNavigation) {
+        navigation = useNavigation()
+    }
 
     useEffect(() => {
         Taro.setNavigationBarTitle({
             title: showTitle ? props.title ? props.title : '' : ''
         })
+
+        if (navigation) {
+            navigation.setOptions({
+                headerTitle: showTitle ? props.title ? props.title : '' : '',
+            });
+        }
+
     }, [showTitle])
 
     function onScroll(e) {
+        console.log('a')
         if (props.titleShowStyle == NaviBarTitleShowType.scrollToShow) {
             if (e.detail.scrollTop > 70) {
                 setShowTitle(true)
@@ -42,6 +58,7 @@ export default function Layout(props: {
     }
 
     usePageScroll((e) => {
+        console.log('b')
         if (props.titleShowStyle == NaviBarTitleShowType.scrollToShow) {
             if (e.scrollTop > 70) {
                 setShowTitle(true)
@@ -52,6 +69,33 @@ export default function Layout(props: {
         }
     })
 
+    function pageDetail() {
+        return <View>
+            {
+                props.title && <View className="layout_title_view" style={{ backgroundColor: global.isDebug ? 'red' : 'transparent' }}>
+                    {
+                        props.isFastSleepTheme ? <Text className='layout_title fast_sleep_text'
+                            style={{
+                                fontSize: props.secondPage ? 28 : 36
+                            }}
+                        >{props.title}</Text> :
+                            <Text className='layout_title'
+                                style={{
+                                    color: props.titleColor ? props.titleColor : '#fff',
+                                    fontSize: props.secondPage ? 28 : 36
+                                }}
+                            >{props.title}</Text>
+                    }
+
+                </View>
+            }
+            {
+                children
+            }
+            <View style={{ height: 50 }} />
+        </View>
+    }
+
 
     switch (type) {
         case TemplateType.list:
@@ -107,26 +151,15 @@ export default function Layout(props: {
             </ScrollView>
         case TemplateType.flex:
             return <View className='flex'>
-                {
-                    props.title && <View className="layout_title_view" style={{ backgroundColor: global.isDebug ? 'red' : 'transparent' }}>
-                        {
-                            props.isFastSleepTheme ? <Text className='layout_title fast_sleep_text'
-                                style={{
-                                    fontSize: props.secondPage ? 28 : 36
-                                }}
-                            >{props.title}</Text> :
-                                <Text className='layout_title'
-                                    style={{
-                                        color: props.titleColor ? props.titleColor : '#fff',
-                                        fontSize: props.secondPage ? 28 : 36
-                                    }}
-                                >{props.title}</Text>
-                        }
 
-                    </View>
+                {
+                    process.env.TARO_ENV == 'weapp' ? pageDetail() :
+                        <ScrollView onScroll={onScroll}>
+                            {
+                                pageDetail()
+                            }
+                        </ScrollView>
                 }
-                {children}
-                <View style={{ height: 50 }} />
             </View>
         case TemplateType.customHeader:
             return <View className='flex'>

+ 25 - 3
src/features/trackSomething/components/Activity.tsx

@@ -15,6 +15,14 @@ import { uploadSessionKey } from "@/services/common";
 import RequestType, { thirdPartRequest } from "@/services/thirdPartRequest";
 import { NaviBarTitleShowType, TemplateType } from "@/utils/types";
 import { useTranslation } from "react-i18next";
+// import { useNavigation } from "@react-navigation/native";
+
+let useNavigation;
+if (process.env.TARO_ENV=='rn'){
+    useNavigation = require("@react-navigation/native").useNavigation
+}
+
+// 
 
 export default function Component(props: any) {
     const { t } = useTranslation()
@@ -30,7 +38,14 @@ export default function Component(props: any) {
     const [latestRecord, setLatestRecord] = useState(null)
     const [triggered, setTriggered] = useState(true)
     const [showErrorPage, setErrorPage] = useState(false)
+    
     const [count, setCount] = useState(0)
+    let navigation;
+    if (useNavigation){
+        navigation = useNavigation()
+    }
+
+    // const navigation = useNavigation();
     // const [title, setTitle] = useState('打卡')
 
 
@@ -131,9 +146,16 @@ export default function Component(props: any) {
             }
         }
         else {
-            Taro.navigateTo({
-                url: '/pages/account/ChooseAuth'
-            })
+            if (process.env.TARO_ENV == 'weapp') {
+                Taro.navigateTo({
+                    url: '/pages/account/ChooseAuth'
+                })
+            }
+            else {
+                // const navigation = useNavigation()
+                navigation.navigate('ChooseAuth')
+            }
+
         }
     }
 

+ 38 - 31
src/features/trackSomething/components/Metric.tsx

@@ -19,6 +19,11 @@ import Layout from "@/components/layout/layout";
 import { NaviBarTitleShowType, TemplateType } from "@/utils/types";
 import { useTranslation } from "react-i18next";
 
+let useNavigation;
+if (process.env.TARO_ENV == 'rn') {
+    useNavigation = require("@react-navigation/native").useNavigation
+}
+
 export default function Component(props: any) {
     const { t } = useTranslation()
     const user = useSelector((state: any) => state.user);
@@ -40,7 +45,9 @@ export default function Component(props: any) {
     const [setupTime, setSetupTime] = useState(0)
     const [triggered, setTriggered] = useState(true)
     const limitPickerRef = useRef<any>(null);
-    const [count,setCount] = useState(0)
+    const [count, setCount] = useState(0)
+
+
 
 
     //未登录<->已登录 状态切换时,执行一次授权检查
@@ -51,7 +58,7 @@ export default function Component(props: any) {
         const timeUntilMidnight = nextMidnight.getTime() - now.getTime();
 
         setTimeout(() => {
-            setCount(count+1)
+            setCount(count + 1)
         }, timeUntilMidnight);
     }, [user.isLogin])
 
@@ -104,7 +111,7 @@ export default function Component(props: any) {
                 return
             }
             Taro.navigateTo({
-                url: '/pages/common/RecordsHistory?type=metric&refreshList=getCards&code=' + item.code + `&title=${item.name}`+'&themeColor='+item.theme_color
+                url: '/pages/common/RecordsHistory?type=metric&refreshList=getCards&code=' + item.code + `&title=${item.name}` + '&themeColor=' + item.theme_color
             })
         }
         else {
@@ -222,9 +229,9 @@ export default function Component(props: any) {
             })
             setList(list)
 
-            setTimeout(()=>{
-                setCount(count+1)
-            },31000)
+            setTimeout(() => {
+                setCount(count + 1)
+            }, 31000)
             // getCards();
         })
     }
@@ -285,9 +292,9 @@ export default function Component(props: any) {
             setList(JSON.parse(JSON.stringify(list)))
 
             global.postBtnUpdateStatus('idle');
-            setTimeout(()=>{
-                setCount(count+1)
-            },31000)
+            setTimeout(() => {
+                setCount(count + 1)
+            }, 31000)
 
         })
     }
@@ -310,11 +317,11 @@ export default function Component(props: any) {
                         if (item.latest_record) {
                             unit = item.schemas[0].default_unit
                             value = getValues(item.latest_record.items)
-                            desc = TimeFormatter.dateDescription(item.latest_record.timestamp,true)
+                            desc = TimeFormatter.dateDescription(item.latest_record.timestamp, true)
                             showDetail = true
                         }
 
-                        if (!user.isLogin){
+                        if (!user.isLogin) {
                             value = '未登录'
                             desc = '登录后可记录'
                         }
@@ -338,19 +345,19 @@ export default function Component(props: any) {
         </View>
     }
 
-    function detailContent(){
-        if (process.env.TARO_ENV=='rn'){
-            return <ScrollView>
-                {
-                    detail()
-                }
-                <View style={{height:150}}/> 
-            </ScrollView>
-        }
+    function detailContent() {
+        // if (process.env.TARO_ENV=='rn'){
+        //     return <ScrollView>
+        //         {
+        //             detail()
+        //         }
+        //         <View style={{height:150}}/> 
+        //     </ScrollView>
+        // }
         return detail()
     }
 
-    return <View style={{ position:'relative' }}>
+    return <View style={{ position: 'relative' }}>
         <Layout children={showErrorPage ? <NoData refresh={() => { getCards() }} /> : detailContent()}
             title={t('page.metric.title')}
             type={TemplateType.flex}
@@ -419,16 +426,16 @@ export default function Component(props: any) {
                     chooseTime((picker as any).getConfirmData());
                     setIsTimePickerOpen(false);
                 }}>
-                <LimitPickers ref={limitPickerRef} 
-                isRealTime={true} time={time} limit={limit} 
-                title={t('feature.track_something.picker_datetime')}
-                themeColor={(metricItem as any).theme_color}
-                limitDay={limitDay} onCancel={() => { setIsTimePickerOpen(false) }}
-                 onChange={(e) => {
-                    chooseTime(e)
-                    //  pickerConfirm(e)
-                    //  hidePicker()
-                }} />
+                <LimitPickers ref={limitPickerRef}
+                    isRealTime={true} time={time} limit={limit}
+                    title={t('feature.track_something.picker_datetime')}
+                    themeColor={(metricItem as any).theme_color}
+                    limitDay={limitDay} onCancel={() => { setIsTimePickerOpen(false) }}
+                    onChange={(e) => {
+                        chooseTime(e)
+                        //  pickerConfirm(e)
+                        //  hidePicker()
+                    }} />
             </Modal>
         }
     </View>

+ 3 - 1
src/pages/clock/Clock.rn.tsx

@@ -46,7 +46,9 @@ import { ColorType } from '@/context/themes/color'
 
 
 export default function IndexPage() {
-    
+    return <View >
+      <View style={{width:100,height:100,borderWidth:2,borderColor:'pink'}}></View>
+    </View>
   const dispatch = useDispatch();
   const { t } = useTranslation()
   const [checkData, setCheckData] = useState(null)

+ 34 - 13
src/pages/rn/RNMain.tsx

@@ -7,6 +7,7 @@ import Clock from '../clock/Clock'
 import Metric from '../metric/Metric'
 import Activity from '../activity/Activity'
 import Profile from '../account/Profile'
+import ChooseAuth from '@/pages/account/ChooseAuth'
 import { View } from '@tarojs/components';
 
 // 创建底部 Tab 导航器
@@ -49,23 +50,15 @@ const App: React.FC = () => {
 */
 
 export default function RNMain() {
-  return (
-    <NavigationContainer theme={{
-      dark:false,
-      colors:{
-        text:'white',
-        primary:'white',
-        card:'white',
-        border:'white',
-        background:'black',
-        notification:'red'
-      }
-    }}>
+
+  function tabNavigator() {
+    return (
       <Tab.Navigator screenOptions={({ route }) => ({
         headerStyle: {
           backgroundColor: 'black',
+          borderBottomWidth: 0, // 隐藏导航条底部边框
         },
-        headerTintColor:'white',
+        headerTintColor: 'white',
         tabBarStyle: { backgroundColor: 'black' }, // tabbar的背景色
         tabBarActiveTintColor: 'white', // 活动标签的颜色
         tabBarInactiveTintColor: 'gray', // 非活动标签的颜色
@@ -75,6 +68,34 @@ export default function RNMain() {
         <Tab.Screen name="Activity" component={Activity} />
         <Tab.Screen name="Profile" component={Profile} />
       </Tab.Navigator>
+    )
+  }
+  return (
+    <NavigationContainer theme={{
+      dark: false,
+      colors: {
+        text: 'white',
+        primary: 'white',
+        card: 'white',
+        border: 'transparent',
+        background: 'black',
+        notification: 'red'
+      }
+    }}>
+      <Stack.Navigator screenOptions={({ route }) => ({
+        headerStyle: {
+          backgroundColor: 'black',
+          borderBottomWidth: 0, // 隐藏导航条底部边框
+          borderBottomColor:'red'
+        },
+        headerTintColor: 'white',
+        tabBarStyle: { backgroundColor: 'black' }, // tabbar的背景色
+        tabBarActiveTintColor: 'white', // 活动标签的颜色
+        tabBarInactiveTintColor: 'gray', // 非活动标签的颜色
+      })}>
+        <Stack.Screen name='Main' component={tabNavigator} options={{ headerShown: false }}/>
+        <Stack.Screen name='ChooseAuth' component={ChooseAuth} />
+      </Stack.Navigator>
     </NavigationContainer>
   )
 }