Giter Club home page Giter Club logo

rn-swipeable-panel's Introduction

React Native Swipeable Panel

rn-swipeable-panel is a swipeable, easy to use bottom panel for your React Native projects. You can extend panel by swiping up, make it small or close by swiping down with pan gestures. Feel free to redesign inside of the panel.

npm version



⚙️ Installation

To install the package;

$ yarn add rn-swipeable-panel

✅ It is done!

🚀 How to use

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';

import { SwipeablePanel } from 'rn-swipeable-panel';

export default App = () => {
  const [panelProps, setPanelProps] = useState({
    fullWidth: true,
    openLarge: true,
    showCloseButton: true,
    onClose: () => closePanel(),
    onPressCloseButton: () => closePanel(),
    // ...or any prop you want
  });
  const [isPanelActive, setIsPanelActive] = useState(false);

  const openPanel = () => {
    setIsPanelActive(true);
  };

  const closePanel = () => {
    setIsPanelActive(false);
  };

  return (
    <View style={styles.container}>
      <Text style={styles.welcome}>Welcome to React Native!</Text>
      <Text style={styles.instructions}>To get started, edit App.js</Text>
      <SwipeablePanel {...panelProps} isActive={isPanelActive}>
        <PanelContent /> {/* Your Content Here */}
      </SwipeablePanel>
    </View>
  );
};

☝️ Options


Properties Type Description Default
isActive bool Show/Hide the panel false
onClose Function Fired when the panel is closed
showCloseButton bool Set true if you want to show close button
fullWidth bool Set true if you want to make full with panel false
openLarge bool Set true if you want to open panel large by default false
onlyLarge bool Set true if you want to let panel open just large mode false
onlySmall bool Set true if you want to let panel open just small mode false
noBackgroundOpacity bool Set true if you want to disable black background opacity false
style Object Use this prop to override panel style {}
closeRootStyle Object Use this prop to override close button background style {}
closeIconStyle Object Use this prop to override close button icon style {}
barStyle Object Use this prop to override bar style {}
smallPanelHeight Object Use this prop to override the small panel default height
barContainerStyle Object Use this prop to override bar container style {}
closeOnTouchOutside bool Set true if you want to close panel by touching outside false
allowTouchOutside bool Set true if you want to make toucable outside of panel false
noBar bool Set true if you want to remove gray bar false
scrollViewProps Object Use this prop to override scroll view that inside the panel {}

⭐️ Show Your Support

Please give a ⭐️ if this project helped you!

👏 Contributing

If you have any questions or requests or want to contribute to rn-swipeable-panel, please write the issue or give me a Pull Request freely.

rn-swipeable-panel's People

Contributors

apperside avatar danieltrizzuto avatar dependabot[bot] avatar doctorrokter avatar enesozturk avatar erdemgonul avatar hranatikk avatar pitztech avatar pritamsoni-hsr avatar smirnovw 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

rn-swipeable-panel's Issues

How to add a style? Cannot add style

I tried to style it, but I'm sorry, it doesn't

<SwipeablePanel
fullWidth
isActive={this.state.swipeablePanelActive}
onClose={this.closePanel}
onPressCloseButton={this.closePanel}
openLarge={true}
noBackgroundOpacity={true}
style={{width: '100%', backgroundColor: 'red',position: 'absolute'}}
>
asdfsd

Feature request: Fade dark background out as panel is minimized

It would be great to have the background fade out when the panel is slid down. That seems to be the behavior of all similar interactions using this slide-down paradigm.

Currently, the dark backdrop disappears suddenly when the panel is dismissed. I've had to work around this by trying to use it as a react-navigation screen that animates its own background on dismissal, though that has come with its own issues, and support in this library would be simpler all around.

1 fps rendering

The panel is working properly for me in a basic sandbox, and all other app animations are smooth, but in the main implementation (with blank/minimal content) where it's above the rest of the app, it is exceedingly, unusably choppy.
Is there a known issue that can cause the movement animation to render at only about 1 fps?

Reusuable

Please making styling reusable. And generally the whole component

header, footer ve scroll u disabled etme

Merhaba Enes,

Gerekli bir kaç özellik var benım zamanım olmadıgı için bu modulu kaldırıp farklı bir modül kullanma ihtiyacı duydum nedeni ise header ı sabitlenmiyor veya footer'ı scroll içinde bu sabit durması gerekenler oynuyor sürekli altta yukarı contant kısmındada scroll kapatma gibi bir şey yapılması gerekiyor.

Teşekkürler.

Module parse failed: Unexpected token

I tried the example and run it on a new project. (using expo)

Encountered error saying

Failed to compile.
C:/Users/mycomputer/Documents/React Native Projects/Test11/node_modules/rn-swipeable-panel/components/Panel.js 13:18
Module parse failed: Unexpected token (13:18)
You may need an appropriate loader to handle this file type.
| 
| export default class SwipeablePanel extends React.Component {
>       static propTypes = {
|               isActive: PropTypes.bool.isRequired,
|               onClose: PropTypes.func,

Also below is my package.json for reference

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "expo": "^34.0.1",
    "react": "16.8.3",
    "react-dom": "^16.8.6",
    "react-native": "https://github.com/expo/react-native/archive/sdk-34.0.0.tar.gz",
    "react-native-web": "^0.11.4",
    "rn-swipeable-panel": "^1.0.14"
  },
  "devDependencies": {
    "babel-preset-expo": "^6.0.0"
  },
  "private": true
}

swipeissue

Margin bottom and show component when fully opened ?

Hi,

Is that possible to start the panel after a component (or add marginBottom) ? And can I hide some specific components and only show if panel is fully opened ?
Example :
image
image

Thank for your awesome module 👍

Matthieu.

Content panel ignore flex

Hi, I am using the component to show content and at the end, place a button to do an action, the problem is that the button ignore the flex styles and show below the text (content) for example

<SwipeablePanel
      isActive={visible}
      onPressCloseButton={onClose}
      showCloseButton={showCloseButton}
      closeOnTouchOutside={closeOnTouchOutside}
      openLarge={openLarge}
      showCloseButton={showCloseButton}
      onClose={onClose}
      fullWidth
      closeIconStyle={styles.closeIcon}
      closeRootStyle={styles.closeRoot}
    >
      <View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
        <View style={{flex: 5}}>
          <Text>Write Content here</Text>
        </View>
        <View style={{flex: 1, alignItems: 'center', width: '100%'}}>
          <Button title="Close" onPress={() => props.onClose()} />
        </View>
      </View>
</SwipeablePanel>

For example

Screenshot_1588697481

Feature Request: Custom styles for background

It would be great if we able to customize the style of background. For example, if I have elements with elevation set I need to set greater elevation to parent panel component. Can you add another property for it?

Can I custom Icon Style?

Thank you for nice library.

I want to change tab style of the rn-swipeable-panel.
Can I do it?

Component doesn't show at all

Hello guys,

I'm trying to use the panel but it doesn't show at all. There's no error, it just doesn't show.
I'm using an iPhone X with iOS 11. I've played around with the style, put it inside a SafeAreaView, and also tried it on an empty screen with no success.

Any ideas?

Panel is not working with React Navigation

Hello,

I was trying to embed a React Navigator inside Swipeable Panel so I can handle a full navigation inside the Panel, but unfortunately I was not able to achieve this. I can just see the Navigation Header, without any content no matter what content I use, even an empty component with a text inside it is not working.

I'm using the following modules

"@react-navigation/native": "^5.7.3",
"@react-navigation/stack": "^5.9.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-39.0.3.tar.gz",
"rn-swipeable-panel": "^1.2.1"

Thanks

Close panel from action inside

Hi @enesozturk,

Thanks for the cool library, we're using it all the time!

Weird issue today, I have a list inside my panel and I want the panel to close itself once I select an item on the list.

But when I do a simple:

                onPress={() =>
                  this.setState({
                    currentShop: index,
                    isShopPanelActive: false
                  })
                }

It doesn't close the panel?

Any idea?

Thanks again,

Théo

scroll view is not working

