Compare commits

..

12 Commits

Author SHA1 Message Date
satyajit.happy
aa40130266 chore: publish
- @react-navigation/bottom-tabs@5.0.0-alpha.16
 - @react-navigation/compat@5.0.0-alpha.10
 - @react-navigation/core@5.0.0-alpha.18
 - @react-navigation/drawer@5.0.0-alpha.17
 - @react-navigation/example@5.0.0-alpha.17
 - @react-navigation/material-bottom-tabs@5.0.0-alpha.16
 - @react-navigation/material-top-tabs@5.0.0-alpha.13
 - @react-navigation/native-stack@5.0.0-alpha.5
 - @react-navigation/routers@5.0.0-alpha.10
 - @react-navigation/stack@5.0.0-alpha.30
2019-10-29 21:20:18 +01:00
satyajit.happy
7635373366 fix: use index of first route when rehydrating tab state 2019-10-29 21:15:02 +01:00
satyajit.happy
941f4e2dec chore: update react-native-paper and screens 2019-10-29 02:42:37 +01:00
osdnk
876c3183e1 fix: make clearKeyboardTimeout private 2019-10-25 09:29:36 +02:00
satyajit.happy
1cc31bf900 chore: fix cocoa pods 2019-10-24 19:32:33 +02:00
satyajit.happy
8f16085808 fix: improve type annotation for screens 2019-10-24 18:56:26 +02:00
satyajit.happy
58fbfdf5c3 chore: remove log 2019-10-24 18:56:26 +02:00
osdnk
07bfc86327 fix: keyboard manager in stack for fast swipe 2019-10-24 18:50:16 +02:00
osdnk
e54d87c41c chore: publish
- @react-navigation/stack@5.0.0-alpha.29
2019-10-22 21:06:37 +02:00
osdnk
225e760a54 fix: conditions in gesture direction 2019-10-22 21:06:02 +02:00
satyajit.happy
f9cfbd01d8 chore: publish
- @react-navigation/bottom-tabs@5.0.0-alpha.15
 - @react-navigation/example@5.0.0-alpha.16
2019-10-22 15:45:16 +02:00
satyajit.happy
3bf46e1ad2 refactor: don't pass orientation to label 2019-10-22 15:30:49 +02:00
34 changed files with 271 additions and 76 deletions

View File

@@ -3,6 +3,22 @@
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.16](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/bottom-tabs@5.0.0-alpha.15...@react-navigation/bottom-tabs@5.0.0-alpha.16) (2019-10-29)
**Note:** Version bump only for package @react-navigation/bottom-tabs
# [5.0.0-alpha.15](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/bottom-tabs@5.0.0-alpha.14...@react-navigation/bottom-tabs@5.0.0-alpha.15) (2019-10-22)
**Note:** Version bump only for package @react-navigation/bottom-tabs
# [5.0.0-alpha.14](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/bottom-tabs@5.0.0-alpha.13...@react-navigation/bottom-tabs@5.0.0-alpha.14) (2019-10-15)

View File

@@ -10,7 +10,7 @@
"android",
"tab"
],
"version": "5.0.0-alpha.14",
"version": "5.0.0-alpha.16",
"license": "MIT",
"repository": {
"type": "git",
@@ -33,7 +33,7 @@
"clean": "del lib"
},
"dependencies": {
"@react-navigation/routers": "^5.0.0-alpha.9"
"@react-navigation/routers": "^5.0.0-alpha.10"
},
"devDependencies": {
"@react-native-community/bob": "^0.7.0",

View File

@@ -71,11 +71,7 @@ export type BottomTabNavigationOptions = {
*/
tabBarLabel?:
| React.ReactNode
| ((props: {
focused: boolean;
color: string;
size: number;
}) => React.ReactNode);
| ((props: { focused: boolean; color: string }) => React.ReactNode);
/**
* React Element or a function that given { focused: boolean, color: string } returns a React.Node, to display in the tab bar.
@@ -221,7 +217,6 @@ export type BottomTabBarProps = BottomTabBarOptions & {
| ((scene: {
focused: boolean;
color: string;
orientation: 'horizontal' | 'vertical';
}) => React.ReactNode | undefined)
| React.ReactNode;
getTestID: (props: { route: Route<string> }) => string | undefined;

View File

@@ -157,11 +157,7 @@ export default class TabBarBottom extends React.Component<Props, State> {
}
if (typeof label === 'function') {
return label({
focused,
color,
orientation: horizontal ? 'horizontal' : 'vertical',
});
return label({ focused, color });
}
return label;

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.10](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/compat@5.0.0-alpha.9...@react-navigation/compat@5.0.0-alpha.10) (2019-10-29)
**Note:** Version bump only for package @react-navigation/compat
# [5.0.0-alpha.9](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/compat@5.0.0-alpha.8...@react-navigation/compat@5.0.0-alpha.9) (2019-10-22)
**Note:** Version bump only for package @react-navigation/compat

View File

@@ -1,7 +1,7 @@
{
"name": "@react-navigation/compat",
"description": "Compatibility layer to write navigator definitions in static configuration format",
"version": "5.0.0-alpha.9",
"version": "5.0.0-alpha.10",
"license": "MIT",
"repository": {
"type": "git",
@@ -24,7 +24,7 @@
"clean": "del lib"
},
"dependencies": {
"@react-navigation/routers": "^5.0.0-alpha.9"
"@react-navigation/routers": "^5.0.0-alpha.10"
},
"devDependencies": {
"@types/react": "^16.9.4",

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.18](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/core@5.0.0-alpha.17...@react-navigation/core@5.0.0-alpha.18) (2019-10-29)
### Bug Fixes
* improve type annotation for screens ([8f16085](https://github.com/react-navigation/navigation-ex/commit/8f16085))
# [5.0.0-alpha.17](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/core@5.0.0-alpha.16...@react-navigation/core@5.0.0-alpha.17) (2019-10-22)
**Note:** Version bump only for package @react-navigation/core

View File

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

View File

@@ -90,8 +90,10 @@ export default function SceneView<
route={route}
>
{'component' in screen && screen.component !== undefined ? (
// @ts-ignore
<screen.component navigation={navigation} route={route} />
) : 'children' in screen && screen.children !== undefined ? (
// @ts-ignore
screen.children({ navigation, route })
) : null}
</StaticContainer>

View File

@@ -521,13 +521,19 @@ export type RouteConfig<
/**
* React component to render for this screen.
*/
component: React.ComponentType<any>;
component: React.ComponentType<{
route: RouteProp<ParamList, RouteName>;
navigation: any;
}>;
}
| {
/**
* Render callback to render content of this screen.
*/
children: (props: any) => React.ReactNode;
children: (props: {
route: RouteProp<ParamList, RouteName>;
navigation: any;
}) => React.ReactNode;
});
export type NavigationContainerRef =

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.17](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/drawer@5.0.0-alpha.16...@react-navigation/drawer@5.0.0-alpha.17) (2019-10-29)
**Note:** Version bump only for package @react-navigation/drawer
# [5.0.0-alpha.16](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/drawer@5.0.0-alpha.15...@react-navigation/drawer@5.0.0-alpha.16) (2019-10-22)

View File

@@ -11,7 +11,7 @@
"material",
"drawer"
],
"version": "5.0.0-alpha.16",
"version": "5.0.0-alpha.17",
"license": "MIT",
"repository": {
"type": "git",
@@ -34,7 +34,7 @@
"clean": "del lib"
},
"dependencies": {
"@react-navigation/routers": "^5.0.0-alpha.9"
"@react-navigation/routers": "^5.0.0-alpha.10"
},
"devDependencies": {
"@react-native-community/bob": "^0.7.0",
@@ -46,7 +46,7 @@
"react-native-gesture-handler": "^1.3.0",
"react-native-reanimated": "^1.3.0",
"react-native-safe-area-context": "^0.3.6",
"react-native-screens": "^2.0.0-alpha.5",
"react-native-screens": "^2.0.0-alpha.6",
"typescript": "^3.6.3"
},
"peerDependencies": {

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.17](https://github.com/satya164/navigation-ex/compare/@react-navigation/example@5.0.0-alpha.16...@react-navigation/example@5.0.0-alpha.17) (2019-10-29)
### Bug Fixes
* improve type annotation for screens ([8f16085](https://github.com/satya164/navigation-ex/commit/8f16085))
# [5.0.0-alpha.16](https://github.com/satya164/navigation-ex/compare/@react-navigation/example@5.0.0-alpha.15...@react-navigation/example@5.0.0-alpha.16) (2019-10-22)
**Note:** Version bump only for package @react-navigation/example
# [5.0.0-alpha.15](https://github.com/satya164/navigation-ex/compare/@react-navigation/example@5.0.0-alpha.14...@react-navigation/example@5.0.0-alpha.15) (2019-10-22)
**Note:** Version bump only for package @react-navigation/example

View File

@@ -93,7 +93,7 @@ PODS:
- React
- RNReanimated (1.2.0):
- React
- RNScreens (2.0.0-alpha.4):
- RNScreens (2.0.0-alpha.6):
- React
- UMBarCodeScannerInterface (4.0.0)
- UMCameraInterface (4.0.0)
@@ -159,7 +159,7 @@ DEPENDENCIES:
- yoga (from `../node_modules/react-native/ReactCommon/yoga`)
SPEC REPOS:
https://github.com/cocoapods/specs.git:
trunk:
- boost-for-react-native
EXTERNAL SOURCES:
@@ -267,7 +267,7 @@ SPEC CHECKSUMS:
react-native-safe-area-context: e380a6f783ccaec848e2f3cc8eb205a62362950d
RNGestureHandler: 5329a942fce3d41c68b84c2c2276ce06a696d8b0
RNReanimated: 1b52415c4302f198cb581282a0166690bad62c43
RNScreens: 84be1a2369a580beb2fea0755cc62ef16b83fffe
RNScreens: 73691421e207a57b85af0fea931e620b05a35e89
UMBarCodeScannerInterface: d5a6fdc98ed6241225b0a8432a7f4e2b397668bc
UMCameraInterface: 68870a3197fee85bd5afca5609ba4a5b7257d19d
UMConstantsInterface: d25b8e8887ca7aaf568c06caf08f4d40734ee4ef
@@ -284,4 +284,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 1276a2dd000c142ccc03272023bb8a6b2d5b9933
COCOAPODS: 1.7.5
COCOAPODS: 1.8.3

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.15",
"version": "5.0.0-alpha.17",
"private": true,
"workspaces": {
"nohoist": [
@@ -27,10 +27,10 @@
"react-dom": "~16.8.3",
"react-native": "~0.59.10",
"react-native-gesture-handler": "~1.3.0",
"react-native-paper": "^3.0.0-alpha.7",
"react-native-paper": "^3.1.1",
"react-native-reanimated": "~1.2.0",
"react-native-safe-area-context": "~0.3.6",
"react-native-screens": "^2.0.0-alpha.5",
"react-native-screens": "^2.0.0-alpha.6",
"react-native-tab-view": "2.10.0",
"react-native-unimodules": "^0.7.0-rc.1",
"react-native-web": "^0.11.7",

View File

@@ -41,15 +41,13 @@ export default function BottomTabsScreen() {
tabBarButtonComponent: TouchableBounce,
}}
>
{props => (
<SimpleStackScreen {...props} options={{ headerMode: 'none' }} />
)}
{props => <SimpleStackScreen {...props} headerMode="none" />}
</BottomTabs.Screen>
<BottomTabs.Screen
name="chat"
component={Chat}
options={{
title: 'Chat',
tabBarLabel: 'Chat',
tabBarIcon: getTabBarIcon('message-reply'),
tabBarButtonComponent: TouchableBounce,
}}

View File

@@ -28,9 +28,7 @@ export default function MaterialBottomTabsScreen() {
tabBarColor: '#C9E7F8',
}}
>
{props => (
<SimpleStackScreen {...props} options={{ headerMode: 'none' }} />
)}
{props => <SimpleStackScreen {...props} headerMode="none" />}
</MaterialBottomTabs.Screen>
<MaterialBottomTabs.Screen
name="chat"

View File

@@ -5,7 +5,6 @@ import { RouteProp, ParamListBase } from '@react-navigation/core';
import {
createStackNavigator,
StackNavigationProp,
StackNavigationOptions,
} from '@react-navigation/stack';
import Article from '../Shared/Article';
import Albums from '../Shared/Albums';
@@ -77,18 +76,17 @@ const AlbumsScreen = ({
const SimpleStack = createStackNavigator<SimpleStackParams>();
type Props = {
options?: StackNavigationOptions;
type Props = Partial<React.ComponentProps<typeof SimpleStack.Navigator>> & {
navigation: StackNavigationProp<ParamListBase>;
};
export default function SimpleStackScreen({ navigation, options }: Props) {
export default function SimpleStackScreen({ navigation, ...rest }: Props) {
navigation.setOptions({
headerShown: false,
});
return (
<SimpleStack.Navigator {...options}>
<SimpleStack.Navigator {...rest}>
<SimpleStack.Screen
name="article"
component={ArticleScreen}

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.16](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/material-bottom-tabs@5.0.0-alpha.15...@react-navigation/material-bottom-tabs@5.0.0-alpha.16) (2019-10-29)
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
# [5.0.0-alpha.15](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/material-bottom-tabs@5.0.0-alpha.14...@react-navigation/material-bottom-tabs@5.0.0-alpha.15) (2019-10-22)

View File

@@ -11,7 +11,7 @@
"material",
"tab"
],
"version": "5.0.0-alpha.15",
"version": "5.0.0-alpha.16",
"license": "MIT",
"repository": {
"type": "git",
@@ -34,7 +34,7 @@
"clean": "del lib"
},
"dependencies": {
"@react-navigation/routers": "^5.0.0-alpha.9"
"@react-navigation/routers": "^5.0.0-alpha.10"
},
"devDependencies": {
"@react-native-community/bob": "^0.7.0",
@@ -44,7 +44,7 @@
"del-cli": "^3.0.0",
"react": "~16.8.3",
"react-native": "~0.59.10",
"react-native-paper": "^3.0.0-alpha.7",
"react-native-paper": "^3.1.1",
"react-native-vector-icons": "^6.6.0",
"typescript": "^3.6.3"
},
@@ -52,7 +52,7 @@
"@react-navigation/core": "^5.0.0-alpha.0",
"react": "*",
"react-native": "*",
"react-native-paper": "^3.0.0-alpha.0",
"react-native-paper": "^3.0.0",
"react-native-vector-icons": "^6.0.0"
},
"@react-native-community/bob": {

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.13](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/material-top-tabs@5.0.0-alpha.12...@react-navigation/material-top-tabs@5.0.0-alpha.13) (2019-10-29)
**Note:** Version bump only for package @react-navigation/material-top-tabs
# [5.0.0-alpha.12](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/material-top-tabs@5.0.0-alpha.11...@react-navigation/material-top-tabs@5.0.0-alpha.12) (2019-10-15)

View File

@@ -11,7 +11,7 @@
"material",
"tab"
],
"version": "5.0.0-alpha.12",
"version": "5.0.0-alpha.13",
"license": "MIT",
"repository": {
"type": "git",
@@ -34,7 +34,7 @@
"clean": "del lib"
},
"dependencies": {
"@react-navigation/routers": "^5.0.0-alpha.9"
"@react-navigation/routers": "^5.0.0-alpha.10"
},
"devDependencies": {
"@react-native-community/bob": "^0.7.0",

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.5](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/native-stack@5.0.0-alpha.4...@react-navigation/native-stack@5.0.0-alpha.5) (2019-10-29)
**Note:** Version bump only for package @react-navigation/native-stack
# [5.0.0-alpha.4](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/native-stack@5.0.0-alpha.3...@react-navigation/native-stack@5.0.0-alpha.4) (2019-10-22)

View File

@@ -6,7 +6,7 @@
"react-native",
"react-navigation"
],
"version": "5.0.0-alpha.4",
"version": "5.0.0-alpha.5",
"license": "MIT",
"repository": {
"type": "git",
@@ -29,19 +29,19 @@
"clean": "del lib"
},
"dependencies": {
"@react-navigation/routers": "^5.0.0-alpha.9"
"@react-navigation/routers": "^5.0.0-alpha.10"
},
"devDependencies": {
"@react-native-community/bob": "^0.7.0",
"del-cli": "^2.0.0",
"react-native-screens": "^2.0.0-alpha.5",
"react-native-screens": "^2.0.0-alpha.6",
"typescript": "^3.5.3"
},
"peerDependencies": {
"@react-navigation/core": "^5.0.0-alpha.0",
"react": "*",
"react-native": "*",
"react-native-screens": "^2.0.0-alpha.5"
"react-native-screens": "^2.0.0-alpha.6"
},
"@react-native-community/bob": {
"source": "src",

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.10](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/routers@5.0.0-alpha.9...@react-navigation/routers@5.0.0-alpha.10) (2019-10-29)
### Bug Fixes
* use index of first route when rehydrating tab state ([7635373](https://github.com/react-navigation/navigation-ex/commit/7635373))
# [5.0.0-alpha.9](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/routers@5.0.0-alpha.8...@react-navigation/routers@5.0.0-alpha.9) (2019-10-03)
**Note:** Version bump only for package @react-navigation/routers

View File

@@ -87,6 +87,27 @@ it('gets rehydrated state from partial state', () => {
stale: false,
});
expect(
router.getRehydratedState(
{
routes: [{ key: 'baz-0', name: 'baz' }],
},
options
)
).toEqual({
index: 1,
key: 'drawer-test',
isDrawerOpen: false,
routeKeyHistory: [],
routeNames: ['bar', 'baz', 'qux'],
routes: [
{ key: 'bar-test', name: 'bar' },
{ key: 'baz-0', name: 'baz', params: { answer: 42 } },
{ key: 'qux-test', name: 'qux', params: { name: 'Jane' } },
],
stale: false,
});
expect(
router.getRehydratedState(
{
@@ -122,7 +143,7 @@ it('gets rehydrated state from partial state', () => {
options
)
).toEqual({
index: 0,
index: 2,
key: 'drawer-test',
isDrawerOpen: false,
routeKeyHistory: [],

View File

@@ -84,6 +84,26 @@ it('gets rehydrated state from partial state', () => {
stale: false,
});
expect(
router.getRehydratedState(
{
routes: [{ key: 'baz-0', name: 'baz' }],
},
options
)
).toEqual({
index: 1,
key: 'tab-test',
routeKeyHistory: [],
routeNames: ['bar', 'baz', 'qux'],
routes: [
{ key: 'bar-test', name: 'bar' },
{ key: 'baz-0', name: 'baz', params: { answer: 42 } },
{ key: 'qux-test', name: 'qux', params: { name: 'Jane' } },
],
stale: false,
});
expect(
router.getRehydratedState(
{
@@ -118,7 +138,7 @@ it('gets rehydrated state from partial state', () => {
options
)
).toEqual({
index: 0,
index: 2,
key: 'tab-test',
routeKeyHistory: [],
routeNames: ['bar', 'baz', 'qux'],

View File

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

View File

@@ -105,6 +105,16 @@ export default function TabRouter({
} as Route<string>;
});
const index = Math.min(
Math.max(
typeof state.index === 'number'
? state.index
: routeNames.indexOf(state.routes[0].name),
0
),
routes.length - 1
);
const routeKeyHistory = state.routeKeyHistory
? state.routeKeyHistory.filter(key => routes.find(r => r.key === key))
: [];
@@ -112,10 +122,7 @@ export default function TabRouter({
return {
stale: false,
key: `tab-${shortid()}`,
index:
typeof state.index === 'number' && state.index < routes.length
? state.index
: 0,
index,
routeNames,
routeKeyHistory,
routes,

View File

@@ -3,6 +3,29 @@
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.30](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/stack@5.0.0-alpha.29...@react-navigation/stack@5.0.0-alpha.30) (2019-10-29)
### Bug Fixes
* keyboard manager in stack for fast swipe ([07bfc86](https://github.com/react-navigation/navigation-ex/commit/07bfc86))
* make clearKeyboardTimeout private ([876c318](https://github.com/react-navigation/navigation-ex/commit/876c318))
# [5.0.0-alpha.29](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/stack@5.0.0-alpha.28...@react-navigation/stack@5.0.0-alpha.29) (2019-10-22)
### Bug Fixes
* conditions in gesture direction ([225e760](https://github.com/react-navigation/navigation-ex/commit/225e760))
# [5.0.0-alpha.28](https://github.com/react-navigation/navigation-ex/compare/@react-navigation/stack@5.0.0-alpha.27...@react-navigation/stack@5.0.0-alpha.28) (2019-10-22)

View File

@@ -10,7 +10,7 @@
"android",
"stack"
],
"version": "5.0.0-alpha.28",
"version": "5.0.0-alpha.30",
"license": "MIT",
"repository": {
"type": "git",
@@ -33,7 +33,7 @@
"clean": "del lib"
},
"dependencies": {
"@react-navigation/routers": "^5.0.0-alpha.9"
"@react-navigation/routers": "^5.0.0-alpha.10"
},
"devDependencies": {
"@react-native-community/bob": "^0.7.0",
@@ -46,7 +46,7 @@
"react-native-gesture-handler": "^1.3.0",
"react-native-reanimated": "^1.3.0",
"react-native-safe-area-context": "^0.3.6",
"react-native-screens": "^2.0.0-alpha.5",
"react-native-screens": "^2.0.0-alpha.6",
"typescript": "^3.6.3"
},
"peerDependencies": {

View File

@@ -11,14 +11,27 @@ type Props = {
};
export default class KeyboardManager extends React.Component<Props> {
componentWillUnmount = () => {
this.clearKeyboardTimeout();
};
// Numeric id of the previously focused text input
// When a gesture didn't change the tab, we can restore the focused input with this
private previouslyFocusedTextInput: number | null = null;
private startTimestamp: number = 0;
private keyboardTimeout: NodeJS.Timeout | undefined;
private clearKeyboardTimeout = () => {
if (this.keyboardTimeout !== undefined) {
clearTimeout(this.keyboardTimeout);
this.keyboardTimeout = undefined;
}
};
private handlePageChangeStart = () => {
if (!this.props.enabled) {
return;
}
this.clearKeyboardTimeout();
const input = TextInput.State.currentlyFocusedField();
@@ -27,12 +40,16 @@ export default class KeyboardManager extends React.Component<Props> {
// Store the id of this input so we can refocus it if change was cancelled
this.previouslyFocusedTextInput = input;
// Store timestamp for touch start
this.startTimestamp = Date.now();
};
private handlePageChangeConfirm = () => {
if (!this.props.enabled) {
return;
}
this.clearKeyboardTimeout();
Keyboard.dismiss();
@@ -44,15 +61,29 @@ export default class KeyboardManager extends React.Component<Props> {
if (!this.props.enabled) {
return;
}
this.clearKeyboardTimeout();
// The page didn't change, we should restore the focus of text input
const input = this.previouslyFocusedTextInput;
if (input) {
TextInput.State.focusTextInput(input);
}
// If the interaction was super short we should make sure keyboard won't hide again.
this.previouslyFocusedTextInput = null;
// Too fast input refocus will result only in keyboard flashing on screen and hiding right away.
// During first ~100ms keyboard will be dismissed no matter what,
// so we have to make sure it won't interrupt input refocus logic.
// That's why when the interaction is shorter than 100ms we add delay so it won't hide once again.
// Subtracting timestamps makes us sure the delay is executed only when needed.
if (Date.now() - this.startTimestamp < 100) {
this.keyboardTimeout = setTimeout(() => {
TextInput.State.focusTextInput(input);
this.previouslyFocusedTextInput = null;
}, 100);
} else {
TextInput.State.focusTextInput(input);
this.previouslyFocusedTextInput = null;
}
}
};
render() {

View File

@@ -713,13 +713,16 @@ export default class Card extends React.Component<Props> {
private gestureActivationCriteria() {
const { layout, gestureDirection, gestureResponseDistance } = this.props;
// Doesn't make sense for a response distance of 0, so this works fine
const distance =
gestureDirection === 'vertical'
? (gestureResponseDistance && gestureResponseDistance.vertical) ||
GESTURE_RESPONSE_DISTANCE_VERTICAL
: (gestureResponseDistance && gestureResponseDistance.horizontal) ||
GESTURE_RESPONSE_DISTANCE_HORIZONTAL;
? gestureResponseDistance &&
gestureResponseDistance.vertical !== undefined
? gestureResponseDistance.vertical
: GESTURE_RESPONSE_DISTANCE_VERTICAL
: gestureResponseDistance &&
gestureResponseDistance.horizontal !== undefined
? gestureResponseDistance.horizontal
: GESTURE_RESPONSE_DISTANCE_HORIZONTAL;
if (gestureDirection === 'vertical') {
return {

View File

@@ -13102,10 +13102,10 @@ react-native-gesture-handler@~1.3.0:
invariant "^2.2.2"
prop-types "^15.5.10"
react-native-paper@^3.0.0-alpha.7:
version "3.0.0-alpha.7"
resolved "https://registry.yarnpkg.com/react-native-paper/-/react-native-paper-3.0.0-alpha.7.tgz#fbbfe5dc9ef8dbd18932786aa3d7f0479501538b"
integrity sha512-tjqewrUMnucLM4yqMiVtCOnrqilnvDDNr2guIImwsUpJ6HWaJKBEFKqB25SEdMvuo88MWSdA0gyRNtS3WRpS3w==
react-native-paper@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/react-native-paper/-/react-native-paper-3.1.1.tgz#971f3097eecb4c061bf10768182b8985442a45ab"
integrity sha512-GHJ/2z/1Nzm4Y1g22Znu09BV7SV4tsR7h/9HrXuj3kFrsJo7zt5e+t/ELLLvycGEo4z1vhV6MtjtIk/PSaKoDA==
dependencies:
"@callstack/react-theme-provider" "^3.0.5"
color "^3.1.2"
@@ -13133,10 +13133,10 @@ react-native-safe-area-view@^0.12.0:
dependencies:
hoist-non-react-statics "^2.3.1"
react-native-screens@^2.0.0-alpha.5:
version "2.0.0-alpha.5"
resolved "https://registry.yarnpkg.com/react-native-screens/-/react-native-screens-2.0.0-alpha.5.tgz#5b6a72df959d31ffaf7045cd5eb753477e80689b"
integrity sha512-uKVc+JYEC59Dz2RPBI4tnaIB8W6T0dHGY6PjUtvkvaBmZBjfxhpezd3m2t8o913Xarx6EvT2maSH8816+MNJnw==
react-native-screens@^2.0.0-alpha.6:
version "2.0.0-alpha.6"
resolved "https://registry.yarnpkg.com/react-native-screens/-/react-native-screens-2.0.0-alpha.6.tgz#238cf7e97ff6008cca75dd1dd4a5a854bce81d57"
integrity sha512-5m59glvDDzQvzdBymIn6GfCnzk/9kaxkREEKLVMdANtZlqIuH3Jbgoc+56pcX5LVSZCMaSozPAQBcLaMWO2JUA==
dependencies:
debounce "^1.2.0"