-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add docs for tabBarOnLongPress and animated switch navigator #404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
83682d7
chore: add doc for tabBarOnLongPress
ad75f42
update docs on v3 branch
e591ef3
docs about animated switch navigator
c8e2a04
Update wording for docs/animated-switch-navigator.md
brentvatne f781abe
document the transition option for animated switch navigator
0bb05f8
Merge branch 'source' into update-docs
brentvatne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
id: animated-switch-navigator | ||
title: createAnimatedSwitchNavigator | ||
sidebar_label: createAnimatedSwitchNavigator | ||
--- | ||
|
||
A switch navigator with the ability to animate transitions between screens. | ||
|
||
To use this navigator, you need to install `react-native-reanimated >= 1.0.0`. If you have a managed Expo project, you need to use >= SDK 33 to have the correct version of Reanimated. | ||
|
||
## API Definition | ||
|
||
```js | ||
import createAnimatedSwitchNavigator from 'react-navigation-animated-switch'; | ||
|
||
createAnimatedSwitchNavigator(RouteConfigs, SwitchNavigatorConfig); | ||
``` | ||
|
||
The route configs and navigator configs are identical to [createSwitchNavigator](switch-navigator.html) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
website/versioned_docs/version-3.x/animated-switch-navigator.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
id: version-3.x-animated-switch-navigator | ||
title: createAnimatedSwitchNavigator | ||
sidebar_label: createAnimatedSwitchNavigator | ||
original_id: animated-switch-navigator | ||
--- | ||
|
||
An SwitchNavigator with animation support. | ||
|
||
To use this navigator, you need to install `react-native-reanimated >= 1.0.0`. If you have a managed Expo project, you need to use >= SDK 33 to have the correct version of Reanimated. | ||
|
||
## API Definition | ||
|
||
```js | ||
import createAnimatedSwitchNavigator from 'react-navigation-animated-switch'; | ||
|
||
createAnimatedSwitchNavigator(RouteConfigs, SwitchNavigatorConfig); | ||
``` | ||
|
||
## RouteConfigs | ||
|
||
The route configs are identical to [createSwitchNavigator](switch-navigator.html) | ||
|
||
## SwitchNavigatorConfig | ||
|
||
The switch navigator configs are identical to [createSwitchNavigator](switch-navigator.html). | ||
|
||
By default, the transition between screens is a cross-fade. You can customize the transition with an additional option `transition`: | ||
|
||
```jsx | ||
import createAnimatedSwitchNavigator from 'react-navigation-animated-switch'; | ||
import { Transition } from 'react-native-reanimated'; | ||
|
||
const MySwitch = createAnimatedSwitchNavigator( | ||
{ | ||
Home: HomeScreen, | ||
Other: OtherScreen, | ||
}, | ||
{ | ||
// The previous screen will slide to the bottom while the next screen will fade in | ||
transition: ( | ||
<Transition.Together> | ||
<Transition.Out | ||
type="slide-bottom" | ||
durationMs={400} | ||
interpolation="easeIn" | ||
/> | ||
<Transition.In type="fade" durationMs={500} /> | ||
</Transition.Together> | ||
), | ||
} | ||
); | ||
``` | ||
|
||
Since the transition are possible thanks to the `Transition` API from `react-native-reanimated`, you can learn more about it [here](https://github.com/kmagiera/react-native-reanimated). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
website/versioned_docs/version-3.x/material-bottom-tab-navigator.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
--- | ||
id: version-3.x-material-bottom-tab-navigator | ||
title: createMaterialBottomTabNavigator | ||
sidebar_label: createMaterialBottomTabNavigator | ||
original_id: material-bottom-tab-navigator | ||
--- | ||
|
||
A material-design themed tab bar on the bottom of the screen that lets you switch between different routes. Routes are lazily initialized -- their screen components are not mounted until they are first focused. | ||
|
||
<img src="/docs/assets/navigators/bottom-navigation.gif" style="width: 420px; max-width: 100%"> | ||
|
||
To use this navigator, you need to install `react-navigation-material-bottom-tabs` | ||
|
||
``` | ||
npm install react-navigation-material-bottom-tabs react-native-paper | ||
``` | ||
|
||
This API also requires that you install `react-native-vector-icons`! If you are using Expo, it will just work out of the box. Otherwise, [follow these installation instructions](https://github.com/oblador/react-native-vector-icons#installation). | ||
|
||
To use this tab navigator, import it from `react-navigation-material-bottom-tabs` | ||
|
||
```js | ||
import { createMaterialBottomTabNavigator } from "react-navigation-material-bottom-tabs"; | ||
|
||
createMaterialBottomTabNavigator( | ||
RouteConfigs, | ||
MaterialBottomTabNavigatorConfig | ||
); | ||
``` | ||
|
||
This library uses the [`BottomNavigation` component from `react-native-paper`](https://callstack.github.io/react-native-paper/bottom-navigation.html). It doesn't include the whole `react-native-paper` library in your bundle, so you don't need to worry about it. | ||
|
||
## RouteConfigs | ||
|
||
The route configs object is a mapping from route name to a route config. | ||
|
||
## MaterialBottomTabNavigatorConfig | ||
|
||
* `shifting` - Whether the shifting style is used, the active tab appears wider and the inactive tabs won't have a label. By default, this is `true` when you have more than 3 tabs. | ||
* `labeled` - Whether to show labels in tabs. When `false`, only icons will be displayed. | ||
* `activeColor` - Custom color for icon and label in the active tab. | ||
* `inactiveColor` - Custom color for icon and label in the inactive tab. | ||
* `barStyle` - Style for the bottom navigation bar. You can set a bottom padding here if you have a translucent navigation bar on Android: `barStyle={{ paddingBottom: 48 }}`. | ||
* `initialRouteName` - The routeName for the initial tab route when first loading. | ||
* `order` - Array of routeNames which defines the order of the tabs. | ||
* `paths` - Provide a mapping of routeName to path config, which overrides the paths set in the routeConfigs. | ||
* `backBehavior` - `initialRoute` to return to initial tab, `order` to return to previous tab, `history` to return to last visited tab, or `none`. | ||
|
||
Example: | ||
|
||
```js | ||
export default createMaterialBottomTabNavigator({ | ||
Album: { screen: Album }, | ||
Library: { screen: Library }, | ||
History: { screen: History }, | ||
Cart: { screen: Cart }, | ||
}, { | ||
initialRouteName: 'Album', | ||
activeColor: '#f0edf6', | ||
inactiveColor: '#3e2465', | ||
barStyle: { backgroundColor: '#694fad' }, | ||
}); | ||
``` | ||
|
||
## `navigationOptions` for screens inside of the navigator | ||
|
||
#### `title` | ||
|
||
Generic title that can be used as a fallback for `headerTitle` and `tabBarLabel`. | ||
|
||
#### `tabBarIcon` | ||
|
||
React Element or a function that given `{ focused: boolean, horizontal: boolean, tintColor: string }` returns a React.Node, to display in the tab bar. `horizontal` is `true` when the device is in landscape and `false` when portrait. The icon is re-rendered whenever the device orientation changes. | ||
|
||
#### `tabBarColor` | ||
|
||
Color for the tab bar when the tab corresponding to the screen is active. Used for the ripple effect. This is only supported when `shifting` is `true`. | ||
|
||
#### `tabBarLabel` | ||
|
||
Title string of a tab displayed in the tab bar. When undefined, scene `title` is used. To hide, see `labeled` option in the previous section. | ||
|
||
#### `tabBarAccessibilityLabel` | ||
|
||
Accessibility label for the tab button. This is read by the screen reader when the user taps the tab. It's recommended to set this if you don't have a label for the tab. | ||
|
||
#### `tabBarTestID` | ||
|
||
ID to locate this tab button in tests. | ||
|
||
#### `tabBarOnPress` | ||
|
||
Callback to handle press events; the argument is an object containing: | ||
|
||
* `navigation`: navigation prop for the screen | ||
* `defaultHandler`: the default handler for tab press | ||
|
||
Useful for adding a custom logic before the transition to the next scene (the tapped one) starts. | ||
|
||
## Using with `react-native-paper` (optional) | ||
|
||
You can use the theming support in `react-native-paper` to customize the material bottom navigation by wrapping your app in [`Provider` from `react-native-paper`](https://callstack.github.io/react-native-paper/getting-started.html). A common use case for this can be to customize the background color for the screens when your app has a dark theme. Follow the [instructions on `react-native-paper`'s documentation](https://callstack.github.io/react-native-paper/theming.html) to learn how to customize the theme. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
id: version-3.x-tab-navigator | ||
title: createTabNavigator | ||
sidebar_label: createTabNavigator | ||
original_id: tab-navigator | ||
--- | ||
|
||
> Note: `createTabNavigator` is removed in `react-navigation@3.x`. Please use `createBottomTabNavigator` and/or `createMaterialTopTabNavigator` instead. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.