Advertisement
Guest User

Untitled

a guest
Jul 11th, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { useState } from 'react';
  2. import { View, StyleSheet, Dimensions, Platform } from 'react-native';
  3. import { Card, Text, List, ListItem, Left, Body, Button, Container } from 'native-base';
  4. import Icon1 from 'react-native-vector-icons/SimpleLineIcons';
  5. import NavigationService from '../components/NavigationService';
  6. import Modal from "react-native-modal";
  7. import RNRestart from 'rn-restart';
  8. import I18n from '../locales';
  9. import { switchLanguage } from '../locales';
  10. import RF from 'react-native-responsive-fontsize';
  11. import { URL } from '../components/url';
  12. import { heightPercentageToDP as hp } from 'react-native-responsive-screen';
  13. import AppHeader from '../components/AppHeader';
  14. var ls = require('react-native-local-storage');
  15. const deviceWidth = Dimensions.get("window").width;
  16. const deviceHeight = Platform.OS === "ios"
  17.     ? Dimensions.get("window").height
  18.     : 2000;
  19. export default function GoBakuCardInfo() {
  20.  
  21.     const [isModalVisible1, setIsModalVisible1] = useState(false);
  22.     const [language, setLanguage] = useState('en');
  23.  
  24.     toggleModal1 = async () => {
  25.         setIsModalVisible1(!isModalVisible1);
  26.         let l = await ls.get('language');
  27.         if (l !== null) {
  28.             setLanguage(l);
  29.         }
  30.     };
  31.  
  32.     onSetLang = async (lang) => {
  33.         setIsModalVisible1(!isModalVisible1);
  34.         ls.save('language', lang);
  35.         let l = await ls.get('language');
  36.         switchLanguage(l, this);
  37.         if (isModalVisible1 === true) {
  38.             RNRestart.Restart();
  39.         }
  40.     };
  41.  
  42.     return (
  43.         <Container>
  44.             <AppHeader title={I18n.t('gobakucardText')} type={'gobakucard'} />
  45.             <View style={styles.viewStyle}>
  46.                 <View style={{ flex: 0.5 }}></View>
  47.                 <View style={styles.listViewStyle}>
  48.                     <List style={styles.listStyle}>
  49.                         <ListItem onPress={() => NavigationService.navigate('InfoDetail', { url: URL + language + '/app-terms-and-conditions/', title: I18n.t('termsText'), anchor: "#"+8414 })} style={styles.listItemStyle} icon noBorder>
  50.                             <Left>
  51.                                 <Icon1 name="credit-card" size={18} />
  52.                             </Left>
  53.                             <Body>
  54.                                 <Text style={styles.textStyle}>{I18n.t('termsText')}</Text>
  55.                             </Body>
  56.                         </ListItem>
  57.                         <ListItem onPress={() => NavigationService.navigate('UsefulInfo', { title: I18n.t('usefulInfoText') })} style={styles.listItemStyle} icon noBorder>
  58.                             <Left>
  59.                                 <Icon1 name="info" size={18} />
  60.                             </Left>
  61.                             <Body>
  62.                                 <Text style={styles.textStyle}>{I18n.t('usefulInfoText')}</Text>
  63.                             </Body>
  64.                         </ListItem>
  65.                         <ListItem onPress={() => NavigationService.navigate('Favourite', { title: I18n.t('favoritesText'), from_page: 'GoBakuCard' })} style={styles.listItemStyle} icon noBorder>
  66.                             <Left>
  67.                                 <Icon1 name="heart" size={18} />
  68.                             </Left>
  69.                             <Body>
  70.                                 <Text style={styles.textStyle}>{I18n.t('favoritesText')}</Text>
  71.                             </Body>
  72.                         </ListItem>
  73.                         <ListItem onPress={() => this.toggleModal1()} style={styles.listItemStyle} icon noBorder>
  74.                             <Left>
  75.                                 <Icon1 name="globe" size={18} />
  76.                             </Left>
  77.                             <Body>
  78.                                 <Text style={styles.textStyle}>{I18n.t('languageText')}</Text>
  79.                             </Body>
  80.                         </ListItem>
  81.                     </List>
  82.                     {(isModalVisible1) ? <Modal
  83.                         style={{ marginTop: hp('30%') }}
  84.                         deviceWidth={deviceWidth}
  85.                         deviceHeight={deviceHeight}
  86.                         backdropColor="#abacac" backdropOpacity={0.90}
  87.                         isVisible={isModalVisible1}
  88.                         onBackdropPress={() => setIsModalVisible1(!isModalVisible1)}>
  89.                         <View style={{ flex: 1 }}>
  90.                             <Card style={styles.modalStyle}>
  91.                                 <List style={styles.languageListStyle}>
  92.                                     <ListItem style={[styles.listItemStyle, { marginTop: 20 }]} noBorder>
  93.                                         {(language === 'en') ? (<Button style={styles.activeBtnStyle} bordered dark block>
  94.                                             <Text>English</Text>
  95.                                         </Button>) : (<Button onPress={() => this.onSetLang('en')} style={styles.deactiveBtnStyle} block>
  96.                                             <Text style={{ color: '#333' }}>English</Text>
  97.                                         </Button>)}
  98.  
  99.                                     </ListItem>
  100.                                     <ListItem style={styles.listItemStyle} noBorder>
  101.                                         {(language === 'ru') ? (<Button style={styles.activeBtnStyle} bordered dark block>
  102.                                             <Text>русский</Text>
  103.                                         </Button>) : (<Button onPress={() => this.onSetLang('ru')} style={styles.deactiveBtnStyle} block>
  104.                                             <Text style={{ color: '#333' }}>русский</Text>
  105.                                         </Button>)}
  106.                                     </ListItem>
  107.                                 </List>
  108.                             </Card>
  109.                         </View>
  110.                     </Modal> : null}
  111.                 </View>
  112.                 <View style={{ flex: 0.5 }}></View>
  113.             </View>
  114.         </Container>
  115.     );
  116.  
  117. }
  118. const styles = StyleSheet.create({
  119.     viewStyle: {
  120.         flex: 1,
  121.         backgroundColor: '#F5F7F6'
  122.     },
  123.     listViewStyle: {
  124.         flex: 2,
  125.         marginLeft: 30,
  126.         marginRight: 30,
  127.         borderRadius: 5,
  128.         backgroundColor: '#fff',
  129.         justifyContent: 'center',
  130.         alignItems: 'center',
  131.         elevation: 4
  132.     },
  133.     modalStyle: {
  134.         borderRadius: 5,
  135.         padding: 30,
  136.         justifyContent: 'center',
  137.         alignItems: 'center'
  138.     },
  139.     listStyle: {
  140.         paddingTop: hp('20%'),
  141.         paddingBottom: hp('20%'),
  142.         marginLeft: 'auto',
  143.         marginRight: 'auto'
  144.     },
  145.     listItemStyle: {
  146.         width: '110%',
  147.         paddingTop: -5
  148.     },
  149.     textStyle: {
  150.         fontSize: RF(2.4),
  151.         paddingLeft: 10
  152.     },
  153.     languageListStyle: {
  154.         justifyContent: 'center',
  155.         alignItems: 'center'
  156.     },
  157.     activeBtnStyle: {
  158.         width: 250,
  159.         borderRadius: 5
  160.     },
  161.     deactiveBtnStyle: {
  162.         backgroundColor: '#fff',
  163.         elevation: 0
  164.     }
  165. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement