2.3.5 • Published 3 months ago

react-native-popup-confirm-toast v2.3.5

Weekly downloads
-
License
ISC
Repository
github
Last release
3 months ago

react-native-popup-confirm-toast

platforms npm npm

github issues github closed issues

Release notes 🐧

  • getStatusBarHeight
  • isIPhoneWithMonobrow

Example Bottom Sheet

Custom Example 1Custom Example 2Custom Example 3Custom Example 4
npm.ionpm.ionpm.ionpm.io

Example Popup Message

Example MessageExample Confirm MessageExample Message AutoCloseExample Custom Body Component
npm.ionpm.ionpm.ionpm.io

Example Toast Message

Example Toast TopExample Toast Bottom
npm.ionpm.io

Usage

Installation

yarn add react-native-popup-confirm-toast
or
npm install react-native-popup-confirm-toast

Usage

Wrap your root component in Provider from react-native-popup-confirm-toast. If you have a vanilla React Native project, it's a good idea to add it in the component which is passed to AppRegistry.registerComponent. This will usually be in the index.js file. If you have an Expo project, you can do this inside the exported component in the App.js file.

Example Provider

import * as React from 'react';
import { AppRegistry } from 'react-native';
import {Root as PopupRootProvider} from 'react-native-popup-confirm-toast';
import { name as appName } from './app.json';
import App from './src/App';

export default function Main() {
  return (
    <PopupRootProvider>
      <App />
    </PopupRootProvider>
  );
}

AppRegistry.registerComponent(appName, () => Main);

Example Bottom Sheet

import { Root, SPSheet } from 'react-native-popup-confirm-toast'

const component = (props) => {
    //hook or class 
    return (<Text>Hi, SekizliPenguen</Text>);
    
    //props.spSheet.hide();
    //props.spSheet.setHeight(150,()=>alert('nice'));
};

<View>
    <TouchableOpacity
        onPress={() => {
            const spSheet = SPSheet;
            spSheet.show({
                component: () => component({...this.props, spSheet}),
                dragFromTopOnly: true,
                onCloseComplete: () => {
                    alert('onCloseComplete');
                },
                onOpenComplete: () => {
                    alert('onOpenComplete');
                },
                height:260
            });
        }
    >
        <Text>Open SPSheet Message</Text>
    </TouchableOpacity>
</View>

Example Message

import {Popup} from 'react-native-popup-confirm-toast'
<View>
    <TouchableOpacity
        onPress={() =>
          Popup.show({
            type: 'success',
            title: 'Success!',
            textBody: 'Mutlak özgürlük, kendi başına hiçbir anlam ifade etmez. ',
            buttonText: 'OK',
            callback: () => Popup.hide()
          })
        }
    >
        <Text>Open Popup Message</Text>
    </TouchableOpacity>
</View>

Example Confirm Message

import {Popup} from 'react-native-popup-confirm-toast'
<View>
    <TouchableOpacity
        onPress={() =>
            Popup.show({
                type: 'confirm',
                title: 'Dikkat!',
                textBody: 'Mutlak özgürlük, kendi başına hiçbir anlam ifade etmez. ',
                buttonText: 'Tamam',
                confirmText: 'Vazgeç',
                callback: () => {
                    alert('Okey Callback && hidden');
                    Popup.hide();
                },
                cancelCallback: () => {
                    alert('Cancel Callback && hidden');
                    Popup.hide();
                },
            })
        }
    >
        <Text>Open Popup Confirm Message</Text>
    </TouchableOpacity>
</View>

Example Custom Body Component

import { Root, Popup } from 'react-native-popup-confirm-toast'
//hooks or class component
const bodyComponent = ({props,bodyProps}) => {
    return (
        <View onLayout={(e}=>bodyProps.onLayout(e)}>
        <Text>Mustafa Kemal ATATÜRK</Text>
        </View>
    );
}

<Root>
    <View>
        <TouchableOpacity
            onPress={() => {
                const popup = Popup;
                popup.show({
                    type: 'confirm',
                    textBody: 'Hesabınızın silinme işlemini onaylamak için şifrenizi giriniz.',
                    bodyComponent: (bodyProps) => bodyComponent({...props,bodyProps,popup}),
                    confirmText: 'Cancel',
                    iconEnabled: false,
                    buttonEnabled: false,
                });
            }}
        >
            <Text>Open Popup Confirm Message</Text>
        </TouchableOpacity>
    </View>
</Root>

Toast

import { Root, Toast } from 'react-native-popup-confirm-toast'
    <Root>
        <View>
            <TouchableOpacity
                onPress={() => 
                      Toast.show({
                          title: 'I\'m Eight!',
                          text: 'The best gift I received in this life are the codes. They are worlds inside the worlds.',
                          backgroundColor: '#702c91',
                          timeColor: '#440f5f',
                          timing: 3000,
                          icon: <Icon name={'check'} color={'#fff'} size={31}/>,
                          position: 'bottom',
                          statusBarType:'dark-content',
                          onCloseComplete: () => {
                            alert('onCloseComplete');
                          },
                          onOpenComplete: () => {
                            alert('onOpenComplete');
                          },
                        })
                }
            >
                <Text>Open Bottom Toast</Text>
            </TouchableOpacity>
            
            <TouchableOpacity
                onPress={() => 
                    Toast.show({
                      title: 'I\'m Eight!',
                      text: 'The best gift I received in this life are the codes. They are worlds inside the worlds.',
                      backgroundColor: '#702c91',
                      timeColor: '#440f5f',
                      timing: 3000,
                      icon: <Icon name={'check'} color={'#fff'} size={31}/>,
                      position: 'top',
                      statusBarTranslucent: false,
                      statusBarType:'light-content',
                      onCloseComplete: () => {
                        alert('onCloseComplete');
                      },
                      onOpenComplete: () => {
                        alert('onOpenComplete');
                      },
                    })
                }
            >
                <Text>Open Top Toast</Text>
            </TouchableOpacity>

        </View>
    </Root>

Documentation

SPSheet

KeyTypeDescriptionDefault
backgroundstringrgba(0, 0, 0, 0.5)
heightnumberauto height (min: 250)250
durationnumberanimation time used when opening250(ms)
closeDurationnumberanimation time used when closing300(ms)
closeOnDragDownbooleanUse drag with motion to close the windowtrue
closeOnPressMaskbooleanpress the outside space to close the windowtrue
closeOnPressBackbooleanPress the back key to close the window (Android only)true
dragTopOnlybooleanuse only the top area of the draggable icon to close the windowfalse
componentcomponent(hook or class)custom modal component containernull
onOpenfunctionworks after the window is openednull
onOpenCompletefunctionworks after the window is openednull
onClosefunctionworks after window is closednull
onCloseCompletefunctionworks after window is closednull
customStylesobjectcustomStyles: { draggableIcon: {}, container: {}, draggableContainer:{} }{}
timingnumberUse this parameter for automatic shutdown.0(ms)
keyboardHeightAdjustmentbooleanre-adjusts the height when the keyboard is openedfalse

Popup

KeyTypeDescriptionDefault
titlestringfalse
textBodystringfalse
bodyComponentcomponent(hook or class)custom modal component containernull
bodyComponentForcebooleanThe component you specify covers the entire spacefalse
onLayoutfunctionwhich triggers this feature for us to automatically calculate the height of the component area you specify.
typeenumenum(success, info, danger, warning, confirm)warning
buttonTextstringOk
confirmTextstringCancel
callbackfunctionok button presspopupHidden
cancelCallbackfunctioncancel button presspopupHidden
backgroundstringrgba(0, 0, 0, 0.5)
timingnumber0 > autoClose0
iconEnabledbooleantrue
iconHeaderStyleobject{height: 75, width: 100, backgroundColor: '#fff'}
iconrequireUrlrequire('../assets/{type}.png')
containerStyleobject{ position: 'absolute', zIndex: 10, backgroundColor: 'rgba(0, 0, 0, 0.5)', alignItems: 'center', top: 0, left: 0,}
modalContainerStyleobject{ width: '90%',backgroundColor: '#fff', borderRadius: 8, alignItems: 'center', overflow: 'hidden', position: 'absolute'}}
buttonContentStyleobject{}
okButtonStyleobject{backgroundColor: '#702c91'}
confirmButtonStyleobjectdefault
okButtonTextStyleobjectdefault
confirmButtonTextStyleobjectdefault
titleTextStyleobjectdefault
descTextStyleobjectdefault
bouncinessnumber15
onClosefunctionwhen the popup is first closedfalse
onCloseCompletefunctionfalse
onOpenfunctionwhen the popup is first openedfalse
onOpenCompletefunctionfalse
durationboolean100
closeDurationboolean100

