Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 KB | None | 0 0
  1. import React, { Component } from "react";
  2. import { View, Platform, AsyncStorage } from "react-native";
  3. import BannersComponent from '../../components/banners/BannersComponent';
  4. import QuickViewComponent from '../../components/quick-view/QuickViewComponent';
  5. import ActionScreensListComponent from '../../components/action-screens-list/ActionScreensListComponent';
  6. import { styles } from './LobbyContainer.styles';
  7. import TouchID from 'react-native-touch-id'
  8. import { LobbyActions } from './LobbyActions';
  9. import * as Keychain from 'react-native-keychain';
  10. import Interactable from 'react-native-interactable';
  11. import { QuickView, Lobby } from '../../mocks/mocks';
  12. import { connect } from 'remx';
  13. import { store } from '../../store/store';
  14.  
  15. class LobbyContainer extends Component {
  16. static navigatorButtons = {
  17. rightButtons: [
  18. {
  19. id: 'sideMenu',
  20. component: 'rightButton'
  21. }
  22. ]
  23. };
  24. constructor(props) {
  25. super(props);
  26. this.optionalConfigObject = {
  27. title: "Authentication Required",
  28. color: "#e00607"
  29. }
  30. this.state = {
  31. isBiometry: false
  32. }
  33.  
  34. this.checkIfBiometrySupported();
  35. this._deltaY = 0;
  36. }
  37.  
  38.  
  39. checkIfBiometrySupported() {
  40. TouchID.isSupported().then(
  41. biometryType => {
  42. this.setState({
  43. isBiometry: true
  44. });
  45. })
  46. .catch(error => {
  47. console.log('biometry is not supported. with error: ', error);
  48. });
  49. }
  50.  
  51. onPressed() {
  52. AsyncStorage.getItem('longToken')
  53. .then(
  54. result => {
  55. if(result) {
  56. if(this.state.isBiometry) {
  57. this.showBiometryModal();
  58. } else {
  59. this.showWebView();
  60. }
  61. } else {
  62. this.pushCalConnect()
  63. }
  64. })
  65. .catch(
  66. error => {
  67. console.log("Async storage get from on press error: ", error);
  68. this.pushCalConnect();
  69. });
  70. }
  71.  
  72. showBiometryModal() {
  73. TouchID.authenticate('', this.optionalConfigObject)
  74. .then(success => {
  75. this.showWebView();
  76. })
  77. .catch(error => {
  78. console.log("error: ", error);
  79. this.showWebView();
  80. });
  81. }
  82.  
  83. pushCalConnect() {
  84. this.props.navigator.push({
  85. screen: "cal4u.CalConnect",
  86. title: "התחברות",
  87. navigatorButtons: {
  88. rightButtons: [
  89. {
  90. id: 'menu',
  91. component: 'rightButton',
  92. passProps: {
  93. navigator: this.props.navigator
  94. }
  95. },
  96. ]
  97. },
  98. passProps: {
  99. isRemember: this.state.isBiometry
  100. }
  101. });
  102. }
  103.  
  104. showWebView() {
  105. this.props.navigator.push({
  106. screen: "cal4u.WebView",
  107. title: "עמוד הלוואות",
  108. navigatorButtons: {
  109. rightButtons: [
  110. {
  111. id: 'menu',
  112. component: 'rightButton',
  113. passProps: {
  114. navigator: this.props.navigator
  115. }
  116. },
  117. ]
  118. }
  119. });
  120. }
  121.  
  122. presentNewScreens() {
  123. this.props.navigator.push({
  124. screen: "cal4u.ScrollMenu",
  125. title: "הארנק שלי",
  126. navigatorButtons: {
  127. rightButtons: [
  128. {
  129. id: 'menu',
  130. component: 'rightButton',
  131. passProps: {
  132. navigator: this.props.navigator
  133. }
  134. },
  135. ]
  136. }
  137. });
  138. }
  139.  
  140. render() {
  141. return (
  142. <View style={styles.container}>
  143.  
  144. <View style={styles.bannersContainer}>
  145. <BannersComponent
  146. items={Lobby.banners}
  147. isAutoplay={true}
  148. />
  149. </View>
  150.  
  151. <View style={styles.screensListContainer}>
  152. <ActionScreensListComponent
  153. onPress={() => this.onPressed()}
  154. onPressNewFlow={() => this.presentNewScreens()}
  155. />
  156. </View>
  157.  
  158. <QuickViewComponent
  159. items={QuickView.cards}
  160. />
  161.  
  162. </View>
  163. );
  164. }
  165. }
  166.  
  167. function mapStateToProps(ownProps) {
  168. return {
  169. isLogged: store.getters.getIsLogged()
  170. };
  171. }
  172.  
  173. export default connect(mapStateToProps)(LobbyContainer);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement