Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.59 KB | None | 0 0
  1. "native-base": "^2.12.1",
  2. "react": "16.8.3",
  3. "react-native": "0.59.0",
  4. "react-native-router-flux": "^4.0.6",
  5.  
  6. const RouterWithRedux = connect()(Router);
  7.  
  8. class AppNavigator extends Component<{}> {
  9. static propTypes = {
  10. drawerState: PropTypes.string
  11. };
  12.  
  13. componentDidUpdate() {
  14. if (this.props.drawerState === "opened") {
  15. this.drawer._root.open();
  16. }
  17.  
  18. if (this.props.drawerState === "closed") {
  19. this.drawer._root.close();
  20. }
  21. }
  22. openDrawer() {
  23. this.drawer._root.open();
  24. }
  25.  
  26. closeDrawer() {
  27. if (this.props.drawerState === "opened") {
  28. this.props.closeDrawer();
  29. }
  30. //this.drawer._root.close();
  31. }
  32.  
  33. render() {
  34. // eslint-disable-line class-methods-use-thisy
  35. return (
  36. <Drawer ref={(ref) => { this.drawer = ref; }}
  37. content={<SideBar navigator={this.navigator} />}
  38. onClose={() => this.closeDrawer()}
  39. type="overlay"
  40. tapToClose
  41. tweenHandler={ratio => {
  42. //eslint-disable-line
  43. return {
  44. drawer: { shadowRadius: ratio < 0.2 ? ratio * 5 * 5 : 5 },
  45. main: {
  46. opacity: (2 - ratio) / 2
  47. }
  48. };
  49. }}
  50.  
  51. >
  52. <StatusBar
  53. backgroundColor={variables.brandPrimary}
  54. barStyle="light-content"
  55. />
  56. <RouterWithRedux>
  57. <Scene key="root" hideNavBar>
  58. <Scene key="login" component={Login} hideNavBar initial={true} />
  59. <Scene key="signIn" component={SignIn} />
  60. <Scene key="home" component={Home} />
  61. <Scene key="register" component={Register} />
  62. <Scene key="sideBar" component={SideBar} />
  63. </Scene>
  64. </RouterWithRedux>
  65. </Drawer >
  66. );
  67. }
  68. }
  69.  
  70. const bindAction = (dispatch) => {
  71. return {
  72. closeDrawer: () => dispatch(closeDrawer())
  73.  
  74.  
  75. };
  76. };
  77.  
  78. const mapStateToProps = state => ({
  79. drawerState: state.drawer.drawerState
  80. });
  81.  
  82. export default connect(
  83. mapStateToProps,
  84. bindAction
  85. )(AppNavigator);
  86.  
  87. class Login extends Component {
  88. render() {
  89. return (
  90. <View style={{ flex: 1 }}>
  91. <View style={{ padding: 10, marginBottom: 60 }}>
  92. <Grid>
  93. <Col style={{ padding: 10 }}>
  94. <Button
  95. onPress={() => Actions.signIn()}
  96. transparent
  97. block
  98. style={styles.loginBtn}
  99. >
  100. <Text style={{ color: commonColor.brandPrimary, fontWeight: "600" }}>
  101. SIGN IN
  102. </Text>
  103. </Button>
  104. </Col>
  105. <Col style={{ padding: 10 }}>
  106. <Button
  107. onPress={() => Actions.register()}
  108. block
  109. style={styles.registerBtn}
  110. >
  111. <Text style={{ fontWeight: "600", color: "#fff" }}>
  112. REGISTER
  113. </Text>
  114. </Button>
  115. </Col>
  116. </Grid>
  117. </View>
  118. </View>
  119. );
  120. }
  121. }
  122.  
  123. export default connect()(Login);
  124.  
  125. class Home extends Component {
  126. constructor(props) {
  127. super(props);
  128. }
  129.  
  130. render() {
  131. return (
  132. <View style={styles.container}>
  133. <Text>Page under construuction</Text>
  134. <View style={styles.headerContainer}>
  135. <Header
  136. iosStatusbar="default"
  137. style={Platform.OS === "ios" ? styles.iosHeader : styles.aHeader}
  138. androidStatusBarColor={commonColor.statusBarLight}
  139. >
  140. <Left>
  141. <Button transparent onPress={this.props.openDrawer}>
  142. <Icon
  143. name="ios-menu"
  144. style={{ color: commonColor.brandPrimary }}
  145. />
  146. </Button>
  147. </Left>
  148. <Body>
  149. <Title style={{ color: commonColor.brandPrimary, marginTop: -2 }}>
  150. Drawer Demo App
  151. </Title>
  152. </Body>
  153. <Right />
  154. </Header>
  155. </View>
  156. </View>
  157. );
  158. }
  159. }
  160. function bindActions(dispatch) {
  161. return {
  162. openDrawer: () => dispatch(openDrawer())
  163. };
  164. }
  165. const mapStateToProps = state => ({
  166. navigation: state.cardNavigation
  167. });
  168.  
  169. export default connect(
  170. mapStateToProps,
  171. bindActions
  172. )(Home);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement