import React, { useCallback, ComponentPropsWithoutRef, ReactNode, useEffect, useMemo, } from 'react' import { View, ViewStyle, ScrollView, Text, Alert, TextStyle as TextStyleType, Keyboard, Platform, TextStyle, } from 'react-native' import Button from 'react-native-paper/lib/module/components/Button' import TextInput from 'react-native-paper/lib/module/components/TextInput/TextInput' import { empty } from '../utils/empty' import { ScreenStyle } from '../style/screen' import { Page } from '../components/Page' import { useTextStyle } from '../hooks/use-style' import { PhoneInput, H1, Paragraph } from '../components' import { CommonScreenProps } from './types' import { ScreenBackground } from '../components/Background' import Animated from 'react-native-reanimated' import { bInterpolate } from 'react-native-redash/lib/module/Animations' import { useTimingTransition } from 'react-native-redash/lib/module/Transitions' import Header from 'react-native-elements/src/header/Header' type Props = CommonScreenProps & { error?: string | null renderError?: ((error: string) => ReactNode) | null /** * Phone number's current state. Used with the `usePhoneNumber` hook. * * To have this logic fully handled for you, see the `AuthFlow component. */ phoneNumber: string /** * Callback function invoked whenever the user types a new phone number. Used with the `usePhoneNumber` hook. * * To have this logic fully handled for you, see the `AuthFlow component. * * @param info * @param info.phoneNumber string that is the current phone number * @param info.valid boolean that tells you if the current phone number is valid or not. If yes, it's ready to send an SMS to. * * To have this logic handled for you, see the `AuthFlow component. */ onChangePhoneNumber: (info: { phoneNumber: string }) => void /** * Callback function called when a user submits their phone number with the send button. Used with the `usePhoneNumber` hook. * * To have this logic fully handled for you, see the `AuthFlow component. * * @param info a dictionary * @param info.phoneNumber the phone number used to submit */ onSubmitPhone: (info: { phoneNumber: string }) => void /** * Boolean to indicate if the text is sending / loading. Button shows loading indicator during this time. */ loading?: boolean /** * Props for the input component. */ inputProps?: Omit, 'style'> /** * Is the current phone number a valid one to send a text to. */ valid?: boolean /** * Props for the scroll view containing the whole screen. For styles, see `containerStyle` */ containerProps?: Omit, 'style'> /** * Style the outer screen. */ containerStyle?: ViewStyle /** * Style the text input. */ inputStyle?: TextStyle /** * The color used for the screens color scheme, such as highlighting the text. This prop is getting phased out, so instead, check out the other style props. */ tintColor?: string /** * Text to show inside the button. Defaults to send. */ buttonText?: string | 'Send' | 'Submit' /** * Props passed onto the react-native-paper button component. */ buttonProps?: Omit< ComponentPropsWithoutRef, 'children' | 'style' > /** * Custom styles for the send button. */ buttonStyle?: ComponentPropsWithoutRef['style'] /** * (Optional) Title to show at the top. Default: "Enter your phone number" */ title?: string /** * (Optional) Message that shows under the title and above the input. Default: "We'll send you a text with a code to confirm it's you." */ message?: string /** * (Optional) Disclaimer that shows under the text input to comply with SMS guidelines. Default: "By tapping , an SMS may be sent. Message & data rates may apply." where BUTTON_TEXT is "Send" by default, but controlled by the `buttonText` prop. * * Can also be a function, where it receives a dictionary as its only argument, with a `buttonText` field. The function is useful to dynamically let the text update based on the buttonText, and is the more recommended usage. * * Here is an example used by the **Memezy** app: * * @example * ```jsx * export default () => { * return ( * `When you press "${buttonText}", we'll send you a text. Message & data rates may apply. Reply chill to stop.`} * /> * ) * } * ``` */ disclaimer?: string | ((info: { buttonText: string }) => string) /** * Optional custom color for the disclaimer text. * * If you want more generalized color editing, see `textColor` prop. */ disclaimerColor?: string /** * (Optional) If someone presses "Send" and their number is invalid, an alert will pop up with this message. * * Default: "Please enter a valid phone number." * */ invalidNumberAlertText?: string /** * Optional function to replace the default button. It currently receives the props for `react-native-paper`'s Button component, where the `children` prop is the text. See their docs for more. * * It also receives the following props: * - `valid`: is the phone number currently valid * - `loading`: is the SMS sending to the user * - `submit`: this function triggers the `onSubmitPhone` callback prop with the current phone number. * * @example * ```jsx * import { Button } from 'react-native-paper' *import { ScreenBackground } from '../components/Background' * export default () => { * return ( *