PedroBern / react-native-collapsible-tab-view

A cross-platform Collapsible Tab View component for React Native
MIT License
869 stars 171 forks source link

Possibility to set the swipeEnabled to false for the Tabs.Tab #238

Open Audrey-Ann opened 2 years ago

Audrey-Ann commented 2 years ago

Feature request

Hello there! I would like to be able to disable the swipe gesture on the Tabs.Tab. That being said, I want to be in control on when the user is able to swipe between tabs. Just like how material-top-tab-navigator does it :

https://reactnavigation.org/docs/material-top-tab-navigator/#swipeenabled

Thank you!

Current behavior

Right now, there is no way to disable the gesture.

andreialecu commented 2 years ago

As an alternative, check out https://github.com/PedroBern/react-native-collapsible-segmented-view

Audrey-Ann commented 2 years ago

Thank you @andreialecu for your fast response, I will try to Fork your project and add this functionality to it :)

I really like how you did it and I need both functionality: allow swipe and disable it.

If you have any other recommandations please do !

Have a wonderful day and thank you again for providing this cool feature ! (and the code is clean !! Love it)

Audrey-Ann commented 2 years ago

@andreialecu after forking the project and playing with the code, I managed with very few lines of code to achieve this feature ! Here are two commits where I managed to do two things

Tested and works well :) Let me know what you think!

kokweng911 commented 2 years ago

@andreialecu after forking the project and playing with the code, I managed with very few lines of code to achieve this feature ! Here are two commits where I managed to do two things

Tested and works well :) Let me know what you think!

You can just add pagerProps={{ scrollEnabled: false }} into Tabs.Container as props scrolling is disabled.

Audrey-Ann commented 2 years ago

@kokweng911 oh I will have to test that!

Still need to hide the tab though too if that something we could integrate into the package: https://github.com/Audrey-Ann/react-native-collapsible-tab-view/commit/8963f4911206d42ab8e4c209206361a238110cae

andreialecu commented 2 years ago

You can conditionally not render the tab via condition && <Tabs.Tab.

Audrey-Ann commented 2 years ago

@andreialecu but I still want to show the content of the tab, just want to hide it. :)

andreialecu commented 2 years ago

I'm not sure I understand what you mean by "show" but "hide".

Mind explaining an exact use case?

Audrey-Ann commented 2 years ago

Of course!

My use case is:

Hope this explanation is clearer. You can see in the commit https://github.com/Audrey-Ann/react-native-collapsible-tab-view/commit/8963f4911206d42ab8e4c209206361a238110cae, it simply hides the tab "label" / "name".

Audrey-Ann commented 2 years ago

@andreialecu any comments on the above ? :) Thanks in advance