rn-project
Version:
#### 项目介绍 类似一个脚手架的工具 此项目致力于构建一套基础,简单,可维护的 适配我司的react-native项目。可在此基础上搭建项目,封装了基础架构,基础组件,以及各种交互等;可快速进行项目搭建,开发。 # 涉及主要技术 - 1. 项目主要架构 * react native * react-navigation * redux
74 lines (68 loc) • 1.84 kB
JavaScript
import React, { Component } from 'react';
import { View, Text, StyleSheet, AsyncStorage } from 'react-native';
import PropTypes from 'prop-types';
import { SafeAreaView } from 'react-navigation';
import BaseStyle from '../constants/Style';
import Btn from '../components/buttons';
import DilogModal from '../components/dilogModal';
export default class LoginScreen extends Component {
static propTypes = {
navigation: PropTypes.object,
};
constructor(props) {
super(props);
this.state = {
DilogModal: false,
};
}
handlogin = () => {
this.setState({ DilogModal: true });
};
rightOption_ = () => {
const { navigation } = this.props;
this.setState({ DilogModal: false });
AsyncStorage.multiSet([['token', '123'], ['userId', '123']]);
toast('恭喜您登录成功');
navigation.navigate('Auth');
};
render() {
const {
navigation: { navigate },
} = this.props;
return (
<SafeAreaView style={BaseStyle.flex} forceInset={{ top: 'never' }}>
<DilogModal
DilogModal={this.state.DilogModal}
text={'确定要登录吗?'}
leftOPtion={() => {
this.setState({ DilogModal: false });
}}
rightOption={() => {
this.rightOption_();
}}
/>
<View style={styles.container}>
<Text>你还没有登录</Text>
<Btn
text={'登录'}
btnStyle={styles.btnStyles}
onPress={() => {
this.handlogin();
}}
/>
</View>
</SafeAreaView>
);
}
}
const styles = StyleSheet.create({
container: {
...BaseStyle.flex,
...BaseStyle.alignItemsCenter,
...BaseStyle.justifyContentCenter,
backgroundColor: '#fff',
},
btnStyles: {
marginTop: 40,
},
});