react-native-navigators
Advanced tools
Comparing version 0.3.0-16 to 0.3.0-17
import { NavigationRouteConfigMap } from 'react-navigation'; | ||
import { NavigationNativeRouterConfig, NativeNavigationOptions } from './types'; | ||
export declare function createNativeNavigator(routeConfigMap: NavigationRouteConfigMap<NativeNavigationOptions, any>, stackConfig: NavigationNativeRouterConfig): import("react-navigation").NavigationNavigator<NavigationNativeRouterConfig, import("react-navigation").NavigationProp<import("react-navigation").NavigationState>>; | ||
export declare function createStackNavigator(routeConfigMap: NavigationRouteConfigMap<NativeNavigationOptions, any>, stackConfig: Omit<NavigationNativeRouterConfig, 'mode' | 'splitRules'>): import("react-navigation").NavigationNavigator<NavigationNativeRouterConfig, import("react-navigation").NavigationProp<import("react-navigation").NavigationState>>; | ||
export declare function createCardNavigator(routeConfigMap: NavigationRouteConfigMap<NativeNavigationOptions, any>, stackConfig: Omit<NavigationNativeRouterConfig, 'headerMode' | 'mode' | 'splitRules'>): import("react-navigation").NavigationNavigator<NavigationNativeRouterConfig, import("react-navigation").NavigationProp<import("react-navigation").NavigationState>>; | ||
export declare function createSplitNavigator(routeConfigMap: NavigationRouteConfigMap<NativeNavigationOptions, any>, stackConfig: Omit<NavigationNativeRouterConfig, 'headerMode' | 'mode'>): import("react-navigation").NavigationNavigator<NavigationNativeRouterConfig, import("react-navigation").NavigationProp<import("react-navigation").NavigationState>>; | ||
import { NativeNavigationRouterConfig, NativeSplitNavigationRouterConfig, NativeNavigationOptions } from './types'; | ||
export declare function createNativeNavigator(routeConfigMap: NavigationRouteConfigMap<NativeNavigationOptions, any>, stackConfig: NativeNavigationRouterConfig): import("react-navigation").NavigationNavigator<NativeNavigationRouterConfig, import("react-navigation").NavigationProp<import("react-navigation").NavigationState>>; | ||
export declare function createStackNavigator(routeConfigMap: NavigationRouteConfigMap<NativeNavigationOptions, any>, stackConfig: Omit<NativeNavigationRouterConfig, 'mode'>): import("react-navigation").NavigationNavigator<NativeNavigationRouterConfig, import("react-navigation").NavigationProp<import("react-navigation").NavigationState>>; | ||
export declare function createCardNavigator(routeConfigMap: NavigationRouteConfigMap<NativeNavigationOptions, any>, stackConfig: Omit<NativeNavigationRouterConfig, 'headerMode' | 'mode'>): import("react-navigation").NavigationNavigator<NativeNavigationRouterConfig, import("react-navigation").NavigationProp<import("react-navigation").NavigationState>>; | ||
export declare function createSplitNavigator(routeConfigMap: NavigationRouteConfigMap<NativeNavigationOptions, any>, splitConfig: Omit<NativeSplitNavigationRouterConfig, 'headerMode' | 'mode'>): import("react-navigation").NavigationNavigator<NativeNavigationRouterConfig, import("react-navigation").NavigationProp<import("react-navigation").NavigationState>>; |
@@ -17,6 +17,6 @@ import { createNavigator, StackRouter } from 'react-navigation'; | ||
} | ||
export function createSplitNavigator(routeConfigMap, stackConfig) { | ||
const router = SplitRouter(routeConfigMap, stackConfig); | ||
return createNavigator(NativeNavigators, router, Object.assign(Object.assign({}, stackConfig), { mode: NativeNavigatorModes.Split })); | ||
export function createSplitNavigator(routeConfigMap, splitConfig) { | ||
const router = SplitRouter(routeConfigMap, splitConfig); | ||
return createNavigator(NativeNavigators, router, Object.assign(Object.assign({}, splitConfig), { mode: NativeNavigatorModes.Split })); | ||
} | ||
//# sourceMappingURL=createNavigators.js.map |
export * from './createNavigators'; | ||
export { default as SplitRouter } from './SplitRouter'; | ||
export { NativeNavigationClosingStateContext } from './NativeScene'; | ||
export { NativeSplitNavigatorOptionsContext } from './NativeSplitNavigatorOptionsWrapper'; | ||
export * from './splitNavigatorRules'; | ||
export * from './types'; |
export * from './createNavigators'; | ||
export { default as SplitRouter } from './SplitRouter'; | ||
export { NativeNavigationClosingStateContext } from './NativeScene'; | ||
export { NativeSplitNavigatorOptionsContext } from './NativeSplitNavigatorOptionsWrapper'; | ||
export * from './splitNavigatorRules'; | ||
export * from './types'; | ||
//# sourceMappingURL=index.js.map |
@@ -5,2 +5,5 @@ import React, { PureComponent } from 'react'; | ||
import NativeStackNavigator from './NativeStackNavigator'; | ||
import NativeCardNavigator from './NativeCardNavigator'; | ||
import NativeSplitNavigator from './NativeSplitNavigator'; | ||
import NativeSplitNavigatorOptionsWrapper from './NativeSplitNavigatorOptionsWrapper'; | ||
import NativeScenes from './NativeScenes'; | ||
@@ -91,21 +94,18 @@ export default class NativeNavigators extends PureComponent { | ||
const { closingRouteKey, routes, descriptors, screenProps } = this.state; | ||
const mode = navigationConfig.mode || NativeNavigatorModes.Stack; | ||
let splitRules = navigationConfig.splitRules; | ||
if (mode !== NativeNavigatorModes.Split && splitRules) { | ||
console.warn(`Navigation config \`splitRules\` is not supported for \`${mode}\` navigator.`); | ||
splitRules = undefined; | ||
const scenes = (<NativeScenes mode={navigationConfig.mode} headerMode={navigationConfig.headerMode} routes={routes} descriptors={descriptors} navigation={navigation} screenProps={screenProps} onOpenRoute={this.handleOpenRoute} onCloseRoute={this.handleCloseRoute} onDismissRoute={this.handleDismissRoute} closingRouteKey={closingRouteKey}/>); | ||
if (navigationConfig.mode === NativeNavigatorModes.Split) { | ||
return (<NativeSplitNavigatorOptionsWrapper options={navigationConfig.defaultNavigatorOptions}> | ||
{options => (<NativeSplitNavigator options={options}> | ||
<NativeScenes splitPrimaryRouteNames={options.splitPrimaryRouteNames} mode={navigationConfig.mode} headerMode={navigationConfig.headerMode} routes={routes} descriptors={descriptors} navigation={navigation} screenProps={screenProps} onOpenRoute={this.handleOpenRoute} onCloseRoute={this.handleCloseRoute} onDismissRoute={this.handleDismissRoute} closingRouteKey={closingRouteKey}/> | ||
</NativeSplitNavigator>)} | ||
</NativeSplitNavigatorOptionsWrapper>); | ||
} | ||
else if (mode === NativeNavigatorModes.Split && !splitRules) { | ||
console.error(`Navigation config \`splitRules\` is required for \`${mode}\` navigator.`); | ||
else if (navigationConfig.mode === NativeNavigatorModes.Card) { | ||
return <NativeCardNavigator>{scenes}</NativeCardNavigator>; | ||
} | ||
let splitPlaceholder = navigationConfig.splitPlaceholder; | ||
if (mode !== NativeNavigatorModes.Split && splitPlaceholder) { | ||
console.warn(`Navigation config \`splitPlaceholder\` is not supported for \`${mode}\` navigator.`); | ||
splitRules = undefined; | ||
else { | ||
return <NativeStackNavigator>{scenes}</NativeStackNavigator>; | ||
} | ||
return (<NativeStackNavigator mode={mode} navigation={navigation} splitRules={splitRules} splitPlaceholder={splitPlaceholder}> | ||
<NativeScenes mode={mode} headerMode={navigationConfig.headerMode} routes={routes} descriptors={descriptors} navigation={navigation} screenProps={screenProps} onOpenRoute={this.handleOpenRoute} onCloseRoute={this.handleCloseRoute} onDismissRoute={this.handleDismissRoute} closingRouteKey={closingRouteKey}/> | ||
</NativeStackNavigator>); | ||
} | ||
} | ||
//# sourceMappingURL=NativeNavigators.js.map |
@@ -6,2 +6,3 @@ import React from 'react'; | ||
closing: boolean; | ||
isSplitPrimary: boolean; | ||
descriptor: NativeNavigationDescriptor; | ||
@@ -8,0 +9,0 @@ route: NavigationRoute<NavigationParams>; |
@@ -12,3 +12,3 @@ import React, { memo, createContext, useContext } from 'react'; | ||
var _a, _b; | ||
const { route, descriptor, closing, mode, screenProps, onDidFocus, onDidBlur } = props; | ||
const { route, descriptor, closing, isSplitPrimary, mode, screenProps, onDidFocus, onDidBlur } = props; | ||
const { key } = route; | ||
@@ -33,3 +33,3 @@ const closingContextState = useContext(NativeNavigationClosingStateContext); | ||
return (<NativeStackScene key={key} transition={((_b = (_a = navigation.dangerouslyGetParent()) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.isTransitioning) ? options.transition || NativeNavigatorTransitions.Default | ||
: NativeNavigatorTransitions.None} gestureEnabled={options.gestureEnabled !== false} translucent={options.translucent === true} transparent={options.transparent === true} splitFullScreen={options.splitFullScreen === true} style={options.cardStyle} statusBarStyle={options.statusBarStyle} statusBarHidden={options.statusBarHidden} closing={closing} onDidFocus={onDidFocus} onDidBlur={onDidBlur} route={route}> | ||
: NativeNavigatorTransitions.None} isSplitPrimary={isSplitPrimary} gestureEnabled={options.gestureEnabled !== false} translucent={options.translucent === true} transparent={options.transparent === true} style={options.cardStyle} statusBarStyle={options.statusBarStyle} statusBarHidden={options.statusBarHidden} closing={closing} onDidFocus={onDidFocus} onDidBlur={onDidBlur} route={route}> | ||
<NativeStackSceneContainer> | ||
@@ -39,3 +39,2 @@ <NativeNavigationClosingStateContext.Provider value={closing || closingContextState}> | ||
</NativeNavigationClosingStateContext.Provider> | ||
{headerMode === NativeNavigatorHeaderModes.Auto ? (<NativeHeader options={options} route={route}/>) : null} | ||
@@ -42,0 +41,0 @@ </NativeStackSceneContainer> |
@@ -8,2 +8,3 @@ import { PureComponent } from 'react'; | ||
headerMode?: NativeNavigatorHeaderModes; | ||
splitPrimaryRouteNames?: string[]; | ||
descriptors: NativeNavigationDescriptorMap; | ||
@@ -10,0 +11,0 @@ screenProps?: unknown; |
@@ -24,7 +24,8 @@ import React, { PureComponent } from 'react'; | ||
render() { | ||
const { routes, descriptors, screenProps, mode, closingRouteKey, headerMode } = this.props; | ||
const { routes, descriptors, screenProps, mode, closingRouteKey, headerMode, splitPrimaryRouteNames } = this.props; | ||
const splitPrimaryRouteSet = new Set(splitPrimaryRouteNames); | ||
return (<> | ||
{routes.map(route => { | ||
const descriptor = descriptors[route.key]; | ||
return (<NativeScene key={route.key} closing={closingRouteKey === route.key} descriptor={descriptor} route={route} screenProps={screenProps} mode={mode} headerMode={headerMode} onDidFocus={this.handleDidFocus} onDidBlur={this.handleDidBlur}/>); | ||
return (<NativeScene key={route.key} isSplitPrimary={splitPrimaryRouteSet.has(route.routeName)} closing={closingRouteKey === route.key} descriptor={descriptor} route={route} screenProps={screenProps} mode={mode} headerMode={headerMode} onDidFocus={this.handleDidFocus} onDidBlur={this.handleDidBlur}/>); | ||
})} | ||
@@ -31,0 +32,0 @@ </>); |
@@ -1,6 +0,5 @@ | ||
import { ComponentType } from 'react'; | ||
import { NavigationInjectedProps } from 'react-navigation'; | ||
import { ElementType } from 'react'; | ||
export declare type NativeSplitPlaceholderProps = { | ||
component: ComponentType<NavigationInjectedProps>; | ||
} & NavigationInjectedProps; | ||
component: ElementType<{}>; | ||
}; | ||
export default function NativeSplitPlaceholder(props: NativeSplitPlaceholderProps): JSX.Element; |
import React from 'react'; | ||
import { requireNativeComponent, StyleSheet } from 'react-native'; | ||
export default function NativeSplitPlaceholder(props) { | ||
const { component: Component, navigation } = props; | ||
const { component: Component } = props; | ||
return (<RNNativeSplitPlaceholder style={StyleSheet.absoluteFill}> | ||
<Component navigation={navigation}/> | ||
<Component /> | ||
</RNNativeSplitPlaceholder>); | ||
@@ -8,0 +8,0 @@ } |
@@ -1,11 +0,6 @@ | ||
import { ReactElement, ComponentType } from 'react'; | ||
import { NavigationInjectedProps } from 'react-navigation'; | ||
import { ReactElement } from 'react'; | ||
import NativeStackScenes, { NativeScenesProps } from './NativeScenes'; | ||
import { NativeNavigatorModes, NativeNavigatorSplitRules } from './types'; | ||
export interface NativeStackNavigatorProps extends NavigationInjectedProps { | ||
mode: NativeNavigatorModes; | ||
splitRules?: NativeNavigatorSplitRules; | ||
splitPlaceholder?: ComponentType<NavigationInjectedProps>; | ||
export interface NativeStackNavigatorProps { | ||
children: ReactElement<NativeScenesProps, typeof NativeStackScenes>; | ||
} | ||
export default function NativeStackNavigator(props: NativeStackNavigatorProps): JSX.Element; |
@@ -1,5 +0,3 @@ | ||
import React, { useState } from 'react'; | ||
import React from 'react'; | ||
import { StyleSheet, requireNativeComponent } from 'react-native'; | ||
import NativeSplitPlaceholder from './NativeSplitPlaceholder'; | ||
import { NativeNavigatorModes } from './types'; | ||
const styles = StyleSheet.create({ | ||
@@ -12,27 +10,7 @@ navigator: { | ||
export default function NativeStackNavigator(props) { | ||
const [mode] = useState(props.mode); | ||
if (mode !== props.mode) { | ||
throw new Error('NativeStackNavigator `mode` prop has been changed, the NativeStackNavigator mode should be constant。'); | ||
} | ||
let Navigator; | ||
switch (mode) { | ||
case NativeNavigatorModes.Card: | ||
Navigator = RNNativeCardNavigator; | ||
break; | ||
case NativeNavigatorModes.Split: | ||
Navigator = RNNativeSplitNavigator; | ||
break; | ||
default: | ||
Navigator = RNNativeStackNavigator; | ||
break; | ||
} | ||
const { splitPlaceholder, navigation } = props; | ||
return (<Navigator style={styles.navigator} splitRules={props.splitRules}> | ||
{splitPlaceholder ? (<NativeSplitPlaceholder navigation={navigation} component={splitPlaceholder}/>) : null} | ||
return (<RNNativeStackNavigator style={styles.navigator}> | ||
{props.children} | ||
</Navigator>); | ||
</RNNativeStackNavigator>); | ||
} | ||
const RNNativeStackNavigator = requireNativeComponent('RNNativeStackNavigator'); | ||
const RNNativeSplitNavigator = requireNativeComponent('RNNativeSplitNavigator'); | ||
const RNNativeCardNavigator = requireNativeComponent('RNNativeCardNavigator'); | ||
//# sourceMappingURL=NativeStackNavigator.js.map |
@@ -11,3 +11,3 @@ import { PureComponent } from 'react'; | ||
gestureEnabled: boolean; | ||
splitFullScreen: boolean; | ||
isSplitPrimary: boolean; | ||
onDidFocus: (route: NavigationRoute) => void; | ||
@@ -14,0 +14,0 @@ onDidBlur: (route: NavigationRoute, dismissed: boolean) => void; |
@@ -22,4 +22,4 @@ import React, { PureComponent } from 'react'; | ||
render() { | ||
const { closing, translucent, transparent, transition, gestureEnabled, style, statusBarStyle, statusBarHidden, splitFullScreen } = this.props; | ||
return (<RNNativeStackScene closing={closing} translucent={translucent} transparent={transparent} transition={transition} gestureEnabled={gestureEnabled} splitFullScreen={splitFullScreen} onDidFocus={this.onDidFocus} onDidBlur={this.onDidBlur} style={style ? [style, StyleSheet.absoluteFill] : StyleSheet.absoluteFill} statusBarStyle={statusBarStyle} statusBarHidden={statusBarHidden}> | ||
const { closing, translucent, transparent, transition, gestureEnabled, style, statusBarStyle, statusBarHidden, isSplitPrimary } = this.props; | ||
return (<RNNativeStackScene closing={closing} translucent={translucent} transparent={transparent} transition={transition} gestureEnabled={gestureEnabled} isSplitPrimary={isSplitPrimary} onDidFocus={this.onDidFocus} onDidBlur={this.onDidBlur} style={style ? [style, StyleSheet.absoluteFill] : StyleSheet.absoluteFill} statusBarStyle={statusBarStyle} statusBarHidden={statusBarHidden}> | ||
{this.props.children} | ||
@@ -26,0 +26,0 @@ </RNNativeStackScene>); |
@@ -1,2 +0,3 @@ | ||
import { NavigationRouter, NavigationRouteConfigMap, NavigationTabRouterConfig } from 'react-navigation'; | ||
export default function SplitRouter(routeConfigs: NavigationRouteConfigMap<any, any>, config?: NavigationTabRouterConfig): NavigationRouter; | ||
import { NavigationRouter, NavigationRouteConfigMap, NavigationTabRouterConfig, NavigationState } from 'react-navigation'; | ||
import { NativeNavigationRouterConfig } from './types'; | ||
export default function SplitRouter(routeConfigs: NavigationRouteConfigMap<any, any>, config?: NavigationTabRouterConfig): NavigationRouter<NavigationState, NativeNavigationRouterConfig>; |
@@ -11,3 +11,3 @@ import { StackRouter, NavigationActions } from 'react-navigation'; | ||
// 如果在 SplitRouter 中对 primary route 的子路由做 NAVIGATE 导航会导致右侧路由退出,交互不符合预期 | ||
if (newState.index === 0 && state.index > 0) { | ||
if ((newState === null || newState === void 0 ? void 0 : newState.index) === 0 && state.index > 0) { | ||
return Object.assign(Object.assign({}, newState), { index: state.index, routes: [...newState.routes, ...state.routes.slice(1)] }); | ||
@@ -23,3 +23,3 @@ } | ||
// 如果 SplitRouter 中对 primary route 的子路由做 BACK 导航会导致右侧路由退出,交互不符合预期 | ||
if (newState.index === 0 && newState.routes.length > 1) { | ||
if ((newState === null || newState === void 0 ? void 0 : newState.index) === 0 && newState.routes.length > 1) { | ||
return Object.assign(Object.assign({}, newState), { index: newState.routes.length - 1 }); | ||
@@ -26,0 +26,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { ReactNode, ComponentType } from 'react'; | ||
import { ReactNode, ElementType } from 'react'; | ||
import { StyleProp, ViewStyle, TextStyle } from 'react-native'; | ||
@@ -9,3 +9,2 @@ import { NavigationParams, NavigationDescriptor, NavigationInjectedProps, NavigationScreenConfig } from 'react-navigation'; | ||
cardStyle?: StyleProp<ViewStyle>; | ||
splitFullScreen?: boolean; | ||
gestureEnabled?: boolean; | ||
@@ -27,10 +26,21 @@ headerLeft?: ReactNode; | ||
}>; | ||
export interface NavigationNativeRouterConfig { | ||
export declare type NativeNavigationRouterConfig = { | ||
mode: NativeNavigatorModes.Card | NativeNavigatorModes.Stack; | ||
headerMode?: NativeNavigatorHeaderModes; | ||
splitRules?: NativeNavigatorSplitRules; | ||
splitPlaceholder?: ComponentType<NavigationInjectedProps>; | ||
mode?: NativeNavigatorModes; | ||
initialRouteName?: string; | ||
defaultNavigationOptions?: NavigationScreenConfig<NativeNavigationOptions, any>; | ||
defaultScreenOptions?: NavigationScreenConfig<NativeNavigationOptions, any>; | ||
} | NativeSplitNavigationRouterConfig; | ||
export interface NativeSplitNavigationRouterConfig { | ||
mode: NativeNavigatorModes.Split; | ||
headerMode?: NativeNavigatorHeaderModes; | ||
initialRouteName?: string; | ||
defaultScreenOptions?: NavigationScreenConfig<NativeNavigationOptions, any>; | ||
defaultNavigatorOptions?: NativeNavigationSplitOptions; | ||
} | ||
export interface NativeNavigationSplitOptions { | ||
isSplitFullScreen?: boolean; | ||
splitRules?: NativeNavigatorSplitRules; | ||
splitPrimaryRouteNames?: string[]; | ||
splitPlaceholder?: ElementType<{}>; | ||
} | ||
export declare enum NativeNavigationStatusBarStyle { | ||
@@ -63,3 +73,3 @@ Default = "default", | ||
export interface NativeNavigatorsProps extends NavigationInjectedProps { | ||
navigationConfig: NavigationNativeRouterConfig; | ||
navigationConfig: NativeNavigationRouterConfig; | ||
screenProps?: any; | ||
@@ -73,17 +83,1 @@ descriptors: NativeNavigationDescriptorMap; | ||
} | ||
export interface NativeNavigatorSize { | ||
width: number; | ||
height: number; | ||
} | ||
export interface NativeNavigatorRect { | ||
x: number; | ||
y: number; | ||
width: number; | ||
height: number; | ||
} | ||
export declare enum NativeNavigatorDirection { | ||
Up = "up", | ||
Down = "down", | ||
Left = "left", | ||
Right = "right" | ||
} |
@@ -33,9 +33,2 @@ export var NativeNavigationStatusBarStyle; | ||
})(NativeNavigationHeaderTypes || (NativeNavigationHeaderTypes = {})); | ||
export var NativeNavigatorDirection; | ||
(function (NativeNavigatorDirection) { | ||
NativeNavigatorDirection["Up"] = "up"; | ||
NativeNavigatorDirection["Down"] = "down"; | ||
NativeNavigatorDirection["Left"] = "left"; | ||
NativeNavigatorDirection["Right"] = "right"; | ||
})(NativeNavigatorDirection || (NativeNavigatorDirection = {})); | ||
//# sourceMappingURL=types.js.map |
{ | ||
"version": "0.3.0-16", | ||
"version": "0.3.0-17", | ||
"name": "react-native-navigators", | ||
@@ -4,0 +4,0 @@ "repository": { |
export * from './createNavigators'; | ||
export { default as SplitRouter } from './SplitRouter'; | ||
export { NativeNavigationClosingStateContext } from './NativeScene'; | ||
export { NativeSplitNavigatorOptionsContext } from './NativeSplitNavigatorOptionsWrapper'; | ||
export * from './splitNavigatorRules'; | ||
export * from './types'; |
@@ -11,6 +11,8 @@ import { | ||
import { NativeNavigationRouterConfig } from './types'; | ||
export default function SplitRouter( | ||
routeConfigs: NavigationRouteConfigMap<any, any>, | ||
config?: NavigationTabRouterConfig | ||
): NavigationRouter { | ||
): NavigationRouter<NavigationState, NativeNavigationRouterConfig> { | ||
const stackRouter = StackRouter(routeConfigs, config); | ||
@@ -25,6 +27,10 @@ const { getStateForAction } = stackRouter; | ||
if (action.type === NavigationActions.NAVIGATE) { | ||
const newState: NavigationState = getStateForAction(action, state); | ||
const newState: NavigationState | null = getStateForAction( | ||
action, | ||
state | ||
); | ||
// StackRouter 对非 active 的子路由进行 NAVIGATE 操作时会主动将该子路由切换成 active | ||
// 如果在 SplitRouter 中对 primary route 的子路由做 NAVIGATE 导航会导致右侧路由退出,交互不符合预期 | ||
if (newState.index === 0 && state.index > 0) { | ||
if (newState?.index === 0 && state.index > 0) { | ||
return { | ||
@@ -39,6 +45,10 @@ ...newState, | ||
} else if (action.type === NavigationActions.BACK && action.key) { | ||
const newState: NavigationState = getStateForAction(action, state); | ||
const newState: NavigationState | null = getStateForAction( | ||
action, | ||
state | ||
); | ||
// StackRouter 通过指定 key 的 action 对非 active 的子路由进行 BACK 导航时会将 active index 切换到该子路由 | ||
// 如果 SplitRouter 中对 primary route 的子路由做 BACK 导航会导致右侧路由退出,交互不符合预期 | ||
if (newState.index === 0 && newState.routes.length > 1) { | ||
if (newState?.index === 0 && newState.routes.length > 1) { | ||
return { | ||
@@ -45,0 +55,0 @@ ...newState, |
@@ -1,2 +0,2 @@ | ||
import { ReactNode, ComponentType } from 'react'; | ||
import { ReactNode, ElementType } from 'react'; | ||
import { StyleProp, ViewStyle, TextStyle } from 'react-native'; | ||
@@ -15,3 +15,2 @@ import { | ||
cardStyle?: StyleProp<ViewStyle>; | ||
splitFullScreen?: boolean; // Options for secondary scene in split navigator | ||
gestureEnabled?: boolean; | ||
@@ -38,14 +37,29 @@ headerLeft?: ReactNode; | ||
export interface NavigationNativeRouterConfig { | ||
export type NativeNavigationRouterConfig = | ||
| { | ||
mode: NativeNavigatorModes.Card | NativeNavigatorModes.Stack; | ||
headerMode?: NativeNavigatorHeaderModes; | ||
initialRouteName?: string; | ||
defaultScreenOptions?: NavigationScreenConfig< | ||
NativeNavigationOptions, | ||
any | ||
>; | ||
} | ||
| NativeSplitNavigationRouterConfig; | ||
export interface NativeSplitNavigationRouterConfig { | ||
mode: NativeNavigatorModes.Split; | ||
headerMode?: NativeNavigatorHeaderModes; | ||
splitRules?: NativeNavigatorSplitRules; | ||
splitPlaceholder?: ComponentType<NavigationInjectedProps>; | ||
mode?: NativeNavigatorModes; | ||
initialRouteName?: string; | ||
defaultNavigationOptions?: NavigationScreenConfig< | ||
NativeNavigationOptions, | ||
any | ||
>; | ||
defaultScreenOptions?: NavigationScreenConfig<NativeNavigationOptions, any>; | ||
defaultNavigatorOptions?: NativeNavigationSplitOptions; | ||
} | ||
export interface NativeNavigationSplitOptions { | ||
isSplitFullScreen?: boolean; | ||
splitRules?: NativeNavigatorSplitRules; | ||
splitPrimaryRouteNames?: string[]; | ||
splitPlaceholder?: ElementType<{}>; | ||
} | ||
export enum NativeNavigationStatusBarStyle { | ||
@@ -87,3 +101,3 @@ Default = 'default', | ||
export interface NativeNavigatorsProps extends NavigationInjectedProps { | ||
navigationConfig: NavigationNativeRouterConfig; | ||
navigationConfig: NativeNavigationRouterConfig; | ||
screenProps?: any; | ||
@@ -98,20 +112,1 @@ descriptors: NativeNavigationDescriptorMap; | ||
} | ||
export interface NativeNavigatorSize { | ||
width: number; | ||
height: number; | ||
} | ||
export interface NativeNavigatorRect { | ||
x: number; | ||
y: number; | ||
width: number; | ||
height: number; | ||
} | ||
export enum NativeNavigatorDirection { | ||
Up = 'up', | ||
Down = 'down', | ||
Left = 'left', | ||
Right = 'right' | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
371701
228
3730