viettel-ekyc-sdk
Version:
71 lines • 3.32 kB
JavaScript
import React, { useEffect, useRef, useState } from 'react';
import { Image, StyleSheet, View } from 'react-native';
import Carousel from 'react-native-snap-carousel';
import { InfoCardFlatList } from '../components/InfoCardFlatList';
import { ListTitle } from '../components/ListTitle';
import { SizedBox } from '../components/SizedBox';
import { OS } from '../constants/OS';
import navigator from '../navigation/navigator';
export const ResultScreen = (props) => {
var _a;
const params = navigator.getParam('params', (_a = props === null || props === void 0 ? void 0 : props.route) === null || _a === void 0 ? void 0 : _a.params);
const { card, faceMatching, headerComponent } = params;
const [carouselData, setCarouselData] = useState([]);
useEffect(() => {
let data = [];
if (card.frontImage) {
data.push({
type: 'front',
imageUri: card.frontImage,
});
}
if (card.backImage) {
data.push({
type: 'back',
imageUri: card.backImage,
});
}
setCarouselData(data);
}, [card]);
const carouselRef = useRef(undefined);
const renderItem = ({ item, index, }) => {
return (React.createElement(View, { style: styles.slideItemContainer, key: 'carousel_' + index },
React.createElement(Image, { source: { uri: item.imageUri }, style: styles.slideImage, resizeMode: 'contain' })));
};
return (React.createElement(View, { style: styles.mainContainer },
headerComponent !== undefined ? headerComponent() : null,
headerComponent !== undefined ? (React.createElement(SizedBox, { width: 0, height: 20 })) : null,
React.createElement(Carousel, { ref: carouselRef, data: carouselData, renderItem: ({ item, index }) => renderItem({ item, index }), sliderWidth: OS.WIDTH - 30, itemWidth: OS.WIDTH - 30, slideStyle: styles.carouselSlideStyle, containerCustomStyle: styles.carousel }),
React.createElement(SizedBox, { width: 0, height: 10 }),
(faceMatching === null || faceMatching === void 0 ? void 0 : faceMatching.faceImage) ? (React.createElement(ListTitle, { avatar: faceMatching === null || faceMatching === void 0 ? void 0 : faceMatching.faceImage, title: (faceMatching === null || faceMatching === void 0 ? void 0 : faceMatching.isMatching)
? 'Xác thực thành công'
: 'Xác thực không thành công', isActive: faceMatching === null || faceMatching === void 0 ? void 0 : faceMatching.isMatching })) : (React.createElement(View, null)),
React.createElement(InfoCardFlatList, { cardInfo: card })));
};
const styles = StyleSheet.create({
mainContainer: {
flex: 1,
flexDirection: 'column',
alignContent: 'center',
alignItems: 'center',
justifyContent: 'flex-start',
backgroundColor: 'lightgray',
paddingTop: OS.STATUS_BAR_HEIGHT,
},
carousel: {
marginTop: 10,
height: 400,
},
carouselSlideStyle: {
borderRadius: 20,
overflow: 'hidden',
},
slideItemContainer: {
// borderRadius: 25,
},
slideImage: {
width: OS.WIDTH - 20,
height: '100%',
},
});
//# sourceMappingURL=ResultScreen.js.map