vbea 2 éve
szülő
commit
6fe507d6d0
2 módosított fájl, 16 hozzáadás és 10 törlés
  1. 10 5
      Strides-APP/app/components/Toolbar.js
  2. 6 5
      Strides-APP/app/pages/Router.js

+ 10 - 5
Strides-APP/app/components/Toolbar.js

@@ -2,21 +2,26 @@ import React from 'react';
 import { Image, Pressable, StyleSheet, View } from 'react-native';
 import TopChargeBackground from '../icons/TopChargeBackground';
 
-export const BackButton = () => {
+export const BackButton = ({color=pageTitleTint}) => {
   return (
     <Pressable
-      style={Styles.backIcon}
+      style={({pressed }) => [
+        (pressed && isIOS) && {
+          opacity: 0.7
+        },
+        Styles.backIcon
+      ]}
       android_ripple = {rippleLessIcon}
       onPress={() => {
         goBack();
       }}>
-      <BackIcon/>
+      <BackIcon color={color}/>
     </Pressable>
   )
 }
 
-export const BackIcon = () => {
-  return <MaterialIcons name={isIOS ? 'arrow-back-ios' : 'arrow-back'} size={24} color={colorDark} />
+export const BackIcon = ({color=pageTitleTint}) => {
+  return <MaterialIcons name={isIOS ? 'arrow-back-ios' : 'arrow-back'} size={24} color={color} />
 }
 
 export const StationBack = ({bottom = 24, scale=1.0}) => {

+ 6 - 5
Strides-APP/app/pages/Router.js

@@ -7,7 +7,7 @@ import { Pressable } from 'react-native';
 import { NavigationContainer } from '@react-navigation/native';
 import { createStackNavigator, TransitionPresets } from '@react-navigation/stack';
 import { enableScreens } from 'react-native-screens';
-import { Styles } from '../components/Toolbar';
+import { BackButton, Styles } from '../components/Toolbar';
 import app from '../../app.json';
 import About from './about/About';
 import Launcher from './Launch';
@@ -372,6 +372,7 @@ const Title = (title, opt = {}, titleScope) => {
   } else {
     options.title = title
   }
+  options.headerLeft = () => <BackButton/>
   return options;
 }
 
@@ -406,14 +407,14 @@ const Router = () => {
   useEffect(() => {
     //注入全局方法
     global.startPage = (name, params = {}) => {
-      navigation.current.navigate(name, params);
+      navigation.current?.navigate(name, params);
     }
     global.dispatchPage = (params) => {
-      navigation.current.dispatch(params);
+      navigation.current?.dispatch(params);
     }
     global.goBack = () => {
-      if (navigation.current.canGoBack()) {
-        navigation.current.goBack();
+      if (navigation.current?.canGoBack()) {
+        navigation.current?.goBack();
       } else {
         startPage(PageList.home);
       }