Skip to main content

InputPopupUI

Overview

sample-alert-popup

API Usage

Step 1. create popup

Using Default

InputPopup.tsx
import { InputPopupUI, createPopup } from 'react-native-global-components';
export default createPopup(InputPopupUI);

or you can override default props

InputPopup.tsx
import {
InputPopupUI,
InputPopupProps,
createPopup,
} from 'react-native-global-components';

const styles: InputPopupProps['styles'] = StyleSheet.create({
// override default styles
});

export default createPopup((props: InputPopupProps) => (
<InputPopupUI {...props} styles={styles} />
));

Step 2. register portal

App.tsx
const App = () => {
return (
<NavigationContainer>
<RootNavigator />
<InputPopup.Portal />
</NavigationContainer>
);
};

Step 3. use anywhere

InputPopup.show({
title: 'Hello👋🏻',
description: 'Please enter your name 🥰',
inputProps: { value: 'initial value' },
buttons: [
{ title: 'Cancel' },
{
title: 'Enter',
onPress: (text) => text && setText(text),
},
],
});

Props

title

title to show

TypeDefaultRequired
stringundefinedNO

description

description text to show below title

TypeDefaultRequired
stringundefinedNO

inputProps

react native text input props

TypeDefaultRequired
TextInputPropsundefinedNO

buttons

react native button props with overriding onPress. use renderButtons for custom button UI.

TypeDefaultRequired
InputPopupButtonProps[{ title: 'Cancel', color: 'black' },{ title: 'Confirm' },]NO
// ButtonProps from react native
interface InputPopupButtonProps extends Omit<ButtonProps, 'onPress'> {
onPress?: (text?: string) => void;
}

renderButtons

render function for Headless button UI. buttons will be ignored when renderButtons provided.

TypeDefaultRequired
(text?: string) => ReactElementundefinedNO

fadeAnimationConfig

fade animation configuration. see useFadeAnimationStyle.

TypeDefaultRequired
FadeAnimationConfigsundefinedNO

androidBackBehavior

behavior on android hardware back button pressed. hide component for default.

TypeDefaultRequired
'hide' or 'none''hide'NO

KeyboardAvoidingLayoutProps

keyboard related props overriding react native KeyboardAvoidingViewProps

TypeDefaultRequired
KeyboardAvoidingLayoutPropsundefinedNO
interface KeyboardAvoidingLayoutProps extends KeyboardAvoidingViewProps {
bottomInset?: number;
topInset?: number;
children?: React.ReactNode;
}

styles

style object to override default style

TypeDefaultRequired
StylesundefinedNO
type Styles = {
title?: StyleProp<TextStyle>;
input?: StyleProp<TextStyle>;
description?: StyleProp<TextStyle>;
container?: StyleProp<ViewStyle>;
buttonContainer?: StyleProp<ViewStyle>;
};