Compare commits

..

5 Commits

Author SHA1 Message Date
satyajit.happy
e6a06ac56e chore: publish
- @react-navigation/core@5.0.0-alpha.20
 - @react-navigation/native-stack@5.0.0-alpha.8
 - @react-navigation/stack@5.0.0-alpha.33
2019-11-02 05:12:02 +01:00
satyajit.happy
2ef5ad4cc2 fix: add horizontal margin to centered title 2019-11-02 05:08:10 +01:00
freddy
74ee216ed4 fix: remove unnecessary paddingHorizontal on stack header 2019-11-02 04:54:07 +01:00
Tien Pham
77f29d374f feat: add headerBackTitleVisible to navigation options in native stack 2019-11-02 04:53:23 +01:00
satyajit.happy
5a34764404 fix: pass rehydrated state in onStateChange and devtools 2019-11-02 04:43:47 +01:00
16 changed files with 113 additions and 24 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.20](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/core@5.0.0-alpha.19...@react-navigation/core@5.0.0-alpha.20) (2019-11-02)
### Bug Fixes
* pass rehydrated state in onStateChange and devtools ([5a34764](https://github.com/react-navigation/navigation-ex/commit/5a34764))
# [5.0.0-alpha.19](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/core@5.0.0-alpha.18...@react-navigation/core@5.0.0-alpha.19) (2019-10-30)

View File

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

View File

@@ -137,9 +137,9 @@ const Container = React.forwardRef(function NavigationContainer(
[trackAction]
);
const getRootState = () => {
const getRootState = React.useCallback(() => {
return getStateForRoute('root');
};
}, [getStateForRoute]);
React.useImperativeHandle(ref, () => ({
...(Object.keys(CommonActions) as Array<keyof typeof CommonActions>).reduce<
@@ -220,18 +220,18 @@ const Container = React.forwardRef(function NavigationContainer(
if (skipTrackingRef.current) {
skipTrackingRef.current = false;
} else {
trackState(state);
trackState(getRootState);
}
navigationStateRef.current = state;
transactionStateRef.current = null;
if (!isFirstMountRef.current && onStateChange) {
onStateChange(state);
onStateChange(getRootState());
}
isFirstMountRef.current = false;
}, [state, onStateChange, trackState]);
}, [state, onStateChange, trackState, getRootState]);
return (
<NavigationBuilderContext.Provider value={builderContext}>

View File

@@ -321,7 +321,28 @@ it('handle resetting state with ref', () => {
});
expect(onStateChange).toBeCalledTimes(1);
expect(onStateChange).lastCalledWith(state);
expect(onStateChange).lastCalledWith({
index: 1,
key: '5',
routeNames: ['foo', 'foo2', 'bar', 'baz'],
routes: [
{
key: 'baz',
name: 'baz',
state: {
index: 0,
key: '6',
routeNames: ['qux', 'lex'],
routes: [{ key: 'qux', name: 'qux' }, { key: 'lex', name: 'lex' }],
stale: false,
type: 'test',
},
},
{ key: 'bar', name: 'bar' },
],
stale: false,
type: 'test',
});
});
it('handle getRootState', () => {

View File

@@ -534,7 +534,19 @@ it('updates route params with setParams applied to parent', () => {
key: '0',
routeNames: ['foo', 'bar'],
routes: [
{ key: 'foo', name: 'foo', params: { username: 'alice' } },
{
key: 'foo',
name: 'foo',
params: { username: 'alice' },
state: {
index: 0,
key: '1',
routeNames: ['baz'],
routes: [{ key: 'baz', name: 'baz' }],
stale: false,
type: 'test',
},
},
{ key: 'bar', name: 'bar' },
],
stale: false,
@@ -549,7 +561,19 @@ it('updates route params with setParams applied to parent', () => {
key: '0',
routeNames: ['foo', 'bar'],
routes: [
{ key: 'foo', name: 'foo', params: { username: 'alice', age: 25 } },
{
key: 'foo',
name: 'foo',
params: { username: 'alice', age: 25 },
state: {
index: 0,
key: '1',
routeNames: ['baz'],
routes: [{ key: 'baz', name: 'baz' }],
stale: false,
type: 'test',
},
},
{ key: 'bar', name: 'bar' },
],
stale: false,

View File

@@ -62,7 +62,7 @@ export default function useDevTools({ name, reset, state }: Options) {
);
const trackState = React.useCallback(
(state: State) => {
(getState: () => State) => {
if (!devTools) {
return;
}
@@ -71,9 +71,11 @@ export default function useDevTools({ name, reset, state }: Options) {
devTools.send(actions.current.shift(), lastStateRef.current);
}
const state = getState();
if (actions.current.length) {
devTools.send(actions.current.pop(), state);
} else if (lastStateRef.current !== state) {
} else {
devTools.send('@@UNKNOWN', state);
}

View File

@@ -14,7 +14,7 @@ export default function useOnGetState({
const route = React.useContext(NavigationRouteContext);
const key = route ? route.key : 'root';
const getter = React.useCallback(() => {
const getRehydratedState = React.useCallback(() => {
const state = getState();
return {
...state,
@@ -26,6 +26,6 @@ export default function useOnGetState({
}, [getState, getStateForRoute]);
React.useEffect(() => {
return addStateGetter && addStateGetter(key, getter);
}, [addStateGetter, getter, key]);
return addStateGetter && addStateGetter(key, getRehydratedState);
}, [addStateGetter, getRehydratedState, key]);
}

View File

@@ -9,7 +9,7 @@ export default function useStateGetters() {
const stateGetters = React.useRef<Record<string, NavigatorStateGetter>>({});
const getStateForRoute = React.useCallback(
routeKey =>
(routeKey: string) =>
stateGetters.current[routeKey] === undefined
? undefined
: stateGetters.current[routeKey](),

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.8](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/native-stack@5.0.0-alpha.7...@react-navigation/native-stack@5.0.0-alpha.8) (2019-11-02)
### Features
* add headerBackTitleVisible to navigation options in native stack ([77f29d3](https://github.com/react-navigation/navigation-ex/commit/77f29d3))
# [5.0.0-alpha.7](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/native-stack@5.0.0-alpha.6...@react-navigation/native-stack@5.0.0-alpha.7) (2019-11-02)

View File

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

View File

@@ -65,6 +65,13 @@ export type NativeStackNavigationOptions = {
* @platform ios
*/
headerBackTitle?: string;
/**
* Whether the back button title should be visible or not. Defaults to `true`.
* Only supported on iOS.
*
* @platform ios
*/
headerBackTitleVisible?: boolean;
/**
* Whether to show the header.
*/

View File

@@ -20,6 +20,7 @@ export default function HeaderConfig(props: Props) {
headerRight,
headerTitle,
headerBackTitle,
headerBackTitleVisible = true,
headerHideBackButton,
headerHideShadow,
headerTintColor,
@@ -53,7 +54,7 @@ export default function HeaderConfig(props: Props) {
? headerTitleStyle.color
: headerTintColor
}
backTitle={headerBackTitle}
backTitle={headerBackTitleVisible ? headerBackTitle : ''}
backTitleFontFamily={headerBackTitleStyle.fontFamily}
backTitleFontSize={headerBackTitleStyle.fontSize}
color={headerTintColor}

View File

@@ -3,6 +3,18 @@
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.33](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/stack@5.0.0-alpha.32...@react-navigation/stack@5.0.0-alpha.33) (2019-11-02)
### Bug Fixes
* add horizontal margin to centered title ([2ef5ad4](https://github.com/react-navigation/navigation-ex/commit/2ef5ad4))
* remove unnecessary paddingHorizontal on stack header ([74ee216](https://github.com/react-navigation/navigation-ex/commit/74ee216))
# [5.0.0-alpha.32](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/stack@5.0.0-alpha.31...@react-navigation/stack@5.0.0-alpha.32) (2019-11-02)

View File

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

View File

@@ -328,10 +328,9 @@ export default class HeaderSegment extends React.Component<Props, State> {
<Animated.View
pointerEvents="box-none"
style={[
headerTitleAlign === 'left' && {
position: 'absolute',
left: leftButton ? 72 : 16,
},
headerTitleAlign === 'left'
? { position: 'absolute', left: leftButton ? 72 : 16 }
: { marginHorizontal: 18 },
titleStyle,
titleContainerStyle,
]}
@@ -366,7 +365,6 @@ export default class HeaderSegment extends React.Component<Props, State> {
const styles = StyleSheet.create({
content: {
flex: 1,
paddingHorizontal: 4,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',

View File

@@ -7,7 +7,9 @@ type Props = TextProps & {
};
export default function HeaderTitle({ style, ...rest }: Props) {
return <Animated.Text {...rest} style={[styles.title, style]} />;
return (
<Animated.Text numberOfLines={1} {...rest} style={[styles.title, style]} />
);
}
const styles = StyleSheet.create({