import { Image, ImageSourcePropType, ImageURISource, StyleSheet, View } from "react-native"; import { useIOTheme } from "../../context"; import { IOSelectionListItemVisualParams, IOSpacer } from "../../core"; import { IOButton } from "../buttons"; import { HStack, VStack } from "../layout"; import { IOLogoPaymentType, LogoPayment } from "../logos"; import { IOSkeleton } from "../skeleton"; import { BodySmall, H6 } from "../typography"; import { ModuleStatic } from "./ModuleStatic"; import { PressableModuleBase } from "./PressableModuleBase"; type LoadingProps = { isLoading: true; loadingAccessibilityLabel?: string; }; type ImageProps = | { paymentLogo: IOLogoPaymentType; image?: never } | { paymentLogo?: never; image: ImageURISource | ImageSourcePropType } | { paymentLogo?: never; image?: never }; type BaseProps = { isLoading?: false; paymentLogo?: IOLogoPaymentType; title: string; subtitle?: string; ctaText?: string; onPress: () => void; } & ImageProps; export type ModuleCheckoutProps = LoadingProps | BaseProps; const IMAGE_MARGIN: IOSpacer = 12; const ModuleBaseContent = ({ paymentLogo, image, title, subtitle }: Pick & Pick) => { const theme = useIOTheme(); return ( {/* Graphical elements */} {paymentLogo ? ( ) : ( image && ( ) )}
{title}
{subtitle && ( {subtitle} )}
); }; export const ModuleCheckout = (props: ModuleCheckoutProps) => { if (props.isLoading) { return ( ); } const { paymentLogo, image, title, subtitle, ctaText, onPress } = props; return ctaText ? ( null} /> ) : ( ); }; const ModuleCheckoutSkeleton = ({ loadingAccessibilityLabel }: Pick) => ( } endBlock={ } /> ); const styles = StyleSheet.create({ image: { width: IOSelectionListItemVisualParams.iconSize, height: IOSelectionListItemVisualParams.iconSize, resizeMode: "contain" } });