ilink-world/screens/wallet/WalletOptionSelect.js

286 lines
11 KiB
JavaScript
Raw Normal View History

2020-06-02 09:05:50 +00:00
import React, { Component } from 'react';
import { StyleSheet, View, Image, StatusBar, Alert, FlatList, TouchableOpacity, ActivityIndicator, Platform, ProgressBarAndroid, Text } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
const route = require('./../../route.json');
let slugify = require('slugify');
import I18n from 'react-native-i18n'
import * as Utils from '../../utils/DeviceUtils';
import { Images } from '../../config/Images';
import { Color } from '../../config/Color';
import { baseUrl } from '../../webservice/IlinkConstants';
import { IlinkEmitter } from "../../utils/events";
import { Provider, Appbar } from 'react-native-paper';
import { readUser } from '../../webservice/AuthApi';
import { FontWeight, Typography } from '../../config/typography';
2020-06-05 16:51:15 +00:00
import LottieView from 'lottie-react-native';
2020-06-09 10:11:19 +00:00
import { isIlinkWorldWallet, optionDepotScreen } from '../../utils/UtilsFunction';
import chunk from 'lodash/chunk';
2020-06-02 09:05:50 +00:00
export default class WalletOptionSelect extends Component {
constructor(props) {
super(props);
IlinkEmitter.on("langueChange", this.updateLangue.bind(this));
this.state = {
options: this.props.navigation.state.params.optionSelect.options,
title: this.props.navigation.state.params.optionSelect.title,
subTitle: this.props.navigation.state.params.optionSelect.subTitle,
hasWallet: this.props.navigation.state.params.hasOwnProperty('wallet')
}
}
static navigationOptions = ({ navigation }) => ({
header: null,
headerMode: 'none',
headerTitle: null,
activeColor: '#f0edf6',
inactiveColor: '#3e2465',
barStyle: { backgroundColor: '#694fad' },
drawerLabel: I18n.t('CREDIT_MANAGE'),
drawerIcon: ({ tintColor }) => (
<Icon
name={'credit-card'}
size={24}
/>)
});
2020-06-09 10:11:19 +00:00
renderItem = (options, isOneElement) => (
isOneElement ?
<>
<View style={[styles.containerTouch]}>
<TouchableOpacity style={styles.contain}
onPress={() => {
/* this.props.navigation.push(options.screen) */
}}
activeOpacity={0.9}>
<Icon name={options.icon}
color={Color.primaryColor}
size={30}
style={styles.imageBanner} />
<View style={[styles.content]}>
<View style={styles.contentTitle}>
<Text style={[Typography.headline, Typography.semibold]}>
{options.title}
</Text>
</View>
</View>
</TouchableOpacity>
</View>
<View style={{ flex: 1 }} />
</> :
<View style={[styles.containerTouch]}>
<TouchableOpacity style={styles.contain}
onPress={() => {
/* this.props.navigation.push(options.screen) */
}}
activeOpacity={0.9}>
<Icon name={options.icon}
color={Color.primaryColor}
size={30}
style={styles.imageBanner} />
<View style={[styles.content]}>
<View style={styles.contentTitle}>
<Text style={[Typography.headline, Typography.semibold]}>
{options.title}
</Text>
</View>
<View style={{ flex: 1 }}>
</View>
</View>
</TouchableOpacity>
</View>
);
2020-06-02 09:05:50 +00:00
updateLangue() {
this.props.navigation.setParams({ name: I18n.t('WALLET') })
this.forceUpdate();
}
render() {
return (
<Provider>
<View style={{ flex: 1 }}>
<StatusBar
backgroundColor={Color.primaryDarkColor}
barStyle="light-content"
translucent={false}
/>
<Appbar.Header dark={true} style={{ backgroundColor: Color.primaryColor }}>
<Appbar.BackAction
onPress={() => { this.props.navigation.pop() }}
/>
<Appbar.Content
title={this.state.title}
subtitle={this.state.subTitle}
/>
</Appbar.Header>
<View style={styles.container}>
2020-06-05 16:51:15 +00:00
2020-06-09 10:11:19 +00:00
<View style={{
justifyContent: 'center',
alignItems: 'center'
}}>
<LottieView
style={styles.lottie}
source={require("./../../datas/json/wallet_with_cash.json")}
autoPlay
loop={false}
/>
</View>
2020-06-05 16:51:15 +00:00
<View style={[styles.checkDefault, { borderBottomColor: Color.borderColor }]}>
<Text
style={[Typography.title3, Typography.semibold]}>
{I18n.t('TRANSACTIONS')}
</Text>
</View>
2020-06-09 10:11:19 +00:00
{
chunk(this.state.options, 2).map((item) => (
<View style={styles.transactionContainer}>
{
item.length === 1 ?
item.map((wallet) => (
this.renderItem(wallet, true)
)) :
item.map((wallet) => (
this.renderItem(wallet, false)
))
}
</View>
))
}
2020-06-05 16:51:15 +00:00
{/* <FlatList
2020-06-02 09:05:50 +00:00
contentContainerStyle={{
paddingHorizontal: 20,
paddingBottom: 10,
}}
data={this.state.options}
keyExtractor={(item, index) => index.toString()}
renderItem={({ item, index }) => (
<TouchableOpacity
style={[styles.item, { borderBottomColor: Color.borderColor }]}
onPress={() => {
if (this.state.hasWallet) {
this.props.navigation.push(item.screen, {
wallet: this.props.navigation.state.params.wallet,
onGoBack: () => this.props.navigation.state.params.onGoBack()
})
} else {
this.props.navigation.push(item.screen)
}
}}>
<View style={{ flexDirection: 'row' }}>
<Icon
name={item.icon}
color={Color.primaryColor}
size={20}
solid
style={{ marginHorizontal: 10 }}
/>
<Text style={[Typography.body1]}>{item.title}</Text>
</View>
<Icon
name="chevron-right"
size={20}
color={Color.primaryColor}
enableRTL={true}
/>
</TouchableOpacity>
)}
2020-06-05 16:51:15 +00:00
/> */}
2020-06-02 09:05:50 +00:00
</View>
</View>
</Provider>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: Color.containerBackgroundColor,
2020-06-05 16:51:15 +00:00
paddingHorizontal: 20,
2020-06-02 09:05:50 +00:00
},
item: {
paddingVertical: 15,
borderBottomWidth: 1,
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center"
2020-06-05 16:51:15 +00:00
},
lottie: {
2020-06-09 10:11:19 +00:00
width: 540,
height: 240
2020-06-05 16:51:15 +00:00
},
checkDefault: {
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
borderBottomWidth: 1,
paddingVertical: 10,
marginTop: 5
},
2020-06-09 10:11:19 +00:00
transactionContainer: {
flexDirection: 'row',
paddingTop: 10,
},
containerTouch: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
shadowColor: Color.borderColor,
borderColor: Color.borderColor,
borderWidth: 0.5,
shadowOffset: { width: 1.5, height: 1.5 },
shadowOpacity: 1.0,
elevation: 5,
borderRadius: 10,
backgroundColor: Color.cardBackgroundColor
},
contain: {
flexDirection: 'row',
justifyContent: 'space-between',
},
imageBanner: {
marginTop: 15,
marginLeft: 5,
width: Utils.scaleWithPixel(30),
height: Utils.scaleWithPixel(30)
},
content: {
height: Utils.scaleWithPixel(60),
paddingHorizontal: 10,
justifyContent: 'space-between',
alignItems: 'flex-start',
flex: 1,
},
contentTitle: {
paddingTop: 12,
}
2020-06-02 09:05:50 +00:00
});