mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-01-24 04:48:16 +08:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d342812102 | ||
|
|
5c13cea6c9 | ||
|
|
2433071930 | ||
|
|
dd03234e2d | ||
|
|
3bd15d3f8b | ||
|
|
2b27bcd134 | ||
|
|
3aee211c73 | ||
|
|
531686ea8e | ||
|
|
951afa5fb1 | ||
|
|
61e71ee09f |
@@ -1,3 +1,12 @@
|
||||
{
|
||||
"presets": ["expo"]
|
||||
"presets": [
|
||||
"expo"
|
||||
],
|
||||
"plugins": [
|
||||
["module-resolver", {
|
||||
"alias": {
|
||||
"react-navigation": "../src/react-navigation"
|
||||
}
|
||||
}]
|
||||
]
|
||||
}
|
||||
|
||||
12
example/README.md
Normal file
12
example/README.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# Navigation Playground Example
|
||||
|
||||
The NavigationPlayground example app includes a variety of patterns and is used as a simple way for contributors to manually integration test changes.
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
yarn bootstrap # in the react-navigation root directory
|
||||
yarn example start
|
||||
```
|
||||
|
||||
You can view this example application directly on Android phones by visiting scanning the QR code on [this site](https://exp.host/@react-navigation/NavigationPlayground) with the [Expo app](https://play.google.com/store/apps/details?id=host.exp.exponent&hl=en).
|
||||
@@ -5,10 +5,6 @@
|
||||
"slug": "react-navigation-stack-demo",
|
||||
"sdkVersion": "33.0.0",
|
||||
"version": "1.0.0",
|
||||
"primaryColor": "#2196f3",
|
||||
"packagerOpts": {
|
||||
"config": "./metro.config.js",
|
||||
"projectRoots": ""
|
||||
}
|
||||
"primaryColor": "#2196f3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"dependencies": {
|
||||
"@expo/vector-icons": "^10.0.0",
|
||||
"@react-native-community/masked-view": "^0.1.1",
|
||||
"@react-navigation/core": "^3.5.0",
|
||||
"@react-navigation/core": "^3.5.1",
|
||||
"@react-navigation/native": "^3.6.2",
|
||||
"expo": "^33.0.7",
|
||||
"expo-asset": "^5.0.1",
|
||||
@@ -24,7 +24,7 @@
|
||||
"react-native-paper": "^2.15.2",
|
||||
"react-navigation-drawer": "^2.0.1",
|
||||
"react-navigation-header-buttons": "^3.0.2",
|
||||
"react-navigation-stack": "^1.5.1",
|
||||
"react-navigation-stack": "^1.7.2",
|
||||
"react-navigation-tabs": "^1.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -7,7 +7,10 @@ import {
|
||||
NavigationScreenProp,
|
||||
NavigationState,
|
||||
} from 'react-navigation';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
import {
|
||||
createStackNavigator,
|
||||
NavigationStackScreenProps,
|
||||
} from 'react-navigation-stack';
|
||||
import { createDrawerNavigator } from 'react-navigation-drawer';
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
import SampleText from './SampleText';
|
||||
@@ -42,17 +45,13 @@ InboxScreen.navigationOptions = {
|
||||
headerTitle: 'Inbox',
|
||||
};
|
||||
|
||||
const EmailScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => <MyNavScreen banner="Email Screen" navigation={navigation} />;
|
||||
const EmailScreen = ({ navigation }: NavigationStackScreenProps) => (
|
||||
<MyNavScreen banner="Email Screen" navigation={navigation} />
|
||||
);
|
||||
|
||||
const DraftsScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => <MyNavScreen banner="Drafts Screen" navigation={navigation} />;
|
||||
const DraftsScreen = ({ navigation }: NavigationStackScreenProps) => (
|
||||
<MyNavScreen banner="Drafts Screen" navigation={navigation} />
|
||||
);
|
||||
DraftsScreen.navigationOptions = {
|
||||
headerTitle: 'Drafts',
|
||||
};
|
||||
|
||||
@@ -6,7 +6,10 @@ import {
|
||||
SafeAreaView,
|
||||
NavigationState,
|
||||
} from 'react-navigation';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
import {
|
||||
createStackNavigator,
|
||||
NavigationStackScreenProps,
|
||||
} from 'react-navigation-stack';
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
import SampleText from './SampleText';
|
||||
|
||||
@@ -95,16 +98,13 @@ const ProfileNavigator = createStackNavigator(
|
||||
}
|
||||
);
|
||||
|
||||
const MyHeaderTestScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => <MyNavScreen banner="Full screen view" navigation={navigation} />;
|
||||
const MyHeaderTestScreen = ({ navigation }: NavigationStackScreenProps) => (
|
||||
<MyNavScreen banner="Full screen view" navigation={navigation} />
|
||||
);
|
||||
|
||||
MyHeaderTestScreen.navigationOptions = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => {
|
||||
}: NavigationStackScreenProps) => {
|
||||
const headerVisible =
|
||||
navigation.state.params && navigation.state.params.headerVisible;
|
||||
return {
|
||||
|
||||
@@ -5,15 +5,16 @@ import {
|
||||
NavigationActions,
|
||||
NavigationEventPayload,
|
||||
NavigationEventSubscription,
|
||||
NavigationScreenProp,
|
||||
NavigationState,
|
||||
NavigationStateRoute,
|
||||
SafeAreaView,
|
||||
StackActions,
|
||||
Themed,
|
||||
withNavigation,
|
||||
} from 'react-navigation';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
import {
|
||||
createStackNavigator,
|
||||
NavigationStackProp,
|
||||
NavigationStackScreenProps,
|
||||
} from 'react-navigation-stack';
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
import { HeaderButtons } from './commonComponents/HeaderButtons';
|
||||
import SampleText from './SampleText';
|
||||
@@ -21,13 +22,12 @@ import SampleText from './SampleText';
|
||||
const DEBUG = false;
|
||||
|
||||
interface MyNavScreenProps {
|
||||
// TODO: satya164 - use stack's navigation type
|
||||
navigation: any;
|
||||
navigation: NavigationStackProp;
|
||||
banner: React.ReactNode;
|
||||
}
|
||||
|
||||
interface BackButtonProps {
|
||||
navigation: NavigationScreenProp<NavigationStateRoute<any>>;
|
||||
navigation: NavigationStackProp;
|
||||
}
|
||||
|
||||
class MyBackButton extends React.Component<BackButtonProps, any> {
|
||||
@@ -100,11 +100,7 @@ class MyNavScreen extends React.Component<MyNavScreenProps> {
|
||||
}
|
||||
}
|
||||
|
||||
interface MyHomeScreenProps {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}
|
||||
|
||||
class MyHomeScreen extends React.Component<MyHomeScreenProps> {
|
||||
class MyHomeScreen extends React.Component<NavigationStackScreenProps> {
|
||||
static navigationOptions = {
|
||||
title: 'Welcome',
|
||||
};
|
||||
@@ -144,12 +140,7 @@ class MyHomeScreen extends React.Component<MyHomeScreenProps> {
|
||||
}
|
||||
}
|
||||
|
||||
interface MyPhotosScreenProps {
|
||||
// TODO: satya164 - use stack's navigation type
|
||||
navigation: any;
|
||||
}
|
||||
|
||||
class MyPhotosScreen extends React.Component<MyPhotosScreenProps> {
|
||||
class MyPhotosScreen extends React.Component<NavigationStackScreenProps> {
|
||||
static navigationOptions = {
|
||||
headerLeft: () => <MyBackButtonWithNavigation />,
|
||||
title: 'Photos',
|
||||
@@ -198,7 +189,7 @@ class MyPhotosScreen extends React.Component<MyPhotosScreenProps> {
|
||||
const MyProfileScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
navigation: NavigationStackProp;
|
||||
}) => (
|
||||
<MyNavScreen
|
||||
banner={`${
|
||||
@@ -208,7 +199,7 @@ const MyProfileScreen = ({
|
||||
/>
|
||||
);
|
||||
|
||||
MyProfileScreen.navigationOptions = (props: MyHomeScreenProps) => {
|
||||
MyProfileScreen.navigationOptions = (props: NavigationStackScreenProps) => {
|
||||
const { navigation } = props;
|
||||
const { state, setParams } = navigation;
|
||||
const { params } = state;
|
||||
|
||||
@@ -3,11 +3,13 @@ import { Button, Image, StyleSheet } from 'react-native';
|
||||
import {
|
||||
NavigationScreenProp,
|
||||
NavigationState,
|
||||
NavigationScreenConfigProps,
|
||||
Themed,
|
||||
SafeAreaView,
|
||||
} from 'react-navigation';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
import {
|
||||
createStackNavigator,
|
||||
NavigationStackScreenProps,
|
||||
} from 'react-navigation-stack';
|
||||
import SampleText from './SampleText';
|
||||
|
||||
interface MyNavScreenProps {
|
||||
@@ -124,11 +126,8 @@ const StackWithCustomHeaderBackImage = createStackNavigator(
|
||||
},
|
||||
},
|
||||
{
|
||||
// TODO: satya164 - use stack's navigation type
|
||||
defaultNavigationOptions: ({
|
||||
theme,
|
||||
}: NavigationScreenConfigProps<any>) => ({
|
||||
headerBackImage: (
|
||||
defaultNavigationOptions: ({ theme }: NavigationStackScreenProps) => ({
|
||||
headerBackImage: () => (
|
||||
<MyCustomHeaderBackImage
|
||||
style={[
|
||||
styles.myCustomHeaderBackImageAlt,
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
import * as React from 'react';
|
||||
import { SafeAreaView, Themed } from 'react-navigation';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
import {
|
||||
createStackNavigator,
|
||||
NavigationStackScreenProps,
|
||||
} from 'react-navigation-stack';
|
||||
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
|
||||
interface NavScreenProps {
|
||||
// TODO: satya164 - use stack's navigation type
|
||||
navigation: any;
|
||||
}
|
||||
|
||||
class HomeScreen extends React.Component<NavScreenProps> {
|
||||
class HomeScreen extends React.Component<NavigationStackScreenProps> {
|
||||
static navigationOptions = {
|
||||
title: 'Welcome',
|
||||
};
|
||||
@@ -32,7 +30,7 @@ class HomeScreen extends React.Component<NavScreenProps> {
|
||||
}
|
||||
}
|
||||
|
||||
class OtherScreen extends React.Component<NavScreenProps> {
|
||||
class OtherScreen extends React.Component<NavigationStackScreenProps> {
|
||||
static navigationOptions = {
|
||||
title: 'Your title here',
|
||||
};
|
||||
@@ -59,7 +57,7 @@ class OtherScreen extends React.Component<NavScreenProps> {
|
||||
}
|
||||
}
|
||||
|
||||
class ScreenWithLongTitle extends React.Component<NavScreenProps> {
|
||||
class ScreenWithLongTitle extends React.Component<NavigationStackScreenProps> {
|
||||
static navigationOptions = {
|
||||
title: "Another title that's kind of long",
|
||||
};
|
||||
@@ -78,7 +76,7 @@ class ScreenWithLongTitle extends React.Component<NavScreenProps> {
|
||||
}
|
||||
}
|
||||
|
||||
class ScreenWithNoHeader extends React.Component<NavScreenProps> {
|
||||
class ScreenWithNoHeader extends React.Component<NavigationStackScreenProps> {
|
||||
static navigationOptions = {
|
||||
header: null,
|
||||
title: 'No Header',
|
||||
|
||||
@@ -5,8 +5,6 @@ import { isIphoneX } from 'react-native-iphone-x-helper';
|
||||
import {
|
||||
NavigationEventPayload,
|
||||
NavigationEventSubscription,
|
||||
NavigationScreenProp,
|
||||
NavigationState,
|
||||
Themed,
|
||||
SupportedThemes,
|
||||
} from 'react-navigation';
|
||||
@@ -14,14 +12,15 @@ import {
|
||||
createStackNavigator,
|
||||
Header,
|
||||
HeaderStyleInterpolator,
|
||||
NavigationStackScreenProps,
|
||||
NavigationStackProp,
|
||||
} from 'react-navigation-stack';
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
import { HeaderButtons } from './commonComponents/HeaderButtons';
|
||||
import SampleText from './SampleText';
|
||||
|
||||
interface MyNavScreenProps {
|
||||
// TODO: satya164 - use stack's navigation type
|
||||
navigation: any;
|
||||
navigation: NavigationStackProp;
|
||||
banner: React.ReactNode;
|
||||
}
|
||||
|
||||
@@ -82,7 +81,7 @@ class MyNavScreen extends React.Component<MyNavScreenProps> {
|
||||
}
|
||||
|
||||
interface MyHomeScreenProps {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
navigation: NavigationStackProp;
|
||||
}
|
||||
|
||||
class MyHomeScreen extends React.Component<MyHomeScreenProps> {
|
||||
@@ -126,7 +125,7 @@ class MyHomeScreen extends React.Component<MyHomeScreenProps> {
|
||||
}
|
||||
|
||||
interface MyPhotosScreenProps {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
navigation: NavigationStackProp;
|
||||
}
|
||||
class MyPhotosScreen extends React.Component<MyPhotosScreenProps> {
|
||||
static navigationOptions = {
|
||||
@@ -176,7 +175,7 @@ class MyPhotosScreen extends React.Component<MyPhotosScreenProps> {
|
||||
const MyProfileScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
navigation: NavigationStackProp;
|
||||
}) => (
|
||||
<MyNavScreen
|
||||
banner={`${navigation.state.params!.mode === 'edit' ? 'Now Editing ' : ''}${
|
||||
@@ -187,7 +186,7 @@ const MyProfileScreen = ({
|
||||
);
|
||||
|
||||
MyProfileScreen.navigationOptions = (props: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
navigation: NavigationStackProp;
|
||||
theme: SupportedThemes;
|
||||
}) => {
|
||||
const { navigation, theme } = props;
|
||||
@@ -227,7 +226,7 @@ const StackWithTranslucentHeader = createStackNavigator(
|
||||
},
|
||||
},
|
||||
{
|
||||
defaultNavigationOptions: ({ theme }: { theme: SupportedThemes }) => ({
|
||||
defaultNavigationOptions: ({ theme }: NavigationStackScreenProps) => ({
|
||||
headerBackground:
|
||||
Platform.OS === 'ios' ? (
|
||||
<BlurView
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
import React from 'react';
|
||||
import { Text, View } from 'react-native';
|
||||
import { Themed } from 'react-navigation';
|
||||
import {
|
||||
NavigationScreenProp,
|
||||
NavigationState,
|
||||
Themed,
|
||||
} from 'react-navigation';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
createStackNavigator,
|
||||
NavigationStackScreenProps,
|
||||
} from 'react-navigation-stack';
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
|
||||
interface Props {
|
||||
navigation: NavigationScreenProp<NavigationState & any>;
|
||||
}
|
||||
|
||||
class HomeScreen extends React.Component<Props, any> {
|
||||
class HomeScreen extends React.Component<NavigationStackScreenProps> {
|
||||
render() {
|
||||
return (
|
||||
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
||||
@@ -37,9 +32,12 @@ class HomeScreen extends React.Component<Props, any> {
|
||||
}
|
||||
}
|
||||
|
||||
class ProfileScreen extends React.Component<any, any> {
|
||||
class ProfileScreen extends React.Component<
|
||||
NavigationStackScreenProps<{ homeKey: string }>
|
||||
> {
|
||||
render() {
|
||||
const { homeKey } = this.props.navigation.state.params;
|
||||
const homeKey = this.props.navigation.getParam('homeKey');
|
||||
|
||||
return (
|
||||
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
||||
<Text>Profile</Text>
|
||||
@@ -64,7 +62,7 @@ class ProfileScreen extends React.Component<any, any> {
|
||||
}
|
||||
}
|
||||
|
||||
class SettingsScreen extends React.Component<Props, any> {
|
||||
class SettingsScreen extends React.Component<NavigationStackScreenProps> {
|
||||
render() {
|
||||
const { homeKey } = this.props.navigation.state.params!;
|
||||
|
||||
|
||||
@@ -7,7 +7,11 @@ import {
|
||||
SafeAreaView,
|
||||
ScrollView,
|
||||
} from 'react-navigation';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
import {
|
||||
createStackNavigator,
|
||||
NavigationStackScreenProps,
|
||||
NavigationStackProp,
|
||||
} from 'react-navigation-stack';
|
||||
import { createBottomTabNavigator } from 'react-navigation-tabs';
|
||||
import { Ionicons } from '@expo/vector-icons';
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
@@ -19,7 +23,7 @@ Nulla convallis pulvinar hendrerit. Nulla mattis sem et aliquam ultrices. Nam eg
|
||||
Praesent lobortis elit sit amet mauris pulvinar, viverra condimentum massa pellentesque. Curabitur massa ex, dignissim eget neque at, fringilla consectetur justo. Cras sollicitudin vel ligula sed cursus. Aliquam porta sem hendrerit diam porta ultricies. Sed eu mi erat. Curabitur id justo vel tortor hendrerit vestibulum id eget est. Morbi eros magna, placerat id diam ut, varius sollicitudin mi. Curabitur pretium finibus accumsan.`;
|
||||
|
||||
interface Props {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
navigation: NavigationStackProp;
|
||||
banner: string;
|
||||
}
|
||||
|
||||
@@ -59,11 +63,7 @@ class MyNavScreen extends React.Component<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
const MyProfileScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => (
|
||||
const MyProfileScreen = ({ navigation }: NavigationStackScreenProps) => (
|
||||
<MyNavScreen
|
||||
banner={`${navigation.state.params!.name}s Profile`}
|
||||
navigation={navigation}
|
||||
|
||||
@@ -7,7 +7,10 @@ import {
|
||||
NavigationState,
|
||||
SafeAreaView,
|
||||
} from 'react-navigation';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
import {
|
||||
createStackNavigator,
|
||||
NavigationStackScreenProps,
|
||||
} from 'react-navigation-stack';
|
||||
import { createBottomTabNavigator } from 'react-navigation-tabs';
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
import SampleText from './SampleText';
|
||||
@@ -59,9 +62,9 @@ const MyProfileScreen = ({
|
||||
|
||||
const MyNotificationsSettingsScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => <MyNavScreen banner="Notifications Screen" navigation={navigation} />;
|
||||
}: NavigationStackScreenProps) => (
|
||||
<MyNavScreen banner="Notifications Screen" navigation={navigation} />
|
||||
);
|
||||
|
||||
const MySettingsScreen = ({
|
||||
navigation,
|
||||
@@ -141,11 +144,7 @@ const StacksOverTabs = createStackNavigator({
|
||||
screen: MyNotificationsSettingsScreen,
|
||||
},
|
||||
Profile: {
|
||||
navigationOptions: ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => ({
|
||||
navigationOptions: ({ navigation }: NavigationStackScreenProps) => ({
|
||||
title: `${navigation.state.params!.name}'s Profile!`,
|
||||
}),
|
||||
path: '/people/:name',
|
||||
|
||||
@@ -11,7 +11,10 @@ import {
|
||||
NavigationState,
|
||||
SafeAreaView,
|
||||
} from 'react-navigation';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
import {
|
||||
createStackNavigator,
|
||||
NavigationStackScreenProps,
|
||||
} from 'react-navigation-stack';
|
||||
import {
|
||||
createMaterialTopTabNavigator,
|
||||
MaterialTopTabBar,
|
||||
@@ -64,11 +67,7 @@ const MyHomeScreen = ({
|
||||
/>
|
||||
);
|
||||
|
||||
const MyProfileScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => (
|
||||
const MyProfileScreen = ({ navigation }: NavigationStackScreenProps) => (
|
||||
<MyNavScreen
|
||||
banner={`${navigation.state.params!.name}s Profile`}
|
||||
navigation={navigation}
|
||||
@@ -77,9 +76,9 @@ const MyProfileScreen = ({
|
||||
|
||||
const MyNotificationsSettingsScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => <MyNavScreen banner="Notifications Screen" navigation={navigation} />;
|
||||
}: NavigationStackScreenProps) => (
|
||||
<MyNavScreen banner="Notifications Screen" navigation={navigation} />
|
||||
);
|
||||
|
||||
const MySettingsScreen = ({
|
||||
navigation,
|
||||
@@ -159,11 +158,7 @@ const StackNavigator = createStackNavigator(
|
||||
},
|
||||
Profile: {
|
||||
screen: MyProfileScreen,
|
||||
navigationOptions: ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => ({
|
||||
navigationOptions: ({ navigation }: NavigationStackScreenProps) => ({
|
||||
title: `${navigation.state.params!.name}'s Profile!`,
|
||||
}),
|
||||
},
|
||||
|
||||
@@ -7,10 +7,13 @@ import {
|
||||
Platform,
|
||||
} from 'react-native';
|
||||
import { Themed, createSwitchNavigator } from 'react-navigation';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
import {
|
||||
createStackNavigator,
|
||||
NavigationStackScreenProps,
|
||||
} from 'react-navigation-stack';
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
|
||||
class SignInScreen extends React.Component<any, any> {
|
||||
class SignInScreen extends React.Component<NavigationStackScreenProps> {
|
||||
static navigationOptions = {
|
||||
title: 'Please sign in',
|
||||
};
|
||||
@@ -34,7 +37,7 @@ class SignInScreen extends React.Component<any, any> {
|
||||
};
|
||||
}
|
||||
|
||||
class HomeScreen extends React.Component<any, any> {
|
||||
class HomeScreen extends React.Component<NavigationStackScreenProps> {
|
||||
static navigationOptions = {
|
||||
title: 'Welcome to the app!',
|
||||
};
|
||||
@@ -64,7 +67,7 @@ class HomeScreen extends React.Component<any, any> {
|
||||
};
|
||||
}
|
||||
|
||||
class OtherScreen extends React.Component<any, any> {
|
||||
class OtherScreen extends React.Component<NavigationStackScreenProps> {
|
||||
static navigationOptions = {
|
||||
title: 'Lots of features here',
|
||||
};
|
||||
|
||||
@@ -918,10 +918,10 @@
|
||||
resolved "https://registry.yarnpkg.com/@react-native-community/netinfo/-/netinfo-2.0.10.tgz#d28a446352e75754b78509557988359133cdbcca"
|
||||
integrity sha512-NrIzyLe0eSbhgMnHl2QdSEhaA7yXh6p9jzMomfUa//hoTXE+xbObGDdiWWSQm2bnXnZJg8XCU3AB9qzvqcuLnA==
|
||||
|
||||
"@react-navigation/core@^3.5.0":
|
||||
version "3.5.0"
|
||||
resolved "https://registry.yarnpkg.com/@react-navigation/core/-/core-3.5.0.tgz#73d1a12448e2bd71855e0080b95a7f51ede0cd9e"
|
||||
integrity sha512-NLm24lA51R8o8c+iFnwtN9elqRzm4OJ8f1qPBCUNIYW1sb8M5yCD53vRP0fRcPFpr/6Xzs2TJMsWnnebwFp0Rw==
|
||||
"@react-navigation/core@^3.5.1":
|
||||
version "3.5.1"
|
||||
resolved "https://registry.yarnpkg.com/@react-navigation/core/-/core-3.5.1.tgz#7a2339fca3496979305fb3a8ab88c2ca8d8c214d"
|
||||
integrity sha512-q7NyhWVYOhVIWqL2GZKa6G78YarXaVTTtOlSDkvy4ZIggo40wZzamlnrJRvsaQX46gsgw45FAWb5SriHh8o7eA==
|
||||
dependencies:
|
||||
hoist-non-react-statics "^3.3.0"
|
||||
path-to-regexp "^1.7.0"
|
||||
@@ -4798,10 +4798,10 @@ react-navigation-header-buttons@^3.0.2:
|
||||
dependencies:
|
||||
react-native-platform-touchable "^1.1.1"
|
||||
|
||||
react-navigation-stack@^1.5.1:
|
||||
version "1.5.1"
|
||||
resolved "https://registry.yarnpkg.com/react-navigation-stack/-/react-navigation-stack-1.5.1.tgz#8a8c0cd0b8498225f4e8e564f06043849961bede"
|
||||
integrity sha512-VEMSsKvicaLlFu6+U4u5YkwFe4hnMTLu83bR15GumuqrpCVPPgl7Qt4fSZCRG/YtC5ZcUiy5EgCRu9MVIINV5w==
|
||||
react-navigation-stack@^1.7.2:
|
||||
version "1.7.2"
|
||||
resolved "https://registry.yarnpkg.com/react-navigation-stack/-/react-navigation-stack-1.7.2.tgz#d7cf7a7dc76c2390024be6358fc65461c848a034"
|
||||
integrity sha512-72oL9rVXUFvFayoA7k+OgXcwP/6e5BAtCSpUXfKX+lZYrJe3BvuhZz2KDhEjdfbuP/sNok55ZRzc3/X1kh5mxQ==
|
||||
dependencies:
|
||||
prop-types "^15.7.2"
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-navigation",
|
||||
"version": "4.0.4",
|
||||
"version": "4.0.7",
|
||||
"description": "Routing and navigation for your React Native apps",
|
||||
"main": "src/react-navigation.js",
|
||||
"types": "typescript/react-navigation.d.ts",
|
||||
@@ -31,7 +31,7 @@
|
||||
"react-native": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@react-navigation/core": "^3.5.0",
|
||||
"@react-navigation/core": "^3.5.1",
|
||||
"@react-navigation/native": "^3.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
27
src/react-navigation.js
vendored
27
src/react-navigation.js
vendored
@@ -1,4 +1,29 @@
|
||||
export * from '@react-navigation/core';
|
||||
export * from '@react-navigation/native';
|
||||
|
||||
export * from './deprecations';
|
||||
// Export each item individually so that they can be evaluated lazily
|
||||
// https://babeljs.io/docs/en/babel-plugin-transform-modules-commonjs#lazy
|
||||
export {
|
||||
createNavigationContainer,
|
||||
createStackNavigator,
|
||||
createBottomTabNavigator,
|
||||
createMaterialTopTabNavigator,
|
||||
createDrawerNavigator,
|
||||
StackGestureContext,
|
||||
DrawerGestureContext,
|
||||
DrawerRouter,
|
||||
DrawerActions,
|
||||
Transitioner,
|
||||
StackView,
|
||||
StackViewCard,
|
||||
StackViewTransitionConfigs,
|
||||
Header,
|
||||
HeaderTitle,
|
||||
HeaderBackButton,
|
||||
HeaderStyleInterpolator,
|
||||
DrawerView,
|
||||
DrawerItems,
|
||||
DrawerSidebar,
|
||||
BottomTabBar,
|
||||
MaterialTopTabBar,
|
||||
} from './deprecations';
|
||||
|
||||
63
typescript/react-navigation.d.ts
vendored
63
typescript/react-navigation.d.ts
vendored
@@ -190,16 +190,16 @@ declare module 'react-navigation' {
|
||||
navigationOptions?: NavigationScreenConfig<Options, NavigationScreenPropType>;
|
||||
};
|
||||
|
||||
export interface NavigationScreenConfigProps<NavigationScreenPropType> {
|
||||
export interface NavigationScreenConfigProps<NavigationScreenPropType, ScreenProps = unknown> {
|
||||
navigation: NavigationScreenPropType;
|
||||
screenProps: unknown;
|
||||
screenProps: ScreenProps;
|
||||
theme: SupportedThemes;
|
||||
}
|
||||
|
||||
export type NavigationScreenConfig<Options, NavigationScreenPropType> =
|
||||
export type NavigationScreenConfig<Options, NavigationScreenPropType, ScreenProps = unknown> =
|
||||
| Options
|
||||
| ((
|
||||
navigationOptionsContainer: NavigationScreenConfigProps<NavigationScreenPropType> & {
|
||||
navigationOptionsContainer: NavigationScreenConfigProps<NavigationScreenPropType, ScreenProps> & {
|
||||
navigationOptions: Options;
|
||||
}
|
||||
) => Options);
|
||||
@@ -345,7 +345,7 @@ declare module 'react-navigation' {
|
||||
|
||||
export interface NavigationJumpToActionPayload {
|
||||
routeName: string;
|
||||
key: string;
|
||||
key?: string;
|
||||
params?: NavigationParams;
|
||||
}
|
||||
|
||||
@@ -542,12 +542,12 @@ declare module 'react-navigation' {
|
||||
dangerouslyGetParent: () => NavigationScreenProp<S> | undefined;
|
||||
}
|
||||
|
||||
export interface NavigationNavigatorProps<O = {}, S = {}> {
|
||||
export interface NavigationNavigatorProps<Options = {}, State = {}, ScreenProps = unknown> {
|
||||
theme?: SupportedThemes | 'no-preference';
|
||||
detached?: boolean;
|
||||
navigation?: NavigationProp<S>;
|
||||
screenProps?: unknown;
|
||||
navigationOptions?: O;
|
||||
navigation?: NavigationProp<State>;
|
||||
screenProps?: ScreenProps;
|
||||
navigationOptions?: Options;
|
||||
}
|
||||
|
||||
export type NavigatorType =
|
||||
@@ -555,7 +555,7 @@ declare module 'react-navigation' {
|
||||
| 'react-navigation/TABS'
|
||||
| 'react-navigation/DRAWER';
|
||||
|
||||
export interface NavigationContainerProps<S = {}, O = {}> {
|
||||
export interface NavigationContainerProps<State = {}, Options = {}, ScreenProps = unknown> {
|
||||
uriPrefix?: string | RegExp;
|
||||
/**
|
||||
* Controls whether the navigation container handles URLs opened via 'Linking'
|
||||
@@ -568,7 +568,7 @@ declare module 'react-navigation' {
|
||||
nextNavigationState: NavigationState,
|
||||
action: NavigationAction
|
||||
) => void | null | undefined;
|
||||
navigation?: NavigationScreenProp<S>;
|
||||
navigation?: NavigationScreenProp<State>;
|
||||
/*
|
||||
* This prop is no longer supported. Use `loadNavigationState` and
|
||||
* `persistNavigationState` instead.
|
||||
@@ -579,8 +579,8 @@ declare module 'react-navigation' {
|
||||
persistNavigationState?: (state: NavigationState) => Promise<any>;
|
||||
|
||||
renderLoadingExperimental?: React.ComponentType;
|
||||
screenProps?: unknown;
|
||||
navigationOptions?: O;
|
||||
screenProps?: ScreenProps;
|
||||
navigationOptions?: Options;
|
||||
style?: StyleProp<ViewStyle>;
|
||||
}
|
||||
|
||||
@@ -613,13 +613,10 @@ declare module 'react-navigation' {
|
||||
backBehavior?: 'none' | 'initialRoute';
|
||||
}
|
||||
|
||||
// Return createNavigationContainer
|
||||
export type _SwitchNavigatorConfig = NavigationSwitchRouterConfig;
|
||||
|
||||
export function createSwitchNavigator(
|
||||
routeConfigMap: NavigationRouteConfigMap<SwitchNavigatorConfig, NavigationScreenProp<NavigationRoute>>,
|
||||
switchConfig?: SwitchNavigatorConfig
|
||||
): NavigationContainer;
|
||||
): NavigationNavigator<{}, NavigationProp<NavigationState>>;
|
||||
|
||||
/**
|
||||
* NavigationActions
|
||||
@@ -738,11 +735,11 @@ declare module 'react-navigation' {
|
||||
getComponent: () => React.ComponentType;
|
||||
}
|
||||
|
||||
export type NavigationView<O, S> = React.ComponentType<
|
||||
export type NavigationView<Options, State, ScreenProps = unknown> = React.ComponentType<
|
||||
{
|
||||
descriptors: { [key: string]: NavigationDescriptor };
|
||||
navigationConfig: O;
|
||||
screenProps?: unknown;
|
||||
navigationConfig: Options;
|
||||
screenProps?: ScreenProps;
|
||||
} & NavigationInjectedProps
|
||||
>;
|
||||
|
||||
@@ -754,9 +751,9 @@ declare module 'react-navigation' {
|
||||
export function createNavigator<S, Options>(
|
||||
view: NavigationView<Options, S>,
|
||||
router: NavigationRouter<S, Options>,
|
||||
navigatorConfig?: {} | null,
|
||||
navigatorConfig?: {},
|
||||
navigatorType?: NavigatorType
|
||||
): any;
|
||||
): NavigationNavigator<Options, NavigationProp<NavigationState>>;
|
||||
|
||||
/**
|
||||
* Create an HOC that injects the navigation and manages the navigation state
|
||||
@@ -779,28 +776,6 @@ declare module 'react-navigation' {
|
||||
Component: NavigationNavigator<Options, NavigationPropType>
|
||||
): NavigationContainer;
|
||||
|
||||
/**
|
||||
* END MANUAL DEFINITIONS OUTSIDE OF TYPEDEFINITION.JS
|
||||
*/
|
||||
|
||||
/**
|
||||
* BEGIN CUSTOM CONVENIENCE INTERFACES
|
||||
*/
|
||||
|
||||
export interface NavigationScreenProps<
|
||||
Params = NavigationParams,
|
||||
Options = {},
|
||||
NavigationScreenPropType = NavigationScreenProp<NavigationRoute>
|
||||
> {
|
||||
navigation: NavigationScreenProp<NavigationRoute<Params>, Params>;
|
||||
screenProps?: unknown;
|
||||
navigationOptions?: NavigationScreenConfig<Options, NavigationScreenPropType>;
|
||||
}
|
||||
|
||||
/**
|
||||
* END CUSTOM CONVENIENCE INTERFACES
|
||||
*/
|
||||
|
||||
export type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;
|
||||
|
||||
export type InferProps<
|
||||
|
||||
@@ -1076,10 +1076,10 @@
|
||||
xcode "^2.0.0"
|
||||
xmldoc "^0.4.0"
|
||||
|
||||
"@react-navigation/core@^3.5.0":
|
||||
version "3.5.0"
|
||||
resolved "https://registry.yarnpkg.com/@react-navigation/core/-/core-3.5.0.tgz#73d1a12448e2bd71855e0080b95a7f51ede0cd9e"
|
||||
integrity sha512-NLm24lA51R8o8c+iFnwtN9elqRzm4OJ8f1qPBCUNIYW1sb8M5yCD53vRP0fRcPFpr/6Xzs2TJMsWnnebwFp0Rw==
|
||||
"@react-navigation/core@^3.5.1":
|
||||
version "3.5.1"
|
||||
resolved "https://registry.yarnpkg.com/@react-navigation/core/-/core-3.5.1.tgz#7a2339fca3496979305fb3a8ab88c2ca8d8c214d"
|
||||
integrity sha512-q7NyhWVYOhVIWqL2GZKa6G78YarXaVTTtOlSDkvy4ZIggo40wZzamlnrJRvsaQX46gsgw45FAWb5SriHh8o7eA==
|
||||
dependencies:
|
||||
hoist-non-react-statics "^3.3.0"
|
||||
path-to-regexp "^1.7.0"
|
||||
|
||||
Reference in New Issue
Block a user