Merge pull request #20928 from newyankeecodeshop/remove-nav

[react-native]: Remove `Navigator` and `NavigationExperimental`
This commit is contained in:
Eloy Durán
2017-10-23 21:26:32 +02:00
committed by GitHub
2 changed files with 9 additions and 653 deletions
+9 -1
View File
@@ -9,7 +9,7 @@ import {
Animated,
StyleProp,
ViewStyle,
NavigationTransitionSpec,
EasingFunction
} from 'react-native'
export type Key = { key: string }
@@ -53,6 +53,14 @@ export type TransitionProps = {
progress: number
}
export type NavigationTransitionSpec = {
duration?: number,
// An easing function from `Easing`.
easing?: EasingFunction,
// A timing function such as `Animated.timing`.
timing?: (value: Animated.Value, config: any) => any,
}
export type TransitionConfigurator = (
currentTransitionProps: TransitionProps,
nextTransitionProps: TransitionProps
-652
View File
@@ -4724,77 +4724,6 @@ export interface TouchableNativeFeedbackStatic extends TouchableMixin, React.Cla
Ripple( color: string, borderless?: boolean ): RippleBackgroundPropType
}
export interface LeftToRightGesture {
// If the gesture can end and restart during one continuous touch
isDetachable: boolean;
// How far the swipe must drag to start transitioning
gestureDetectMovement: number;
// Amplitude of release velocity that is considered still
notMoving: number;
// Fraction of directional move required.
directionRatio: number;
// Velocity to transition with when the gesture release was "not moving"
snapVelocity: number;
// Region that can trigger swipe. iOS default is 30px from the left edge
edgeHitWidth: number;
// Ratio of gesture completion when non-velocity release will cause action
stillCompletionRatio: number;
fullDistance: any;
direction: string;
}
export interface JumpGesture extends LeftToRightGesture {
overswipe: {
frictionConstant: number
frictionByDistance: number
}
}
// see /NavigatorSceneConfigs.js
export interface SceneConfig {
// A list of all gestures that are enabled on this scene
gestures?: {
pop?: LeftToRightGesture,
},
// Rebound spring parameters when transitioning FROM this scene
springFriction: number;
springTension: number;
// Velocity to start at when transitioning without gesture
defaultTransitionVelocity: number;
// Animation interpolators for horizontal transitioning:
animationInterpolators: {
into: () => boolean,
out: () => boolean
};
}
export interface JumpSceneConfig extends SceneConfig {
gestures: {
pop?: LeftToRightGesture
jumpBack: JumpGesture
jumpForward: JumpGesture
}
}
// see /NavigatorSceneConfigs.js
export interface SceneConfigs {
PushFromRight: SceneConfig;
PushFromLeft: SceneConfig;
FloatFromRight: SceneConfig;
FloatFromLeft: SceneConfig;
FloatFromBottom: SceneConfig;
FloatFromBottomAndroid: SceneConfig;
FadeAndroid: SceneConfig;
HorizontalSwipeJump: SceneConfig;
HorizontalSwipeJumpFromRight: SceneConfig;
VerticalUpSwipeJump: SceneConfig;
VerticalDownSwipeJump: SceneConfig;
}
export interface Route {
component?: React.ComponentType<any>
id?: string
@@ -4811,83 +4740,9 @@ export interface Route {
index?: number
onRightButtonPress?: () => void
rightButtonTitle?: string
sceneConfig?: SceneConfig
wrapperStyle?: any
}
/**
* @see https://facebook.github.io/react-native/docs/navigator.html#content
*/
export interface NavigatorProperties {
/**
* Optional function that allows configuration about scene animations and gestures.
* Will be invoked with `route` and `routeStack` parameters, where `route`
* corresponds to the current scene being rendered by the `Navigator` and
* `routeStack` is the set of currently mounted routes that the navigator
* could transition to. The function should return a scene configuration object.
*/
configureScene?: (route: Route, routeStack: Route[]) => SceneConfig
/**
* Specify a route to start on.
* A route is an object that the navigator will use to identify each scene to render.
* initialRoute must be a route in the initialRouteStack if both props are provided.
* The initialRoute will default to the last item in the initialRouteStack.
*/
initialRoute?: Route
/**
* Provide a set of routes to initially mount.
* Required if no initialRoute is provided.
* Otherwise, it will default to an array containing only the initialRoute
*/
initialRouteStack?: Route[]
/**
* Optionally provide a navigation bar that persists across scene transitions
*/
navigationBar?: React.ReactElement<NavigatorStatic.NavigationBarProperties>
/**
* Optionally provide the navigator object from a parent Navigator
*/
navigator?: Navigator
/**
* @deprecated Use navigationContext.addListener('willfocus', callback) instead.
*/
onDidFocus?: () => any
/**
* @deprecated Use navigationContext.addListener('willfocus', callback) instead.
*/
onWillFocus?: () => any
/**
* Required function which renders the scene for a given route.
* Will be invoked with the route and the navigator object
*/
renderScene: ( route: Route, navigator: Navigator ) => React.ReactElement<ViewProperties>
/**
* Styles to apply to the container of each scene
*/
sceneStyle?: StyleProp<ViewStyle>
}
/**
* Class that contains the info and methods for app navigation.
*/
export interface NavigationContext {
parent: NavigationContext;
top: NavigationContext;
currentRoute: any;
appendChild(childContext: NavigationContext): void;
addListener(eventType: string, listener: () => void, useCapture?: boolean): NativeEventSubscription;
emit(eventType: string, data: any, didEmitCallback?: () => void): void;
dispose(): void;
}
interface InteractionMixin {
createInteractionHandle(): number
clearInteractionHandle(clearHandle: number): void
@@ -4915,210 +4770,6 @@ interface SubscribableMixin {
addListenerOn( eventEmitter: any, eventType: string, listener: () => any, context: any ): void
}
/**
* Use Navigator to transition between different scenes in your app.
* To accomplish this, provide route objects to the navigator to identify each scene,
* and also a renderScene function that the navigator can use to render the scene for a given route.
*
* To change the animation or gesture properties of the scene, provide a configureScene prop to get the config object for a given route.
* See Navigator.SceneConfigs for default animations and more info on scene config options.
* @see https://facebook.github.io/react-native/docs/navigator.html
*/
export interface NavigatorStatic extends TimerMixin, InteractionMixin, SubscribableMixin, React.ComponentClass<NavigatorProperties> {
SceneConfigs: SceneConfigs;
NavigationBar: NavigatorStatic.NavigationBarStatic;
BreadcrumbNavigationBar: NavigatorStatic.BreadcrumbNavigationBarStatic;
navigationContext: NavigationContext;
/**
* returns the current list of routes
*/
getCurrentRoutes(): Route[];
/**
* Jump backward without unmounting the current scen
*/
jumpBack(): void;
/**
* Jump forward to the next scene in the route stack
*/
jumpForward(): void;
/**
* Transition to an existing scene without unmounting
*/
jumpTo(route: Route): void;
/**
* Navigate forward to a new scene, squashing any scenes that you could jumpForward to
*/
push(route: Route): void;
/**
* Transition back and unmount the current scene
*/
pop(): void;
/**
* Go back N scenes at once. When N=1, behavior matches `pop()`.
* When N is invalid(negative or bigger than current routes count), do nothing.
* @param n The number of scenes to pop. Should be an integer.
*/
popN(n: number): void
/**
* Replace the current scene with a new route
*/
replace(route: Route): void;
/**
* Replace a scene as specified by an index
*/
replaceAtIndex(route: Route, index: number): void;
/**
* Replace the previous scene
*/
replacePrevious(route: Route): void;
/**
* Reset every scene with an array of routes
*/
immediatelyResetRouteStack(routes: Route[]): void;
/**
* Pop to a particular scene, as specified by its route. All scenes after it will be unmounted
*/
popToRoute(route: Route): void;
/**
* Pop to the first scene in the stack, unmounting every other scene
*/
popToTop(): void;
/**
* Replace the previous scene and pop to it.
*/
replacePreviousAndPop( route: Route ): void;
/**
* Navigate to a new scene and reset route stack.
*/
resetTo( route: Route ): void;
}
export namespace NavigatorStatic {
export interface NavState {
routeStack: Route[]
presentedIndex: number
}
// @see NavigationBarStyle.ios.js
export interface NavigationBarStyle {
General: {
NavBarHeight: number
StatusBarHeight: number
TotalNavHeight: number
},
Interpolators: {
// Animating *into* the center stage from the right
RightToCenter: () => boolean
// Animating out of the center stage, to the left
CenterToLeft: () => boolean
// Both stages (animating *past* the center stage)
RightToLeft: () => boolean
},
Stages: {
Left: {
Title: FlexStyle
LeftButton: FlexStyle
RightButton: FlexStyle
},
Center: {
Title: FlexStyle
LeftButton: FlexStyle
RightButton: FlexStyle
},
Right: {
Title: FlexStyle
LeftButton: FlexStyle
RightButton: FlexStyle
},
}
}
export interface NavigationBarRouteMapper {
Title: (route: Route, nav: Navigator, index: number, navState: NavState) => JSX.Element | null;
LeftButton: (route: Route, nav: Navigator, index: number, navState: NavState) => JSX.Element | null;
RightButton: (route: Route, nav: Navigator, index: number, navState: NavState) => JSX.Element | null;
}
/**
* @see NavigatorNavigationBar.js
*/
export interface NavigationBarProperties {
navigator?: Navigator
routeMapper?: NavigationBarRouteMapper
navState?: NavState
navigationStyles?: NavigationBarStyle
style?: StyleProp<ViewStyle>
}
export interface NavigationBarStatic extends React.ComponentClass<NavigationBarProperties> {
Styles: NavigationBarStyle
StylesAndroid: NavigationBarStyle;
StylesIOS: NavigationBarStyle;
/**
* Stop transtion, immediately resets the cached state and re-render the
* whole view.
*/
immediatelyRefresh(): void;
}
export type NavigationBar = NavigationBarStatic
export var NavigationBar: NavigationBarStatic
export interface BreadcrumbNavigationBarStyle {
//TODO &see NavigatorBreadcrumbNavigationBar.js
}
export interface BreadcrumbNavigationBarRouteMapper {
rightContentForRoute: (route: Route, navigator: Navigator) => React.ReactElement<any>
titleContentForRoute: (route: Route, navigator: Navigator) => React.ReactElement<any>
iconForRoute: (route: Route, navigator: Navigator) => React.ReactElement<any>
//in samples...
separatorForRoute: (route: Route, navigator: Navigator) => React.ReactElement<any>
}
/**
* @see NavigatorNavigationBar.js
*/
export interface BreadcrumbNavigationBarProperties {
navigator?: Navigator
routeMapper?: BreadcrumbNavigationBarRouteMapper
navState?: NavState
style?: StyleProp<ViewStyle>
}
export interface BreadcrumbNavigationBarStatic extends React.ComponentClass<BreadcrumbNavigationBarProperties> {
Styles: BreadcrumbNavigationBarStyle
immediatelyRefresh(): void
}
export type BreadcrumbNavigationBar = BreadcrumbNavigationBarStatic
var BreadcrumbNavigationBar: BreadcrumbNavigationBarStatic
}
// @see https://github.com/facebook/react-native/blob/0.34-stable\Libraries\StyleSheet\StyleSheetTypes.js
export namespace StyleSheet {
type NamedStyles<T> = {
@@ -8457,303 +8108,6 @@ export interface ImageStoreStatic {
): void
}
export interface TabsReducerStatic {
JumpToAction(index: number): any;
}
export type TabsReducerFunction = (params: any) => any;
export interface NavigationTab {
key: string;
}
export interface NavigationAction {
type: string;
}
export interface NavigationRoute {
key: string;
title?: string;
}
export interface NavigationState extends NavigationRoute {
index: number;
routes: NavigationRoute[];
}
export type NavigationRenderer = (
route: NavigationState,
onNavigate: (action: NavigationAction) => boolean
) => JSX.Element;
interface SubViewProps extends NavigationSceneRendererProps {
onNavigateBack?(): void;
}
type SubViewRenderer = (subViewProps: SubViewProps) => JSX.Element | null;
export interface NavigationHeaderProps extends NavigationSceneRendererProps {
onNavigateBack?(): void,
renderLeftComponent?: SubViewRenderer,
renderRightComponent?: SubViewRenderer,
renderTitleComponent?: SubViewRenderer,
style?: StyleProp<ViewStyle>,
viewProps?: any,
statusBarHeight?: number | NavigationAnimatedValue
}
export interface NavigationHeaderStatic extends React.ComponentClass<NavigationHeaderProps> {
Title: NavigationHeaderTitleStatic
HEIGHT: number
}
export interface NavigationHeaderTitleProps {
children?: JSX.Element,
style?: StyleProp<ViewStyle>,
textStyle?: StyleProp<TextStyle>,
viewProps?: any
}
export interface NavigationHeaderTitleStatic extends React.ComponentClass<NavigationHeaderTitleProps> {
}
export interface NavigationCardStackProps {
/**
* Custom style applied to the card.
*/
cardStyle?: StyleProp<ViewStyle>
/**
* Custom style interpolator for the card.
*/
cardStyleInterpolator?: (props: NavigationSceneRendererProps) => StyleProp<ViewStyle>
/**
* Direction of the cards movement. Value could be `horizontal` or
* `vertical`. Default value is `horizontal`.
*/
direction?: 'horizontal' | 'vertical'
/**
* The distance from the edge of the card which gesture response can start
* for. Defaults value is `30`.
*/
gestureResponseDistance?: number
/**
* Enable gestures. Default value is true
*/
enableGestures?: boolean,
/**
* The controlled navigation state. Typically, the navigation state
* look like this:
*
* ```js
* const navigationState = {
* index: 0, // the index of the selected route.
* routes: [ // A list of routes.
* {key: 'page 1'}, // The 1st route.
* {key: 'page 2'}, // The second route.
* ],
* };
* ```
*/
navigationState: NavigationState,
/**
* Callback that is called when the "back" action is performed.
* This happens when the back button is pressed or the back gesture is
* performed.
*/
onNavigateBack?: () => any,
/**
* Function that renders the header.
*/
renderHeader?: NavigationSceneRenderer,
/**
* Function that renders the a scene for a route.
*/
renderScene: NavigationSceneRenderer,
/**
* Custom style applied to the cards stack.
*/
style?: StyleProp<ViewStyle>,
}
// Object Instances
export type NavigationAnimatedValue = Animated.Value;
// Value & Structs.
export type NavigationGestureDirection = 'horizontal' | 'vertical';
export type NavigationLayout = {
height: NavigationAnimatedValue,
initHeight: number,
initWidth: number,
isMeasured: boolean,
width: NavigationAnimatedValue,
};
export type NavigationScene = {
index: number,
isActive: boolean,
isStale: boolean,
key: string,
route: NavigationRoute,
};
// Similar to `NavigationTransitionProps`, except that the prop `scene`
// represents the scene for the renderer to render.
export interface NavigationSceneRendererProps {
layout: NavigationLayout,
navigationState: NavigationState,
position: NavigationAnimatedValue,
progress: NavigationAnimatedValue,
scenes: Array<NavigationScene>,
scene: NavigationScene,
gestureResponseDistance?: number,
}
export interface NavigationSceneRenderer extends React.StatelessComponent<NavigationSceneRendererProps> {
}
export interface NavigationPropTypes {
// helpers
extractSceneRendererProps(props: NavigationSceneRendererProps): NavigationSceneRendererProps
// Bundled propTypes.
SceneRendererProps: {
layout: string,
navigationState: string,
position: string,
progress: string,
scene: string,
scenes: NavigationScene[],
}
// propTypes
SceneRenderer: any, // TODO: fix this
action: NavigationAction,
navigationState: NavigationState,
navigationRoute: NavigationRoute,
panHandlers: GestureResponderHandlers,
}
export interface NavigationCardProps extends React.ComponentClass<NavigationSceneRendererProps> {
onComponentRef: (ref: any) => void,
onNavigateBack?: () => any,
panHandlers?: GestureResponderHandlers,
pointerEvents: string,
renderScene: NavigationSceneRenderer,
style?: StyleProp<ViewStyle>,
}
export interface NavigationCardStackStatic extends React.ComponentClass<NavigationCardStackProps> {
}
export interface NavigationCardStatic extends React.ComponentClass<NavigationCardProps> {
}
/**
* Utilities to perform atomic operation with navigate state and routes.
*
* ```javascript
* const state1 = {key: 'page 1'};
* const state2 = NavigationStateUtils.push(state1, {key: 'page 2'});
* ```
*/
export interface NavigationStateUtils {
get(state: NavigationState, key: string): NavigationRoute
indexOf(state: NavigationState, key: string): number
has(state: NavigationState, key: string): boolean
push(state: NavigationState, route: NavigationRoute): NavigationState
pop(state: NavigationState): NavigationState
jumpToIndex(state: NavigationState, index: number): NavigationState
jumpTo(state: NavigationState, key: string): NavigationState
back(state: NavigationState): NavigationState
forward(state: NavigationState): NavigationState
replaceAt(
state: NavigationState,
key: string,
route: NavigationRoute
): NavigationState
replaceAtIndex(
state: NavigationState,
index: number,
route: NavigationRoute
): NavigationState
reset(
state: NavigationState,
routes: Array<NavigationRoute>,
index?: number
): NavigationState
}
export type NavigationTransitionProps = {
// The layout of the transitioner of the scenes.
layout: NavigationLayout,
// The navigation state of the transitioner.
navigationState: NavigationState,
// The progressive index of the transitioner's navigation state.
position: NavigationAnimatedValue,
// The value that represents the progress of the transition when navigation
// state changes from one to another. Its numberic value will range from 0
// to 1.
// progress.__getAnimatedValue() < 1 : transtion is happening.
// progress.__getAnimatedValue() == 1 : transtion completes.
progress: NavigationAnimatedValue,
// All the scenes of the transitioner.
scenes: Array<NavigationScene>,
// The active scene, corresponding to the route at
// `navigationState.routes[navigationState.index]`.
scene: NavigationScene,
// The gesture distance for `horizontal` and `vertical` transitions
gestureResponseDistance?: number,
}
export type NavigationTransitionSpec = {
duration?: number,
// An easing function from `Easing`.
easing?: EasingFunction,
// A timing function such as `Animated.timing`.
timing?: (value: NavigationAnimatedValue, config: any) => any,
}
export interface NavigationTransitionerProps {
configureTransition?: (
a: NavigationTransitionProps,
b?: NavigationTransitionProps
) => NavigationTransitionSpec,
navigationState: NavigationState,
onTransitionEnd?: () => void,
onTransitionStart?: () => void,
render: (a: NavigationTransitionProps, b?: NavigationTransitionProps) => any,
style: any,
}
export interface NavigationTransitioner extends React.ComponentClass<NavigationTransitionerProps> {
}
export interface NavigationCard extends React.ComponentClass<NavigationCardProps> {
}
export interface NavigationExperimentalStatic {
// Core
StateUtils: NavigationStateUtils
// Views
Transitioner: NavigationTransitioner,
//AnimatedView: NavigationAnimatedViewStatic;
// CustomComponents:
Card: NavigationCard,
CardStack: NavigationCardStackStatic;
Header: NavigationHeaderStatic;
PropTypes: NavigationPropTypes,
}
//
// Interfacing with Native Modules
// https://facebook.github.io/react-native/docs/native-modules-ios.html
@@ -8898,9 +8252,6 @@ export type MaskedView = MaskedViewStatic
export var Modal: ModalStatic
export type Modal = ModalStatic
export var Navigator: NavigatorStatic
export type Navigator = NavigatorStatic
export var NavigatorIOS: NavigatorIOSStatic
export type NavigatorIOS = NavigatorIOSStatic
@@ -9106,9 +8457,6 @@ export type Vibration = VibrationStatic
export var Dimensions: Dimensions;
export var ShadowPropTypesIOS: ShadowPropTypesIOSStatic;
export type NavigationExperimental = NavigationExperimentalStatic;
export var NavigationExperimental: NavigationExperimentalStatic;
export type Easing = EasingStatic;
export var Easing: EasingStatic;