Commit 85ec6e8d by Giang Tran

Merge branch 'thuynt_change_bank_view' into '08_April'

fix bug bank dialog

See merge request !3
parents 7e120a1c 966d0e67
......@@ -35,12 +35,12 @@ android_library(
android_build_config(
name = "build_config",
package = "com.invest",
package = "com.dcv.invest",
)
android_resource(
name = "res",
package = "com.invest",
package = "com.dcv.invest",
res = "src/main/res",
)
......
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.invest">
package="com.dcv.invest">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA"/>
......
package com.invest;
package com.dcv.invest;
import android.os.Bundle;
import com.facebook.react.ReactActivity;
import com.zoontek.rnbootsplash.RNBootSplash;
......
package com.invest;
package com.dcv.invest;
import android.app.Application;
import android.content.Context;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.reactnativecommunity.netinfo.NetInfoPackage;
import com.zoontek.rnbootsplash.RNBootSplashPackage;
import com.zoontek.rnbootsplash.RNBootSplashPackage;
import com.BV.LinearGradient.LinearGradientPackage;
import com.oblador.vectoricons.VectorIconsPackage;
import com.oblador.vectoricons.VectorIconsPackage;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import com.facebook.react.ReactApplication; //<- Dòng này
import com.zoontek.rnbootsplash.RNBootSplashPackage;
public class MainApplication extends Application implements ReactApplication {
......@@ -72,7 +66,7 @@ public class MainApplication extends Application implements ReactApplication {
We use reflection here to pick up the class that initializes Flipper,
since Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("com.invest.ReactNativeFlipper");
Class<?> aClass = Class.forName("com.dcv.invest.ReactNativeFlipper");
aClass
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
.invoke(null, context, reactInstanceManager);
......
......@@ -44,7 +44,7 @@
<key>NSCameraUsageDescription</key>
<string>Accect connect camera</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<string/>
<key>NSPhotoLibraryUsageDescription</key>
<string>To upload images</string>
<key>UIAppFonts</key>
......
import React, {useState, useEffect} from 'react';
import React, {useState,useEffect} from 'react';
import {
Text,
View,
......@@ -8,8 +8,6 @@ import {
StyleSheet,
TextInput,
ActivityIndicator,
SafeAreaView,
StatusBar,
} from 'react-native';
import _ from 'lodash';
import AntDesign from 'react-native-vector-icons/AntDesign';
......@@ -23,16 +21,17 @@ import {
} from '../../Config/Functions';
import I18n from '../../helper/i18/i18n';
import ItemBank from './ItemBank';
import {SafeAreaView} from 'react-native-safe-area-context';
const SelectBankModal = (props) => {
console.log(props);
console.log(props)
const [modalVisible, setModalVisible] = useState(false);
const [valueSearch, setValueSearch] = useState('');
const [result, setResult] = useState(props.data);
const [keySearch, setKeySearch] = useState('');
useEffect(() => {
setResult(props.data);
}, [props.data]);
useEffect(()=>{
setResult(props.data)
},[props.data])
const localFilter = (data, allowFields = [], search_text) => {
if (!data) return [];
if (!search_text || search_text === '') return data;
......@@ -45,10 +44,10 @@ const SelectBankModal = (props) => {
let added = false;
allowFields.map((param) => {
if (
!added &&
(item[param + ''] + '')
.toLowerCase()
.includes(search_text.toLowerCase())
!added &&
(item[param + ''] + '')
.toLowerCase()
.includes(search_text.toLowerCase())
) {
result.push(item);
added = true;
......@@ -60,13 +59,16 @@ const SelectBankModal = (props) => {
};
const _onSearch = async (keySearch) => {
const data = props.data
? localFilter(props.data, ['code', 'name'], keySearch).map((x) => ({
id: x.id,
code: x.code,
name: x.name,
logo: x.logo,
}))
: [];
? localFilter(props.data, ['code', 'name'], keySearch)
.map(
(x) => ({
id: x.id,
code: x.code,
name: x.name,
logo: x.logo,
})
)
: [];
// remove duplicate
let result = [];
......@@ -77,119 +79,124 @@ const SelectBankModal = (props) => {
setResult(result);
};
const _onPressItem = (item) => {
console.log('_onPressItem', item);
props.onPressItem(item);
console.log('_onPressItem', item)
props.onPressItem(item)
setValueSearch(item ? item.name : '');
setModalVisible(false);
};
return (
<View>
<TouchableOpacity
style={[styles.buttonShowModal]}
onPress={() => {
setModalVisible(true);
setKeySearch('');
_onSearch(keySearch);
}}>
<View style={styles.flexRowJustifyBetween}>
<Text
style={[styles.txtTitle, {flex: 1, flexWrap: 'wrap'}]}
numberOfLines={1}
ellipsizeMode="tail">
{valueSearch.trim()}
</Text>
<View>
{valueSearch === '' ? (
<TouchableOpacity
onPress={() => {
setModalVisible(true);
_onSearch(keySearch);
}}
hitSlop={{left: WIDTHXD(50), right: WIDTHXD(50)}}>
<AntDesign
name="search1"
size={WIDTHXD(43)}
color={R.colors.iconGray}
/>
</TouchableOpacity>
) : (
<TouchableOpacity
onPress={() => {
_onPressItem(null);
}}
hitSlop={{left: WIDTHXD(50), right: WIDTHXD(50)}}>
<AntDesign
name="close"
size={WIDTHXD(43)}
color={R.colors.iconGray}
/>
</TouchableOpacity>
)}
</View>
</View>
</TouchableOpacity>
<Modal
animated={true}
animationType="fade"
visible={modalVisible}
presentationStyle="pageSheet">
<View style={styles.overViewModal}>
<View style={[styles.container]}>
<View style={styles.viewTitle}>
<Text style={[styles.title]}>{props.title}</Text>
<TouchableOpacity
style={styles.btClose}
onPress={() => setModalVisible(false)}>
<AntDesign
name="close"
size={WIDTHXD(48)}
color={R.colors.black}
/>
</TouchableOpacity>
</View>
<View style={styles.viewContent}>
<View style={styles.inputSearch}>
<TextInput
style={styles.input}
value={keySearch}
placeholder={I18n.t('Search')}
placeholderTextColor={R.colors.color777}
onChangeText={(keySearch) => {
setKeySearch(keySearch);
_onSearch(keySearch);
}}
/>
<AntDesign
name="search1"
size={WIDTHXD(40)}
color={R.colors.gray}
style={{position: 'absolute', left: WIDTHXD(28)}}
/>
</View>
{!_.isEmpty(result) ? (
<View style={styles.viewResult}>
<FlatList
data={result}
extraData={result}
style={styles.flatlist}
renderItem={({item, index}) => (
<ItemBank
item={item}
isEndItem={index == result.length - 1}
onPress={(item) => _onPressItem(item)}
/>
)}
/>
</View>
<View>
<TouchableOpacity
style={[styles.buttonShowModal]}
onPress={() => {
setModalVisible(true);
setKeySearch('');
_onSearch(keySearch);
}}>
<View style={styles.flexRowJustifyBetween}>
<Text
style={[styles.txtTitle, {flex: 1, flexWrap: 'wrap'}]}
numberOfLines={1}
ellipsizeMode="tail">
{valueSearch.trim()}
</Text>
<View>
{valueSearch === '' ? (
<TouchableOpacity
onPress={() => {
setModalVisible(true);
_onSearch(keySearch);
}}
hitSlop={{left: WIDTHXD(50), right: WIDTHXD(50)}}>
<AntDesign
name="search1"
size={WIDTHXD(43)}
color={R.colors.iconGray}
/>
</TouchableOpacity>
) : (
<Text style={styles.txtEmpty}>{I18n.t('NullDataSearch')}</Text>
<TouchableOpacity
onPress={() => {
_onPressItem(null);
}}
hitSlop={{left: WIDTHXD(50), right: WIDTHXD(50)}}>
<AntDesign
name="close"
size={WIDTHXD(43)}
color={R.colors.iconGray}
/>
</TouchableOpacity>
)}
</View>
</View>
</View>
</Modal>
</View>
</TouchableOpacity>
<Modal
animated={true}
animationType="fade"
visible={modalVisible}
>
<SafeAreaView>
<View style={styles.overViewModal}>
<View style={[styles.container]}>
<View style={styles.viewTitle}>
<Text style={[styles.title]}>{props.title}</Text>
<TouchableOpacity
style={styles.btClose}
onPress={() => setModalVisible(false)}>
<AntDesign
name="close"
size={WIDTHXD(48)}
color={R.colors.black}
/>
</TouchableOpacity>
</View>
<View style={styles.viewContent}>
<View style={styles.inputSearch}>
<TextInput
style={styles.input}
value={keySearch}
placeholder={I18n.t('Search')}
placeholderTextColor={R.colors.color777}
onChangeText={(keySearch) => {
setKeySearch(keySearch);
_onSearch(keySearch);
}}
/>
<AntDesign
name="search1"
size={WIDTHXD(40)}
color={R.colors.gray}
style={{position: 'absolute', left: WIDTHXD(28)}}
/>
</View>
{!_.isEmpty(result) ? (
<View style={styles.viewResult}>
<FlatList
data={result}
extraData={result}
style={styles.flatlist}
renderItem={({item, index}) => (
<ItemBank
item={item}
isEndItem = {index == result.length - 1}
onPress={(item) => _onPressItem(item)}
/>
)}
/>
</View>
) : (
<Text style={styles.txtEmpty}>
{I18n.t('NullDataSearch')}
</Text>
)}
</View>
</View>
</View>
</SafeAreaView>
</Modal>
</View>
);
};
......@@ -209,14 +216,14 @@ const styles = StyleSheet.create({
viewTitle: {
width: getWidth(),
height: HEIGHTXD(85),
marginTop: WIDTHXD(90),
marginTop: WIDTHXD(30),
flexDirection: 'row',
justifyContent: 'center',
position: 'relative',
},
txtTitle: {
marginRight: WIDTHXD(24),
color: R.colors.black0,
color: R.colors.black,
fontSize: getFontXD(42),
},
viewContent: {
......@@ -235,7 +242,7 @@ const styles = StyleSheet.create({
},
flatlist: {
width: getWidth(),
marginBottom: HEIGHTXD(250),
marginBottom: HEIGHTXD(300)
},
input: {
height: WIDTHXD(99),
......@@ -281,14 +288,12 @@ const styles = StyleSheet.create({
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
paddingHorizontal: WIDTHXD(24),
paddingHorizontal: WIDTHXD(5),
},
overViewModal: {
height: '100%',
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#rgba(0,0,0,0.7)',
margin: 0,
},
btClose: {
alignSelf: 'center',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment