From 0a662c983503e7cc4d30503c452626f6ab9a7a29 Mon Sep 17 00:00:00 2001 From: Dave Rogers Date: Mon, 20 Nov 2017 16:16:43 -0700 Subject: [PATCH] Allow transition configuration between tabs (#2222) * allow transition configuration between tabs * we don't need to pass configureTransition to TabBarComponent * Update TabAnimations.js * Update TabNavigator.md --- docs/api/navigators/TabNavigator.md | 1 + examples/NavigationPlayground/js/App.js | 6 + .../NavigationPlayground/js/TabAnimations.js | 126 ++++++++++++++++++ src/navigators/TabNavigator.js | 2 + src/views/TabView/TabView.js | 15 ++- 5 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 examples/NavigationPlayground/js/TabAnimations.js diff --git a/docs/api/navigators/TabNavigator.md b/docs/api/navigators/TabNavigator.md index 062122d..ebec7e2 100644 --- a/docs/api/navigators/TabNavigator.md +++ b/docs/api/navigators/TabNavigator.md @@ -87,6 +87,7 @@ The route configs object is a mapping from route name to a route config, which t - `tabBarPosition` - Position of the tab bar, can be `'top'` or `'bottom'`. - `swipeEnabled` - Whether to allow swiping between tabs. - `animationEnabled` - Whether to animate when changing tabs. +- `configureTransition` - a function that, given `currentTransitionProps` and `nextTransitionProps`, returns a configuration object that describes the animation between tabs. - `lazy` - Whether to lazily render tabs as needed as opposed to rendering them upfront. - `initialLayout` - Optional object containing the initial `height` and `width`, can be passed to prevent the one frame delay in [react-native-tab-view](https://github.com/react-native-community/react-native-tab-view#avoid-one-frame-delay) rendering. - `tabBarOptions` - Configure the tab bar, see below. diff --git a/examples/NavigationPlayground/js/App.js b/examples/NavigationPlayground/js/App.js index ac849a2..94798b5 100644 --- a/examples/NavigationPlayground/js/App.js +++ b/examples/NavigationPlayground/js/App.js @@ -25,6 +25,7 @@ import StacksInTabs from './StacksInTabs'; import StacksOverTabs from './StacksOverTabs'; import SimpleStack from './SimpleStack'; import SimpleTabs from './SimpleTabs'; +import TabAnimations from './TabAnimations'; const ExampleRoutes = { SimpleStack: { @@ -90,6 +91,11 @@ const ExampleRoutes = { screen: SimpleTabs, path: 'settings', }, + TabAnimations: { + name: 'Animated Tabs Example', + description: 'Tab transitions have custom animations', + screen: TabAnimations, + }, }; const MainScreen = ({ navigation }) => ( diff --git a/examples/NavigationPlayground/js/TabAnimations.js b/examples/NavigationPlayground/js/TabAnimations.js new file mode 100644 index 0000000..ebe2512 --- /dev/null +++ b/examples/NavigationPlayground/js/TabAnimations.js @@ -0,0 +1,126 @@ +/** + * @flow + */ + +import React from 'react'; +import { Button, ScrollView, Animated } from 'react-native'; +import { StackNavigator, TabNavigator } from 'react-navigation'; + +import Ionicons from 'react-native-vector-icons/Ionicons'; +import SampleText from './SampleText'; + +const MyNavScreen = ({ navigation, banner }) => ( + + {banner} +