Compare commits

..

15 Commits

Author SHA1 Message Date
Satyajit Sahoo
e87925c086 chore: publish
- @react-navigation/bottom-tabs@5.0.0-alpha.23
 - @react-navigation/core@5.0.0-alpha.26
 - @react-navigation/drawer@5.0.0-alpha.25
 - @react-navigation/material-bottom-tabs@5.0.0-alpha.22
 - @react-navigation/material-top-tabs@5.0.0-alpha.20
 - @react-navigation/native-stack@5.0.0-alpha.15
 - @react-navigation/stack@5.0.0-alpha.40
2019-12-07 05:23:12 +01:00
Satyajit Sahoo
7b13a81ac8 fix: don't handle replace if screen to replace with isn't present
fixes #193
2019-12-07 05:22:19 +01:00
Satyajit Sahoo
d618ab382e feat: export underlying views used to build navigators (#191)
Exporting the underlying views makes it easy to build custom navigators on top of our views. Libraries such as react-native-router-flux rely on such exports to build custom routing solutions while being able to take advantage of our work.

This can also be the solution to adding custom behaviour without us needing to add separate config to override the router.
2019-12-04 00:22:53 +01:00
Satyajit Sahoo
c7a5cfd5b2 chore: publish
- @react-navigation/stack@5.0.0-alpha.39
2019-12-03 20:40:35 +01:00
Satyajit Sahoo
87d445b4e4 fix: disable pointerEvents on header when not focused 2019-12-03 20:33:41 +01:00
Satyajit Sahoo
eaf88478cc fix: correctly update layout on onLayout events 2019-12-03 20:32:38 +01:00
Satyajit Sahoo
f271e299ac chore: publish
- @react-navigation/core@5.0.0-alpha.25
 - @react-navigation/stack@5.0.0-alpha.38
2019-11-29 18:10:20 +01:00
Michał Osadnik
5a0dfa1a15 fix: wrap reset and resetRoot inside transaction (#189)
fixes #185
2019-11-29 17:40:28 +01:00
Satyajit Sahoo
2750cad272 fix: respect custom safearea insets when calculating header height
fixes #190
2019-11-29 17:25:34 +01:00
Satyajit Sahoo
2e715ef48e chore: publish
- @react-navigation/drawer@5.0.0-alpha.24
2019-11-27 13:07:20 +01:00
Satyajit Sahoo
7080517c91 fix: enable gestures by default in drawer. closes #188 2019-11-27 13:04:31 +01:00
osdnk
d733066476 chore: publish
- @react-navigation/core@5.0.0-alpha.24
 - @react-navigation/example@5.0.0-alpha.23
 - @react-navigation/material-top-tabs@5.0.0-alpha.19
 - @react-navigation/native-stack@5.0.0-alpha.14
2019-11-20 16:01:25 +01:00
osdnk
d0099f0968 chore: bump rntv 2019-11-20 16:00:30 +01:00
Thibault Malbranche
c3e9e4578e fix: allow passing partial params to setParams (#177)
Since params get merged, no need to send them all I think :)
2019-11-19 22:58:44 +01:00
Satyajit Sahoo
cb426d06de docs: add large title example 2019-11-18 01:16:33 +01:00
40 changed files with 466 additions and 202 deletions

View File

@@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [5.0.0-alpha.23](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/bottom-tabs@5.0.0-alpha.22...@react-navigation/bottom-tabs@5.0.0-alpha.23) (2019-12-07)
### Features
* export underlying views used to build navigators ([#191](https://github.com/react-navigation/navigation-ex/issues/191)) ([d618ab3](https://github.com/react-navigation/navigation-ex/commit/d618ab382ecc5eccbcd5faa89e76f9ed2d75f405))
# [5.0.0-alpha.22](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/bottom-tabs@5.0.0-alpha.21...@react-navigation/bottom-tabs@5.0.0-alpha.22) (2019-11-17)

View File

@@ -10,7 +10,7 @@
"android",
"tab"
],
"version": "5.0.0-alpha.22",
"version": "5.0.0-alpha.23",
"license": "MIT",
"repository": {
"type": "git",

View File

@@ -6,6 +6,7 @@ export { default as createBottomTabNavigator } from './navigators/createBottomTa
/**
* Views
*/
export { default as BottomTabView } from './views/BottomTabView';
export { default as BottomTabBar } from './views/BottomTabBar';
/**

View File

@@ -3,6 +3,39 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [5.0.0-alpha.26](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/core@5.0.0-alpha.25...@react-navigation/core@5.0.0-alpha.26) (2019-12-07)
### Bug Fixes
* don't handle replace if screen to replace with isn't present ([7b13a81](https://github.com/react-navigation/navigation-ex/commit/7b13a81ac8260879c8658be5704f46db59a72c73)), closes [#193](https://github.com/react-navigation/navigation-ex/issues/193)
# [5.0.0-alpha.25](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/core@5.0.0-alpha.24...@react-navigation/core@5.0.0-alpha.25) (2019-11-29)
### Bug Fixes
* wrap reset and resetRoot inside transaction ([#189](https://github.com/react-navigation/navigation-ex/issues/189)) ([5a0dfa1](https://github.com/react-navigation/navigation-ex/commit/5a0dfa1a155715714c8483fafc5a94dbc5120754)), closes [#185](https://github.com/react-navigation/navigation-ex/issues/185)
# [5.0.0-alpha.24](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/core@5.0.0-alpha.23...@react-navigation/core@5.0.0-alpha.24) (2019-11-20)
### Bug Fixes
* allow passing partial params to `setParams` ([#177](https://github.com/react-navigation/navigation-ex/issues/177)) ([c3e9e45](https://github.com/react-navigation/navigation-ex/commit/c3e9e4578e98aa5b0635949a288e19eaeec12c85))
# [5.0.0-alpha.23](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/core@5.0.0-alpha.22...@react-navigation/core@5.0.0-alpha.23) (2019-11-17)

View File

@@ -6,7 +6,7 @@
"react-native",
"react-navigation"
],
"version": "5.0.0-alpha.23",
"version": "5.0.0-alpha.26",
"license": "MIT",
"repository": {
"type": "git",

View File

@@ -22,6 +22,10 @@ const BaseRouter = {
const { name, key, params } = action.payload;
if (!state.routeNames.includes(name)) {
return null;
}
return {
...state,
routes: state.routes.map((route, i) =>

View File

@@ -112,79 +112,6 @@ const Container = React.forwardRef(function NavigationContainer(
const isFirstMountRef = React.useRef<boolean>(true);
const skipTrackingRef = React.useRef<boolean>(false);
const reset = React.useCallback((state: NavigationState) => {
skipTrackingRef.current = true;
setNavigationState(state);
}, []);
const { trackState, trackAction } = useDevTools({
name: '@react-navigation',
reset,
state,
});
const { listeners, addListener: addFocusedListener } = useFocusedListeners();
const { getStateForRoute, addStateGetter } = useStateGetters();
const dispatch = (
action: NavigationAction | ((state: NavigationState) => NavigationAction)
) => {
listeners[0](navigation => navigation.dispatch(action));
};
const canGoBack = () => {
const { result, handled } = listeners[0](navigation =>
navigation.canGoBack()
);
if (handled) {
return result;
} else {
return false;
}
};
const resetRoot = React.useCallback(
(state?: PartialState<NavigationState> | NavigationState) => {
trackAction('@@RESET_ROOT');
setNavigationState(state);
},
[trackAction]
);
const getRootState = React.useCallback(() => {
return getStateForRoute('root');
}, [getStateForRoute]);
React.useImperativeHandle(ref, () => ({
...(Object.keys(CommonActions) as Array<keyof typeof CommonActions>).reduce<
any
>((acc, name) => {
acc[name] = (...args: any[]) =>
dispatch(
CommonActions[name](
// @ts-ignore
...args
)
);
return acc;
}, {}),
resetRoot,
dispatch,
canGoBack,
getRootState,
}));
const builderContext = React.useMemo(
() => ({
addFocusedListener,
addStateGetter,
trackAction,
}),
[addFocusedListener, trackAction, addStateGetter]
);
const performTransaction = React.useCallback((callback: () => void) => {
if (isTransactionActiveRef.current) {
throw new Error(
@@ -222,6 +149,86 @@ const Container = React.forwardRef(function NavigationContainer(
transactionStateRef.current = navigationState;
}, []);
const reset = React.useCallback(
(state: NavigationState) => {
performTransaction(() => {
skipTrackingRef.current = true;
setState(state);
});
},
[performTransaction, setState]
);
const { trackState, trackAction } = useDevTools({
name: '@react-navigation',
reset,
state,
});
const { listeners, addListener: addFocusedListener } = useFocusedListeners();
const { getStateForRoute, addStateGetter } = useStateGetters();
const dispatch = (
action: NavigationAction | ((state: NavigationState) => NavigationAction)
) => {
listeners[0](navigation => navigation.dispatch(action));
};
const canGoBack = () => {
const { result, handled } = listeners[0](navigation =>
navigation.canGoBack()
);
if (handled) {
return result;
} else {
return false;
}
};
const resetRoot = React.useCallback(
(state?: PartialState<NavigationState> | NavigationState) => {
performTransaction(() => {
trackAction('@@RESET_ROOT');
setState(state);
});
},
[performTransaction, setState, trackAction]
);
const getRootState = React.useCallback(() => {
return getStateForRoute('root');
}, [getStateForRoute]);
React.useImperativeHandle(ref, () => ({
...(Object.keys(CommonActions) as Array<keyof typeof CommonActions>).reduce<
any
>((acc, name) => {
acc[name] = (...args: any[]) =>
dispatch(
CommonActions[name](
// @ts-ignore
...args
)
);
return acc;
}, {}),
resetRoot,
dispatch,
canGoBack,
getRootState,
}));
const builderContext = React.useMemo(
() => ({
addFocusedListener,
addStateGetter,
trackAction,
}),
[addFocusedListener, trackAction, addStateGetter]
);
const context = React.useMemo(
() => ({
state,

View File

@@ -65,6 +65,15 @@ it("doesn't handle REPLACE if source key isn't present", () => {
expect(result).toBe(null);
});
it("doesn't handle REPLACE if screen to replace with isn't present", () => {
const result = BaseRouter.getStateForAction(
STATE,
CommonActions.replace('nonexistent', { answer: 42 })
);
expect(result).toBe(null);
});
it('sets params for the focused screen with SET_PARAMS', () => {
const result = BaseRouter.getStateForAction(
STATE,

View File

@@ -371,7 +371,7 @@ export type NavigationHelpers<
* @param params Params object for the current route.
*/
setParams<RouteName extends keyof ParamList>(
params: ParamList[RouteName]
params: Partial<ParamList[RouteName]>
): void;
};
@@ -409,7 +409,7 @@ export type NavigationProp<
*
* @param params Params object for the current route.
*/
setParams(params: ParamList[RouteName]): void;
setParams(params: Partial<ParamList[RouteName]>): void;
/**
* Update the options for the route.

View File

@@ -3,6 +3,28 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [5.0.0-alpha.25](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/drawer@5.0.0-alpha.24...@react-navigation/drawer@5.0.0-alpha.25) (2019-12-07)
### Features
* export underlying views used to build navigators ([#191](https://github.com/react-navigation/navigation-ex/issues/191)) ([d618ab3](https://github.com/react-navigation/navigation-ex/commit/d618ab382ecc5eccbcd5faa89e76f9ed2d75f405))
# [5.0.0-alpha.24](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/drawer@5.0.0-alpha.23...@react-navigation/drawer@5.0.0-alpha.24) (2019-11-27)
### Bug Fixes
* enable gestures by default in drawer. closes [#188](https://github.com/react-navigation/navigation-ex/issues/188) ([7080517](https://github.com/react-navigation/navigation-ex/commit/7080517c914b4821e07a6320de94660e50d02950))
# [5.0.0-alpha.23](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/drawer@5.0.0-alpha.22...@react-navigation/drawer@5.0.0-alpha.23) (2019-11-17)

View File

@@ -11,7 +11,7 @@
"material",
"drawer"
],
"version": "5.0.0-alpha.23",
"version": "5.0.0-alpha.25",
"license": "MIT",
"repository": {
"type": "git",

View File

@@ -6,10 +6,10 @@ export { default as createDrawerNavigator } from './navigators/createDrawerNavig
/**
* Views
*/
export { default as DrawerView } from './views/DrawerView';
export { default as DrawerItem } from './views/DrawerItem';
export { default as DrawerItemList } from './views/DrawerItemList';
export { default as DrawerContent } from './views/DrawerContent';
export { default as DrawerView } from './views/DrawerView';
/**
* Utilities

View File

@@ -40,10 +40,10 @@ function DrawerNavigator({
return (
<DrawerView
{...rest}
state={state}
descriptors={descriptors}
navigation={navigation}
{...rest}
/>
);
}

View File

@@ -97,9 +97,9 @@ type Props = {
export default class DrawerView extends React.PureComponent<Props> {
static defaultProps = {
locked: false,
drawerPostion: I18nManager.isRTL ? 'left' : 'right',
drawerType: 'front',
gestureEnabled: true,
swipeEdgeWidth: 32,
swipeVelocityThreshold: 500,
keyboardDismissMode: 'on-drag',
@@ -447,10 +447,7 @@ export default class DrawerView extends React.PureComponent<Props> {
{
nativeEvent: {
oldState: (s: Animated.Value<number>) =>
cond(
and(eq(s, State.ACTIVE), this.isGestureEnabled),
set(this.manuallyTriggerSpring, TRUE)
),
cond(eq(s, State.ACTIVE), set(this.manuallyTriggerSpring, TRUE)),
},
},
]);

View File

@@ -217,7 +217,7 @@ export default class DrawerView extends React.PureComponent<Props, State> {
<DrawerGestureContext.Provider value={this.drawerGestureRef}>
<Drawer
open={state.isDrawerOpen}
gestureEnabled={gestureEnabled === true}
gestureEnabled={gestureEnabled !== false}
onOpen={this.handleDrawerOpen}
onClose={this.handleDrawerClose}
onGestureRef={this.setDrawerGestureRef}

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [5.0.0-alpha.23](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/example@5.0.0-alpha.22...@react-navigation/example@5.0.0-alpha.23) (2019-11-20)
**Note:** Version bump only for package @react-navigation/example
# [5.0.0-alpha.22](https://github.com/satya164/navigation-ex/compare/@react-navigation/example@5.0.0-alpha.21...@react-navigation/example@5.0.0-alpha.22) (2019-11-17)
**Note:** Version bump only for package @react-navigation/example

View File

@@ -1,7 +1,7 @@
{
"name": "@react-navigation/example",
"description": "Demo app to showcase various functionality of React Navigation",
"version": "5.0.0-alpha.22",
"version": "5.0.0-alpha.23",
"private": true,
"workspaces": {
"nohoist": [
@@ -32,7 +32,7 @@
"react-native-reanimated-web": "npm:react-native-reanimated@^1.3.2",
"react-native-safe-area-context": "~0.6.0",
"react-native-screens": "^2.0.0-alpha.11",
"react-native-tab-view": "2.10.2",
"react-native-tab-view": "2.11.0",
"react-native-unimodules": "^0.7.0-rc.1",
"react-native-web": "^0.11.7",
"scheduler": "^0.18.0",

View File

@@ -1,5 +1,5 @@
import * as React from 'react';
import { View, StyleSheet } from 'react-native';
import { View, Text, ScrollView, StyleSheet } from 'react-native';
import { Button } from 'react-native-paper';
// eslint-disable-next-line import/no-unresolved
import { enableScreens } from 'react-native-screens';
@@ -14,7 +14,6 @@ import {
createNativeStackNavigator,
NativeStackNavigationProp,
} from '@react-navigation/native-stack';
import Article from '../Shared/Article';
import Albums from '../Shared/Albums';
type NativeStackParams = {
@@ -26,12 +25,11 @@ type NativeStackNavigation = NativeStackNavigationProp<NativeStackParams>;
const ArticleScreen = ({
navigation,
route,
}: {
navigation: NativeStackNavigation;
route: RouteProp<NativeStackParams, 'article'>;
}) => (
<React.Fragment>
<ScrollView style={styles.container} contentContainerStyle={styles.content}>
<View style={styles.buttons}>
<Button
mode="contained"
@@ -48,8 +46,66 @@ const ArticleScreen = ({
Go back
</Button>
</View>
<Article author={{ name: route.params.author }} />
</React.Fragment>
<Text style={styles.title}>What is Lorem Ipsum?</Text>
<Text style={styles.paragraph}>
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry&apos;s standard dummy text ever since
the 1500s, when an unknown printer took a galley of type and scrambled it
to make a type specimen book. It has survived not only five centuries, but
also the leap into electronic typesetting, remaining essentially
unchanged. It was popularised in the 1960s with the release of Letraset
sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem
Ipsum.
</Text>
<Text style={styles.title}>Where does it come from?</Text>
<Text style={styles.paragraph}>
Contrary to popular belief, Lorem Ipsum is not simply random text. It has
roots in a piece of classical Latin literature from 45 BC, making it over
2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney
College in Virginia, looked up one of the more obscure Latin words,
consectetur, from a Lorem Ipsum passage, and going through the cites of
the word in classical literature, discovered the undoubtable source. Lorem
Ipsum comes from sections 1.10.32 and 1.10.33 of &quot;de Finibus Bonorum
et Malorum&quot; (The Extremes of Good and Evil) by Cicero, written in 45
BC. This book is a treatise on the theory of ethics, very popular during
the Renaissance. The first line of Lorem Ipsum, &quot;Lorem ipsum dolor
sit amet..&quot;, comes from a line in section 1.10.32.
</Text>
<Text style={styles.paragraph}>
The standard chunk of Lorem Ipsum used since the 1500s is reproduced below
for those interested. Sections 1.10.32 and 1.10.33 from &quot;de Finibus
Bonorum et Malorum&quot; by Cicero are also reproduced in their exact
original form, accompanied by English versions from the 1914 translation
by H. Rackham.
</Text>
<Text style={styles.title}>Why do we use it?</Text>
<Text style={styles.paragraph}>
It is a long established fact that a reader will be distracted by the
readable content of a page when looking at its layout. The point of using
Lorem Ipsum is that it has a more-or-less normal distribution of letters,
as opposed to using &quot;Content here, content here&quot;, making it look
like readable English. Many desktop publishing packages and web page
editors now use Lorem Ipsum as their default model text, and a search for
&quot;lorem ipsum&quot; will uncover many web sites still in their
infancy. Various versions have evolved over the years, sometimes by
accident, sometimes on purpose (injected humour and the like).
</Text>
<Text style={styles.title}>Where can I get some?</Text>
<Text style={styles.paragraph}>
There are many variations of passages of Lorem Ipsum available, but the
majority have suffered alteration in some form, by injected humour, or
randomised words which don&apos;t look even slightly believable. If you
are going to use a passage of Lorem Ipsum, you need to be sure there
isn&apos;t anything embarrassing hidden in the middle of text. All the
Lorem Ipsum generators on the Internet tend to repeat predefined chunks as
necessary, making this the first true generator on the Internet. It uses a
dictionary of over 200 Latin words, combined with a handful of model
sentence structures, to generate Lorem Ipsum which looks reasonable. The
generated Lorem Ipsum is therefore always free from repetition, injected
humour, or non-characteristic words etc.
</Text>
</ScrollView>
);
const AlbumsScreen = ({
@@ -110,10 +166,11 @@ export default function NativeStackScreen({ navigation }: Props) {
<NativeStack.Screen
name="article"
component={ArticleScreen}
options={({ route }) => ({
title: `Article by ${route.params.author}`,
})}
initialParams={{ author: 'Gandalf' }}
options={{
title: 'Lorem Ipsum',
headerLargeTitle: true,
headerHideShadow: true,
}}
/>
<NativeStack.Screen
name="album"
@@ -134,4 +191,24 @@ const styles = StyleSheet.create({
button: {
margin: 8,
},
container: {
backgroundColor: 'white',
},
content: {
paddingVertical: 16,
},
title: {
color: '#000',
fontWeight: 'bold',
fontSize: 24,
marginVertical: 8,
marginHorizontal: 16,
},
paragraph: {
color: '#000',
fontSize: 16,
lineHeight: 24,
marginVertical: 8,
marginHorizontal: 16,
},
});

View File

@@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [5.0.0-alpha.22](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/material-bottom-tabs@5.0.0-alpha.21...@react-navigation/material-bottom-tabs@5.0.0-alpha.22) (2019-12-07)
### Features
* export underlying views used to build navigators ([#191](https://github.com/react-navigation/navigation-ex/issues/191)) ([d618ab3](https://github.com/react-navigation/navigation-ex/commit/d618ab382ecc5eccbcd5faa89e76f9ed2d75f405))
# [5.0.0-alpha.21](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/material-bottom-tabs@5.0.0-alpha.20...@react-navigation/material-bottom-tabs@5.0.0-alpha.21) (2019-11-17)
**Note:** Version bump only for package @react-navigation/material-bottom-tabs

View File

@@ -11,7 +11,7 @@
"material",
"tab"
],
"version": "5.0.0-alpha.21",
"version": "5.0.0-alpha.22",
"license": "MIT",
"repository": {
"type": "git",

View File

@@ -3,6 +3,11 @@
*/
export { default as createMaterialBottomTabNavigator } from './navigators/createMaterialBottomTabNavigator';
/**
* Views
*/
export { default as MaterialBottomTabView } from './views/MaterialBottomTabView';
/**
* Types
*/

View File

@@ -3,6 +3,25 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [5.0.0-alpha.20](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/material-top-tabs@5.0.0-alpha.19...@react-navigation/material-top-tabs@5.0.0-alpha.20) (2019-12-07)
### Features
* export underlying views used to build navigators ([#191](https://github.com/react-navigation/navigation-ex/issues/191)) ([d618ab3](https://github.com/react-navigation/navigation-ex/commit/d618ab382ecc5eccbcd5faa89e76f9ed2d75f405))
# [5.0.0-alpha.19](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/material-top-tabs@5.0.0-alpha.18...@react-navigation/material-top-tabs@5.0.0-alpha.19) (2019-11-20)
**Note:** Version bump only for package @react-navigation/material-top-tabs
# [5.0.0-alpha.18](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/material-top-tabs@5.0.0-alpha.17...@react-navigation/material-top-tabs@5.0.0-alpha.18) (2019-11-17)
**Note:** Version bump only for package @react-navigation/material-top-tabs

View File

@@ -11,7 +11,7 @@
"material",
"tab"
],
"version": "5.0.0-alpha.18",
"version": "5.0.0-alpha.20",
"license": "MIT",
"repository": {
"type": "git",
@@ -45,7 +45,7 @@
"react-native": "~0.59.10",
"react-native-gesture-handler": "^1.5.0",
"react-native-reanimated": "^1.4.0",
"react-native-tab-view": "^2.10.1",
"react-native-tab-view": "^2.11.0",
"typescript": "^3.7.2"
},
"peerDependencies": {
@@ -54,7 +54,7 @@
"react-native": "*",
"react-native-gesture-handler": "^1.0.0",
"react-native-reanimated": "^1.0.0",
"react-native-tab-view": "^2.10.0"
"react-native-tab-view": "^2.11.0"
},
"@react-native-community/bob": {
"source": "src",

View File

@@ -6,6 +6,7 @@ export { default as createMaterialTopTabNavigator } from './navigators/createMat
/**
* Views
*/
export { default as MaterialTopTabView } from './views/MaterialTopTabView';
export { default as MaterialTopTabBar } from './views/MaterialTopTabBar';
/**

View File

@@ -3,6 +3,25 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [5.0.0-alpha.15](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/native-stack@5.0.0-alpha.14...@react-navigation/native-stack@5.0.0-alpha.15) (2019-12-07)
### Features
* export underlying views used to build navigators ([#191](https://github.com/react-navigation/navigation-ex/issues/191)) ([d618ab3](https://github.com/react-navigation/navigation-ex/commit/d618ab382ecc5eccbcd5faa89e76f9ed2d75f405))
# [5.0.0-alpha.14](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/native-stack@5.0.0-alpha.13...@react-navigation/native-stack@5.0.0-alpha.14) (2019-11-20)
**Note:** Version bump only for package @react-navigation/native-stack
# [5.0.0-alpha.13](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/native-stack@5.0.0-alpha.12...@react-navigation/native-stack@5.0.0-alpha.13) (2019-11-17)
**Note:** Version bump only for package @react-navigation/native-stack

View File

@@ -6,7 +6,7 @@
"react-native",
"react-navigation"
],
"version": "5.0.0-alpha.13",
"version": "5.0.0-alpha.15",
"license": "MIT",
"repository": {
"type": "git",

View File

@@ -3,6 +3,11 @@
*/
export { default as createNativeStackNavigator } from './navigators/createNativeStackNavigator';
/**
* Views
*/
export { default as NativeStackView } from './views/NativeStackView';
/**
* Types
*/

View File

@@ -16,7 +16,7 @@ import {
screensEnabled,
// eslint-disable-next-line import/no-unresolved
} from 'react-native-screens';
import StackView from '../views/StackView';
import NativeStackView from '../views/NativeStackView';
import {
NativeStackNavigatorProps,
NativeStackNavigationOptions,
@@ -64,11 +64,11 @@ function NativeStackNavigator(props: NativeStackNavigatorProps) {
);
return (
<StackView
<NativeStackView
{...rest}
state={state}
navigation={navigation}
descriptors={descriptors}
{...rest}
/>
);
}

View File

@@ -85,6 +85,8 @@ export type NativeStackNavigationOptions = {
headerTranslucent?: boolean;
/**
* Boolean to set native property to prefer large title header (like in iOS setting).
* For large title to collapse on scroll, the content of the screen should be wrapped in a scrollable view such as `ScrollView` or `FlatList`.
* If the scrollable area doesn't fill the screen, the large title won't collapse on scroll.
* Only supported on iOS.
*
* @platform ios

View File

@@ -29,7 +29,11 @@ type Props = {
descriptors: NativeStackDescriptorMap;
};
export default function StackView({ state, navigation, descriptors }: Props) {
export default function NativeStackView({
state,
navigation,
descriptors,
}: Props) {
return (
<ScreenStack style={styles.scenes}>
{state.routes.map(route => {

View File

@@ -3,6 +3,40 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [5.0.0-alpha.40](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/stack@5.0.0-alpha.39...@react-navigation/stack@5.0.0-alpha.40) (2019-12-07)
### Features
* export underlying views used to build navigators ([#191](https://github.com/react-navigation/navigation-ex/issues/191)) ([d618ab3](https://github.com/react-navigation/navigation-ex/commit/d618ab382ecc5eccbcd5faa89e76f9ed2d75f405))
# [5.0.0-alpha.39](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/stack@5.0.0-alpha.38...@react-navigation/stack@5.0.0-alpha.39) (2019-12-03)
### Bug Fixes
* correctly update layout on onLayout events ([eaf8847](https://github.com/react-navigation/navigation-ex/commit/eaf88478cc392fb9ff0b69c7539595920db8e010))
* disable pointerEvents on header when not focused ([87d445b](https://github.com/react-navigation/navigation-ex/commit/87d445b4e4468cf6c17787f47dd875ab8a95598a))
# [5.0.0-alpha.38](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/stack@5.0.0-alpha.37...@react-navigation/stack@5.0.0-alpha.38) (2019-11-29)
### Bug Fixes
* respect custom safearea insets when calculating header height ([2750cad](https://github.com/react-navigation/navigation-ex/commit/2750cad272def2e701ba2823a6e5693cee61eff0)), closes [#190](https://github.com/react-navigation/navigation-ex/issues/190)
# [5.0.0-alpha.37](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/stack@5.0.0-alpha.36...@react-navigation/stack@5.0.0-alpha.37) (2019-11-17)

View File

@@ -10,7 +10,7 @@
"android",
"stack"
],
"version": "5.0.0-alpha.37",
"version": "5.0.0-alpha.40",
"license": "MIT",
"repository": {
"type": "git",

View File

@@ -16,6 +16,7 @@ export const Assets = [
/**
* Views
*/
export { default as StackView } from './views/Stack/StackView';
export { default as Header } from './views/Header/Header';
export { default as HeaderTitle } from './views/Header/HeaderTitle';
export { default as HeaderBackButton } from './views/Header/HeaderBackButton';

View File

@@ -11,7 +11,6 @@ import {
StackNavigationState,
StackActions,
} from '@react-navigation/routers';
import KeyboardManager from '../views/KeyboardManager';
import StackView from '../views/Stack/StackView';
import {
StackNavigationConfig,
@@ -24,7 +23,6 @@ type Props = DefaultNavigatorOptions<StackNavigationOptions> &
StackNavigationConfig;
function StackNavigator({
keyboardHandlingEnabled,
initialRouteName,
children,
screenOptions,
@@ -64,17 +62,12 @@ function StackNavigator({
);
return (
<KeyboardManager enabled={keyboardHandlingEnabled !== false}>
{props => (
<StackView
state={state}
descriptors={descriptors}
navigation={navigation}
{...rest}
{...props}
/>
)}
</KeyboardManager>
<StackView
{...rest}
state={state}
descriptors={descriptors}
navigation={navigation}
/>
);
}

View File

@@ -114,7 +114,7 @@ export default function HeaderContainer({
})
: undefined
}
pointerEvents="box-none"
pointerEvents={isFocused ? 'box-none' : 'none'}
accessibilityElementsHidden={!isFocused}
importantForAccessibility={
isFocused ? 'auto' : 'no-hide-descendants'

View File

@@ -79,17 +79,20 @@ export default class HeaderSegment extends React.Component<Props, State> {
private handleTitleLayout = (e: LayoutChangeEvent) => {
const { height, width } = e.nativeEvent.layout;
const { titleLayout } = this.state;
if (
titleLayout &&
height === titleLayout.height &&
width === titleLayout.width
) {
return;
}
this.setState(({ titleLayout }) => {
if (
titleLayout &&
height === titleLayout.height &&
width === titleLayout.width
) {
return null;
}
this.setState({ titleLayout: { height, width } });
return {
titleLayout: { height, width },
};
});
};
private handleLeftLabelLayout = (e: LayoutChangeEvent) => {

View File

@@ -60,7 +60,7 @@ type Props = TransitionPreset & {
floatingHeaderHeight: number;
};
export default class StackItem extends React.PureComponent<Props> {
export default class CardContainer extends React.PureComponent<Props> {
private handleOpen = () => {
const { scene, onTransitionEnd, onOpenRoute } = this.props;

View File

@@ -16,7 +16,7 @@ import { StackNavigationState } from '@react-navigation/routers';
import { getDefaultHeaderHeight } from '../Header/HeaderSegment';
import { Props as HeaderContainerProps } from '../Header/HeaderContainer';
import StackItem from './StackItem';
import CardContainer from './CardContainer';
import {
DefaultTransition,
ModalTransition,
@@ -121,21 +121,25 @@ const getFloatingHeaderHeights = (
layout: Layout,
previous: Record<string, number>
) => {
const defaultHeaderHeight = getDefaultHeaderHeight(layout, insets);
return routes.reduce<Record<string, number>>((acc, curr) => {
const { options = {} } = descriptors[curr.key] || {};
const { height = previous[curr.key] } = StyleSheet.flatten(
options.headerStyle || {}
);
acc[curr.key] = typeof height === 'number' ? height : defaultHeaderHeight;
acc[curr.key] =
typeof height === 'number'
? height
: getDefaultHeaderHeight(layout, {
...insets,
...options.safeAreaInsets,
});
return acc;
}, {});
};
export default class Stack extends React.Component<Props, State> {
export default class CardStack extends React.Component<Props, State> {
static getDerivedStateFromProps(props: Props, state: State) {
if (
props.routes === state.routes &&
@@ -229,25 +233,24 @@ export default class Stack extends React.Component<Props, State> {
private handleLayout = (e: LayoutChangeEvent) => {
const { height, width } = e.nativeEvent.layout;
if (
height === this.state.layout.height &&
width === this.state.layout.width
) {
return;
}
const layout = { width, height };
this.setState(state => ({
layout,
floatingHeaderHeights: getFloatingHeaderHeights(
this.props.routes,
this.props.insets,
state.descriptors,
this.setState((state, props) => {
if (height === state.layout.height && width === state.layout.width) {
return null;
}
return {
layout,
{}
),
}));
floatingHeaderHeights: getFloatingHeaderHeights(
props.routes,
props.insets,
state.descriptors,
layout,
{}
),
};
});
};
private handleFloatingHeaderLayout = ({
@@ -257,18 +260,20 @@ export default class Stack extends React.Component<Props, State> {
route: Route<string>;
height: number;
}) => {
const previousHeight = this.state.floatingHeaderHeights[route.key];
this.setState(({ floatingHeaderHeights }) => {
const previousHeight = this.state.floatingHeaderHeights[route.key];
if (previousHeight && previousHeight === height) {
return;
}
if (previousHeight && previousHeight === height) {
return null;
}
this.setState(state => ({
floatingHeaderHeights: {
...state.floatingHeaderHeights,
[route.key]: height,
},
}));
return {
floatingHeaderHeights: {
...floatingHeaderHeights,
[route.key]: height,
},
};
});
};
private handleTransitionStart = (
@@ -426,7 +431,7 @@ export default class Stack extends React.Component<Props, State> {
active={isScreenActive}
pointerEvents="box-none"
>
<StackItem
<CardContainer
index={index}
active={index === self.length - 1}
focused={focused}

View File

@@ -4,7 +4,8 @@ import { SafeAreaConsumer, EdgeInsets } from 'react-native-safe-area-context';
import { Route } from '@react-navigation/core';
import { StackActions, StackNavigationState } from '@react-navigation/routers';
import Stack from './Stack';
import CardStack from './CardStack';
import KeyboardManager from '../KeyboardManager';
import HeaderContainer, {
Props as HeaderContainerProps,
} from '../Header/HeaderContainer';
@@ -19,9 +20,6 @@ type Props = StackNavigationConfig & {
state: StackNavigationState;
navigation: StackNavigationHelpers;
descriptors: StackDescriptorMap;
onPageChangeStart?: () => void;
onPageChangeConfirm?: () => void;
onPageChangeCancel?: () => void;
};
type State = {
@@ -307,9 +305,7 @@ class StackView extends React.Component<Props, State> {
const {
state,
navigation,
onPageChangeStart,
onPageChangeConfirm,
onPageChangeCancel,
keyboardHandlingEnabled,
mode = 'card',
...rest
} = this.props;
@@ -328,28 +324,30 @@ class StackView extends React.Component<Props, State> {
<SafeAreaProviderCompat>
<SafeAreaConsumer>
{insets => (
<Stack
mode={mode}
insets={insets as EdgeInsets}
getPreviousRoute={this.getPreviousRoute}
getGesturesEnabled={this.getGesturesEnabled}
routes={routes}
openingRouteKeys={openingRouteKeys}
closingRouteKeys={closingRouteKeys}
onGoBack={this.handleGoBack}
onOpenRoute={this.handleOpenRoute}
onCloseRoute={this.handleCloseRoute}
onPageChangeStart={onPageChangeStart}
onPageChangeConfirm={onPageChangeConfirm}
onPageChangeCancel={onPageChangeCancel}
renderHeader={this.renderHeader}
renderScene={this.renderScene}
headerMode={headerMode}
state={state}
navigation={navigation}
descriptors={descriptors}
{...rest}
/>
<KeyboardManager enabled={keyboardHandlingEnabled !== false}>
{props => (
<CardStack
mode={mode}
insets={insets as EdgeInsets}
getPreviousRoute={this.getPreviousRoute}
getGesturesEnabled={this.getGesturesEnabled}
routes={routes}
openingRouteKeys={openingRouteKeys}
closingRouteKeys={closingRouteKeys}
onGoBack={this.handleGoBack}
onOpenRoute={this.handleOpenRoute}
onCloseRoute={this.handleCloseRoute}
renderHeader={this.renderHeader}
renderScene={this.renderScene}
headerMode={headerMode}
state={state}
navigation={navigation}
descriptors={descriptors}
{...rest}
{...props}
/>
)}
</KeyboardManager>
)}
</SafeAreaConsumer>
</SafeAreaProviderCompat>

View File

@@ -13220,15 +13220,10 @@ react-native-screens@^2.0.0-alpha.11:
dependencies:
debounce "^1.2.0"
react-native-tab-view@2.10.2:
version "2.10.2"
resolved "https://registry.yarnpkg.com/react-native-tab-view/-/react-native-tab-view-2.10.2.tgz#35ae92f574f2220312138f479a99ad3cbf981b6f"
integrity sha512-DJMz7WDlQiykgvojaEPM5MKFNMlGC89SMhX++wkD6iJ4TK04NyUgvUKsZYuY7u6k0o0HtG7sNeexFsbxfwhrVg==
react-native-tab-view@^2.10.1:
version "2.10.1"
resolved "https://registry.yarnpkg.com/react-native-tab-view/-/react-native-tab-view-2.10.1.tgz#3ddff9858a1f7da7477dc9f52a69a6bf17f31541"
integrity sha512-U4swsor8h1A1mkBFUX+k1FXvijVsh7ZhD01O0cxKjR5Q7hBXCCygP3rs9jCjnoRMhyMJHsbmeZypUs5l+mVdGQ==
react-native-tab-view@2.11.0, react-native-tab-view@^2.11.0:
version "2.11.0"
resolved "https://registry.yarnpkg.com/react-native-tab-view/-/react-native-tab-view-2.11.0.tgz#2e57d1f617ccc88c7f452708804f3409f880b700"
integrity sha512-vqetlxGO7A8bnqvXcB50MWpRZAImXFrDGz1WCQKdCqe03Ey3ZzENe7yLuWrtBJYlepGfOLAsmCXv+wW82Yfm1w==
react-native-testing-library@^1.9.1:
version "1.11.1"