From be8155fcbb0fe6ed881fd97c5b72947a1a0e77d8 Mon Sep 17 00:00:00 2001 From: "satyajit.happy" Date: Thu, 12 Sep 2019 20:10:48 +0200 Subject: [PATCH] feat: export types for ScreenProps amd ScreenComponent --- example/package.json | 2 +- example/yarn.lock | 8 +++---- package.json | 4 ++-- src/index.tsx | 12 +++++++++++ .../createMaterialBottomTabNavigator.tsx | 5 +++-- src/types.tsx | 21 +++++++++++++++++++ yarn.lock | 8 +++---- 7 files changed, 47 insertions(+), 13 deletions(-) diff --git a/example/package.json b/example/package.json index 008724f..61cef6d 100644 --- a/example/package.json +++ b/example/package.json @@ -19,7 +19,7 @@ "react-native-gesture-handler": "~1.3.0", "react-native-paper": "^3.0.0-alpha.4", "react-native-reanimated": "~1.1.0", - "react-navigation": "^4.0.3", + "react-navigation": "^4.0.4", "react-navigation-stack": "^1.5.4" }, "devDependencies": { diff --git a/example/yarn.lock b/example/yarn.lock index 91f2502..20e0a61 100644 --- a/example/yarn.lock +++ b/example/yarn.lock @@ -4318,10 +4318,10 @@ react-navigation-stack@^1.5.4: dependencies: prop-types "^15.7.2" -react-navigation@^4.0.3: - version "4.0.3" - resolved "https://registry.yarnpkg.com/react-navigation/-/react-navigation-4.0.3.tgz#ba2cacb71db56e22ee50d774829ebc7fa95a0724" - integrity sha512-oASR5gHwd6se1Mw8AM4Ie8GicD5mKzRiYP6oaQujiQroQzQPij9sXxkRSqOscd/Kw1/Hf3htvBX3ZRPbOkWsfA== +react-navigation@^4.0.4: + version "4.0.4" + resolved "https://registry.yarnpkg.com/react-navigation/-/react-navigation-4.0.4.tgz#afa43c7183891d38708cf57f1d4394fed1d4c2ad" + integrity sha512-MZeVkYkFTKZobhrXMV3Hgeg0HHeokCrYsbxActVfO0n6zfzm0/La6EiC2mIHiwOymvb1ZygyFf90vryLUMEBNA== dependencies: "@react-navigation/core" "^3.5.0" "@react-navigation/native" "^3.6.2" diff --git a/package.json b/package.json index 8f038a8..ca36266 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "react-native-gesture-handler": "^1.4.1", "react-native-paper": "^3.0.0-alpha.4", "react-native-reanimated": "^1.2.0", - "react-navigation": "^4.0.3", + "react-navigation": "^4.0.4", "release-it": "^12.3.6", "typescript": "^3.5.2" }, @@ -68,7 +68,7 @@ "react": "*", "react-native": "*", "react-native-paper": "^2.2.2 || ^3.0.0-alpha.1", - "react-navigation": "^4.0.3" + "react-navigation": "^4.0.4" }, "husky": { "hooks": { diff --git a/src/index.tsx b/src/index.tsx index 8ca4fa6..e88177e 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,3 +1,15 @@ export { default as createMaterialBottomTabNavigator, } from './navigators/createMaterialBottomTabNavigator'; + +/** + * Types + */ +export { + NavigationTabState, + NavigationTabProp, + NavigationTabScreenProps, + NavigationMaterialBottomTabOptions, + NavigationMaterialBottomTabConfig, + NavigationMaterialBottomTabScreenComponent, +} from './types'; diff --git a/src/navigators/createMaterialBottomTabNavigator.tsx b/src/navigators/createMaterialBottomTabNavigator.tsx index 1fe0cb4..f77cdd8 100644 --- a/src/navigators/createMaterialBottomTabNavigator.tsx +++ b/src/navigators/createMaterialBottomTabNavigator.tsx @@ -54,12 +54,13 @@ export type NavigationViewProps = { export default function createMaterialBottomTabNavigator( routes: NavigationRouteConfigMap< NavigationMaterialBottomTabOptions, - NavigationTabProp + NavigationTabProp >, config: CreateNavigatorConfig< NavigationMaterialBottomTabConfig, NavigationTabRouterConfig, - NavigationMaterialBottomTabOptions + NavigationMaterialBottomTabOptions, + NavigationTabProp > = {} ) { class NavigationView extends React.Component { diff --git a/src/types.tsx b/src/types.tsx index 6df8f24..89ebc47 100644 --- a/src/types.tsx +++ b/src/types.tsx @@ -4,6 +4,8 @@ import { NavigationState, NavigationScreenProp, NavigationParams, + NavigationScreenConfig, + SupportedThemes, } from 'react-navigation'; export type NavigationTabState = NavigationState; @@ -85,3 +87,22 @@ export type NavigationMaterialBottomTabConfig = { barStyleDark?: StyleProp; style?: StyleProp; }; + +export type NavigationTabScreenProps< + Params = NavigationParams, + ScreenProps = unknown +> = { + theme: SupportedThemes; + navigation: NavigationTabProp; + screenProps: ScreenProps; +}; + +export type NavigationMaterialBottomTabScreenComponent< + Params = NavigationParams, + ScreenProps = unknown +> = React.ComponentType> & { + navigationOptions?: NavigationScreenConfig< + NavigationMaterialBottomTabOptions, + NavigationTabProp + >; +}; diff --git a/yarn.lock b/yarn.lock index 66dc895..5648c2e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7378,10 +7378,10 @@ react-native@~0.59.8: xmldoc "^0.4.0" yargs "^9.0.0" -react-navigation@^4.0.3: - version "4.0.3" - resolved "https://registry.yarnpkg.com/react-navigation/-/react-navigation-4.0.3.tgz#ba2cacb71db56e22ee50d774829ebc7fa95a0724" - integrity sha512-oASR5gHwd6se1Mw8AM4Ie8GicD5mKzRiYP6oaQujiQroQzQPij9sXxkRSqOscd/Kw1/Hf3htvBX3ZRPbOkWsfA== +react-navigation@^4.0.4: + version "4.0.4" + resolved "https://registry.yarnpkg.com/react-navigation/-/react-navigation-4.0.4.tgz#afa43c7183891d38708cf57f1d4394fed1d4c2ad" + integrity sha512-MZeVkYkFTKZobhrXMV3Hgeg0HHeokCrYsbxActVfO0n6zfzm0/La6EiC2mIHiwOymvb1ZygyFf90vryLUMEBNA== dependencies: "@react-navigation/core" "^3.5.0" "@react-navigation/native" "^3.6.2"