Toast

KeyTypeDescriptionDefault
titlestringfalse
textstringDescriptionfalse
titleTextStyleobject{color: '#fff',fontWeight: 'bold',fontSize: 16}
descTextStyleobject{marginTop: 5,fontSize: 13,color: '#fff', fontWeight: '400',}
backgroundColorstring#1da1f2
timeColorstringtime backgroundColor#1c6896
positionenumparameters => top, bottombottom
iconcomponent(react-native-vector-icons or component)null
timingnumber5000 ms
statusBarTypestringdefault
statusBarTranslucentbooleanfalse
statusBarHiddenbooleanfalse
statusBarAndroidHiddenbooleantrue
statusBarAppleHiddenbooleanfalse
hiddenDurationnumber200 ms
startDurationnumber200 ms
onOpenfunctionworks after the window is openednull
onOpenCompletefunctionworks after the window is openednull
onClosefunctionworks after window is closednull
onCloseCompletefunctionworks after window is closednull

Methods

Component NameMethod NameExampleDescription
SPSheetshowconst spSheet = SPSheet; spSheet.show(config);
SPSheethideconst spSheet = SPSheet; spSheet.hide();
SPSheetsetHeightconst spSheet = SPSheet; spSheet.setHeight(500,completeEventFunction);allows you to change the box height
Popupshowconst popup = Popup; popup.show(config);
Popuphideconst popup = Popup; popup.hide();
Toastshowconst toast = Toast; toast.show(config);
Toasthideconst toast = Toast; toast.hide();

Helper Function

    import {getStatusBarHeight} from 'react-native-popup-confirm-toast';

Author

SekizliPenguen

License

MIT

2.3.5

3 months ago

2.3.4

3 months ago

2.3.3

3 months ago

2.3.0

1 year ago

2.3.2

12 months ago

2.3.1

1 year ago

2.2.9

1 year ago

2.2.8

1 year ago

2.2.3

1 year ago

2.2.5

1 year ago

2.2.4

1 year ago

2.2.7

1 year ago

2.2.6

1 year ago

2.2.1

2 years ago

2.1.2

2 years ago

2.2.0

2 years ago

2.1.4

2 years ago

2.2.2

2 years ago

2.1.3

2 years ago

2.1.6

2 years ago

2.1.5

2 years ago

2.1.8

2 years ago

2.1.7

2 years ago

2.1.9

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.7

2 years ago

2.0.9

2 years ago

2.0.8

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.6

2 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago