Commit 4e8851a4 by 肖亮

feat:更新tabbar及操作退出

parent a7f591d8
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import React, { useEffect, useState } from 'react' import React, { useEffect, useState } from 'react'
import { TextInput, Text, TouchableHighlight, View, NativeModules, StatusBar, Platform } from 'react-native'; import { TextInput, Text, TouchableHighlight, View, NativeModules, StatusBar, Platform } from 'react-native';
import Tabbar from '../../components/Tabbar'; // import Tabbar from '../../components/Tabbar';
import { user as userServices } from '../../services'; import { user as userServices } from '../../services';
import styles from './style'; import styles from './style';
...@@ -24,7 +24,7 @@ const Equipment = () => { ...@@ -24,7 +24,7 @@ const Equipment = () => {
const handleSave = async () => { const handleSave = async () => {
if (/^[\w\d_-]{4,20}$/.test(nickName)) { if (/^[\w\d_-]{4,20}$/.test(nickname)) {
const data = await userServices.setNickName({ nickname }); const data = await userServices.setNickName({ nickname });
BMCUI.show('修改昵称成功!'); BMCUI.show('修改昵称成功!');
exit(); exit();
...@@ -35,7 +35,6 @@ const Equipment = () => { ...@@ -35,7 +35,6 @@ const Equipment = () => {
return ( return (
<View style={styles.container}> <View style={styles.container}>
<Tabbar title="修改昵称" />
<View> <View>
<TextInput <TextInput
style={styles.input} style={styles.input}
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import React, { useEffect, useState } from 'react' import React, { useEffect, useState } from 'react'
import { ScrollView, View, Text, SafeAreaView, NativeModules, FlatList } from 'react-native'; import { ScrollView, View, Text, SafeAreaView, NativeModules, FlatList } from 'react-native';
import Tabbar from '../../components/Tabbar'; // import Tabbar from '../../components/Tabbar';
import { equiment as equimentServices } from '../../services'; import { equiment as equimentServices } from '../../services';
import styles from './style'; import styles from './style';
...@@ -29,7 +29,6 @@ const Equipment = () => { ...@@ -29,7 +29,6 @@ const Equipment = () => {
return ( return (
<SafeAreaView> <SafeAreaView>
<View style={styles.container}> <View style={styles.container}>
<Tabbar title="常用设备" />
<Text style={styles.tip}> <Text style={styles.tip}>
标题文字点击无反馈,文字超长则隐藏,文字超长则隐藏 标题文字点击无反馈,文字超长则隐藏,文字超长则隐藏
</Text> </Text>
......
import React from 'react' import React from 'react'
import { NavigationContainer } from '@react-navigation/native'; import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack'; import { NativeModules } from 'react-native';
import { createStackNavigator, HeaderBackButton } from '@react-navigation/stack';
import Equipment from '../pages/Equipment' import Equipment from '../pages/Equipment'
import ChangeNickname from '../pages/ChangeNickname' import ChangeNickname from '../pages/ChangeNickname'
const Stack = createStackNavigator(); const Stack = createStackNavigator();
const { BMCAction: { exit } } = NativeModules;
const pathMap = { const pathMap = {
'/equiment': 'equiment', '/equiment': 'equiment',
...@@ -13,18 +15,31 @@ const pathMap = { ...@@ -13,18 +15,31 @@ const pathMap = {
function AllStack(props) { function AllStack(props) {
const { path } = props; const { path } = props;
console.log('pathMap[path]', pathMap[path]); const headerLeft = (props) => (
<HeaderBackButton
{...props}
onPress={() => {
exit()
}}
/>
);
return ( return (
<Stack.Navigator initialRouteName={pathMap[path] || 'changeNickname'}> <Stack.Navigator initialRouteName={pathMap[path] || 'changeNickname'}>
<Stack.Screen options={{title: '常用设备'}} name="equiment" component={Equipment} /> <Stack.Screen options={{
<Stack.Screen options={{title: '修改昵称'}} name="changeNickname" component={ChangeNickname} /> title: '常用设备',
headerLeft: headerLeft,
}} name="equiment" component={Equipment} />
<Stack.Screen options={{
title: '修改昵称',
headerLeft: headerLeft,
}} name="changeNickname" component={ChangeNickname} />
</Stack.Navigator> </Stack.Navigator>
); );
} }
export default function App(props) { export default function App(props) {
const { path } = props; const { path } = props;
console.log('path', path);
return ( return (
<NavigationContainer> <NavigationContainer>
<AllStack path={path} /> <AllStack path={path} />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment