-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate from @uiw/react-native-template 0.1.2 to 1.0.0
- Loading branch information
1 parent
20bf86e
commit 1ada110
Showing
20 changed files
with
286 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,40 @@ | ||
import 'react-native-gesture-handler'; | ||
import React from 'react'; | ||
import { View, StatusBar, StyleSheet } from 'react-native'; | ||
import { StatusBar } from 'react-native'; | ||
import { NavigationContainer } from '@react-navigation/native'; | ||
import { createStackNavigator } from '@react-navigation/stack'; | ||
import { Provider } from 'react-redux'; | ||
import { store } from './models'; | ||
import { Navigation } from './routes/nav'; | ||
import AuthLoadingScreen from './pages/AuthLoading'; | ||
import { stackPageData } from './routes' | ||
|
||
const Stack = createStackNavigator(); | ||
|
||
export default () => { | ||
let [theme] = React.useState('light'); | ||
return ( | ||
<Provider store={store}> | ||
<View style={styles.warpper}> | ||
<StatusBar barStyle="dark-content" /> | ||
<Navigation theme={theme} /> | ||
</View> | ||
<StatusBar barStyle="light-content" /> | ||
<AuthLoadingScreen> | ||
{(token) => ( | ||
<NavigationContainer> | ||
<Stack.Navigator initialRouteName={!!token ? 'Home': 'SignIn'}> | ||
{stackPageData.map((props, index) => { | ||
return ( | ||
<Stack.Screen | ||
key={index} | ||
{...props} | ||
// name="Home" | ||
// options={{ | ||
// header: () => null | ||
// }} | ||
// component={Home} | ||
/> | ||
) | ||
})} | ||
</Stack.Navigator> | ||
</NavigationContainer> | ||
)} | ||
</AuthLoadingScreen> | ||
</Provider> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
warpper: { | ||
flex: 1, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,39 @@ | ||
import AsyncStorage from '@react-native-community/async-storage'; | ||
import { userAuth } from '../services/users'; | ||
import conf from '../config'; | ||
|
||
export default { | ||
state: { | ||
/** | ||
* 验证是否登录 | ||
*/ | ||
authState: false, | ||
token: null, | ||
apihost: null, | ||
}, | ||
reducers: { | ||
update: (state, payload) => ({ ...state, ...payload }), | ||
}, | ||
effects: { | ||
}, | ||
effects: dispatch => ({ | ||
async authToken(_, { global }) { | ||
|
||
let host = await AsyncStorage.getItem('apihost'); | ||
if (!host && conf.hosts[0]) { | ||
await AsyncStorage.setItem('apihost', JSON.stringify(conf.hosts[0])); | ||
await this.update({ apihost: conf.hosts[0] }); | ||
} | ||
|
||
if (!global.token) { | ||
await AsyncStorage.removeItem('userData'); | ||
await AsyncStorage.removeItem('token'); | ||
} | ||
|
||
const data = await userAuth(); | ||
if (data && data.token) { | ||
await this.update({ authState: true, token: data.token }); | ||
} else { | ||
await this.update({ authState: true, token: null }); | ||
} | ||
} | ||
}), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,25 @@ | ||
import React from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { View, Text } from 'react-native'; | ||
import { Button } from '@uiw/react-native'; | ||
import { StatusBar } from 'react-native'; | ||
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'; | ||
import homeTabData from '../../routes/homeTab'; | ||
|
||
const BottomTabs = createBottomTabNavigator(); | ||
|
||
class DashboardScreen extends React.Component { | ||
render() { | ||
const { loading } = this.props; | ||
return ( | ||
<View> | ||
<Text>This Home Page.</Text> | ||
<Button loading={loading.logout} disabled={loading.logout} type="danger" onPress={this.props.logout}> | ||
Logout | ||
</Button> | ||
</View> | ||
<React.Fragment> | ||
<StatusBar barStyle="dark-content" /> | ||
<BottomTabs.Navigator> | ||
{homeTabData.map((props, idx) => { | ||
return ( | ||
<BottomTabs.Screen key={idx} {...props} /> | ||
) | ||
})} | ||
</BottomTabs.Navigator> | ||
</React.Fragment> | ||
); | ||
} | ||
} | ||
|
||
export default connect( | ||
({ loading, users }) => ({ | ||
loading: loading.effects.users, | ||
}), | ||
({ users }) => ({ | ||
update: users.update, | ||
logout: users.logout, | ||
}), | ||
)(DashboardScreen); | ||
export default DashboardScreen; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React, { Component } from 'react'; | ||
import { View, Text, SafeAreaView } from 'react-native'; | ||
|
||
export default class MyScreen extends Component { | ||
render() { | ||
return ( | ||
<SafeAreaView> | ||
<View> | ||
<Text>设置</Text> | ||
</View> | ||
</SafeAreaView> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React, { Component } from 'react'; | ||
import { View, Text, SafeAreaView } from 'react-native'; | ||
import { Button, List, Icon } from '@uiw/react-native'; | ||
|
||
export default class MyScreen extends Component { | ||
render() { | ||
const { navigation } = this.props; | ||
return ( | ||
<SafeAreaView style={{flex:1}}> | ||
<View style={{flex:1}}> | ||
<List | ||
flat={true} | ||
data={[ | ||
{ title: '企业开票' }, | ||
{ title: '我的熟车' }, | ||
{ title: '设置' }, | ||
{ title: '退出登录', onPress: () => navigation.replace('SignIn') }, | ||
]} | ||
renderItem={({ item, index }) => { | ||
return ( | ||
<List.Item | ||
key={index} | ||
extra={<Icon name="right" fill="#abb0b5" size={14} />} | ||
size="large" | ||
paddingLeft={15} | ||
style={{ borderBottomWidth: 0, }} | ||
onPress={item.onPress || null} | ||
> | ||
<View> | ||
<Text>{item.title}</Text> | ||
</View> | ||
</List.Item> | ||
) | ||
}} | ||
/> | ||
</View> | ||
</SafeAreaView> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React, { Component } from 'react'; | ||
import { View, Text, SafeAreaView } from 'react-native'; | ||
|
||
export default class MyScreen extends Component { | ||
render() { | ||
return ( | ||
<SafeAreaView> | ||
<View> | ||
<Text>订单首页</Text> | ||
</View> | ||
</SafeAreaView> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React, { Component } from 'react'; | ||
import { View, Text, SafeAreaView } from 'react-native'; | ||
|
||
export default class MyScreen extends Component { | ||
render() { | ||
return ( | ||
<SafeAreaView> | ||
<View> | ||
<Text>发货首页</Text> | ||
</View> | ||
</SafeAreaView> | ||
); | ||
} | ||
} |
Oops, something went wrong.