Giter VIP home page Giter VIP logo

react-native-modalize's Introduction

Modalize

npm version

A highly customizable modal/bottom sheet that loves scrolling content.

This component has been built with react-native-gesture-handler to address the common issue of scrolling, swiping and handling the keyboard behaviors, you can face with react-native's modal.

This component comes with a ScrollView, the default renderer, a FlatList or a SectionList. They are all three built-in and make your life easier, just pass your content and Modalize will handle the rest for you. You can also have the possibility to pass your own custom renderer.

Simple Fixed Snapping Absolute FlatList Open Apple Facebook Slack

Installation

yarn add react-native-modalize react-native-gesture-handler
iOS
npx pod-install ios
Android

React Native <= 0.59

Follow this guide to complete the Android installation.

React Native > 0.60

You don't need to follow the guide mentioned above because autolinking from React already did the steps.

Usage

Here is a quick example, using the default ScrollView renderer.

import React, { useRef } from 'react';
import { View, Text, TouchableOpacity } from 'react-native';
import { Modalize } from 'react-native-modalize';

export const App = () => {
  const modalizeRef = useRef<Modalize>(null);

  const onOpen = () => {
    modalizeRef.current?.open();
  };

  return (
    <>
      <TouchableOpacity onPress={onOpen}>
        <Text>Open the modal</Text>
      </TouchableOpacity>

      <Modalize ref={modalizeRef}>...your content</Modalize>
    </>
  );
};

Documentation

Please check out the full documentation available here to find all about the props, methods and examples of Modalize's usage.

react-native-modalize's People

Contributors

archansel avatar bcpugh avatar caiangums avatar charpeni avatar dependabot[bot] avatar enniel avatar erkki-lukk avatar esirei avatar fortezhuo avatar grohden avatar hagmic avatar harrigee avatar helderberto avatar jeremybarbet avatar jhhayashi avatar jordanl17 avatar kotielnikov avatar lucidninja avatar maryjenel avatar nwaughachukwuma avatar omgdef avatar petterruud avatar ragularuban avatar renovate-bot avatar renovate[bot] avatar stephenlacy avatar vforvasile avatar wandersonalwes avatar wesleyfaveri avatar xxsnakerxx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-modalize's Issues

Problem using the react-native-modalize

I am facing minor problem while using the modalize which is there are blank space at the bottom of the modal. However, the blank space will not showed when using the 'withReactModal'

Screenshot_1559015282

Any solution to solve it ?

Lazy load content only when modal is open?

Issue:

I've been using this package in many production apps and it works flawlessly, tho there is one issue I've found so far which is lazy loading of the modalize component (not sure if it's an issue)

Explanation:

I use modalize to show transaction invoices in my app, which is an async action as I need to fetch the data first, the issue is that the data fetching (done inside the modalize itself) starts as soon as the component is mounted in the parent screen, is there a simple fix I'm not aware of?

Expected behavior:

I want data fetching to start when the modal actually opens

Thanks

"Failed to build the preview" when we test on Circle CI

The test of my local with yarn and JEST is success but of Circle CI is failed.
Does anyone know the solution of the error below?

ERR! => Failed to build the preview
ERR! ./node_modules/react-native-modalize/lib/Modalize.js 311:72
ERR! Module parse failed: Unexpected token (311:72)
ERR! You may need an appropriate loader to handle this file type.
ERR! |         _this.renderComponent = function (Component, name) {
ERR! |             // @ts-ignore
ERR! >             var element = React.isValidElement(Component) ? Component : <Component />;
ERR! |             // We don't need to calculate header and footer if they are absolutely positioned
ERR! |             if (Component && utils_1.hasAbsoluteStyle(Component)) {
ERR!  @ ./node_modules/react-native-modalize/lib/index.js 3:17-38
ERR!  @ ./src/organisms/modals/ShareSNSModal.tsx
ERR!  @ ./src/screens/MyPageScreen.tsx
ERR!  @ ./src/screens/MyPageScreen.story.tsx
ERR!  @ ./src sync \.story\.tsx?$
ERR!  @ ./.storybook/config.js
ERR!  @ multi ./node_modules/@storybook/core/dist/server/common/polyfills.js ./node_modules/@storybook/core/dist/server/preview/globals.js ./.storybook/config.js

Animation duration props?

Hey, thanks for developing this, this is really useful, I was wondering is there any way to increase/decrease animation duration? or props like that?

Thanks

Android hardwareBackPress event

I suggest you to move
addEventListener('hardwareBackPress') to onAnimateOpen
and
removeEventListener('hardwareBackPress') to onAnimateClose

It won't replace original hardwareBackPress(for example react-navigation) if React Component contains Modalize.

Problem with bottom and header navbar with expo

Screenshot_20190909_194159
i want to show the modal on top navbar, i have to try with zIndex at but not working,...please help how to fix it, thnks🙂

update : done! with top bar, with change the modal render position , but bottom navbar stil on top

Module `react-native-gesture-handler` does not exist in the Haste module map

i get this issue:

error: bundling failed: Error: Unable to resolve module react-native-gesture-handlerfrom/Users/gvl/Desktop/modelize/node_modules/react-native-modalize/lib/Modalize.js: Module react-native-gesture-handler does not exist in the Haste module map

i use:
"react": "16.8.3",
"react-native": "0.59.8"

Fixed view non-modal

Great job on the module, turns out to be almost exactly what I need.

Is it somehow possible to make it not be a modal, and always be available? Like Apple Maps does with their search?

This seems to do exactly what I need, minus it being a modal. I need to not have a backdrop. 😄

[react-native-modalize] swipeable not working on android

Hi, i'm using your library with react-native-router-flux and i had a problem on android, swipeable does not work. Modal builds without errors, works on IOS but android does not respond to swipes. (Sorry, my english is not good :) )

  • "react-native-modalize": "^1.1.1"
  • "react-native-gesture-handler": "^1.3.0" (react-native link react-native-gesture-handler)
  • "react-native": "^0.59.8"
  • "react-native-router-flux": "4.0.6"

Screen Shot 2019-07-21 at 11 37 11 PM

Screen Shot 2019-07-21 at 11 37 33 PM

Thank you in advance :)

withReactModal and Android

Hi,

i just found out that "withReactModal" will break swipe to dismiss on android. What can I do to achieve a full screen modal which works as intended on iOS and Android? Without the use of "withReactModal" my modal gets rendered inside my childrens component and has wrong positioning and wrong height @jeremybarbet.

Using "withReactModal" is exactly what I need, a fullscreen modal which perfectly works with my slideshow (which btw was the first and only modal I found which did what I need, because every other lib with flick to dismiss didn't work with slideshows/scrollviews) and swipes up form bottom to top + overlapping the tab bar perfectly. You mentioned to have a look at react-navigation example but there isn't even a stackNavigator or anything else inside of it.

I use react-navigation but your examples didn't help me here. Any help here is appreciated.

Android Header with input bug with keyboard avoid view

bug

<Modalize ref={ref => this.modal = ref}
                flatListProps={{
                    data: this.data,
                    renderItem: this._renderItem,
                    keyExtractor: this.props.keyExtractor || this._keyExtractor,
                    keyboardShouldPersistTaps: 'always',

                }}
                HeaderComponent={this._headerComponent}
                modalHeight={deviceHeight}
                keyboardAvoidingBehavior="height"
                FooterComponent={this.props.multi ? this._footerComponent : null}
            >

            </Modalize>

Do you have any solution? Thanks

Cover all parent views

The model only covers the c component its rendered in, there should an option to cover the whole screen, like react native model

HeaderComponent and FooterComponent rendering

HeaderComponent and FooterComponent render many times

export class test extends Component {

    renderHeader = () => {
        console.count('HeaderComponent');
        return (<View />)
    }

    render() {
        return (
            <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
                <Modalize ref={ref => this.modal = ref} HeaderComponent={this.renderHeader}>

                </Modalize>
                <Button onPress={() => this.modal.open()} title='OPEN'></Button>
            </View>
        )
    }
}

export default test
"react-native": "0.59.8",
"react-native-modalize": "^1.0.0-alpha.23"

console.count() prints 9-10 times, is it normal?

Is there a way to know if modal reached to top?

I'm trying to use the modal in an allways open state. But I need to understand if the modal is opened or not to show a header. But since the modal is allways open, I cant do anything about it. I think maybe there is a way to know if it reached its top position. Is there?

[TS] flat/section props could have infered item types

Currently, flat/section item types are declared with any, this is error prone. Consider this:

type MyItems = { a: number, id: string }

const items : MyItems[] = []

// ...

<Modalize
  ref={ it => ref.current = it }
  flatListProps={ {
     data: items,
     keyExtractor: it => it.key,
     renderItem: ({ item }) => (<Text> { item.jojo }</Text>)
  } } />

In the above example, item is identified by ts as any, so accessing non existing props is fine for the compiler.

You could make this type safe by changing two declarations:

// Options.d.ts
export interface IProps<FlatListItem, SecionListItem> {
    ...
    flatListProps?: FlatListProps<FlatListItem>;
    sectionListProps?: SectionListProps<SecionListItem>;
    ...
}

// Modalize.d.ts
export default class Modalize<FlatListItem = any, SecionListItem = any>
    extends React.Component<IProps<FlatListItem, SecionListItem>, IState> {
   ...
}

With the above example definition, the compiler would complain about my attempt to access non existing props on the item cuz it would infer that it is a MyItems type.

Edit:
I've added the defaults any for the generic types in Modalize class, to keep stuff like:

const modalRef = useRef<Modalize | null>()

working (otherwise you would need to declare the generics there)

Keyboard avoiding view not working when input component is inside Footer.

Hey @jeremybarbet

Thanks for the awesome library. So I am trying to get a text input work inside a footer and the keyboardAvoidingView doesn't seem to work when the input is inside the footer. Here is a video of this.

Kapture 2019-08-29 at 19 55 37

Here is the code for the Modalize component.

<Modalize
        ref={this.modal}
        HeaderComponent={this.renderHeader}
        keyboardAvoidingBehavior="padding"
        modalHeight={DEVICE_HEIGHT - HEADER_HEIGHT}
        FooterComponent={this.renderFooter}
        onClosed={this.onClosed}
        withHandle={false}
        flatListProps={{
          data: comments,
          renderItem: ({ item }) => <SingleComment comment={item} key={item.id} />,
          keyExtractor: (item, index) => (item && item.id ? item.id.toString() : index),
          showsVerticalScrollIndicator: false
        }}
        overlayStyle={{
          backgroundColor: 'rgba(29, 33, 41, 0.2)'
        }}
      />

I've tried all the enums related to keyboardAvoidingBehavior ('height', 'position', 'padding') but none of them seem to work. Any help in pointing me to the right direction would help immensely.

Swipe gesture not working with latest expo

Using the latest version of "expo": "32.0.0" make the swipe gesture not working anymore. If you are not using expo, you are not concerned, if you are, you must do:

"expo": 31.0.0,
"react-native": "https://github.com/expo/react-native/archive/sdk-31.0.0.tar.gz"

The possibility of adding new features

Hi @jeremybarbet ,
It would be possible to add the following features:

  1. The possibility to change the background color for example
    if I do that, it works
    style = {{backgroundColor: '#ccc'}}
    but not so:
    style = {{backgroundColor: 'rgba (0,0,0, 1)'}}
  2. It would be interesting to have a gradient background I was trying and thinking about rn-gradients that totally in js.

react-navigation modal

Hello, really nice module !
i'd like to know how i could use Modalize and react-navigation to open a modal above the all screen (and not use withReactModal).

thanks for your time

rctrootview canceltouches is deprecated

Modalize.open() with flatlistprops is showing a deprecation on DEBUG and the app is quiting on RELEASE, here's the dependencies.

"dependencies": { "@react-native-community/async-storage": "^1.6.2", "@react-native-community/geolocation": "^2.0.2", "@react-native-community/netinfo": "^4.2.2", "@react-native-community/push-notification-ios": "^1.0.2", "axios": "^0.19.0", "lodash": "^4.17.15", "lottie-ios": "3.0.3", "lottie-react-native": "^3.1.1", "mobx": "^5.13.0", "mobx-react-lite": "^1.4.1", "moment": "^2.24.0", "prop-types": "^15.7.2", "react": "16.9.0", "react-native": "0.61.0", "react-native-fast-image": "^7.0.2", "react-native-fbsdk": "^1.0.4", "react-native-gesture-handler": "^1.4.1", "react-native-google-signin": "^2.0.0", "react-native-image-crop-picker": "^0.25.2", "react-native-linear-gradient": "^2.5.6", "react-native-modalize": "^1.2.1", "react-native-onesignal": "^3.4.1", "react-native-rate": "^1.1.7", "react-native-reanimated": "https://github.com/kmagiera/react-native-reanimated", "react-native-screens": "^1.0.0-alpha.23", "react-native-splash-screen": "^3.2.0", "react-native-svg": "^9.9.4", "react-native-track-player": "^2.0.0-rc13", "react-native-vector-icons": "^6.6.0", "react-navigation": "^4.0.9", "react-navigation-drawer": "^2.2.2", "react-navigation-stack": "^1.9.0", "react-navigation-tabs": "^2.5.5" },

ScreenShot

TouchableOpacity onPress doesn't work inside the view

Here I have used Modalize

<Modalize ref={this.modal}
                          style={{height:'93%'}}
                          handlePosition={'outside'}
                          height={300}>
                    <components.ReactionList wallPostId={this.state.item.id}/>
 </Modalize>

This is a part of components.ReactionList

 <TouchableOpacity style={styles.buttonTab} onPress={this.handlePress}>
                <Text style={{alignSelf: 'center'}}>All Test</Text>
 </TouchableOpacity>

Please let us know how do we solve this issue

Remaining before release

General

  • Remove definitions file
  • Tap gesture on overlay
  • Keyboard avoiding view

iOS

  • Bounce to the bottom of scrollview, and disable on top of it

Android

  • Make it works

custom android Back Press actions?

hey guys. is there any way i can set custom actions when android back button is pressed? i already tried with onRequestClose props(from react native modal).

Can we have sticky headers inside the modal?

Is there a possibility to add sticky headers to the content inside modal?

<Scrollview stickyHeader={[0,1]}>
... Content
</Scrollview>

PS:

  1. The absolute property of header and footer component is not clear

Keyboard automatically closes when a textinput is focused inside the modal

Issue:

Keyboard automatically closes after typing a single character on iOS (haven't tested android) when a text input inside the modal is focused

Modal:

<Modalize
                ref={this.modal}
                adjustToContentHeight
                keyboardAvoidingBehavior={'padding'}
                onClosed={this.onClosed}
                modalStyle={{ marginTop: 32 }}
                flatListProps={{
                    stickyHeaderIndices: [0],
                    ListHeaderComponent: () => this._listHeaderComponent(),
                    data: this.data,
                    renderItem: this.renderItem,
                    keyExtractor: item => item.email,
                    showsVerticalScrollIndicator: false,
                }}
            />
        );

ListHeader component:

_listHeaderComponent = () => (
        <View style={{flex: 1, justifyContent: 'center', height: 60, width: '100%', backgroundColor: 'salmon' }}>
            <TextInput
                style={{ fontSize: 20, backgroundColor: 'yellow' }}
                value={this.state.searchQuery}
                onChangeText={searchQuery => this.setState({ searchQuery })}
            />
        </View>
    );

EXPO SNACK: https://snack.expo.io/HkZULlxSB

Modal Height While in Full Screen and Keyboard Shown

Hi,

Recently I used your latest version of your modal component (1.0.0-alpha.21). I tried to set adjustToContentHeight to true. Children height was hardcoded with minHeight : 1000 (will have more content later). Then, it was great until the keyboard shown in full screen modal.

Before the keyboard was shown (it was great)
Before the keyboard was shown

After the keyboard was shown (modal shown until covering the status bar)
After the keyboard was shown (modal shown until covering the status bar)

Then, the keyboard was dismissed and the TextInput refocused (modal height was changing, but not like the first one)
Then, the keyboard was dismissed and the TextInput refocused (modal height was changing)

How to solve this height issue?

[Question] Components Outside the Modal ?

Screenshot 2019-07-25 at 17 42 13

This is just an example of what I'm looking for. I wonder that is that possible that can we make our components outside of the modal? Just like the above image's button on the top right side.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.