import { FlipColors } from "@flip.id/ui-kit"; import { F2Text, F2Touchable } from "../../../Flip2/components"; import { AppUtils } from "../../../Flip2/utils"; import React, { useCallback, useMemo } from "react"; import { Platform, // TouchableNativeFeedback, View, } from "react-native"; import { DeleteNumpad } from "../../../../icons/function"; import { DirectionRight } from "../../../../icons/navigation"; import { EnhancedTouchableOpacity } from "../../EnhancedTouchableOpacity"; import { StyleUtils } from "../../../Flip2/utils"; interface IKeypad { text: string; w: number; h?: string; as?: React.ComponentType; onPress?: (text: string) => void; accessibilityLabel?: string; testID?: string; disabled?: boolean; } const KeyPad: React.FC = (props) => { const { w, as, onPress, text, accessibilityLabel, testID, disabled } = props; const isSmallScreenHeight = StyleUtils.getScreenHeight() <= StyleUtils.IPHONE_7_HEIGHT; const defaultHeight = isSmallScreenHeight ? 46 : 52; const isSubmitKey = text === "submit"; const isDeleteKey = text === "delete"; const onPressKeypad = useCallback(() => { onPress?.(text); }, [onPress, text]); if (as) { return ( {isSubmitKey && } {isDeleteKey && } {!isSubmitKey && !isDeleteKey && } ); } const nativeProps = useMemo(() => { if (AppUtils.isAndroid() || AppUtils.isIOS()) { const { TouchableNativeFeedback } = require("react-native"); return { background: TouchableNativeFeedback.Ripple( FlipColors.neutral.Container, false ), }; } return {}; }, []); return ( {isSubmitKey && } {isDeleteKey && } {!isSubmitKey && !isDeleteKey && } ); }; export default React.memo(KeyPad); type INumberText = { text: string; }; const NumberText = React.memo(({ text }: INumberText) => ( {text} ));