An open API service indexing awesome lists of open source software.

https://github.com/r0b0t3d/react-native-collapsible

Fully customizable collapsible views
https://github.com/r0b0t3d/react-native-collapsible

collapsible collapsible-accordion collapsible-headers

Last synced: about 2 months ago
JSON representation

Fully customizable collapsible views

Awesome Lists containing this project

README

        

# @r0b0t3d/react-native-collapsible

Fully customizable collapsible views

![alt text](pictures/intro.gif 'Intro')

## Installation

```sh
yarn add @r0b0t3d/react-native-collapsible
```

I am using `reanimated 2` for animation. So you should install and follow instruction here to setup your project [react-native-reanimated](https://docs.swmansion.com/react-native-reanimated/docs/installation)

## Key features
1️⃣ Support FlatList/ScrollView
2️⃣ Support sticky header
3️⃣ Can have multiple sticky headers
4️⃣ Easy to customize

## Usage
### 1. Basic
```jsx
import {
CollapsibleContainer,
CollapsibleFlatList,
CollapsibleScrollView,
} from '@r0b0t3d/react-native-collapsible';

// ...
const MyComponent = () => {
const {
collapse, // <-- Collapse header
expand, // <-- Expand header
scrollY, // <-- Animated scroll position. In case you need to do some animation in your header or somewhere else
} = useCollapsibleContext();

return (
// 1️⃣ (Required) Outermost container
// 2️⃣ (Required) Header view

// 3️⃣ Sticky view





)
}

export default withCollapsibleContext(MyComponent); // 5️⃣ (Required)wrap your component with `withCollapsibleContext`
```

### 2. Advance
We support multiple `CollapsibleHeaderContainer` and `StickyView`. It come useful in case you need to break your code into smaller component.

`Parent.tsx`
```jsx
const Parent = () => {
const [tabIndex, setTabIndex] = useState(0)

return (






{tabIndex === 0 && }
{tabIndex === 1 && }

)
}
```

`FirstTab.tsx`
```jsx
const FirstTab = () => {
return (
<>











>
)
}
```

## Showcases
```
Note: Feel free to add your showcase here by a PR
```
| App | Gif |
| ----------- | ----------- |
| [ANU Global](https://apps.apple.com/us/app/anu-global/id1540735849) | |

## Breaking changes

### 1.0.0

- Removed

- `persistHeaderHeight`
- `contentMinHeight`

- Added
- `CollapsibleContainer`
- `StickyView`

## Tips

#### 1. Trigger scroll when scroll inside `CollapsibleHeaderContainer`

- If your header doesn't contains touchable component, try `pointerEvents="none"`

```jsx


Header

```

- If your header contains touchable componet, try to set `pointerEvents="box-none"` for every nested views that contains touchable, otherwise use `pointerEvents="none"`

```jsx

// <-- this is parent view
// <-- this view doesn't contain touchable component
Header

// <-- this view contain touchable component

Some text


Button


```

## Contributing

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

## License

MIT