import { useContext, useEffect, useState } from "react"; import { FlatList, Keyboard, Platform, StyleSheet, View } from "react-native"; import { Actions, DispatchContext, StateContext } from "../context/state"; // import { isAndroid } from "../util/helpers"; import { PaymentType } from "../util/types"; import { responsiveScale } from "../theme/scalling"; import Loader from "./Loader"; import PillContainer from "./PillContainer"; import CardSection from "./sections/CardSection"; import KonbiniSection from "./sections/KonbiniSection"; import PaidyFormSection from "./sections/PaidyFormSection"; import SheetFooter from "./sections/SheetFooter"; import SimpleRedirectSection from "./sections/SimpleRedirectSection"; import SingleInputFormSection from "./sections/SingleInputFormSection"; import TransferFormSection from "./sections/TransferFormSection"; const SheetContent = () => { const { paymentType, loading } = useContext(StateContext); const dispatch = useContext(DispatchContext); const [keyboardHeight, setKeyboardHeight] = useState(0); useEffect(() => { const keyboardDidShowListener = Keyboard.addListener( "keyboardDidShow", (e) => setKeyboardHeight(e.endCoordinates.height) ); const keyboardDidHideListener = Keyboard.addListener( "keyboardDidHide", () => setKeyboardHeight(0) ); return () => { keyboardDidShowListener.remove(); keyboardDidHideListener.remove(); }; }, []); const handlePillSelect = (type: PaymentType) => { dispatch({ type: Actions.SET_PAYMENT_OPTION, payload: type }); }; const getBaseScreenByPaymentType = (paymentType: PaymentType) => { switch (paymentType) { case PaymentType.CREDIT: return ; case PaymentType.ALI_PAY: case PaymentType.AU_PAY: case PaymentType.PAY_PAY: case PaymentType.LINE_PAY: case PaymentType.MER_PAY: case PaymentType.RAKUTEN: return ; case PaymentType.NET_CASH: case PaymentType.BIT_CASH: case PaymentType.WEB_MONEY: return ; case PaymentType.BANK_TRANSFER: case PaymentType.PAY_EASY: return ; case PaymentType.KONBINI: return ; case PaymentType.PAIDY: return ; default: return; } }; const renderItem = () => { return ( {loading?.app ? ( ) : ( <> {getBaseScreenByPaymentType(paymentType)} )} ); }; return ( item.key} contentContainerStyle={[ styles.flatListContent, { paddingBottom: keyboardHeight }, ]} ListFooterComponent={ <> } ListFooterComponentStyle={styles.footerContent} keyboardShouldPersistTaps="handled" /> ); }; const styles = StyleSheet.create({ mainContent: { flex: 1, }, flatListContent: { flexGrow: 1, }, item: { height: "100%", }, footerSpace: { flex: 1, }, footerContent: { ...Platform.select({ ios: { marginBottom: responsiveScale(100), marginTop: -responsiveScale(60), }, android: { marginBottom: responsiveScale(100), marginTop: -responsiveScale(60), }, }), }, }); export default SheetContent;