import React, { useContext, useRef, useState } from 'react'; import { Dimensions, ScrollView, StyleSheet, TouchableOpacity, View, } from 'react-native'; import { ApplicationContext, MiniAppContext } from '../Context'; import { Button } from '../Button'; import { Colors, Radius, Spacing, Styles } from '../Consts'; import { Icon } from '../Icon'; import { Image } from '../Image'; import { Text, useScaleSize } from '../Text'; import { PopupNotifyProps } from './types'; import { runOnJS } from 'react-native-reanimated'; const PopupNotify: React.FC = ({ image, title = 'Title', description = 'Description', error, secondary, primary, buttonDirection = 'row', onIconClose, onRequestClose, }) => { const context = useContext(MiniAppContext); const { theme, navigator, translate } = useContext(ApplicationContext); const [scrollContent, setScrollContent] = useState(false); const { width: widthDevice } = Dimensions.get('window'); const scaledMaxHeight = useScaleSize(172); const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false; const closeAction = useRef('touch_outside'); let descriptionStyle = {}; let Description: any = View; if (scrollContent) { Description = ScrollView; descriptionStyle = { maxHeight: scaledMaxHeight }; } /** * on action popup * @param callback */ const onAction = (callback?: () => void) => { if (typeof onRequestClose === 'function') { onRequestClose?.(callback); } else { navigator?.pop(); runOnJS(() => callback?.())(); } }; /** * build main action of popup */ const buildAction = () => { const renderRow = () => { return ( {!!secondary?.title && ( <>