hello there,
is there any way I can scroll through children content inside the panel?
I think the ability to drag it upward after the panel is already opened is the problem(correct me if I'm wrong)
update: ScrollView is not working on ios specifically
WhatsApp Image 2020-01-22 at 3 45 46 PM

1.1.0 Breaks

Version 1.1.0 removed the component folder from the node modules and doesn't build, and the last version that works is Version 1.0.28. Just wanted to let you know!

Considered the Status Bar Height

Package Version: 1.0.27
OS: Android

Currently, the package isn't considered the status bar height, and causing the background opacity doesn't apply full height of the screen, it's really nice if the background opacity also applied to the whole screen

Code Suggetion:

const STATUSBAR_HEIGHT = Platform.OS === 'ios' ? 20 : StatusBar.currentHeight;
const FULL_HEIGHT = Dimensions.get("window").height + STATUSBAR_HEIGHT;

photo6187973045541513671

Panel (zIndex/elevation?) under Android button

On Android, the panel appears below a standard React Native button. Is there a way to ensure that it remains on top of all content?

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow
 */

import React, {Component} from 'react';
import {View, Button} from 'react-native';
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore: this is just a demo
import SwipeablePanel from 'rn-swipeable-panel';
import {Configurations} from './Configuration';

type AppState = {
  content: Function;
  isActive: boolean;
  openLarge: boolean;
  onlyLarge: boolean;
  fullWidth: boolean;
  noBar: boolean;
  showCloseButton: boolean;
  noBackgroundOpacity: boolean;
  bounceAnimation: boolean;
  closeOnTouchOutside: boolean;
};

export default class SwipeablePanelDemo extends Component<{}, AppState> {
  constructor(props: {}) {
    super(props);
    this.state = {
      content: (): any => null,
      isActive: false,
      openLarge: false,
      onlyLarge: false,
      fullWidth: false,
      noBackgroundOpacity: false,
      bounceAnimation: false,
      closeOnTouchOutside: false,
      noBar: false,
      showCloseButton: false,
    };
  }

  openConfigurationsPanel = () => {
    this.setState({
      isActive: true,
      openLarge: false,
      fullWidth: false,
      showCloseButton: false,
      noBar: false,
      content: (): any => <Configurations state={this.state} changeState={this.changeState} />,
    });
  };

  changeState = (state: any) => {
    this.setState(state);
  };

  openDefaultPanel = () => {
    // eslint-disable-next-line @typescript-eslint/no-empty-function
    this.setState({isActive: true, openLarge: false, content: () => {}});
  };

  closePanel = () => {
    this.setState({
      isActive: false,
      fullWidth: false,
      openLarge: false,
      showCloseButton: false,
      noBackgroundOpacity: false,
      closeOnTouchOutside: false,
      noBar: false,
    });
  };

  render() {
    const {isActive, showCloseButton, closeOnTouchOutside, fullWidth, noBackgroundOpacity, openLarge, noBar} = this.state;

    return (
      <>
        <View>
          <Button onPress={this.openConfigurationsPanel} title="Open Config Panel" />
        </View>
        <SwipeablePanel
          fullWidth={fullWidth}
          noBar={noBar}
          openLarge={openLarge}
          showCloseButton={showCloseButton}
          noBackgroundOpacity={noBackgroundOpacity}
          isActive={isActive}
          closeOnTouchOutside={closeOnTouchOutside}
          onClose={() => {
            this.setState({isActive: false});
          }}>
          {this.state.content()}
        </SwipeablePanel>
      </>
    );
  }
}

Close the panel by touching outside the panel

Hi Enes, I'm trying to modifying the Panel.js to implement the feature of closing the panel by touching the area outside the panel but I'm having problem with it. Is there any way to do it?

Thank you very much for making this!!!

[Feature Request] Disable scroll inside panel

Desired behavior:

Ability for contents inside the SwipeablePanel to have a fixed height, and the panel itself cannot be scrolled.

E.g.

 <SwipeablePanel
            onlyLarge
            canScroll={false}
            isActive={isPanelActive}
            noBackgroundOpacity={true}
            showCloseButton={false}>{ ... }</SwipeablePanel>

This behavior might be possible already, but I haven't been able to figure it out.

openLarge don't working

I used the openLarge option, but nothing happened.

I really hoped that the panel could open everything completely. But still, it opens only a part.

Not able to give horizontal scroll inside Swipeable panel

Hi, i was trying to put a horizontal scroll inside Swipeable panel, but its not working, will you please check this.

My code here:



export const Sav = () => {
return (



<Image
style={{ width: 20, height: 20 }}
source={require('_assets/icons/calendar-icon.png')}
/>


When you like to visit
Pick a time for a FREE assisted house visit
You can reschedule later if you are busy

{/* horizontal code here */}

{hellocategory.map(
({ title, subTitle }, index) => (

{title}
{subTitle}

)
)}





)
}

PFA screenshot:

Screenshot 1941-07-12 at 9 18 52 PM

Scroll Events interference and backdrop not covering entire screen.

  • When SwipeablePanel is placed inside a scrollview, pan-responder doesn't work properly, scrollevents from parent scrollview are also getting captured.
  • With react-navigation, when headers are present on navigator, panel backdrop doesn't cover that part.

A workaround for this that I'm using rn is to wrap SwipeablePanel inside a native modal with fade animationType which is handling both issues

Scroll not working in flatlist in android but working fine in iOS

Hi,
scroll not working in flatlist in android but working fine in iOS
here is my code
var list={
1,2,3,............,,50,51,52,53,54,55
}
<SwipeablePanel
fullWidth
showCloseButton={true}
//style={{ zIndex: 1 }}
panel_height={700}
closeRootStyle={{ backgroundColor: Theme.DividerColor }}
isActive={this.state.swipeablePanelActive}
onClose={this.closePanel}
onPressCloseButton={this.closePanel}>
<FlatList
//keyboardShouldPersistTaps='handled'
contentContainerStyle={{ paddingBottom: 100 }}
ListHeaderComponent={null}
ListFooterComponent={null}
scrollEnabled={true}
style={[styles.list, { height: Dimensions.get('window').height }]}
data={this.state.list? this.state.list : null}
renderItem={({ item, index, separators }) => (
<View style={{ marginTop: 40, top: 10 }}>
{index}

)}
/>

in it showing only 29 items, the rest of items not showing

can you please tell me the solution for this.
thank you

Panel header

Hi Enes,

Would it be possible to have a props option to add a header under the bar or to replace the bar, which will not be moved when the children component scrolls?

Thank you!

Error while bundling the assets

Hi

I have installed this package in one one of my react native project.
I used the below command to run the project
npx react-native run-android

The project has built successfully, but while bundling the assets, I am getting the error.
I have attached the screenshot for your reference.

Below are the platform details
Platform: Mac OS Catalina

Node version: 11.10.0
React-Native: 0.61.1

I have tried installing this by deleting the node_modules and clean the cache (npm cache and metro) but none of the tricks worked.

I appreciate any help on this

Thanks

WhatsApp Image 2020-07-22 at 5 57 40 PM

Control opacity

Feature request to optionally show the panel without affecting background opacity. Similar to the Google Maps bottom panel behavior.

Scroll bouncing effect appear when swipe up the panel

I have a flat list from the flat list item tap I'm going to open the bottom panel. When open and when I'm going to swipe up it creates a gap in the bottom of the screen and bounce to scroll up from the view.Please give a solution for this?
Before swipe up -
bcd

After swipe up -
abcd

Panel is not correctly placed on orientation change (tablet)

I'm using the swipeable panel on a tablet app and there is an issue when the tablet orientation change.
Opening the panel in landscape mode give this:
image
and when switching to portrait mode the panel is moved to the right:
image

Same issue when opening the panel in portrait mode and changing to landscape.
In this case, the panel is moved a little bit to the left.

Could you help to to solve this?

Typescript problem

'@types/rn-swipeable-panel@latest' is not in the npm registry either in yarn

noBar prop doesn't remove the grey Bar

Setting the noBar prop to true doesn't remove the grey bar. Can a fix for that be made? Seems like it would be a quick one. I could even work on it if that's something you'd be open to

Feature Request: onlySmall option

It wold be great to have and onlySmall option that prevent the container to go large when user swipes up. I use only the small version in my app and makes no sense when the user enlarge it because its only blank space.

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.