Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 48 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
[![npm version](https://badge.fury.io/js/react-native-dynamic-tab-view.svg)](https://badge.fury.io/js/react-native-dynamic-tab-view)

## Features
## Features

![example-gif](https://github.com/oguzkaganeren/react-native-dynamic-tab-view/blob/master/example.gif)

- Easy to use and easy to read code
- React-Native Javascript library built on top of `FlatList`.

### Usecases
- Dynamic tab data that can be populated by code (typically tabs are determined by an API call)
- Ability to select any index (and just the zeroth index) as the default index.
### Usecases

- Dynamic tab data that can be populated by code (typically tabs are determined by an API call)
- Ability to select any index (and just the zeroth index) as the default index.

## How to use

Simply install by running `yarn add react-native-dynamic-tab-view`

Use it by
Use it by

```
import DynamicTabView from 'react-native-dynamic-tab-view';
Expand All @@ -35,51 +40,56 @@ Here `data` is of the format
{ title: 'Tab3', key: 'item3' },
]
```
`title` sets the tab title

`title` sets the tab title
`key` is used internally by React. It can be any unique string

### Important Props
* **data** data to tell the number of tabs and set the layout
* **renderTab** method to render individual tab. It should return a valid React Component
* **onChangeTab** callback that will be invoked when a user changes tab
* **defaultIndex** index of the tab that will be selected by default.
* **containerStyle** style for the dynamic tab view container
* **headerBackgroundColor** background color for header
* **headerUnderlayColor** Color for header underlay
* **headerTextStyle** style for header text
### Important Props

- **data** data to tell the number of tabs and set the layout
- **renderTab** method to render individual tab. It should return a valid React Component
- **onChangeTab** callback that will be invoked when a user changes tab
- **defaultIndex** index of the tab that will be selected by default.
- **containerStyle** style for the dynamic tab view container
- **headerBackgroundColor** background color for header
- **headerUnderlayColor** Color for header underlay
- **headerTextStyle** style for header text

### Run the Example project

1. `cd Example`
2. `npm install`
3. `react-native run-android` or `react-native run-ios`


or try expo: [Dynamic Tab View Example](https://snack.expo.io/@har2008preet/vigorous-apples)

## FAQs

### Why are you building another TabView library?
At present, there are two tabView libraries that are out there
* [react-native-scrollable-tab-view](https://www.google.com/search?q=react-native-scrollable-tab-view)
* [react-native-tab-view](https://github.com/react-native-community/react-native-tab-view)
I have used both of them and I had multitude of issues with them.
* `react-native-scrollable-tab-view`
- Doesn't have proper maintainence. Last update was back in October. There are lot of open PRs.
- Code is bloated and I tried fixing issues, but couldn't navigate my way through
- Uses different code for Android and iOS and therefore I had issues like some view works with Android well and not with iOS and viceverca
* `react-native-tab-view`
### Why are you building another TabView library?

At present, there are two tabView libraries that are out there

- [react-native-scrollable-tab-view](https://www.google.com/search?q=react-native-scrollable-tab-view)
- [react-native-tab-view](https://github.com/react-native-community/react-native-tab-view)
I have used both of them and I had multitude of issues with them.
- `react-native-scrollable-tab-view`
- Doesn't have proper maintainence. Last update was back in October. There are lot of open PRs.
- Code is bloated and I tried fixing issues, but couldn't navigate my way through
- Uses different code for Android and iOS and therefore I had issues like some view works with Android well and not with iOS and viceverca
- `react-native-tab-view`
- Uses different code for Android and iOS
- Couldn't get default page selected working with this.
- Couldn't get default page selected working with this.
- Built and works well for static views (dynamic tabs doesn't work very well with Android)



### How's react-native-dynamic-tab-view different?
- Uses same code for Android and iOS
- More importantly, uses FlatList for creating the tabViews
- Easy to read code

### Contributors
* [@yeswanth](https://github.com/yeswanth)
* [@priyathamv](https://github.com/priyathamv)
* [@indupal](https://github.com/indupal)
* [@har2008preet](https://github.com/har2008preet) - Expo Example

- Uses same code for Android and iOS
- More importantly, uses FlatList for creating the tabViews
- Easy to read code

### Contributors

- [@yeswanth](https://github.com/yeswanth)
- [@priyathamv](https://github.com/priyathamv)
- [@indupal](https://github.com/indupal)
- [@har2008preet](https://github.com/har2008preet) - Expo Example
Binary file added example.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions src/DynamicTabView.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import { ColorValue } from 'react-native';
export interface DynamicTabProps {
defaultIndex: Number;
containerStyle: StyleSheet;
headerContainerStyle: StyleSheet;
headerBackgroundColor: ColorValue;
headerTextStyle: StyleSheet;
headerActiveTextStyle: StyleSheet;
headerUnderlayColor: ColorValue;
highlightStyle: StyleSheet;
data: any;
tabContainerStyle: StyleSheet;
noHighlightStyle: StyleSheet;
extraData: any;
renderTab: CallableFunction;
onChangeTab: CallableFunction;
}
declare const DynamicTabView: React.FC<DynamicTabProps>;
export default DynamicTabView;
204 changes: 0 additions & 204 deletions src/DynamicTabView.js

This file was deleted.

Loading