diff --git a/native/account/registration/registration-navigator.react.js b/native/account/registration/registration-navigator.react.js --- a/native/account/registration/registration-navigator.react.js +++ b/native/account/registration/registration-navigator.react.js @@ -1,10 +1,10 @@ // @flow -import { - createStackNavigator, - type StackNavigationProp, - type StackNavigationHelpers, -} from '@react-navigation/stack'; +import type { + StackNavigationProp, + StackNavigationHelpers, +} from '@react-navigation/core'; +import { createStackNavigator } from '@react-navigation/stack'; import * as React from 'react'; import AvatarSelection from './avatar-selection.react.js'; diff --git a/native/chat/chat-header.react.js b/native/chat/chat-header.react.js --- a/native/chat/chat-header.react.js +++ b/native/chat/chat-header.react.js @@ -1,6 +1,6 @@ // @flow -import type { StackHeaderProps } from '@react-navigation/stack'; +import type { StackHeaderProps } from '@react-navigation/core'; import * as React from 'react'; import Header from '../navigation/header.react.js'; diff --git a/native/chat/chat-router.js b/native/chat/chat-router.js --- a/native/chat/chat-router.js +++ b/native/chat/chat-router.js @@ -8,7 +8,7 @@ StackNavigationState, RouterConfigOptions, GenericNavigationAction, -} from '@react-navigation/native'; +} from '@react-navigation/core'; import { StackRouter, CommonActions } from '@react-navigation/native'; import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; diff --git a/native/chat/chat.react.js b/native/chat/chat.react.js --- a/native/chat/chat.react.js +++ b/native/chat/chat.react.js @@ -1,23 +1,23 @@ // @flow -import { - createMaterialTopTabNavigator, - type MaterialTopTabNavigationProp, -} from '@react-navigation/material-top-tabs'; +import type { + MaterialTopTabNavigationProp, + StackNavigationState, + StackOptions, + StackNavigationEventMap, + StackNavigatorProps, + ExtraStackNavigatorProps, + StackHeaderProps, + StackNavigationProp, + StackNavigationHelpers, + ParamListBase, +} from '@react-navigation/core'; +import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs'; import { createNavigatorFactory, useNavigationBuilder, - type StackNavigationState, - type StackOptions, - type StackNavigationEventMap, - type StackNavigatorProps, - type ExtraStackNavigatorProps, - type StackHeaderProps as CoreStackHeaderProps, - type StackNavigationProp, - type StackNavigationHelpers, - type ParamListBase, } from '@react-navigation/native'; -import { StackView, type StackHeaderProps } from '@react-navigation/stack'; +import { StackView } from '@react-navigation/stack'; import invariant from 'invariant'; import * as React from 'react'; import { Platform, View, useWindowDimensions } from 'react-native'; @@ -205,7 +205,7 @@ ExtraStackNavigatorProps, >(ChatNavigator); -const header = (props: CoreStackHeaderProps) => { +const header = (props: StackHeaderProps) => { // Flow has trouble reconciling identical types between different libdefs, // and flow-typed has no way for one libdef to depend on another const castProps: StackHeaderProps = (props: any); diff --git a/native/chat/message-list-header-title.react.js b/native/chat/message-list-header-title.react.js --- a/native/chat/message-list-header-title.react.js +++ b/native/chat/message-list-header-title.react.js @@ -1,9 +1,7 @@ // @flow -import { - HeaderTitle, - type HeaderTitleInputProps, -} from '@react-navigation/elements'; +import type { HeaderTitleInputProps } from '@react-navigation/core'; +import { HeaderTitle } from '@react-navigation/elements'; import * as React from 'react'; import { View } from 'react-native'; diff --git a/native/chat/multimedia-message-multimedia.react.js b/native/chat/multimedia-message-multimedia.react.js --- a/native/chat/multimedia-message-multimedia.react.js +++ b/native/chat/multimedia-message-multimedia.react.js @@ -1,6 +1,7 @@ // @flow -import { type LeafRoute, useRoute } from '@react-navigation/native'; +import type { LeafRoute } from '@react-navigation/core'; +import { useRoute } from '@react-navigation/native'; import invariant from 'invariant'; import * as React from 'react'; import { View, StyleSheet } from 'react-native'; diff --git a/native/chat/multimedia-message.react.js b/native/chat/multimedia-message.react.js --- a/native/chat/multimedia-message.react.js +++ b/native/chat/multimedia-message.react.js @@ -4,7 +4,7 @@ LeafRoute, NavigationProp, ParamListBase, -} from '@react-navigation/native'; +} from '@react-navigation/core'; import { useNavigation, useRoute } from '@react-navigation/native'; import * as React from 'react'; import { View } from 'react-native'; diff --git a/native/chat/thread-settings-header-title.react.js b/native/chat/thread-settings-header-title.react.js --- a/native/chat/thread-settings-header-title.react.js +++ b/native/chat/thread-settings-header-title.react.js @@ -1,9 +1,7 @@ // @flow -import { - HeaderTitle, - type HeaderTitleInputProps, -} from '@react-navigation/elements'; +import type { HeaderTitleInputProps } from '@react-navigation/core'; +import { HeaderTitle } from '@react-navigation/elements'; import * as React from 'react'; import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; diff --git a/native/community-creation/community-creation-navigator.react.js b/native/community-creation/community-creation-navigator.react.js --- a/native/community-creation/community-creation-navigator.react.js +++ b/native/community-creation/community-creation-navigator.react.js @@ -1,10 +1,10 @@ // @flow -import { - createStackNavigator, - type StackNavigationProp, - type StackNavigationHelpers, -} from '@react-navigation/stack'; +import type { + StackNavigationProp, + StackNavigationHelpers, +} from '@react-navigation/core'; +import { createStackNavigator } from '@react-navigation/stack'; import * as React from 'react'; import CommunityConfiguration from './community-configuration.react.js'; diff --git a/native/flow-typed/npm/@react-navigation/bottom-tabs_v6.x.x.js b/native/flow-typed/npm/@react-navigation/bottom-tabs_v6.x.x.js --- a/native/flow-typed/npm/@react-navigation/bottom-tabs_v6.x.x.js +++ b/native/flow-typed/npm/@react-navigation/bottom-tabs_v6.x.x.js @@ -3,2263 +3,16 @@ declare module '@react-navigation/bottom-tabs' { - //--------------------------------------------------------------------------- - // SECTION 1: IDENTICAL TYPE DEFINITIONS - // This section is identical across all React Navigation libdefs and contains - // shared definitions. We wish we could make it DRY and import from a shared - // definition, but that isn't yet possible. - //--------------------------------------------------------------------------- - - /** - * We start with some definitions that we have copy-pasted from React Native - * source files. - */ - - // This is a bastardization of the true StyleObj type located in - // react-native/Libraries/StyleSheet/StyleSheetTypes. We unfortunately can't - // import that here, and it's too lengthy (and consequently too brittle) to - // copy-paste here either. - declare type StyleObj = - | null - | void - | number - | false - | '' - | $ReadOnlyArray - | { [name: string]: any, ... }; - declare type ViewStyleProp = StyleObj; - declare type TextStyleProp = StyleObj; - declare type AnimatedViewStyleProp = StyleObj; - declare type AnimatedTextStyleProp = StyleObj; - - // Vaguely copied from - // react-native/Libraries/Animated/src/animations/Animation.js - declare type EndResult = { finished: boolean, ... }; - declare type EndCallback = (result: EndResult) => void; - declare interface Animation { - start( - fromValue: number, - onUpdate: (value: number) => void, - onEnd: ?EndCallback, - previousAnimation: ?Animation, - animatedValue: AnimatedValue, - ): void; - stop(): void; - } - declare type AnimationConfig = { - isInteraction?: boolean, - useNativeDriver: boolean, - onComplete?: ?EndCallback, - iterations?: number, - ... - }; - - // Vaguely copied from - // react-native/Libraries/Animated/src/nodes/AnimatedTracking.js - declare interface AnimatedTracking { - constructor( - value: AnimatedValue, - parent: any, - animationClass: any, - animationConfig: Object, - callback?: ?EndCallback, - ): void; - update(): void; - } - - // Vaguely copied from - // react-native/Libraries/Animated/src/nodes/AnimatedValue.js - declare type ValueListenerCallback = (state: { value: number, ... }) => void; - declare interface AnimatedValue { - constructor(value: number): void; - setValue(value: number): void; - setOffset(offset: number): void; - flattenOffset(): void; - extractOffset(): void; - addListener(callback: ValueListenerCallback): string; - removeListener(id: string): void; - removeAllListeners(): void; - stopAnimation(callback?: ?(value: number) => void): void; - resetAnimation(callback?: ?(value: number) => void): void; - interpolate(config: InterpolationConfigType): AnimatedInterpolation; - animate(animation: Animation, callback: ?EndCallback): void; - stopTracking(): void; - track(tracking: AnimatedTracking): void; - } - - // Copied from - // react-native/Libraries/Animated/src/animations/TimingAnimation.js - declare type TimingAnimationConfigSingle = AnimationConfig & { - toValue: number | AnimatedValue, - easing?: (value: number) => number, - duration?: number, - delay?: number, - ... - }; - - // Copied from - // react-native/Libraries/Animated/src/animations/SpringAnimation.js - declare type SpringAnimationConfigSingle = AnimationConfig & { - toValue: number | AnimatedValue, - overshootClamping?: boolean, - restDisplacementThreshold?: number, - restSpeedThreshold?: number, - velocity?: number, - bounciness?: number, - speed?: number, - tension?: number, - friction?: number, - stiffness?: number, - damping?: number, - mass?: number, - delay?: number, - ... - }; - - // Copied from react-native/Libraries/Types/CoreEventTypes.js - declare type SyntheticEvent = $ReadOnly<{| - bubbles: ?boolean, - cancelable: ?boolean, - currentTarget: number, - defaultPrevented: ?boolean, - dispatchConfig: $ReadOnly<{| - registrationName: string, - |}>, - eventPhase: ?number, - preventDefault: () => void, - isDefaultPrevented: () => boolean, - stopPropagation: () => void, - isPropagationStopped: () => boolean, - isTrusted: ?boolean, - nativeEvent: T, - persist: () => void, - target: ?number, - timeStamp: number, - type: ?string, - |}>; - declare type Layout = $ReadOnly<{| - x: number, - y: number, - width: number, - height: number, - |}>; - declare type LayoutEvent = SyntheticEvent< - $ReadOnly<{| - layout: Layout, - |}>, - >; - declare type BlurEvent = SyntheticEvent< - $ReadOnly<{| - target: number, - |}>, - >; - declare type FocusEvent = SyntheticEvent< - $ReadOnly<{| - target: number, - |}>, - >; - declare type ResponderSyntheticEvent = $ReadOnly<{| - ...SyntheticEvent, - touchHistory: $ReadOnly<{| - indexOfSingleActiveTouch: number, - mostRecentTimeStamp: number, - numberActiveTouches: number, - touchBank: $ReadOnlyArray< - $ReadOnly<{| - touchActive: boolean, - startPageX: number, - startPageY: number, - startTimeStamp: number, - currentPageX: number, - currentPageY: number, - currentTimeStamp: number, - previousPageX: number, - previousPageY: number, - previousTimeStamp: number, - |}>, - >, - |}>, - |}>; - declare type PressEvent = ResponderSyntheticEvent< - $ReadOnly<{| - changedTouches: $ReadOnlyArray<$PropertyType>, - force: number, - identifier: number, - locationX: number, - locationY: number, - pageX: number, - pageY: number, - target: ?number, - timestamp: number, - touches: $ReadOnlyArray<$PropertyType>, - |}>, - >; - - // Vaguely copied from - // react-native/Libraries/Animated/src/nodes/AnimatedInterpolation.js - declare type ExtrapolateType = 'extend' | 'identity' | 'clamp'; - declare type InterpolationConfigType = { - inputRange: Array, - outputRange: Array | Array, - easing?: (input: number) => number, - extrapolate?: ExtrapolateType, - extrapolateLeft?: ExtrapolateType, - extrapolateRight?: ExtrapolateType, - ... - }; - declare interface AnimatedInterpolation { - interpolate(config: InterpolationConfigType): AnimatedInterpolation; - } - - // Copied from react-native/Libraries/Components/View/ViewAccessibility.js - declare type AccessibilityRole = - | 'none' - | 'button' - | 'link' - | 'search' - | 'image' - | 'keyboardkey' - | 'text' - | 'adjustable' - | 'imagebutton' - | 'header' - | 'summary' - | 'alert' - | 'checkbox' - | 'combobox' - | 'menu' - | 'menubar' - | 'menuitem' - | 'progressbar' - | 'radio' - | 'radiogroup' - | 'scrollbar' - | 'spinbutton' - | 'switch' - | 'tab' - | 'tablist' - | 'timer' - | 'toolbar'; - declare type AccessibilityActionInfo = $ReadOnly<{ - name: string, - label?: string, - ... - }>; - declare type AccessibilityActionEvent = SyntheticEvent< - $ReadOnly<{actionName: string, ...}>, - >; - declare type AccessibilityState = { - disabled?: boolean, - selected?: boolean, - checked?: ?boolean | 'mixed', - busy?: boolean, - expanded?: boolean, - ... - }; - declare type AccessibilityValue = $ReadOnly<{| - min?: number, - max?: number, - now?: number, - text?: string, - |}>; - - // Copied from - // react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js - declare type Stringish = string; - declare type EdgeInsetsProp = $ReadOnly<$Partial>; - declare type TouchableWithoutFeedbackProps = $ReadOnly<{| - accessibilityActions?: ?$ReadOnlyArray, - accessibilityElementsHidden?: ?boolean, - accessibilityHint?: ?Stringish, - accessibilityIgnoresInvertColors?: ?boolean, - accessibilityLabel?: ?Stringish, - accessibilityLiveRegion?: ?('none' | 'polite' | 'assertive'), - accessibilityRole?: ?AccessibilityRole, - accessibilityState?: ?AccessibilityState, - accessibilityValue?: ?AccessibilityValue, - accessibilityViewIsModal?: ?boolean, - accessible?: ?boolean, - children?: ?React$Node, - delayLongPress?: ?number, - delayPressIn?: ?number, - delayPressOut?: ?number, - disabled?: ?boolean, - focusable?: ?boolean, - hitSlop?: ?EdgeInsetsProp, - importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'), - nativeID?: ?string, - onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed, - onBlur?: ?(event: BlurEvent) => mixed, - onFocus?: ?(event: FocusEvent) => mixed, - onLayout?: ?(event: LayoutEvent) => mixed, - onLongPress?: ?(event: PressEvent) => mixed, - onPress?: ?(event: PressEvent) => mixed, - onPressIn?: ?(event: PressEvent) => mixed, - onPressOut?: ?(event: PressEvent) => mixed, - pressRetentionOffset?: ?EdgeInsetsProp, - rejectResponderTermination?: ?boolean, - testID?: ?string, - touchSoundDisabled?: ?boolean, - |}>; - - // Copied from react-native/Libraries/Image/ImageSource.js - declare type ImageURISource = $ReadOnly<{ - uri?: ?string, - bundle?: ?string, - method?: ?string, - headers?: ?Object, - body?: ?string, - cache?: ?('default' | 'reload' | 'force-cache' | 'only-if-cached'), - width?: ?number, - height?: ?number, - scale?: ?number, - ... - }>; - - /** - * The following is copied from react-native-gesture-handler's libdef - */ - - declare type StateUndetermined = 0; - declare type StateFailed = 1; - declare type StateBegan = 2; - declare type StateCancelled = 3; - declare type StateActive = 4; - declare type StateEnd = 5; - - declare type GestureHandlerState = - | StateUndetermined - | StateFailed - | StateBegan - | StateCancelled - | StateActive - | StateEnd; - - declare type $SyntheticEvent = { - +nativeEvent: $ReadOnly<$Exact>, - ... - }; - - declare type $Event = $SyntheticEvent<{ - handlerTag: number, - numberOfPointers: number, - state: GestureHandlerState, - oldState: GestureHandlerState, - ...$Exact, - ... - }>; - - declare type $EventHandlers = {| - onGestureEvent?: ($Event) => mixed, - onHandlerStateChange?: ($Event) => mixed, - onBegan?: ($Event) => mixed, - onFailed?: ($Event) => mixed, - onCancelled?: ($Event) => mixed, - onActivated?: ($Event) => mixed, - onEnded?: ($Event) => mixed, - |}; - - declare type HitSlop = - | number - | {| - left?: number, - top?: number, - right?: number, - bottom?: number, - vertical?: number, - horizontal?: number, - width?: number, - height?: number, - |} - | {| - width: number, - left: number, - |} - | {| - width: number, - right: number, - |} - | {| - height: number, - top: number, - |} - | {| - height: number, - bottom: number, - |}; - - declare type $GestureHandlerProps< - AdditionalProps: {...}, - ExtraEventsProps: {...} - > = $ReadOnly<{| - ...$Exact, - ...$EventHandlers, - id?: string, - enabled?: boolean, - waitFor?: React$Ref | Array>, - simultaneousHandlers?: React$Ref | Array>, - shouldCancelWhenOutside?: boolean, - minPointers?: number, - hitSlop?: HitSlop, - children?: React$Node, - |}>; - - declare type PanGestureHandlerProps = $GestureHandlerProps< - { - activeOffsetY?: number | [number, number], - activeOffsetX?: number | [number, number], - failOffsetY?: number | [number, number], - failOffsetX?: number | [number, number], - minDist?: number, - minVelocity?: number, - minVelocityX?: number, - minVelocityY?: number, - minPointers?: number, - maxPointers?: number, - avgTouches?: boolean, - ... - }, - { - x: number, - y: number, - absoluteX: number, - absoluteY: number, - translationX: number, - translationY: number, - velocityX: number, - velocityY: number, - ... - } - >; - - /** - * MAGIC - */ - - declare type $If = $Call< - ((true, Then, Else) => Then) & ((false, Then, Else) => Else), - Test, - Then, - Else, - >; - declare type $IsA = $Call< - (Y => true) & (mixed => false), - X, - >; - declare type $IsUndefined = $IsA; - - declare type $Partial = $ReadOnly<$Rest>; - - // If { ...T, ... } counts as a T, then we're inexact - declare type $IsExact = $Call< - (T => false) & (mixed => true), - { ...T, ... }, - >; - - /** - * Actions, state, etc. - */ - - declare export type ScreenParams = { +[key: string]: mixed, ... }; - - declare export type BackAction = {| - +type: 'GO_BACK', - +source?: string, - +target?: string, - |}; - declare export type NavigateAction = {| - +type: 'NAVIGATE', - +payload: - | {| +key: string, +params?: ScreenParams |} - | {| +name: string, +key?: string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type ResetAction = {| - +type: 'RESET', - +payload: StaleNavigationState, - +source?: string, - +target?: string, - |}; - declare export type SetParamsAction = {| - +type: 'SET_PARAMS', - +payload: {| +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type CommonAction = - | BackAction - | NavigateAction - | ResetAction - | SetParamsAction; - - declare type NavigateActionCreator = {| - (routeName: string, params?: ScreenParams): NavigateAction, - ( - | {| +key: string, +params?: ScreenParams |} - | {| +name: string, +key?: string, +params?: ScreenParams |}, - ): NavigateAction, - |}; - declare export type CommonActionsType = {| - +navigate: NavigateActionCreator, - +goBack: () => BackAction, - +reset: (state: PossiblyStaleNavigationState) => ResetAction, - +setParams: (params: ScreenParams) => SetParamsAction, - |}; - - declare export type GenericNavigationAction = {| - +type: string, - +payload?: { +[key: string]: mixed, ... }, - +source?: string, - +target?: string, - |}; - - declare export type LeafRoute = {| - +key: string, - +name: RouteName, - +params?: ScreenParams, - |}; - declare export type StateRoute = {| - ...LeafRoute, - +state: NavigationState | StaleNavigationState, - |}; - declare export type Route = - | LeafRoute - | StateRoute; - - declare export type NavigationState = {| - +key: string, - +index: number, - +routeNames: $ReadOnlyArray, - +history?: $ReadOnlyArray, - +routes: $ReadOnlyArray>, - +type: string, - +stale: false, - |}; - - declare export type StaleLeafRoute = {| - +key?: string, - +name: RouteName, - +params?: ScreenParams, - |}; - declare export type StaleStateRoute = {| - ...StaleLeafRoute, - +state: StaleNavigationState, - |}; - declare export type StaleRoute = - | StaleLeafRoute - | StaleStateRoute; - declare export type StaleNavigationState = {| - // It's possible to pass React Nav a StaleNavigationState with an undefined - // index, but React Nav will always return one with the index set. This is - // the same as for the type property below, but in the case of index we tend - // to rely on it being set more... - +index: number, - +history?: $ReadOnlyArray, - +routes: $ReadOnlyArray>, - +type?: string, - +stale?: true, - |}; - - declare export type PossiblyStaleNavigationState = - | NavigationState - | StaleNavigationState; - declare export type PossiblyStaleRoute = - | Route - | StaleRoute; - - /** - * Routers - */ - - declare type ActionCreators< - State: NavigationState, - Action: GenericNavigationAction, - > = { - +[key: string]: (...args: any) => (Action | State => Action), - ... - }; - - declare export type DefaultRouterOptions = { - +initialRouteName?: string, - ... - }; - - declare export type RouterFactory< - State: NavigationState, - Action: GenericNavigationAction, - RouterOptions: DefaultRouterOptions, - > = (options: RouterOptions) => Router; - - declare export type ParamListBase = { +[key: string]: ?ScreenParams, ... }; - - declare export type RouterConfigOptions = {| - +routeNames: $ReadOnlyArray, - +routeParamList: ParamListBase, - |}; - - declare export type Router< - State: NavigationState, - Action: GenericNavigationAction, - > = {| - +type: $PropertyType, - +getInitialState: (options: RouterConfigOptions) => State, - +getRehydratedState: ( - partialState: PossiblyStaleNavigationState, - options: RouterConfigOptions, - ) => State, - +getStateForRouteNamesChange: ( - state: State, - options: RouterConfigOptions, - ) => State, - +getStateForRouteFocus: (state: State, key: string) => State, - +getStateForAction: ( - state: State, - action: Action, - options: RouterConfigOptions, - ) => ?PossiblyStaleNavigationState; - +shouldActionChangeFocus: (action: GenericNavigationAction) => boolean, - +actionCreators?: ActionCreators, - |}; - - /** - * Stack actions and router - */ - - declare export type StackNavigationState = {| - ...NavigationState, - +type: 'stack', - |}; - - declare export type ReplaceAction = {| - +type: 'REPLACE', - +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type PushAction = {| - +type: 'PUSH', - +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type PopAction = {| - +type: 'POP', - +payload: {| +count: number |}, - +source?: string, - +target?: string, - |}; - declare export type PopToTopAction = {| - +type: 'POP_TO_TOP', - +source?: string, - +target?: string, - |}; - declare export type StackAction = - | CommonAction - | ReplaceAction - | PushAction - | PopAction - | PopToTopAction; - - declare export type StackActionsType = {| - +replace: (routeName: string, params?: ScreenParams) => ReplaceAction, - +push: (routeName: string, params?: ScreenParams) => PushAction, - +pop: (count?: number) => PopAction, - +popToTop: () => PopToTopAction, - |}; - - declare export type StackRouterOptions = $Exact; - - /** - * Tab actions and router - */ - - declare export type TabNavigationState = {| - ...NavigationState, - +type: 'tab', - +history: $ReadOnlyArray<{| type: 'route', key: string |}>, - |}; - - declare export type JumpToAction = {| - +type: 'JUMP_TO', - +payload: {| +name: string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type TabAction = - | CommonAction - | JumpToAction; - - declare export type TabActionsType = {| - +jumpTo: string => JumpToAction, - |}; - - declare export type TabRouterOptions = {| - ...$Exact, - +backBehavior?: 'initialRoute' | 'order' | 'history' | 'none', - |}; - - /** - * Drawer actions and router - */ - - declare type DrawerHistoryEntry = - | {| +type: 'route', +key: string |} - | {| +type: 'drawer' |}; - declare export type DrawerNavigationState = {| - ...NavigationState, - +type: 'drawer', - +history: $ReadOnlyArray, - |}; - - declare export type OpenDrawerAction = {| - +type: 'OPEN_DRAWER', - +source?: string, - +target?: string, - |}; - declare export type CloseDrawerAction = {| - +type: 'CLOSE_DRAWER', - +source?: string, - +target?: string, - |}; - declare export type ToggleDrawerAction = {| - +type: 'TOGGLE_DRAWER', - +source?: string, - +target?: string, - |}; - declare export type DrawerAction = - | TabAction - | OpenDrawerAction - | CloseDrawerAction - | ToggleDrawerAction; - - declare export type DrawerActionsType = {| - ...TabActionsType, - +openDrawer: () => OpenDrawerAction, - +closeDrawer: () => CloseDrawerAction, - +toggleDrawer: () => ToggleDrawerAction, - |}; - - declare export type DrawerRouterOptions = {| - ...TabRouterOptions, - +defaultStatus?: 'open' | 'closed', - |}; - - /** - * Events - */ - - declare export type EventMapBase = { - +[name: string]: {| - +data?: mixed, - +canPreventDefault?: boolean, - |}, - ... - }; - declare type EventPreventDefaultProperties = $If< - Test, - {| +defaultPrevented: boolean, +preventDefault: () => void |}, - {| |}, - >; - declare type EventDataProperties = $If< - $IsUndefined, - {| |}, - {| +data: Data |}, - >; - declare type EventArg< - EventName: string, - CanPreventDefault: ?boolean = false, - Data = void, - > = {| - ...EventPreventDefaultProperties, - ...EventDataProperties, - +type: EventName, - +target?: string, - |}; - declare type GlobalEventMap = {| - +state: {| +data: {| +state: State |}, +canPreventDefault: false |}, - |}; - declare type EventMapCore = {| - ...GlobalEventMap, - +focus: {| +data: void, +canPreventDefault: false |}, - +blur: {| +data: void, +canPreventDefault: false |}, - +beforeRemove: {| - +data: {| +action: GenericNavigationAction |}, - +canPreventDefault: true, - |}, - |}; - declare type EventListenerCallback< - EventName: string, - State: PossiblyStaleNavigationState = NavigationState, - EventMap: EventMapBase = EventMapCore, - > = (e: EventArg< - EventName, - $PropertyType< - $ElementType< - {| ...EventMap, ...EventMapCore |}, - EventName, - >, - 'canPreventDefault', - >, - $PropertyType< - $ElementType< - {| ...EventMap, ...EventMapCore |}, - EventName, - >, - 'data', - >, - >) => mixed; - - /** - * Navigation prop - */ - - declare type PartialWithMergeProperty = $If< - $IsExact, - { ...$Partial, +merge: true }, - { ...$Partial, +merge: true, ... }, - >; - - declare type EitherExactOrPartialWithMergeProperty = - | ParamsType - | PartialWithMergeProperty; - - declare export type SimpleNavigate = - >( - routeName: DestinationRouteName, - params: EitherExactOrPartialWithMergeProperty< - $ElementType, - >, - ) => void; - - declare export type Navigate = - & SimpleNavigate - & >( - route: $If< - $IsUndefined<$ElementType>, - | {| +key: string |} - | {| +name: DestinationRouteName, +key?: string |}, - | {| - +key: string, - +params?: EitherExactOrPartialWithMergeProperty< - $ElementType, - >, - |} - | {| - +name: DestinationRouteName, - +key?: string, - +params?: EitherExactOrPartialWithMergeProperty< - $ElementType, - >, - |}, - >, - ) => void; - - declare type CoreNavigationHelpers< - ParamList: ParamListBase, - State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, - EventMap: EventMapBase = EventMapCore, - > = { - +navigate: Navigate, - +dispatch: ( - action: - | GenericNavigationAction - | (State => GenericNavigationAction), - ) => void, - +reset: PossiblyStaleNavigationState => void, - +goBack: () => void, - +isFocused: () => boolean, - +canGoBack: () => boolean, - +getId: () => string | void, - +getParent: >(id?: string) => ?Parent, - +getState: () => NavigationState, - +addListener: |}, - >>( - name: EventName, - callback: EventListenerCallback, - ) => () => void, - +removeListener: |}, - >>( - name: EventName, - callback: EventListenerCallback, - ) => void, - ... - }; - - declare export type NavigationHelpers< - ParamList: ParamListBase, - State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, - EventMap: EventMapBase = EventMapCore, - > = { - ...$Exact>, - +setParams: (params: ScreenParams) => void, - ... - }; - - declare type SetParamsInput< - ParamList: ParamListBase, - RouteName: $Keys = $Keys, - > = $If< - $IsUndefined<$ElementType>, - empty, - $Partial<$NonMaybeType<$ElementType>>, - >; - - declare export type NavigationProp< - ParamList: ParamListBase, - RouteName: $Keys = $Keys, - State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = { - ...$Exact>, - +setOptions: (options: $Partial) => void, - +setParams: (params: SetParamsInput) => void, - ... - }; - - /** - * CreateNavigator - */ - - declare export type RouteProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - > = {| - ...LeafRoute, - +params: $ElementType, - +path?: string, - |}; - - declare type ScreenOptionsProp< - ScreenOptions: {...}, - RouteParam, - NavHelpers, - > = - | ScreenOptions - | ({| +route: RouteParam, +navigation: NavHelpers |}) => ScreenOptions; - declare export type ScreenListeners< - State: NavigationState = NavigationState, - EventMap: EventMapBase = EventMapCore, - > = $ObjMapi< - {| [name: $Keys]: empty |}, - >(K, empty) => EventListenerCallback, - >; - declare type ScreenListenersProp< - ScreenListenersParam: {...}, - RouteParam, - NavHelpers, - > = - | ScreenListenersParam - | ({| +route: RouteParam, +navigation: NavHelpers |}) => ScreenListenersParam; - - declare type BaseScreenProps< - ParamList: ParamListBase, - NavProp, - RouteName: $Keys = $Keys, - State: NavigationState = NavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = {| - +name: RouteName, - +options?: ScreenOptionsProp< - ScreenOptions, - RouteProp, - NavProp, - >, - +listeners?: ScreenListenersProp< - ScreenListeners, - RouteProp, - NavProp, - >, - +initialParams?: $Partial<$ElementType>, - +getId?: ({ - +params: $ElementType, - }) => string | void, - +navigationKey?: string, - |}; - - declare export type ScreenProps< - ParamList: ParamListBase, - NavProp, - RouteName: $Keys = $Keys, - State: NavigationState = NavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = - | {| - ...BaseScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >, - +component: React$ComponentType<{| - +route: RouteProp, - +navigation: NavProp, - |}>, - |} - | {| - ...BaseScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >, - +getComponent: () => React$ComponentType<{| - +route: RouteProp, - +navigation: NavProp, - |}>, - |} - | {| - ...BaseScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >, - +children: ({| - +route: RouteProp, - +navigation: NavProp, - |}) => React$Node, - |}; - - declare export type ScreenComponent< - GlobalParamList: ParamListBase, - ParamList: ParamListBase, - State: NavigationState = NavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = < - RouteName: $Keys, - NavProp: NavigationProp< - GlobalParamList, - RouteName, - State, - ScreenOptions, - EventMap, - >, - >(props: ScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >) => React$Node; - - declare type ScreenOptionsProps< - ScreenOptions: {...}, - RouteParam, - NavHelpers, - > = {| - +screenOptions?: ScreenOptionsProp, - |}; - declare type ScreenListenersProps< - ScreenListenersParam: {...}, - RouteParam, - NavHelpers, - > = {| - +screenListeners?: ScreenListenersProp< - ScreenListenersParam, - RouteParam, - NavHelpers, - >, - |}; - declare export type ExtraNavigatorPropsBase = { - ...$Exact, - +id?: string, - +children?: React$Node, - ... - }; - declare export type NavigatorProps< - ScreenOptions: {...}, - ScreenListenersParam, - RouteParam, - NavHelpers, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - > = { - ...$Exact, - ...ScreenOptionsProps, - ...ScreenListenersProps, - +defaultScreenOptions?: - | ScreenOptions - | ({| - +route: RouteParam, - +navigation: NavHelpers, - +options: ScreenOptions, - |}) => ScreenOptions, - ... - }; - declare export type NavigatorPropsBase< - ScreenOptions: {...}, - ScreenListenersParam: {...}, - NavHelpers, - > = NavigatorProps< - ScreenOptions, - ScreenListenersParam, - RouteProp<>, - NavHelpers, - ExtraNavigatorPropsBase, - >; - - declare export type CreateNavigator< - State: NavigationState, - ScreenOptions: {...}, - EventMap: EventMapBase, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - > = < - GlobalParamList: ParamListBase, - ParamList: ParamListBase, - NavHelpers: NavigationHelpers< - GlobalParamList, - State, - EventMap, - >, - >() => {| - +Screen: ScreenComponent< - GlobalParamList, - ParamList, - State, - ScreenOptions, - EventMap, - >, - +Navigator: React$ComponentType<$Exact, - RouteProp, - NavHelpers, - ExtraNavigatorProps, - >>>, - +Group: React$ComponentType<{| - ...ScreenOptionsProps, NavHelpers>, - +children: React$Node, - +navigationKey?: string, - |}>, - |}; - - declare export type CreateNavigatorFactory = < - State: NavigationState, - ScreenOptions: {...}, - EventMap: EventMapBase, - NavHelpers: NavigationHelpers< - ParamListBase, - State, - EventMap, - >, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - >( - navigator: React$ComponentType<$Exact, - RouteProp<>, - NavHelpers, - ExtraNavigatorProps, - >>>, - ) => CreateNavigator; - - - /** - * useNavigationBuilder - */ - - declare export type Descriptor< - NavHelpers, - ScreenOptions: {...} = {...}, - > = {| - +render: () => React$Node, - +options: $ReadOnly, - +navigation: NavHelpers, - |}; - - declare export type UseNavigationBuilder = < - State: NavigationState, - Action: GenericNavigationAction, - ScreenOptions: {...}, - RouterOptions: DefaultRouterOptions, - NavHelpers, - EventMap: EventMapBase, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - >( - routerFactory: RouterFactory, - options: $Exact, - RouteProp<>, - NavHelpers, - ExtraNavigatorProps, - >>, - ) => {| - +id?: string, - +state: State, - +descriptors: {| +[key: string]: Descriptor |}, - +navigation: NavHelpers, - |}; - - /** - * EdgeInsets - */ - - declare type EdgeInsets = {| - +top: number, - +right: number, - +bottom: number, - +left: number, - |}; - - /** - * TransitionPreset - */ - - declare export type TransitionSpec = - | {| - animation: 'spring', - config: $Diff< - SpringAnimationConfigSingle, - { toValue: number | AnimatedValue, ... }, - >, - |} - | {| - animation: 'timing', - config: $Diff< - TimingAnimationConfigSingle, - { toValue: number | AnimatedValue, ... }, - >, - |}; - - declare export type StackCardInterpolationProps = {| - +current: {| - +progress: AnimatedInterpolation, - |}, - +next?: {| - +progress: AnimatedInterpolation, - |}, - +index: number, - +closing: AnimatedInterpolation, - +swiping: AnimatedInterpolation, - +inverted: AnimatedInterpolation, - +layouts: {| - +screen: {| +width: number, +height: number |}, - |}, - +insets: EdgeInsets, - |}; - declare export type StackCardInterpolatedStyle = {| - containerStyle?: AnimatedViewStyleProp, - cardStyle?: AnimatedViewStyleProp, - overlayStyle?: AnimatedViewStyleProp, - shadowStyle?: AnimatedViewStyleProp, - |}; - declare export type StackCardStyleInterpolator = ( - props: StackCardInterpolationProps, - ) => StackCardInterpolatedStyle; - - declare export type StackHeaderInterpolationProps = {| - +current: {| - +progress: AnimatedInterpolation, - |}, - +next?: {| - +progress: AnimatedInterpolation, - |}, - +layouts: {| - +header: {| +width: number, +height: number |}, - +screen: {| +width: number, +height: number |}, - +title?: {| +width: number, +height: number |}, - +leftLabel?: {| +width: number, +height: number |}, - |}, - |}; - declare export type StackHeaderInterpolatedStyle = {| - leftLabelStyle?: AnimatedViewStyleProp, - leftButtonStyle?: AnimatedViewStyleProp, - rightButtonStyle?: AnimatedViewStyleProp, - titleStyle?: AnimatedViewStyleProp, - backgroundStyle?: AnimatedViewStyleProp, - |}; - declare export type StackHeaderStyleInterpolator = ( - props: StackHeaderInterpolationProps, - ) => StackHeaderInterpolatedStyle; - - declare type GestureDirection = - | 'horizontal' - | 'horizontal-inverted' - | 'vertical' - | 'vertical-inverted'; - - declare export type TransitionPreset = {| - +gestureDirection: GestureDirection, - +transitionSpec: {| - +open: TransitionSpec, - +close: TransitionSpec, - |}, - +cardStyleInterpolator: StackCardStyleInterpolator, - +headerStyleInterpolator: StackHeaderStyleInterpolator, - |}; - - /** - * Header common options - */ - - declare export type SceneProgress = {| - +current: AnimatedInterpolation, - +next?: AnimatedInterpolation, - +previous?: AnimatedInterpolation, - |}; - - declare export type HeaderProps = {| - +navigation: NavProp, - +route: RouteProp<>, - +options: ScreenOptions, - +layout: {| +width: number, +height: number |}, - |}; - - declare export type HeaderButtonProps = $Partial<{| - +tintColor: string, - +pressColor: string, - +pressOpacity: number, - |}>; - - declare export type HeaderLeftButtonProps = $Partial<{| - ...HeaderButtonProps, - +labelVisible: boolean, - |}>; - - declare type HeaderTitleInputBase = { - +onLayout: LayoutEvent => void, - +children: string, - +allowFontScaling: ?boolean, - +tintColor: ?string, - +style: ?AnimatedTextStyleProp, - ... - }; - - declare export type HeaderTitleInputProps = - $Exact; - - declare export type HeaderCommonOptions< - NavHeaderProps, - NavHeaderLeftProps, - NavHeaderRightProps, - > = $Partial<{| - +header: NavHeaderProps => React$Node, - +headerShown: boolean, - +headerTitle: string | ( HeaderTitleInputProps => React$Node), - +headerTitleAlign: 'left' | 'center', - +headerTitleStyle: AnimatedTextStyleProp, - +headerTitleContainerStyle: AnimatedViewStyleProp, - +headerTintColor: string, - +headerTitleAllowFontScaling: boolean, - +headerLeft: NavHeaderLeftProps => React$Node, - +headerLeftContainerStyle: AnimatedViewStyleProp, - +headerRight: NavHeaderRightProps => React$Node, - +headerRightContainerStyle: AnimatedViewStyleProp, - +headerBackground: ({| style: AnimatedViewStyleProp |}) => React$Node, - +headerStyle: AnimatedViewStyleProp, - +headerTransparent: boolean, - +headerStatusBarHeight: number, - +headerShadowVisible: boolean, - +headerBackgroundContainerStyle: AnimatedViewStyleProp, - +headerPressColor: string, - +headerPressOpacity: number, - |}>; - - /** - * Stack options - */ - - declare export type StackDescriptor = Descriptor< - StackNavigationHelpers<>, - StackOptions, - >; - - declare type Scene = {| - +route: T, - +descriptor: StackDescriptor, - +progress: SceneProgress, - |}; - - declare export type StackHeaderProps = {| - ...HeaderProps, StackOptions>, - +progress: SceneProgress, - +back?: {| +title: string |}, - +styleInterpolator: StackHeaderStyleInterpolator, - |}; - - declare export type StackHeaderButtonProps = $Partial<{| - ...HeaderButtonProps, - +canGoBack: boolean, - |}>; - - declare export type StackHeaderLeftButtonProps = $Partial<{| - ...StackHeaderButtonProps, - +onPress: (() => void), - +backImage: (props: {| tintColor: string |}) => React$Node, - +label: string, - +truncatedLabel: string, - +labelVisible: boolean, - +labelStyle: AnimatedTextStyleProp, - +allowFontScaling: boolean, - +onLabelLayout: LayoutEvent => void, - +screenLayout: {| +width: number, +height: number |}, - +titleLayout: {| +width: number, +height: number |}, - +disabled: boolean, - +accessibilityLabel: string, - +style: ViewStyleProp, - |}>; - - declare export type StackOptions = $Partial<{| - +title: string, - +cardShadowEnabled: boolean, - +cardOverlayEnabled: boolean, - +cardOverlay: {| style: ViewStyleProp |} => React$Node, - +cardStyle: ViewStyleProp, - +animationEnabled: boolean, - +animationTypeForReplace: 'push' | 'pop', - +gestureEnabled: boolean, - +gestureResponseDistance: number, - +gestureVelocityImpact: number, - +safeAreaInsets: $Partial, - +keyboardHandlingEnabled: boolean, - +presentation: 'card' | 'modal' | 'transparentModal', - // Transition - ...TransitionPreset, - // Header - ...HeaderCommonOptions< - StackHeaderProps, - StackHeaderLeftButtonProps, - StackHeaderButtonProps, - >, - +headerMode: 'float' | 'screen', - +headerBackAllowFontScaling: boolean, - +headerBackTitle: string | null, - +headerBackTitleStyle: TextStyleProp, - +headerBackTitleVisible: boolean, - +headerTruncatedBackTitle: string, - +headerBackImage: $PropertyType, - +headerBackAccessibilityLabel: string, - |}>; - - /** - * Stack navigation prop - */ - - declare export type StackNavigationEventMap = {| - ...EventMapCore, - +transitionStart: {| - +data: {| +closing: boolean |}, - +canPreventDefault: false, - |}, - +transitionEnd: {| - +data: {| +closing: boolean |}, - +canPreventDefault: false, - |}, - +gestureStart: {| +data: void, +canPreventDefault: false |}, - +gestureEnd: {| +data: void, +canPreventDefault: false |}, - +gestureCancel: {| +data: void, +canPreventDefault: false |}, - |}; - - declare type StackExtraNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - > = {| - +replace: SimpleNavigate, - +push: SimpleNavigate, - +pop: (count?: number) => void, - +popToTop: () => void, - |}; - - declare export type StackNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = StackNavigationEventMap, - > = { - ...$Exact>, - ...StackExtraNavigationHelpers, - ... - }; - - declare export type StackNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = StackOptions, - EventMap: EventMapBase = StackNavigationEventMap, - > = {| - ...$Exact>, - ...StackExtraNavigationHelpers, - |}; - - /** - * Miscellaneous stack exports - */ - - declare type StackNavigationConfig = {| - +detachInactiveScreens?: boolean, - |}; - - declare export type ExtraStackNavigatorProps = {| - ...$Exact, - ...StackRouterOptions, - ...StackNavigationConfig, - |}; - - declare export type StackNavigatorProps< - NavHelpers: StackNavigationHelpers<> = StackNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraStackNavigatorProps, - >>; - - /** - * Bottom tab options - */ - - declare export type BottomTabBarButtonProps = {| - ...$Diff< - TouchableWithoutFeedbackProps, - {| onPress?: ?(event: PressEvent) => mixed |}, - >, - +to?: string, - +children: React$Node, - +onPress?: (MouseEvent | PressEvent) => void, - |}; - - declare export type TabBarVisibilityAnimationConfig = - | {| - +animation: 'spring', - +config?: $Diff< - SpringAnimationConfigSingle, - { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, - >, - |} - | {| - +animation: 'timing', - +config?: $Diff< - TimingAnimationConfigSingle, - { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, - >, - |}; - - declare export type BottomTabOptions = $Partial<{| - +title: string, - +tabBarLabel: - | string - | ({| focused: boolean, color: string |}) => React$Node, - +tabBarIcon: ({| - focused: boolean, - color: string, - size: number, - |}) => React$Node, - +tabBarBadge: number | string, - +tabBarBadgeStyle: TextStyleProp, - +tabBarAccessibilityLabel: string, - +tabBarTestID: string, - +tabBarVisibilityAnimationConfig: $Partial<{| - +show: TabBarVisibilityAnimationConfig, - +hide: TabBarVisibilityAnimationConfig, - |}>, - +tabBarButton: BottomTabBarButtonProps => React$Node, - +tabBarHideOnKeyboard: boolean, - +tabBarActiveTintColor: string, - +tabBarInactiveTintColor: string, - +tabBarActiveBackgroundColor: string, - +tabBarInactiveBackgroundColor: string, - +tabBarAllowFontScaling: boolean, - +tabBarShowLabel: boolean, - +tabBarLabelStyle: TextStyleProp, - +tabBarIconStyle: TextStyleProp, - +tabBarItemStyle: ViewStyleProp, - +tabBarLabelPosition: 'beside-icon' | 'below-icon', - +tabBarStyle: ViewStyleProp, - +unmountOnBlur: boolean, - +lazy: boolean, - ...HeaderCommonOptions< - HeaderProps, BottomTabOptions>, - HeaderLeftButtonProps, - HeaderButtonProps, - >, - |}>; - - /** - * Bottom tab navigation prop - */ - - declare export type BottomTabNavigationEventMap = {| - ...EventMapCore, - +tabPress: {| +data: void, +canPreventDefault: true |}, - +tabLongPress: {| +data: void, +canPreventDefault: false |}, - |}; - - declare type TabExtraNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - > = {| - +jumpTo: SimpleNavigate, - |}; - - declare export type BottomTabNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = BottomTabNavigationEventMap, - > = { - ...$Exact>, - ...TabExtraNavigationHelpers, - ... - }; - - declare export type BottomTabNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = BottomTabOptions, - EventMap: EventMapBase = BottomTabNavigationEventMap, - > = {| - ...$Exact>, - ...TabExtraNavigationHelpers, - |}; - - /** - * Miscellaneous bottom tab exports - */ - - declare export type BottomTabDescriptor = Descriptor< - BottomTabNavigationHelpers<>, - BottomTabOptions, - >; - - declare type BottomTabNavigationBuilderResult = {| - +state: TabNavigationState, - +navigation: BottomTabNavigationHelpers<>, - +descriptors: {| +[key: string]: BottomTabDescriptor |}, - |}; - - declare export type BottomTabBarProps = BottomTabNavigationBuilderResult; - - declare type BottomTabNavigationConfig = {| - +tabBar?: BottomTabBarProps => React$Node, - +safeAreaInsets?: $Partial, - +detachInactiveScreens?: boolean, - |}; - - declare export type ExtraBottomTabNavigatorProps = {| - ...$Exact, - ...TabRouterOptions, - ...BottomTabNavigationConfig, - |}; - - declare export type BottomTabNavigatorProps< - NavHelpers: BottomTabNavigationHelpers<> = BottomTabNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, + BottomTabNavigationEventMap, ExtraBottomTabNavigatorProps, - >>; - - /** - * Material bottom tab options - */ - - declare export type MaterialBottomTabOptions = $Partial<{| - +title: string, - +tabBarColor: string, - +tabBarLabel: string, - +tabBarIcon: - | string - | ({| +focused: boolean, +color: string |}) => React$Node, - +tabBarBadge: boolean | number | string, - +tabBarAccessibilityLabel: string, - +tabBarTestID: string, - |}>; - - /** - * Material bottom tab navigation prop - */ - - declare export type MaterialBottomTabNavigationEventMap = {| - ...EventMapCore, - +tabPress: {| +data: void, +canPreventDefault: true |}, - |}; - - declare export type MaterialBottomTabNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, - > = { - ...$Exact>, - ...TabExtraNavigationHelpers, - ... - }; - - declare export type MaterialBottomTabNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = MaterialBottomTabOptions, - EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, - > = {| - ...$Exact>, - ...TabExtraNavigationHelpers, - |}; - - /** - * Miscellaneous material bottom tab exports - */ - - declare export type PaperFont = {| - +fontFamily: string, - +fontWeight?: - | 'normal' - | 'bold' - | '100' - | '200' - | '300' - | '400' - | '500' - | '600' - | '700' - | '800' - | '900', - |}; - - declare export type PaperFonts = {| - +regular: PaperFont, - +medium: PaperFont, - +light: PaperFont, - +thin: PaperFont, - |}; - - declare export type PaperTheme = {| - +dark: boolean, - +mode?: 'adaptive' | 'exact', - +roundness: number, - +colors: {| - +primary: string, - +background: string, - +surface: string, - +accent: string, - +error: string, - +text: string, - +onSurface: string, - +onBackground: string, - +disabled: string, - +placeholder: string, - +backdrop: string, - +notification: string, - |}, - +fonts: PaperFonts, - +animation: {| - +scale: number, - |}, - |}; - - declare export type PaperRoute = {| - +key: string, - +title?: string, - +icon?: any, - +badge?: string | number | boolean, - +color?: string, - +accessibilityLabel?: string, - +testID?: string, - |}; - - declare export type PaperTouchableProps = {| - ...TouchableWithoutFeedbackProps, - +key: string, - +route: PaperRoute, - +children: React$Node, - +borderless?: boolean, - +centered?: boolean, - +rippleColor?: string, - |}; - - declare export type MaterialBottomTabNavigationConfig = {| - +shifting?: boolean, - +labeled?: boolean, - +renderTouchable?: PaperTouchableProps => React$Node, - +activeColor?: string, - +inactiveColor?: string, - +sceneAnimationEnabled?: boolean, - +keyboardHidesNavigationBar?: boolean, - +barStyle?: ViewStyleProp, - +style?: ViewStyleProp, - +theme?: PaperTheme, - |}; - - declare export type ExtraMaterialBottomTabNavigatorProps = {| - ...$Exact, - ...TabRouterOptions, - ...MaterialBottomTabNavigationConfig, - |}; - - declare export type MaterialBottomTabNavigatorProps< - NavHelpers: MaterialBottomTabNavigationHelpers<> = - MaterialBottomTabNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraMaterialBottomTabNavigatorProps, - >>; - - /** - * Material top tab options - */ - - declare export type MaterialTopTabOptions = $Partial<{| - +title: string, - +tabBarLabel: - | string - | ({| +focused: boolean, +color: string |}) => React$Node, - +tabBarIcon: ({| +focused: boolean, +color: string |}) => React$Node, - +tabBarAccessibilityLabel: string, - +tabBarTestID: string, - +tabBarActiveTintColor: string, - +tabBarInactiveTintColor: string, - +tabBarPressColor: string, - +tabBarPressOpacity: number, - +tabBarShowLabel: boolean, - +tabBarShowIcon: boolean, - +tabBarAllowFontScaling: boolean, - +tabBarBounces: boolean, - +tabBarScrollEnabled: boolean, - +tabBarIconStyle: ViewStyleProp, - +tabBarLabelStyle: TextStyleProp, - +tabBarItemStyle: ViewStyleProp, - +tabBarIndicatorStyle: ViewStyleProp, - +tabBarIndicatorContainerStyle: ViewStyleProp, - +tabBarContentContainerStyle: ViewStyleProp, - +tabBarStyle: ViewStyleProp, - +tabBarBadge: () => React$Node, - +tabBarIndicator: MaterialTopTabBarIndicatorProps => React$Node, - +lazy: boolean, - +lazyPlaceholder: ({| +route: Route<> |}) => React$Node, - |}>; - - /** - * Material top tab navigation prop - */ - - declare export type MaterialTopTabNavigationEventMap = {| - ...EventMapCore, - +tabPress: {| +data: void, +canPreventDefault: true |}, - +tabLongPress: {| +data: void, +canPreventDefault: false |}, - +swipeStart: {| +data: void, +canPreventDefault: false |}, - +swipeEnd: {| +data: void, +canPreventDefault: false |}, - |}; - - declare export type MaterialTopTabNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = MaterialTopTabNavigationEventMap, - > = { - ...$Exact>, - ...TabExtraNavigationHelpers, - ... - }; - - declare export type MaterialTopTabNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = MaterialTopTabOptions, - EventMap: EventMapBase = MaterialTopTabNavigationEventMap, - > = {| - ...$Exact>, - ...TabExtraNavigationHelpers, - |}; - - /** - * Miscellaneous material top tab exports - */ - - declare type MaterialTopTabPagerCommonProps = {| - +keyboardDismissMode: 'none' | 'on-drag' | 'auto', - +swipeEnabled: boolean, - +swipeVelocityImpact?: number, - +springVelocityScale?: number, - +springConfig: $Partial<{| - +damping: number, - +mass: number, - +stiffness: number, - +restSpeedThreshold: number, - +restDisplacementThreshold: number, - |}>, - +timingConfig: $Partial<{| - +duration: number, - |}>, - |}; - - declare export type MaterialTopTabPagerProps = {| - ...MaterialTopTabPagerCommonProps, - +onSwipeStart?: () => void, - +onSwipeEnd?: () => void, - +onIndexChange: (index: number) => void, - +navigationState: TabNavigationState, - +layout: {| +width: number, +height: number |}, - +removeClippedSubviews: boolean, - +children: ({| - +addListener: (type: 'enter', listener: number => void) => void, - +removeListener: (type: 'enter', listener: number => void) => void, - +position: any, // Reanimated.Node - +render: React$Node => React$Node, - +jumpTo: string => void, - |}) => React$Node, - +gestureHandlerProps: PanGestureHandlerProps, - |}; - - declare export type MaterialTopTabBarIndicatorProps = {| - +state: TabNavigationState, - +width: string, - +style?: ViewStyleProp, - +getTabWidth: number => number, - |}; - - declare export type MaterialTopTabDescriptor = Descriptor< - MaterialBottomTabNavigationHelpers<>, - MaterialBottomTabOptions, - >; - - declare type MaterialTopTabNavigationBuilderResult = {| - +state: TabNavigationState, - +navigation: MaterialTopTabNavigationHelpers<>, - +descriptors: {| +[key: string]: MaterialTopTabDescriptor |}, - |}; - - declare export type MaterialTopTabBarProps = {| - ...MaterialTopTabNavigationBuilderResult, - +layout: {| +width: number, +height: number |}, - +position: any, // Reanimated.Node - +jumpTo: string => void, - |}; - - declare export type MaterialTopTabNavigationConfig = {| - ...$Partial, - +position?: any, // Reanimated.Value - +tabBarPosition?: 'top' | 'bottom', - +initialLayout?: $Partial<{| +width: number, +height: number |}>, - +lazyPreloadDistance?: number, - +removeClippedSubviews?: boolean, - +sceneContainerStyle?: ViewStyleProp, - +style?: ViewStyleProp, - +gestureHandlerProps?: PanGestureHandlerProps, - +pager?: MaterialTopTabPagerProps => React$Node, - +tabBar?: MaterialTopTabBarProps => React$Node, - |}; - - declare export type ExtraMaterialTopTabNavigatorProps = {| - ...$Exact, - ...TabRouterOptions, - ...MaterialTopTabNavigationConfig, - |}; - - declare export type MaterialTopTabNavigatorProps< - NavHelpers: MaterialTopTabNavigationHelpers<> = - MaterialTopTabNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraMaterialTopTabNavigatorProps, - >>; - - /** - * Drawer options - */ - - declare export type DrawerOptions = $Partial<{| - +title: string, - +lazy: boolean, - +drawerLabel: - | string - | ({| +color: string, +focused: boolean |}) => React$Node, - +drawerIcon: ({| - +color: string, - +size: number, - +focused: boolean, - |}) => React$Node, - +drawerActiveTintColor: string, - +drawerActiveBackgroundColor: string, - +drawerInactiveTintColor: string, - +drawerInactiveBackgroundColor: string, - +drawerItemStyle: ViewStyleProp, - +drawerLabelStyle: TextStyleProp, - +drawerContentContainerStyle: ViewStyleProp, - +drawerContentStyle: ViewStyleProp, - +drawerStyle: ViewStyleProp, - +drawerPosition: 'left' | 'right', - +drawerType: 'front' | 'back' | 'slide' | 'permanent', - +drawerHideStatusBarOnOpen: boolean, - +drawerStatusBarAnimation: 'slide' | 'none' | 'fade', - +overlayColor: string, - +sceneContainerStyle: ViewStyleProp, - +gestureHandlerProps: PanGestureHandlerProps, - +swipeEnabled: boolean, - +swipeEdgeWidth: number, - +swipeMinDistance: number, - +keyboardDismissMode: 'on-drag' | 'none', - +unmountOnBlur: boolean, - ...HeaderCommonOptions< - HeaderProps, DrawerOptions>, - HeaderLeftButtonProps, - HeaderButtonProps, - >, - |}>; - - /** - * Drawer navigation prop - */ - - declare export type DrawerNavigationEventMap = - EventMapCore; - - declare type DrawerExtraNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - > = {| - +jumpTo: SimpleNavigate, - +openDrawer: () => void, - +closeDrawer: () => void, - +toggleDrawer: () => void, - |}; - - declare export type DrawerNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = DrawerNavigationEventMap, - > = { - ...$Exact>, - ...DrawerExtraNavigationHelpers, - ... - }; - - declare export type DrawerNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = DrawerOptions, - EventMap: EventMapBase = DrawerNavigationEventMap, - > = {| - ...$Exact>, - ...DrawerExtraNavigationHelpers, - |}; - - /** - * Miscellaneous drawer exports - */ - - declare export type DrawerDescriptor = Descriptor< - DrawerNavigationHelpers<>, - DrawerOptions, - >; - - declare type DrawerNavigationBuilderResult = {| - +state: DrawerNavigationState, - +navigation: DrawerNavigationHelpers<>, - +descriptors: {| +[key: string]: DrawerDescriptor |}, - |}; - - declare export type DrawerNavigationConfig = {| - +drawerContent?: DrawerNavigationBuilderResult => React$Node, - +detachInactiveScreens?: boolean, - +useLegacyImplementation?: boolean, - |}; - - declare export type ExtraDrawerNavigatorProps = {| - ...$Exact, - ...DrawerRouterOptions, - ...DrawerNavigationConfig, - |}; - - declare export type DrawerNavigatorProps< - NavHelpers: DrawerNavigationHelpers<> = DrawerNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraDrawerNavigatorProps, - >>; - - /** - * BaseNavigationContainer - */ - - declare export type BaseNavigationContainerProps = {| - +children: React$Node, - +initialState?: PossiblyStaleNavigationState, - +onStateChange?: (state: ?PossiblyStaleNavigationState) => void, - +independent?: boolean, - |}; - - declare export type ContainerEventMap = {| - ...GlobalEventMap, - +options: {| - +data: {| +options: { +[key: string]: mixed, ... } |}, - +canPreventDefault: false, - |}, - +__unsafe_action__: {| - +data: {| - +action: GenericNavigationAction, - +noop: boolean, - |}, - +canPreventDefault: false, - |}, - |}; - - declare export type BaseNavigationContainerInterface = {| - ...$Exact>, - +resetRoot: (state?: PossiblyStaleNavigationState) => void, - +getRootState: () => NavigationState, - +getCurrentRoute: () => RouteProp<> | void, - +getCurrentOptions: () => Object | void, - +isReady: () => boolean, - |}; - - declare type BaseNavigationContainerInterfaceRef = {| - ...BaseNavigationContainerInterface, - +current: BaseNavigationContainerInterface | null, - |}; - - /** - * State utils - */ - - declare export type GetStateFromPath = ( - path: string, - options?: LinkingConfig, - ) => PossiblyStaleNavigationState; - - declare export type GetPathFromState = ( - state?: ?PossiblyStaleNavigationState, - options?: LinkingConfig, - ) => string; - - declare export type GetFocusedRouteNameFromRoute = - PossiblyStaleRoute => ?string; - - /** - * Linking - */ - - declare export type ScreenLinkingConfig = {| - +path?: string, - +exact?: boolean, - +parse?: {| +[param: string]: string => mixed |}, - +stringify?: {| +[param: string]: mixed => string |}, - +screens?: ScreenLinkingConfigMap, - +initialRouteName?: string, - |}; - - declare export type ScreenLinkingConfigMap = {| - +[routeName: string]: string | ScreenLinkingConfig, - |}; - - declare export type LinkingConfig = {| - +initialRouteName?: string, - +screens: ScreenLinkingConfigMap, - |}; - - declare export type LinkingOptions = {| - +enabled?: boolean, - +prefixes: $ReadOnlyArray, - +config?: LinkingConfig, - +getStateFromPath?: GetStateFromPath, - +getPathFromState?: GetPathFromState, - |}; - - /** - * NavigationContainer - */ - - declare export type Theme = {| - +dark: boolean, - +colors: {| - +primary: string, - +background: string, - +card: string, - +text: string, - +border: string, - |}, - |}; - - declare export type NavigationContainerType = React$AbstractComponent< - {| - ...BaseNavigationContainerProps, - +theme?: Theme, - +linking?: LinkingOptions, - +fallback?: React$Node, - +onReady?: () => mixed, - |}, - BaseNavigationContainerInterface, - >; - - //--------------------------------------------------------------------------- - // SECTION 2: EXPORTED MODULE - // This section defines the module exports and contains exported types that - // are not present in any other React Navigation libdef. - //--------------------------------------------------------------------------- + BottomTabBarProps, + BottomTabNavigationConfig, + BottomTabNavigationBuilderResult, + } from '@react-navigation/core'; /** * createBottomTabNavigator diff --git a/native/flow-typed/npm/@react-navigation/core_v6.x.x.js b/native/flow-typed/npm/@react-navigation/core_v6.x.x.js --- a/native/flow-typed/npm/@react-navigation/core_v6.x.x.js +++ b/native/flow-typed/npm/@react-navigation/core_v6.x.x.js @@ -5,9 +5,6 @@ //--------------------------------------------------------------------------- // SECTION 1: IDENTICAL TYPE DEFINITIONS - // This section is identical across all React Navigation libdefs and contains - // shared definitions. We wish we could make it DRY and import from a shared - // definition, but that isn't yet possible. //--------------------------------------------------------------------------- /** @@ -27,9 +24,9 @@ | '' | $ReadOnlyArray | { [name: string]: any, ... }; - declare type ViewStyleProp = StyleObj; - declare type TextStyleProp = StyleObj; - declare type AnimatedViewStyleProp = StyleObj; + declare export type ViewStyleProp = StyleObj; + declare export type TextStyleProp = StyleObj; + declare export type AnimatedViewStyleProp = StyleObj; declare type AnimatedTextStyleProp = StyleObj; // Vaguely copied from @@ -180,7 +177,7 @@ >, |}>, |}>; - declare type PressEvent = ResponderSyntheticEvent< + declare export type PressEvent = ResponderSyntheticEvent< $ReadOnly<{| changedTouches: $ReadOnlyArray<$PropertyType>, force: number, @@ -303,7 +300,7 @@ |}>; // Copied from react-native/Libraries/Image/ImageSource.js - declare type ImageURISource = $ReadOnly<{ + declare export type ImageURISource = $ReadOnly<{ uri?: ?string, bundle?: ?string, method?: ?string, @@ -404,7 +401,7 @@ children?: React$Node, |}>; - declare type PanGestureHandlerProps = $GestureHandlerProps< + declare export type PanGestureHandlerProps = $GestureHandlerProps< { activeOffsetY?: number | [number, number], activeOffsetX?: number | [number, number], @@ -1338,7 +1335,7 @@ +labelVisible: boolean, |}>; - declare type HeaderTitleInputBase = { + declare export type HeaderTitleInputBase = { +onLayout: LayoutEvent => void, +children: string, +allowFontScaling: ?boolean, @@ -1514,7 +1511,7 @@ * Miscellaneous stack exports */ - declare type StackNavigationConfig = {| + declare export type StackNavigationConfig = {| +detachInactiveScreens?: boolean, |}; @@ -1658,7 +1655,7 @@ BottomTabOptions, >; - declare type BottomTabNavigationBuilderResult = {| + declare export type BottomTabNavigationBuilderResult = {| +state: TabNavigationState, +navigation: BottomTabNavigationHelpers<>, +descriptors: {| +[key: string]: BottomTabDescriptor |}, @@ -1666,7 +1663,7 @@ declare export type BottomTabBarProps = BottomTabNavigationBuilderResult; - declare type BottomTabNavigationConfig = {| + declare export type BottomTabNavigationConfig = {| +tabBar?: BottomTabBarProps => React$Node, +safeAreaInsets?: $Partial, +detachInactiveScreens?: boolean, @@ -1969,7 +1966,7 @@ MaterialBottomTabOptions, >; - declare type MaterialTopTabNavigationBuilderResult = {| + declare export type MaterialTopTabNavigationBuilderResult = {| +state: TabNavigationState, +navigation: MaterialTopTabNavigationHelpers<>, +descriptors: {| +[key: string]: MaterialTopTabDescriptor |}, @@ -2110,7 +2107,7 @@ DrawerOptions, >; - declare type DrawerNavigationBuilderResult = {| + declare export type DrawerNavigationBuilderResult = {| +state: DrawerNavigationState, +navigation: DrawerNavigationHelpers<>, +descriptors: {| +[key: string]: DrawerDescriptor |}, @@ -2177,7 +2174,7 @@ +isReady: () => boolean, |}; - declare type BaseNavigationContainerInterfaceRef = {| + declare export type BaseNavigationContainerInterfaceRef = {| ...BaseNavigationContainerInterface, +current: BaseNavigationContainerInterface | null, |}; @@ -2257,8 +2254,6 @@ //--------------------------------------------------------------------------- // SECTION 2: EXPORTED MODULE - // This section defines the module exports and contains exported types that - // are not present in any other React Navigation libdef. //--------------------------------------------------------------------------- /** diff --git a/native/flow-typed/npm/@react-navigation/devtools_v6.x.x.js b/native/flow-typed/npm/@react-navigation/devtools_v6.x.x.js --- a/native/flow-typed/npm/@react-navigation/devtools_v6.x.x.js +++ b/native/flow-typed/npm/@react-navigation/devtools_v6.x.x.js @@ -3,2264 +3,6 @@ declare module '@react-navigation/devtools' { - //--------------------------------------------------------------------------- - // SECTION 1: IDENTICAL TYPE DEFINITIONS - // This section is identical across all React Navigation libdefs and contains - // shared definitions. We wish we could make it DRY and import from a shared - // definition, but that isn't yet possible. - //--------------------------------------------------------------------------- - - /** - * We start with some definitions that we have copy-pasted from React Native - * source files. - */ - - // This is a bastardization of the true StyleObj type located in - // react-native/Libraries/StyleSheet/StyleSheetTypes. We unfortunately can't - // import that here, and it's too lengthy (and consequently too brittle) to - // copy-paste here either. - declare type StyleObj = - | null - | void - | number - | false - | '' - | $ReadOnlyArray - | { [name: string]: any, ... }; - declare type ViewStyleProp = StyleObj; - declare type TextStyleProp = StyleObj; - declare type AnimatedViewStyleProp = StyleObj; - declare type AnimatedTextStyleProp = StyleObj; - - // Vaguely copied from - // react-native/Libraries/Animated/src/animations/Animation.js - declare type EndResult = { finished: boolean, ... }; - declare type EndCallback = (result: EndResult) => void; - declare interface Animation { - start( - fromValue: number, - onUpdate: (value: number) => void, - onEnd: ?EndCallback, - previousAnimation: ?Animation, - animatedValue: AnimatedValue, - ): void; - stop(): void; - } - declare type AnimationConfig = { - isInteraction?: boolean, - useNativeDriver: boolean, - onComplete?: ?EndCallback, - iterations?: number, - ... - }; - - // Vaguely copied from - // react-native/Libraries/Animated/src/nodes/AnimatedTracking.js - declare interface AnimatedTracking { - constructor( - value: AnimatedValue, - parent: any, - animationClass: any, - animationConfig: Object, - callback?: ?EndCallback, - ): void; - update(): void; - } - - // Vaguely copied from - // react-native/Libraries/Animated/src/nodes/AnimatedValue.js - declare type ValueListenerCallback = (state: { value: number, ... }) => void; - declare interface AnimatedValue { - constructor(value: number): void; - setValue(value: number): void; - setOffset(offset: number): void; - flattenOffset(): void; - extractOffset(): void; - addListener(callback: ValueListenerCallback): string; - removeListener(id: string): void; - removeAllListeners(): void; - stopAnimation(callback?: ?(value: number) => void): void; - resetAnimation(callback?: ?(value: number) => void): void; - interpolate(config: InterpolationConfigType): AnimatedInterpolation; - animate(animation: Animation, callback: ?EndCallback): void; - stopTracking(): void; - track(tracking: AnimatedTracking): void; - } - - // Copied from - // react-native/Libraries/Animated/src/animations/TimingAnimation.js - declare type TimingAnimationConfigSingle = AnimationConfig & { - toValue: number | AnimatedValue, - easing?: (value: number) => number, - duration?: number, - delay?: number, - ... - }; - - // Copied from - // react-native/Libraries/Animated/src/animations/SpringAnimation.js - declare type SpringAnimationConfigSingle = AnimationConfig & { - toValue: number | AnimatedValue, - overshootClamping?: boolean, - restDisplacementThreshold?: number, - restSpeedThreshold?: number, - velocity?: number, - bounciness?: number, - speed?: number, - tension?: number, - friction?: number, - stiffness?: number, - damping?: number, - mass?: number, - delay?: number, - ... - }; - - // Copied from react-native/Libraries/Types/CoreEventTypes.js - declare type SyntheticEvent = $ReadOnly<{| - bubbles: ?boolean, - cancelable: ?boolean, - currentTarget: number, - defaultPrevented: ?boolean, - dispatchConfig: $ReadOnly<{| - registrationName: string, - |}>, - eventPhase: ?number, - preventDefault: () => void, - isDefaultPrevented: () => boolean, - stopPropagation: () => void, - isPropagationStopped: () => boolean, - isTrusted: ?boolean, - nativeEvent: T, - persist: () => void, - target: ?number, - timeStamp: number, - type: ?string, - |}>; - declare type Layout = $ReadOnly<{| - x: number, - y: number, - width: number, - height: number, - |}>; - declare type LayoutEvent = SyntheticEvent< - $ReadOnly<{| - layout: Layout, - |}>, - >; - declare type BlurEvent = SyntheticEvent< - $ReadOnly<{| - target: number, - |}>, - >; - declare type FocusEvent = SyntheticEvent< - $ReadOnly<{| - target: number, - |}>, - >; - declare type ResponderSyntheticEvent = $ReadOnly<{| - ...SyntheticEvent, - touchHistory: $ReadOnly<{| - indexOfSingleActiveTouch: number, - mostRecentTimeStamp: number, - numberActiveTouches: number, - touchBank: $ReadOnlyArray< - $ReadOnly<{| - touchActive: boolean, - startPageX: number, - startPageY: number, - startTimeStamp: number, - currentPageX: number, - currentPageY: number, - currentTimeStamp: number, - previousPageX: number, - previousPageY: number, - previousTimeStamp: number, - |}>, - >, - |}>, - |}>; - declare type PressEvent = ResponderSyntheticEvent< - $ReadOnly<{| - changedTouches: $ReadOnlyArray<$PropertyType>, - force: number, - identifier: number, - locationX: number, - locationY: number, - pageX: number, - pageY: number, - target: ?number, - timestamp: number, - touches: $ReadOnlyArray<$PropertyType>, - |}>, - >; - - // Vaguely copied from - // react-native/Libraries/Animated/src/nodes/AnimatedInterpolation.js - declare type ExtrapolateType = 'extend' | 'identity' | 'clamp'; - declare type InterpolationConfigType = { - inputRange: Array, - outputRange: Array | Array, - easing?: (input: number) => number, - extrapolate?: ExtrapolateType, - extrapolateLeft?: ExtrapolateType, - extrapolateRight?: ExtrapolateType, - ... - }; - declare interface AnimatedInterpolation { - interpolate(config: InterpolationConfigType): AnimatedInterpolation; - } - - // Copied from react-native/Libraries/Components/View/ViewAccessibility.js - declare type AccessibilityRole = - | 'none' - | 'button' - | 'link' - | 'search' - | 'image' - | 'keyboardkey' - | 'text' - | 'adjustable' - | 'imagebutton' - | 'header' - | 'summary' - | 'alert' - | 'checkbox' - | 'combobox' - | 'menu' - | 'menubar' - | 'menuitem' - | 'progressbar' - | 'radio' - | 'radiogroup' - | 'scrollbar' - | 'spinbutton' - | 'switch' - | 'tab' - | 'tablist' - | 'timer' - | 'toolbar'; - declare type AccessibilityActionInfo = $ReadOnly<{ - name: string, - label?: string, - ... - }>; - declare type AccessibilityActionEvent = SyntheticEvent< - $ReadOnly<{actionName: string, ...}>, - >; - declare type AccessibilityState = { - disabled?: boolean, - selected?: boolean, - checked?: ?boolean | 'mixed', - busy?: boolean, - expanded?: boolean, - ... - }; - declare type AccessibilityValue = $ReadOnly<{| - min?: number, - max?: number, - now?: number, - text?: string, - |}>; - - // Copied from - // react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js - declare type Stringish = string; - declare type EdgeInsetsProp = $ReadOnly<$Partial>; - declare type TouchableWithoutFeedbackProps = $ReadOnly<{| - accessibilityActions?: ?$ReadOnlyArray, - accessibilityElementsHidden?: ?boolean, - accessibilityHint?: ?Stringish, - accessibilityIgnoresInvertColors?: ?boolean, - accessibilityLabel?: ?Stringish, - accessibilityLiveRegion?: ?('none' | 'polite' | 'assertive'), - accessibilityRole?: ?AccessibilityRole, - accessibilityState?: ?AccessibilityState, - accessibilityValue?: ?AccessibilityValue, - accessibilityViewIsModal?: ?boolean, - accessible?: ?boolean, - children?: ?React$Node, - delayLongPress?: ?number, - delayPressIn?: ?number, - delayPressOut?: ?number, - disabled?: ?boolean, - focusable?: ?boolean, - hitSlop?: ?EdgeInsetsProp, - importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'), - nativeID?: ?string, - onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed, - onBlur?: ?(event: BlurEvent) => mixed, - onFocus?: ?(event: FocusEvent) => mixed, - onLayout?: ?(event: LayoutEvent) => mixed, - onLongPress?: ?(event: PressEvent) => mixed, - onPress?: ?(event: PressEvent) => mixed, - onPressIn?: ?(event: PressEvent) => mixed, - onPressOut?: ?(event: PressEvent) => mixed, - pressRetentionOffset?: ?EdgeInsetsProp, - rejectResponderTermination?: ?boolean, - testID?: ?string, - touchSoundDisabled?: ?boolean, - |}>; - - // Copied from react-native/Libraries/Image/ImageSource.js - declare type ImageURISource = $ReadOnly<{ - uri?: ?string, - bundle?: ?string, - method?: ?string, - headers?: ?Object, - body?: ?string, - cache?: ?('default' | 'reload' | 'force-cache' | 'only-if-cached'), - width?: ?number, - height?: ?number, - scale?: ?number, - ... - }>; - - /** - * The following is copied from react-native-gesture-handler's libdef - */ - - declare type StateUndetermined = 0; - declare type StateFailed = 1; - declare type StateBegan = 2; - declare type StateCancelled = 3; - declare type StateActive = 4; - declare type StateEnd = 5; - - declare type GestureHandlerState = - | StateUndetermined - | StateFailed - | StateBegan - | StateCancelled - | StateActive - | StateEnd; - - declare type $SyntheticEvent = { - +nativeEvent: $ReadOnly<$Exact>, - ... - }; - - declare type $Event = $SyntheticEvent<{ - handlerTag: number, - numberOfPointers: number, - state: GestureHandlerState, - oldState: GestureHandlerState, - ...$Exact, - ... - }>; - - declare type $EventHandlers = {| - onGestureEvent?: ($Event) => mixed, - onHandlerStateChange?: ($Event) => mixed, - onBegan?: ($Event) => mixed, - onFailed?: ($Event) => mixed, - onCancelled?: ($Event) => mixed, - onActivated?: ($Event) => mixed, - onEnded?: ($Event) => mixed, - |}; - - declare type HitSlop = - | number - | {| - left?: number, - top?: number, - right?: number, - bottom?: number, - vertical?: number, - horizontal?: number, - width?: number, - height?: number, - |} - | {| - width: number, - left: number, - |} - | {| - width: number, - right: number, - |} - | {| - height: number, - top: number, - |} - | {| - height: number, - bottom: number, - |}; - - declare type $GestureHandlerProps< - AdditionalProps: {...}, - ExtraEventsProps: {...} - > = $ReadOnly<{| - ...$Exact, - ...$EventHandlers, - id?: string, - enabled?: boolean, - waitFor?: React$Ref | Array>, - simultaneousHandlers?: React$Ref | Array>, - shouldCancelWhenOutside?: boolean, - minPointers?: number, - hitSlop?: HitSlop, - children?: React$Node, - |}>; - - declare type PanGestureHandlerProps = $GestureHandlerProps< - { - activeOffsetY?: number | [number, number], - activeOffsetX?: number | [number, number], - failOffsetY?: number | [number, number], - failOffsetX?: number | [number, number], - minDist?: number, - minVelocity?: number, - minVelocityX?: number, - minVelocityY?: number, - minPointers?: number, - maxPointers?: number, - avgTouches?: boolean, - ... - }, - { - x: number, - y: number, - absoluteX: number, - absoluteY: number, - translationX: number, - translationY: number, - velocityX: number, - velocityY: number, - ... - } - >; - - /** - * MAGIC - */ - - declare type $If = $Call< - ((true, Then, Else) => Then) & ((false, Then, Else) => Else), - Test, - Then, - Else, - >; - declare type $IsA = $Call< - (Y => true) & (mixed => false), - X, - >; - declare type $IsUndefined = $IsA; - - declare type $Partial = $ReadOnly<$Rest>; - - // If { ...T, ... } counts as a T, then we're inexact - declare type $IsExact = $Call< - (T => false) & (mixed => true), - { ...T, ... }, - >; - - /** - * Actions, state, etc. - */ - - declare export type ScreenParams = { +[key: string]: mixed, ... }; - - declare export type BackAction = {| - +type: 'GO_BACK', - +source?: string, - +target?: string, - |}; - declare export type NavigateAction = {| - +type: 'NAVIGATE', - +payload: - | {| +key: string, +params?: ScreenParams |} - | {| +name: string, +key?: string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type ResetAction = {| - +type: 'RESET', - +payload: StaleNavigationState, - +source?: string, - +target?: string, - |}; - declare export type SetParamsAction = {| - +type: 'SET_PARAMS', - +payload: {| +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type CommonAction = - | BackAction - | NavigateAction - | ResetAction - | SetParamsAction; - - declare type NavigateActionCreator = {| - (routeName: string, params?: ScreenParams): NavigateAction, - ( - | {| +key: string, +params?: ScreenParams |} - | {| +name: string, +key?: string, +params?: ScreenParams |}, - ): NavigateAction, - |}; - declare export type CommonActionsType = {| - +navigate: NavigateActionCreator, - +goBack: () => BackAction, - +reset: (state: PossiblyStaleNavigationState) => ResetAction, - +setParams: (params: ScreenParams) => SetParamsAction, - |}; - - declare export type GenericNavigationAction = {| - +type: string, - +payload?: { +[key: string]: mixed, ... }, - +source?: string, - +target?: string, - |}; - - declare export type LeafRoute = {| - +key: string, - +name: RouteName, - +params?: ScreenParams, - |}; - declare export type StateRoute = {| - ...LeafRoute, - +state: NavigationState | StaleNavigationState, - |}; - declare export type Route = - | LeafRoute - | StateRoute; - - declare export type NavigationState = {| - +key: string, - +index: number, - +routeNames: $ReadOnlyArray, - +history?: $ReadOnlyArray, - +routes: $ReadOnlyArray>, - +type: string, - +stale: false, - |}; - - declare export type StaleLeafRoute = {| - +key?: string, - +name: RouteName, - +params?: ScreenParams, - |}; - declare export type StaleStateRoute = {| - ...StaleLeafRoute, - +state: StaleNavigationState, - |}; - declare export type StaleRoute = - | StaleLeafRoute - | StaleStateRoute; - declare export type StaleNavigationState = {| - // It's possible to pass React Nav a StaleNavigationState with an undefined - // index, but React Nav will always return one with the index set. This is - // the same as for the type property below, but in the case of index we tend - // to rely on it being set more... - +index: number, - +history?: $ReadOnlyArray, - +routes: $ReadOnlyArray>, - +type?: string, - +stale?: true, - |}; - - declare export type PossiblyStaleNavigationState = - | NavigationState - | StaleNavigationState; - declare export type PossiblyStaleRoute = - | Route - | StaleRoute; - - /** - * Routers - */ - - declare type ActionCreators< - State: NavigationState, - Action: GenericNavigationAction, - > = { - +[key: string]: (...args: any) => (Action | State => Action), - ... - }; - - declare export type DefaultRouterOptions = { - +initialRouteName?: string, - ... - }; - - declare export type RouterFactory< - State: NavigationState, - Action: GenericNavigationAction, - RouterOptions: DefaultRouterOptions, - > = (options: RouterOptions) => Router; - - declare export type ParamListBase = { +[key: string]: ?ScreenParams, ... }; - - declare export type RouterConfigOptions = {| - +routeNames: $ReadOnlyArray, - +routeParamList: ParamListBase, - |}; - - declare export type Router< - State: NavigationState, - Action: GenericNavigationAction, - > = {| - +type: $PropertyType, - +getInitialState: (options: RouterConfigOptions) => State, - +getRehydratedState: ( - partialState: PossiblyStaleNavigationState, - options: RouterConfigOptions, - ) => State, - +getStateForRouteNamesChange: ( - state: State, - options: RouterConfigOptions, - ) => State, - +getStateForRouteFocus: (state: State, key: string) => State, - +getStateForAction: ( - state: State, - action: Action, - options: RouterConfigOptions, - ) => ?PossiblyStaleNavigationState; - +shouldActionChangeFocus: (action: GenericNavigationAction) => boolean, - +actionCreators?: ActionCreators, - |}; - - /** - * Stack actions and router - */ - - declare export type StackNavigationState = {| - ...NavigationState, - +type: 'stack', - |}; - - declare export type ReplaceAction = {| - +type: 'REPLACE', - +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type PushAction = {| - +type: 'PUSH', - +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type PopAction = {| - +type: 'POP', - +payload: {| +count: number |}, - +source?: string, - +target?: string, - |}; - declare export type PopToTopAction = {| - +type: 'POP_TO_TOP', - +source?: string, - +target?: string, - |}; - declare export type StackAction = - | CommonAction - | ReplaceAction - | PushAction - | PopAction - | PopToTopAction; - - declare export type StackActionsType = {| - +replace: (routeName: string, params?: ScreenParams) => ReplaceAction, - +push: (routeName: string, params?: ScreenParams) => PushAction, - +pop: (count?: number) => PopAction, - +popToTop: () => PopToTopAction, - |}; - - declare export type StackRouterOptions = $Exact; - - /** - * Tab actions and router - */ - - declare export type TabNavigationState = {| - ...NavigationState, - +type: 'tab', - +history: $ReadOnlyArray<{| type: 'route', key: string |}>, - |}; - - declare export type JumpToAction = {| - +type: 'JUMP_TO', - +payload: {| +name: string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type TabAction = - | CommonAction - | JumpToAction; - - declare export type TabActionsType = {| - +jumpTo: string => JumpToAction, - |}; - - declare export type TabRouterOptions = {| - ...$Exact, - +backBehavior?: 'initialRoute' | 'order' | 'history' | 'none', - |}; - - /** - * Drawer actions and router - */ - - declare type DrawerHistoryEntry = - | {| +type: 'route', +key: string |} - | {| +type: 'drawer' |}; - declare export type DrawerNavigationState = {| - ...NavigationState, - +type: 'drawer', - +history: $ReadOnlyArray, - |}; - - declare export type OpenDrawerAction = {| - +type: 'OPEN_DRAWER', - +source?: string, - +target?: string, - |}; - declare export type CloseDrawerAction = {| - +type: 'CLOSE_DRAWER', - +source?: string, - +target?: string, - |}; - declare export type ToggleDrawerAction = {| - +type: 'TOGGLE_DRAWER', - +source?: string, - +target?: string, - |}; - declare export type DrawerAction = - | TabAction - | OpenDrawerAction - | CloseDrawerAction - | ToggleDrawerAction; - - declare export type DrawerActionsType = {| - ...TabActionsType, - +openDrawer: () => OpenDrawerAction, - +closeDrawer: () => CloseDrawerAction, - +toggleDrawer: () => ToggleDrawerAction, - |}; - - declare export type DrawerRouterOptions = {| - ...TabRouterOptions, - +defaultStatus?: 'open' | 'closed', - |}; - - /** - * Events - */ - - declare export type EventMapBase = { - +[name: string]: {| - +data?: mixed, - +canPreventDefault?: boolean, - |}, - ... - }; - declare type EventPreventDefaultProperties = $If< - Test, - {| +defaultPrevented: boolean, +preventDefault: () => void |}, - {| |}, - >; - declare type EventDataProperties = $If< - $IsUndefined, - {| |}, - {| +data: Data |}, - >; - declare type EventArg< - EventName: string, - CanPreventDefault: ?boolean = false, - Data = void, - > = {| - ...EventPreventDefaultProperties, - ...EventDataProperties, - +type: EventName, - +target?: string, - |}; - declare type GlobalEventMap = {| - +state: {| +data: {| +state: State |}, +canPreventDefault: false |}, - |}; - declare type EventMapCore = {| - ...GlobalEventMap, - +focus: {| +data: void, +canPreventDefault: false |}, - +blur: {| +data: void, +canPreventDefault: false |}, - +beforeRemove: {| - +data: {| +action: GenericNavigationAction |}, - +canPreventDefault: true, - |}, - |}; - declare type EventListenerCallback< - EventName: string, - State: PossiblyStaleNavigationState = NavigationState, - EventMap: EventMapBase = EventMapCore, - > = (e: EventArg< - EventName, - $PropertyType< - $ElementType< - {| ...EventMap, ...EventMapCore |}, - EventName, - >, - 'canPreventDefault', - >, - $PropertyType< - $ElementType< - {| ...EventMap, ...EventMapCore |}, - EventName, - >, - 'data', - >, - >) => mixed; - - /** - * Navigation prop - */ - - declare type PartialWithMergeProperty = $If< - $IsExact, - { ...$Partial, +merge: true }, - { ...$Partial, +merge: true, ... }, - >; - - declare type EitherExactOrPartialWithMergeProperty = - | ParamsType - | PartialWithMergeProperty; - - declare export type SimpleNavigate = - >( - routeName: DestinationRouteName, - params: EitherExactOrPartialWithMergeProperty< - $ElementType, - >, - ) => void; - - declare export type Navigate = - & SimpleNavigate - & >( - route: $If< - $IsUndefined<$ElementType>, - | {| +key: string |} - | {| +name: DestinationRouteName, +key?: string |}, - | {| - +key: string, - +params?: EitherExactOrPartialWithMergeProperty< - $ElementType, - >, - |} - | {| - +name: DestinationRouteName, - +key?: string, - +params?: EitherExactOrPartialWithMergeProperty< - $ElementType, - >, - |}, - >, - ) => void; - - declare type CoreNavigationHelpers< - ParamList: ParamListBase, - State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, - EventMap: EventMapBase = EventMapCore, - > = { - +navigate: Navigate, - +dispatch: ( - action: - | GenericNavigationAction - | (State => GenericNavigationAction), - ) => void, - +reset: PossiblyStaleNavigationState => void, - +goBack: () => void, - +isFocused: () => boolean, - +canGoBack: () => boolean, - +getId: () => string | void, - +getParent: >(id?: string) => ?Parent, - +getState: () => NavigationState, - +addListener: |}, - >>( - name: EventName, - callback: EventListenerCallback, - ) => () => void, - +removeListener: |}, - >>( - name: EventName, - callback: EventListenerCallback, - ) => void, - ... - }; - - declare export type NavigationHelpers< - ParamList: ParamListBase, - State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, - EventMap: EventMapBase = EventMapCore, - > = { - ...$Exact>, - +setParams: (params: ScreenParams) => void, - ... - }; - - declare type SetParamsInput< - ParamList: ParamListBase, - RouteName: $Keys = $Keys, - > = $If< - $IsUndefined<$ElementType>, - empty, - $Partial<$NonMaybeType<$ElementType>>, - >; - - declare export type NavigationProp< - ParamList: ParamListBase, - RouteName: $Keys = $Keys, - State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = { - ...$Exact>, - +setOptions: (options: $Partial) => void, - +setParams: (params: SetParamsInput) => void, - ... - }; - - /** - * CreateNavigator - */ - - declare export type RouteProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - > = {| - ...LeafRoute, - +params: $ElementType, - +path?: string, - |}; - - declare type ScreenOptionsProp< - ScreenOptions: {...}, - RouteParam, - NavHelpers, - > = - | ScreenOptions - | ({| +route: RouteParam, +navigation: NavHelpers |}) => ScreenOptions; - declare export type ScreenListeners< - State: NavigationState = NavigationState, - EventMap: EventMapBase = EventMapCore, - > = $ObjMapi< - {| [name: $Keys]: empty |}, - >(K, empty) => EventListenerCallback, - >; - declare type ScreenListenersProp< - ScreenListenersParam: {...}, - RouteParam, - NavHelpers, - > = - | ScreenListenersParam - | ({| +route: RouteParam, +navigation: NavHelpers |}) => ScreenListenersParam; - - declare type BaseScreenProps< - ParamList: ParamListBase, - NavProp, - RouteName: $Keys = $Keys, - State: NavigationState = NavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = {| - +name: RouteName, - +options?: ScreenOptionsProp< - ScreenOptions, - RouteProp, - NavProp, - >, - +listeners?: ScreenListenersProp< - ScreenListeners, - RouteProp, - NavProp, - >, - +initialParams?: $Partial<$ElementType>, - +getId?: ({ - +params: $ElementType, - }) => string | void, - +navigationKey?: string, - |}; - - declare export type ScreenProps< - ParamList: ParamListBase, - NavProp, - RouteName: $Keys = $Keys, - State: NavigationState = NavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = - | {| - ...BaseScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >, - +component: React$ComponentType<{| - +route: RouteProp, - +navigation: NavProp, - |}>, - |} - | {| - ...BaseScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >, - +getComponent: () => React$ComponentType<{| - +route: RouteProp, - +navigation: NavProp, - |}>, - |} - | {| - ...BaseScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >, - +children: ({| - +route: RouteProp, - +navigation: NavProp, - |}) => React$Node, - |}; - - declare export type ScreenComponent< - GlobalParamList: ParamListBase, - ParamList: ParamListBase, - State: NavigationState = NavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = < - RouteName: $Keys, - NavProp: NavigationProp< - GlobalParamList, - RouteName, - State, - ScreenOptions, - EventMap, - >, - >(props: ScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >) => React$Node; - - declare type ScreenOptionsProps< - ScreenOptions: {...}, - RouteParam, - NavHelpers, - > = {| - +screenOptions?: ScreenOptionsProp, - |}; - declare type ScreenListenersProps< - ScreenListenersParam: {...}, - RouteParam, - NavHelpers, - > = {| - +screenListeners?: ScreenListenersProp< - ScreenListenersParam, - RouteParam, - NavHelpers, - >, - |}; - declare export type ExtraNavigatorPropsBase = { - ...$Exact, - +id?: string, - +children?: React$Node, - ... - }; - declare export type NavigatorProps< - ScreenOptions: {...}, - ScreenListenersParam, - RouteParam, - NavHelpers, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - > = { - ...$Exact, - ...ScreenOptionsProps, - ...ScreenListenersProps, - +defaultScreenOptions?: - | ScreenOptions - | ({| - +route: RouteParam, - +navigation: NavHelpers, - +options: ScreenOptions, - |}) => ScreenOptions, - ... - }; - declare export type NavigatorPropsBase< - ScreenOptions: {...}, - ScreenListenersParam: {...}, - NavHelpers, - > = NavigatorProps< - ScreenOptions, - ScreenListenersParam, - RouteProp<>, - NavHelpers, - ExtraNavigatorPropsBase, - >; - - declare export type CreateNavigator< - State: NavigationState, - ScreenOptions: {...}, - EventMap: EventMapBase, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - > = < - GlobalParamList: ParamListBase, - ParamList: ParamListBase, - NavHelpers: NavigationHelpers< - GlobalParamList, - State, - EventMap, - >, - >() => {| - +Screen: ScreenComponent< - GlobalParamList, - ParamList, - State, - ScreenOptions, - EventMap, - >, - +Navigator: React$ComponentType<$Exact, - RouteProp, - NavHelpers, - ExtraNavigatorProps, - >>>, - +Group: React$ComponentType<{| - ...ScreenOptionsProps, NavHelpers>, - +children: React$Node, - +navigationKey?: string, - |}>, - |}; - - declare export type CreateNavigatorFactory = < - State: NavigationState, - ScreenOptions: {...}, - EventMap: EventMapBase, - NavHelpers: NavigationHelpers< - ParamListBase, - State, - EventMap, - >, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - >( - navigator: React$ComponentType<$Exact, - RouteProp<>, - NavHelpers, - ExtraNavigatorProps, - >>>, - ) => CreateNavigator; - - - /** - * useNavigationBuilder - */ - - declare export type Descriptor< - NavHelpers, - ScreenOptions: {...} = {...}, - > = {| - +render: () => React$Node, - +options: $ReadOnly, - +navigation: NavHelpers, - |}; - - declare export type UseNavigationBuilder = < - State: NavigationState, - Action: GenericNavigationAction, - ScreenOptions: {...}, - RouterOptions: DefaultRouterOptions, - NavHelpers, - EventMap: EventMapBase, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - >( - routerFactory: RouterFactory, - options: $Exact, - RouteProp<>, - NavHelpers, - ExtraNavigatorProps, - >>, - ) => {| - +id?: string, - +state: State, - +descriptors: {| +[key: string]: Descriptor |}, - +navigation: NavHelpers, - |}; - - /** - * EdgeInsets - */ - - declare type EdgeInsets = {| - +top: number, - +right: number, - +bottom: number, - +left: number, - |}; - - /** - * TransitionPreset - */ - - declare export type TransitionSpec = - | {| - animation: 'spring', - config: $Diff< - SpringAnimationConfigSingle, - { toValue: number | AnimatedValue, ... }, - >, - |} - | {| - animation: 'timing', - config: $Diff< - TimingAnimationConfigSingle, - { toValue: number | AnimatedValue, ... }, - >, - |}; - - declare export type StackCardInterpolationProps = {| - +current: {| - +progress: AnimatedInterpolation, - |}, - +next?: {| - +progress: AnimatedInterpolation, - |}, - +index: number, - +closing: AnimatedInterpolation, - +swiping: AnimatedInterpolation, - +inverted: AnimatedInterpolation, - +layouts: {| - +screen: {| +width: number, +height: number |}, - |}, - +insets: EdgeInsets, - |}; - declare export type StackCardInterpolatedStyle = {| - containerStyle?: AnimatedViewStyleProp, - cardStyle?: AnimatedViewStyleProp, - overlayStyle?: AnimatedViewStyleProp, - shadowStyle?: AnimatedViewStyleProp, - |}; - declare export type StackCardStyleInterpolator = ( - props: StackCardInterpolationProps, - ) => StackCardInterpolatedStyle; - - declare export type StackHeaderInterpolationProps = {| - +current: {| - +progress: AnimatedInterpolation, - |}, - +next?: {| - +progress: AnimatedInterpolation, - |}, - +layouts: {| - +header: {| +width: number, +height: number |}, - +screen: {| +width: number, +height: number |}, - +title?: {| +width: number, +height: number |}, - +leftLabel?: {| +width: number, +height: number |}, - |}, - |}; - declare export type StackHeaderInterpolatedStyle = {| - leftLabelStyle?: AnimatedViewStyleProp, - leftButtonStyle?: AnimatedViewStyleProp, - rightButtonStyle?: AnimatedViewStyleProp, - titleStyle?: AnimatedViewStyleProp, - backgroundStyle?: AnimatedViewStyleProp, - |}; - declare export type StackHeaderStyleInterpolator = ( - props: StackHeaderInterpolationProps, - ) => StackHeaderInterpolatedStyle; - - declare type GestureDirection = - | 'horizontal' - | 'horizontal-inverted' - | 'vertical' - | 'vertical-inverted'; - - declare export type TransitionPreset = {| - +gestureDirection: GestureDirection, - +transitionSpec: {| - +open: TransitionSpec, - +close: TransitionSpec, - |}, - +cardStyleInterpolator: StackCardStyleInterpolator, - +headerStyleInterpolator: StackHeaderStyleInterpolator, - |}; - - /** - * Header common options - */ - - declare export type SceneProgress = {| - +current: AnimatedInterpolation, - +next?: AnimatedInterpolation, - +previous?: AnimatedInterpolation, - |}; - - declare export type HeaderProps = {| - +navigation: NavProp, - +route: RouteProp<>, - +options: ScreenOptions, - +layout: {| +width: number, +height: number |}, - |}; - - declare export type HeaderButtonProps = $Partial<{| - +tintColor: string, - +pressColor: string, - +pressOpacity: number, - |}>; - - declare export type HeaderLeftButtonProps = $Partial<{| - ...HeaderButtonProps, - +labelVisible: boolean, - |}>; - - declare type HeaderTitleInputBase = { - +onLayout: LayoutEvent => void, - +children: string, - +allowFontScaling: ?boolean, - +tintColor: ?string, - +style: ?AnimatedTextStyleProp, - ... - }; - - declare export type HeaderTitleInputProps = - $Exact; - - declare export type HeaderCommonOptions< - NavHeaderProps, - NavHeaderLeftProps, - NavHeaderRightProps, - > = $Partial<{| - +header: NavHeaderProps => React$Node, - +headerShown: boolean, - +headerTitle: string | ( HeaderTitleInputProps => React$Node), - +headerTitleAlign: 'left' | 'center', - +headerTitleStyle: AnimatedTextStyleProp, - +headerTitleContainerStyle: AnimatedViewStyleProp, - +headerTintColor: string, - +headerTitleAllowFontScaling: boolean, - +headerLeft: NavHeaderLeftProps => React$Node, - +headerLeftContainerStyle: AnimatedViewStyleProp, - +headerRight: NavHeaderRightProps => React$Node, - +headerRightContainerStyle: AnimatedViewStyleProp, - +headerBackground: ({| style: AnimatedViewStyleProp |}) => React$Node, - +headerStyle: AnimatedViewStyleProp, - +headerTransparent: boolean, - +headerStatusBarHeight: number, - +headerShadowVisible: boolean, - +headerBackgroundContainerStyle: AnimatedViewStyleProp, - +headerPressColor: string, - +headerPressOpacity: number, - |}>; - - /** - * Stack options - */ - - declare export type StackDescriptor = Descriptor< - StackNavigationHelpers<>, - StackOptions, - >; - - declare type Scene = {| - +route: T, - +descriptor: StackDescriptor, - +progress: SceneProgress, - |}; - - declare export type StackHeaderProps = {| - ...HeaderProps, StackOptions>, - +progress: SceneProgress, - +back?: {| +title: string |}, - +styleInterpolator: StackHeaderStyleInterpolator, - |}; - - declare export type StackHeaderButtonProps = $Partial<{| - ...HeaderButtonProps, - +canGoBack: boolean, - |}>; - - declare export type StackHeaderLeftButtonProps = $Partial<{| - ...StackHeaderButtonProps, - +onPress: (() => void), - +backImage: (props: {| tintColor: string |}) => React$Node, - +label: string, - +truncatedLabel: string, - +labelVisible: boolean, - +labelStyle: AnimatedTextStyleProp, - +allowFontScaling: boolean, - +onLabelLayout: LayoutEvent => void, - +screenLayout: {| +width: number, +height: number |}, - +titleLayout: {| +width: number, +height: number |}, - +disabled: boolean, - +accessibilityLabel: string, - +style: ViewStyleProp, - |}>; - - declare export type StackOptions = $Partial<{| - +title: string, - +cardShadowEnabled: boolean, - +cardOverlayEnabled: boolean, - +cardOverlay: {| style: ViewStyleProp |} => React$Node, - +cardStyle: ViewStyleProp, - +animationEnabled: boolean, - +animationTypeForReplace: 'push' | 'pop', - +gestureEnabled: boolean, - +gestureResponseDistance: number, - +gestureVelocityImpact: number, - +safeAreaInsets: $Partial, - +keyboardHandlingEnabled: boolean, - +presentation: 'card' | 'modal' | 'transparentModal', - // Transition - ...TransitionPreset, - // Header - ...HeaderCommonOptions< - StackHeaderProps, - StackHeaderLeftButtonProps, - StackHeaderButtonProps, - >, - +headerMode: 'float' | 'screen', - +headerBackAllowFontScaling: boolean, - +headerBackTitle: string | null, - +headerBackTitleStyle: TextStyleProp, - +headerBackTitleVisible: boolean, - +headerTruncatedBackTitle: string, - +headerBackImage: $PropertyType, - +headerBackAccessibilityLabel: string, - |}>; - - /** - * Stack navigation prop - */ - - declare export type StackNavigationEventMap = {| - ...EventMapCore, - +transitionStart: {| - +data: {| +closing: boolean |}, - +canPreventDefault: false, - |}, - +transitionEnd: {| - +data: {| +closing: boolean |}, - +canPreventDefault: false, - |}, - +gestureStart: {| +data: void, +canPreventDefault: false |}, - +gestureEnd: {| +data: void, +canPreventDefault: false |}, - +gestureCancel: {| +data: void, +canPreventDefault: false |}, - |}; - - declare type StackExtraNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - > = {| - +replace: SimpleNavigate, - +push: SimpleNavigate, - +pop: (count?: number) => void, - +popToTop: () => void, - |}; - - declare export type StackNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = StackNavigationEventMap, - > = { - ...$Exact>, - ...StackExtraNavigationHelpers, - ... - }; - - declare export type StackNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = StackOptions, - EventMap: EventMapBase = StackNavigationEventMap, - > = {| - ...$Exact>, - ...StackExtraNavigationHelpers, - |}; - - /** - * Miscellaneous stack exports - */ - - declare type StackNavigationConfig = {| - +detachInactiveScreens?: boolean, - |}; - - declare export type ExtraStackNavigatorProps = {| - ...$Exact, - ...StackRouterOptions, - ...StackNavigationConfig, - |}; - - declare export type StackNavigatorProps< - NavHelpers: StackNavigationHelpers<> = StackNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraStackNavigatorProps, - >>; - - /** - * Bottom tab options - */ - - declare export type BottomTabBarButtonProps = {| - ...$Diff< - TouchableWithoutFeedbackProps, - {| onPress?: ?(event: PressEvent) => mixed |}, - >, - +to?: string, - +children: React$Node, - +onPress?: (MouseEvent | PressEvent) => void, - |}; - - declare export type TabBarVisibilityAnimationConfig = - | {| - +animation: 'spring', - +config?: $Diff< - SpringAnimationConfigSingle, - { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, - >, - |} - | {| - +animation: 'timing', - +config?: $Diff< - TimingAnimationConfigSingle, - { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, - >, - |}; - - declare export type BottomTabOptions = $Partial<{| - +title: string, - +tabBarLabel: - | string - | ({| focused: boolean, color: string |}) => React$Node, - +tabBarIcon: ({| - focused: boolean, - color: string, - size: number, - |}) => React$Node, - +tabBarBadge: number | string, - +tabBarBadgeStyle: TextStyleProp, - +tabBarAccessibilityLabel: string, - +tabBarTestID: string, - +tabBarVisibilityAnimationConfig: $Partial<{| - +show: TabBarVisibilityAnimationConfig, - +hide: TabBarVisibilityAnimationConfig, - |}>, - +tabBarButton: BottomTabBarButtonProps => React$Node, - +tabBarHideOnKeyboard: boolean, - +tabBarActiveTintColor: string, - +tabBarInactiveTintColor: string, - +tabBarActiveBackgroundColor: string, - +tabBarInactiveBackgroundColor: string, - +tabBarAllowFontScaling: boolean, - +tabBarShowLabel: boolean, - +tabBarLabelStyle: TextStyleProp, - +tabBarIconStyle: TextStyleProp, - +tabBarItemStyle: ViewStyleProp, - +tabBarLabelPosition: 'beside-icon' | 'below-icon', - +tabBarStyle: ViewStyleProp, - +unmountOnBlur: boolean, - +lazy: boolean, - ...HeaderCommonOptions< - HeaderProps, BottomTabOptions>, - HeaderLeftButtonProps, - HeaderButtonProps, - >, - |}>; - - /** - * Bottom tab navigation prop - */ - - declare export type BottomTabNavigationEventMap = {| - ...EventMapCore, - +tabPress: {| +data: void, +canPreventDefault: true |}, - +tabLongPress: {| +data: void, +canPreventDefault: false |}, - |}; - - declare type TabExtraNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - > = {| - +jumpTo: SimpleNavigate, - |}; - - declare export type BottomTabNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = BottomTabNavigationEventMap, - > = { - ...$Exact>, - ...TabExtraNavigationHelpers, - ... - }; - - declare export type BottomTabNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = BottomTabOptions, - EventMap: EventMapBase = BottomTabNavigationEventMap, - > = {| - ...$Exact>, - ...TabExtraNavigationHelpers, - |}; - - /** - * Miscellaneous bottom tab exports - */ - - declare export type BottomTabDescriptor = Descriptor< - BottomTabNavigationHelpers<>, - BottomTabOptions, - >; - - declare type BottomTabNavigationBuilderResult = {| - +state: TabNavigationState, - +navigation: BottomTabNavigationHelpers<>, - +descriptors: {| +[key: string]: BottomTabDescriptor |}, - |}; - - declare export type BottomTabBarProps = BottomTabNavigationBuilderResult; - - declare type BottomTabNavigationConfig = {| - +tabBar?: BottomTabBarProps => React$Node, - +safeAreaInsets?: $Partial, - +detachInactiveScreens?: boolean, - |}; - - declare export type ExtraBottomTabNavigatorProps = {| - ...$Exact, - ...TabRouterOptions, - ...BottomTabNavigationConfig, - |}; - - declare export type BottomTabNavigatorProps< - NavHelpers: BottomTabNavigationHelpers<> = BottomTabNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraBottomTabNavigatorProps, - >>; - - /** - * Material bottom tab options - */ - - declare export type MaterialBottomTabOptions = $Partial<{| - +title: string, - +tabBarColor: string, - +tabBarLabel: string, - +tabBarIcon: - | string - | ({| +focused: boolean, +color: string |}) => React$Node, - +tabBarBadge: boolean | number | string, - +tabBarAccessibilityLabel: string, - +tabBarTestID: string, - |}>; - - /** - * Material bottom tab navigation prop - */ - - declare export type MaterialBottomTabNavigationEventMap = {| - ...EventMapCore, - +tabPress: {| +data: void, +canPreventDefault: true |}, - |}; - - declare export type MaterialBottomTabNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, - > = { - ...$Exact>, - ...TabExtraNavigationHelpers, - ... - }; - - declare export type MaterialBottomTabNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = MaterialBottomTabOptions, - EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, - > = {| - ...$Exact>, - ...TabExtraNavigationHelpers, - |}; - - /** - * Miscellaneous material bottom tab exports - */ - - declare export type PaperFont = {| - +fontFamily: string, - +fontWeight?: - | 'normal' - | 'bold' - | '100' - | '200' - | '300' - | '400' - | '500' - | '600' - | '700' - | '800' - | '900', - |}; - - declare export type PaperFonts = {| - +regular: PaperFont, - +medium: PaperFont, - +light: PaperFont, - +thin: PaperFont, - |}; - - declare export type PaperTheme = {| - +dark: boolean, - +mode?: 'adaptive' | 'exact', - +roundness: number, - +colors: {| - +primary: string, - +background: string, - +surface: string, - +accent: string, - +error: string, - +text: string, - +onSurface: string, - +onBackground: string, - +disabled: string, - +placeholder: string, - +backdrop: string, - +notification: string, - |}, - +fonts: PaperFonts, - +animation: {| - +scale: number, - |}, - |}; - - declare export type PaperRoute = {| - +key: string, - +title?: string, - +icon?: any, - +badge?: string | number | boolean, - +color?: string, - +accessibilityLabel?: string, - +testID?: string, - |}; - - declare export type PaperTouchableProps = {| - ...TouchableWithoutFeedbackProps, - +key: string, - +route: PaperRoute, - +children: React$Node, - +borderless?: boolean, - +centered?: boolean, - +rippleColor?: string, - |}; - - declare export type MaterialBottomTabNavigationConfig = {| - +shifting?: boolean, - +labeled?: boolean, - +renderTouchable?: PaperTouchableProps => React$Node, - +activeColor?: string, - +inactiveColor?: string, - +sceneAnimationEnabled?: boolean, - +keyboardHidesNavigationBar?: boolean, - +barStyle?: ViewStyleProp, - +style?: ViewStyleProp, - +theme?: PaperTheme, - |}; - - declare export type ExtraMaterialBottomTabNavigatorProps = {| - ...$Exact, - ...TabRouterOptions, - ...MaterialBottomTabNavigationConfig, - |}; - - declare export type MaterialBottomTabNavigatorProps< - NavHelpers: MaterialBottomTabNavigationHelpers<> = - MaterialBottomTabNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraMaterialBottomTabNavigatorProps, - >>; - - /** - * Material top tab options - */ - - declare export type MaterialTopTabOptions = $Partial<{| - +title: string, - +tabBarLabel: - | string - | ({| +focused: boolean, +color: string |}) => React$Node, - +tabBarIcon: ({| +focused: boolean, +color: string |}) => React$Node, - +tabBarAccessibilityLabel: string, - +tabBarTestID: string, - +tabBarActiveTintColor: string, - +tabBarInactiveTintColor: string, - +tabBarPressColor: string, - +tabBarPressOpacity: number, - +tabBarShowLabel: boolean, - +tabBarShowIcon: boolean, - +tabBarAllowFontScaling: boolean, - +tabBarBounces: boolean, - +tabBarScrollEnabled: boolean, - +tabBarIconStyle: ViewStyleProp, - +tabBarLabelStyle: TextStyleProp, - +tabBarItemStyle: ViewStyleProp, - +tabBarIndicatorStyle: ViewStyleProp, - +tabBarIndicatorContainerStyle: ViewStyleProp, - +tabBarContentContainerStyle: ViewStyleProp, - +tabBarStyle: ViewStyleProp, - +tabBarBadge: () => React$Node, - +tabBarIndicator: MaterialTopTabBarIndicatorProps => React$Node, - +lazy: boolean, - +lazyPlaceholder: ({| +route: Route<> |}) => React$Node, - |}>; - - /** - * Material top tab navigation prop - */ - - declare export type MaterialTopTabNavigationEventMap = {| - ...EventMapCore, - +tabPress: {| +data: void, +canPreventDefault: true |}, - +tabLongPress: {| +data: void, +canPreventDefault: false |}, - +swipeStart: {| +data: void, +canPreventDefault: false |}, - +swipeEnd: {| +data: void, +canPreventDefault: false |}, - |}; - - declare export type MaterialTopTabNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = MaterialTopTabNavigationEventMap, - > = { - ...$Exact>, - ...TabExtraNavigationHelpers, - ... - }; - - declare export type MaterialTopTabNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = MaterialTopTabOptions, - EventMap: EventMapBase = MaterialTopTabNavigationEventMap, - > = {| - ...$Exact>, - ...TabExtraNavigationHelpers, - |}; - - /** - * Miscellaneous material top tab exports - */ - - declare type MaterialTopTabPagerCommonProps = {| - +keyboardDismissMode: 'none' | 'on-drag' | 'auto', - +swipeEnabled: boolean, - +swipeVelocityImpact?: number, - +springVelocityScale?: number, - +springConfig: $Partial<{| - +damping: number, - +mass: number, - +stiffness: number, - +restSpeedThreshold: number, - +restDisplacementThreshold: number, - |}>, - +timingConfig: $Partial<{| - +duration: number, - |}>, - |}; - - declare export type MaterialTopTabPagerProps = {| - ...MaterialTopTabPagerCommonProps, - +onSwipeStart?: () => void, - +onSwipeEnd?: () => void, - +onIndexChange: (index: number) => void, - +navigationState: TabNavigationState, - +layout: {| +width: number, +height: number |}, - +removeClippedSubviews: boolean, - +children: ({| - +addListener: (type: 'enter', listener: number => void) => void, - +removeListener: (type: 'enter', listener: number => void) => void, - +position: any, // Reanimated.Node - +render: React$Node => React$Node, - +jumpTo: string => void, - |}) => React$Node, - +gestureHandlerProps: PanGestureHandlerProps, - |}; - - declare export type MaterialTopTabBarIndicatorProps = {| - +state: TabNavigationState, - +width: string, - +style?: ViewStyleProp, - +getTabWidth: number => number, - |}; - - declare export type MaterialTopTabDescriptor = Descriptor< - MaterialBottomTabNavigationHelpers<>, - MaterialBottomTabOptions, - >; - - declare type MaterialTopTabNavigationBuilderResult = {| - +state: TabNavigationState, - +navigation: MaterialTopTabNavigationHelpers<>, - +descriptors: {| +[key: string]: MaterialTopTabDescriptor |}, - |}; - - declare export type MaterialTopTabBarProps = {| - ...MaterialTopTabNavigationBuilderResult, - +layout: {| +width: number, +height: number |}, - +position: any, // Reanimated.Node - +jumpTo: string => void, - |}; - - declare export type MaterialTopTabNavigationConfig = {| - ...$Partial, - +position?: any, // Reanimated.Value - +tabBarPosition?: 'top' | 'bottom', - +initialLayout?: $Partial<{| +width: number, +height: number |}>, - +lazyPreloadDistance?: number, - +removeClippedSubviews?: boolean, - +sceneContainerStyle?: ViewStyleProp, - +style?: ViewStyleProp, - +gestureHandlerProps?: PanGestureHandlerProps, - +pager?: MaterialTopTabPagerProps => React$Node, - +tabBar?: MaterialTopTabBarProps => React$Node, - |}; - - declare export type ExtraMaterialTopTabNavigatorProps = {| - ...$Exact, - ...TabRouterOptions, - ...MaterialTopTabNavigationConfig, - |}; - - declare export type MaterialTopTabNavigatorProps< - NavHelpers: MaterialTopTabNavigationHelpers<> = - MaterialTopTabNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraMaterialTopTabNavigatorProps, - >>; - - /** - * Drawer options - */ - - declare export type DrawerOptions = $Partial<{| - +title: string, - +lazy: boolean, - +drawerLabel: - | string - | ({| +color: string, +focused: boolean |}) => React$Node, - +drawerIcon: ({| - +color: string, - +size: number, - +focused: boolean, - |}) => React$Node, - +drawerActiveTintColor: string, - +drawerActiveBackgroundColor: string, - +drawerInactiveTintColor: string, - +drawerInactiveBackgroundColor: string, - +drawerItemStyle: ViewStyleProp, - +drawerLabelStyle: TextStyleProp, - +drawerContentContainerStyle: ViewStyleProp, - +drawerContentStyle: ViewStyleProp, - +drawerStyle: ViewStyleProp, - +drawerPosition: 'left' | 'right', - +drawerType: 'front' | 'back' | 'slide' | 'permanent', - +drawerHideStatusBarOnOpen: boolean, - +drawerStatusBarAnimation: 'slide' | 'none' | 'fade', - +overlayColor: string, - +sceneContainerStyle: ViewStyleProp, - +gestureHandlerProps: PanGestureHandlerProps, - +swipeEnabled: boolean, - +swipeEdgeWidth: number, - +swipeMinDistance: number, - +keyboardDismissMode: 'on-drag' | 'none', - +unmountOnBlur: boolean, - ...HeaderCommonOptions< - HeaderProps, DrawerOptions>, - HeaderLeftButtonProps, - HeaderButtonProps, - >, - |}>; - - /** - * Drawer navigation prop - */ - - declare export type DrawerNavigationEventMap = - EventMapCore; - - declare type DrawerExtraNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - > = {| - +jumpTo: SimpleNavigate, - +openDrawer: () => void, - +closeDrawer: () => void, - +toggleDrawer: () => void, - |}; - - declare export type DrawerNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = DrawerNavigationEventMap, - > = { - ...$Exact>, - ...DrawerExtraNavigationHelpers, - ... - }; - - declare export type DrawerNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = DrawerOptions, - EventMap: EventMapBase = DrawerNavigationEventMap, - > = {| - ...$Exact>, - ...DrawerExtraNavigationHelpers, - |}; - - /** - * Miscellaneous drawer exports - */ - - declare export type DrawerDescriptor = Descriptor< - DrawerNavigationHelpers<>, - DrawerOptions, - >; - - declare type DrawerNavigationBuilderResult = {| - +state: DrawerNavigationState, - +navigation: DrawerNavigationHelpers<>, - +descriptors: {| +[key: string]: DrawerDescriptor |}, - |}; - - declare export type DrawerNavigationConfig = {| - +drawerContent?: DrawerNavigationBuilderResult => React$Node, - +detachInactiveScreens?: boolean, - +useLegacyImplementation?: boolean, - |}; - - declare export type ExtraDrawerNavigatorProps = {| - ...$Exact, - ...DrawerRouterOptions, - ...DrawerNavigationConfig, - |}; - - declare export type DrawerNavigatorProps< - NavHelpers: DrawerNavigationHelpers<> = DrawerNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraDrawerNavigatorProps, - >>; - - /** - * BaseNavigationContainer - */ - - declare export type BaseNavigationContainerProps = {| - +children: React$Node, - +initialState?: PossiblyStaleNavigationState, - +onStateChange?: (state: ?PossiblyStaleNavigationState) => void, - +independent?: boolean, - |}; - - declare export type ContainerEventMap = {| - ...GlobalEventMap, - +options: {| - +data: {| +options: { +[key: string]: mixed, ... } |}, - +canPreventDefault: false, - |}, - +__unsafe_action__: {| - +data: {| - +action: GenericNavigationAction, - +noop: boolean, - |}, - +canPreventDefault: false, - |}, - |}; - - declare export type BaseNavigationContainerInterface = {| - ...$Exact>, - +resetRoot: (state?: PossiblyStaleNavigationState) => void, - +getRootState: () => NavigationState, - +getCurrentRoute: () => RouteProp<> | void, - +getCurrentOptions: () => Object | void, - +isReady: () => boolean, - |}; - - declare type BaseNavigationContainerInterfaceRef = {| - ...BaseNavigationContainerInterface, - +current: BaseNavigationContainerInterface | null, - |}; - - /** - * State utils - */ - - declare export type GetStateFromPath = ( - path: string, - options?: LinkingConfig, - ) => PossiblyStaleNavigationState; - - declare export type GetPathFromState = ( - state?: ?PossiblyStaleNavigationState, - options?: LinkingConfig, - ) => string; - - declare export type GetFocusedRouteNameFromRoute = - PossiblyStaleRoute => ?string; - - /** - * Linking - */ - - declare export type ScreenLinkingConfig = {| - +path?: string, - +exact?: boolean, - +parse?: {| +[param: string]: string => mixed |}, - +stringify?: {| +[param: string]: mixed => string |}, - +screens?: ScreenLinkingConfigMap, - +initialRouteName?: string, - |}; - - declare export type ScreenLinkingConfigMap = {| - +[routeName: string]: string | ScreenLinkingConfig, - |}; - - declare export type LinkingConfig = {| - +initialRouteName?: string, - +screens: ScreenLinkingConfigMap, - |}; - - declare export type LinkingOptions = {| - +enabled?: boolean, - +prefixes: $ReadOnlyArray, - +config?: LinkingConfig, - +getStateFromPath?: GetStateFromPath, - +getPathFromState?: GetPathFromState, - |}; - - /** - * NavigationContainer - */ - - declare export type Theme = {| - +dark: boolean, - +colors: {| - +primary: string, - +background: string, - +card: string, - +text: string, - +border: string, - |}, - |}; - - declare export type NavigationContainerType = React$AbstractComponent< - {| - ...BaseNavigationContainerProps, - +theme?: Theme, - +linking?: LinkingOptions, - +fallback?: React$Node, - +onReady?: () => mixed, - |}, - BaseNavigationContainerInterface, - >; - - //--------------------------------------------------------------------------- - // SECTION 2: EXPORTED MODULE - // This section defines the module exports and contains exported types that - // are not present in any other React Navigation libdef. - //--------------------------------------------------------------------------- - declare export function useReduxDevToolsExtension( container: { +current: ?React$ElementRef, ... }, ): void; diff --git a/native/flow-typed/npm/@react-navigation/drawer_v6.x.x.js b/native/flow-typed/npm/@react-navigation/drawer_v6.x.x.js --- a/native/flow-typed/npm/@react-navigation/drawer_v6.x.x.js +++ b/native/flow-typed/npm/@react-navigation/drawer_v6.x.x.js @@ -3,2263 +3,18 @@ declare module '@react-navigation/drawer' { - //--------------------------------------------------------------------------- - // SECTION 1: IDENTICAL TYPE DEFINITIONS - // This section is identical across all React Navigation libdefs and contains - // shared definitions. We wish we could make it DRY and import from a shared - // definition, but that isn't yet possible. - //--------------------------------------------------------------------------- - - /** - * We start with some definitions that we have copy-pasted from React Native - * source files. - */ - - // This is a bastardization of the true StyleObj type located in - // react-native/Libraries/StyleSheet/StyleSheetTypes. We unfortunately can't - // import that here, and it's too lengthy (and consequently too brittle) to - // copy-paste here either. - declare type StyleObj = - | null - | void - | number - | false - | '' - | $ReadOnlyArray - | { [name: string]: any, ... }; - declare type ViewStyleProp = StyleObj; - declare type TextStyleProp = StyleObj; - declare type AnimatedViewStyleProp = StyleObj; - declare type AnimatedTextStyleProp = StyleObj; - - // Vaguely copied from - // react-native/Libraries/Animated/src/animations/Animation.js - declare type EndResult = { finished: boolean, ... }; - declare type EndCallback = (result: EndResult) => void; - declare interface Animation { - start( - fromValue: number, - onUpdate: (value: number) => void, - onEnd: ?EndCallback, - previousAnimation: ?Animation, - animatedValue: AnimatedValue, - ): void; - stop(): void; - } - declare type AnimationConfig = { - isInteraction?: boolean, - useNativeDriver: boolean, - onComplete?: ?EndCallback, - iterations?: number, - ... - }; - - // Vaguely copied from - // react-native/Libraries/Animated/src/nodes/AnimatedTracking.js - declare interface AnimatedTracking { - constructor( - value: AnimatedValue, - parent: any, - animationClass: any, - animationConfig: Object, - callback?: ?EndCallback, - ): void; - update(): void; - } - - // Vaguely copied from - // react-native/Libraries/Animated/src/nodes/AnimatedValue.js - declare type ValueListenerCallback = (state: { value: number, ... }) => void; - declare interface AnimatedValue { - constructor(value: number): void; - setValue(value: number): void; - setOffset(offset: number): void; - flattenOffset(): void; - extractOffset(): void; - addListener(callback: ValueListenerCallback): string; - removeListener(id: string): void; - removeAllListeners(): void; - stopAnimation(callback?: ?(value: number) => void): void; - resetAnimation(callback?: ?(value: number) => void): void; - interpolate(config: InterpolationConfigType): AnimatedInterpolation; - animate(animation: Animation, callback: ?EndCallback): void; - stopTracking(): void; - track(tracking: AnimatedTracking): void; - } - - // Copied from - // react-native/Libraries/Animated/src/animations/TimingAnimation.js - declare type TimingAnimationConfigSingle = AnimationConfig & { - toValue: number | AnimatedValue, - easing?: (value: number) => number, - duration?: number, - delay?: number, - ... - }; - - // Copied from - // react-native/Libraries/Animated/src/animations/SpringAnimation.js - declare type SpringAnimationConfigSingle = AnimationConfig & { - toValue: number | AnimatedValue, - overshootClamping?: boolean, - restDisplacementThreshold?: number, - restSpeedThreshold?: number, - velocity?: number, - bounciness?: number, - speed?: number, - tension?: number, - friction?: number, - stiffness?: number, - damping?: number, - mass?: number, - delay?: number, - ... - }; - - // Copied from react-native/Libraries/Types/CoreEventTypes.js - declare type SyntheticEvent = $ReadOnly<{| - bubbles: ?boolean, - cancelable: ?boolean, - currentTarget: number, - defaultPrevented: ?boolean, - dispatchConfig: $ReadOnly<{| - registrationName: string, - |}>, - eventPhase: ?number, - preventDefault: () => void, - isDefaultPrevented: () => boolean, - stopPropagation: () => void, - isPropagationStopped: () => boolean, - isTrusted: ?boolean, - nativeEvent: T, - persist: () => void, - target: ?number, - timeStamp: number, - type: ?string, - |}>; - declare type Layout = $ReadOnly<{| - x: number, - y: number, - width: number, - height: number, - |}>; - declare type LayoutEvent = SyntheticEvent< - $ReadOnly<{| - layout: Layout, - |}>, - >; - declare type BlurEvent = SyntheticEvent< - $ReadOnly<{| - target: number, - |}>, - >; - declare type FocusEvent = SyntheticEvent< - $ReadOnly<{| - target: number, - |}>, - >; - declare type ResponderSyntheticEvent = $ReadOnly<{| - ...SyntheticEvent, - touchHistory: $ReadOnly<{| - indexOfSingleActiveTouch: number, - mostRecentTimeStamp: number, - numberActiveTouches: number, - touchBank: $ReadOnlyArray< - $ReadOnly<{| - touchActive: boolean, - startPageX: number, - startPageY: number, - startTimeStamp: number, - currentPageX: number, - currentPageY: number, - currentTimeStamp: number, - previousPageX: number, - previousPageY: number, - previousTimeStamp: number, - |}>, - >, - |}>, - |}>; - declare type PressEvent = ResponderSyntheticEvent< - $ReadOnly<{| - changedTouches: $ReadOnlyArray<$PropertyType>, - force: number, - identifier: number, - locationX: number, - locationY: number, - pageX: number, - pageY: number, - target: ?number, - timestamp: number, - touches: $ReadOnlyArray<$PropertyType>, - |}>, - >; - - // Vaguely copied from - // react-native/Libraries/Animated/src/nodes/AnimatedInterpolation.js - declare type ExtrapolateType = 'extend' | 'identity' | 'clamp'; - declare type InterpolationConfigType = { - inputRange: Array, - outputRange: Array | Array, - easing?: (input: number) => number, - extrapolate?: ExtrapolateType, - extrapolateLeft?: ExtrapolateType, - extrapolateRight?: ExtrapolateType, - ... - }; - declare interface AnimatedInterpolation { - interpolate(config: InterpolationConfigType): AnimatedInterpolation; - } - - // Copied from react-native/Libraries/Components/View/ViewAccessibility.js - declare type AccessibilityRole = - | 'none' - | 'button' - | 'link' - | 'search' - | 'image' - | 'keyboardkey' - | 'text' - | 'adjustable' - | 'imagebutton' - | 'header' - | 'summary' - | 'alert' - | 'checkbox' - | 'combobox' - | 'menu' - | 'menubar' - | 'menuitem' - | 'progressbar' - | 'radio' - | 'radiogroup' - | 'scrollbar' - | 'spinbutton' - | 'switch' - | 'tab' - | 'tablist' - | 'timer' - | 'toolbar'; - declare type AccessibilityActionInfo = $ReadOnly<{ - name: string, - label?: string, - ... - }>; - declare type AccessibilityActionEvent = SyntheticEvent< - $ReadOnly<{actionName: string, ...}>, - >; - declare type AccessibilityState = { - disabled?: boolean, - selected?: boolean, - checked?: ?boolean | 'mixed', - busy?: boolean, - expanded?: boolean, - ... - }; - declare type AccessibilityValue = $ReadOnly<{| - min?: number, - max?: number, - now?: number, - text?: string, - |}>; - - // Copied from - // react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js - declare type Stringish = string; - declare type EdgeInsetsProp = $ReadOnly<$Partial>; - declare type TouchableWithoutFeedbackProps = $ReadOnly<{| - accessibilityActions?: ?$ReadOnlyArray, - accessibilityElementsHidden?: ?boolean, - accessibilityHint?: ?Stringish, - accessibilityIgnoresInvertColors?: ?boolean, - accessibilityLabel?: ?Stringish, - accessibilityLiveRegion?: ?('none' | 'polite' | 'assertive'), - accessibilityRole?: ?AccessibilityRole, - accessibilityState?: ?AccessibilityState, - accessibilityValue?: ?AccessibilityValue, - accessibilityViewIsModal?: ?boolean, - accessible?: ?boolean, - children?: ?React$Node, - delayLongPress?: ?number, - delayPressIn?: ?number, - delayPressOut?: ?number, - disabled?: ?boolean, - focusable?: ?boolean, - hitSlop?: ?EdgeInsetsProp, - importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'), - nativeID?: ?string, - onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed, - onBlur?: ?(event: BlurEvent) => mixed, - onFocus?: ?(event: FocusEvent) => mixed, - onLayout?: ?(event: LayoutEvent) => mixed, - onLongPress?: ?(event: PressEvent) => mixed, - onPress?: ?(event: PressEvent) => mixed, - onPressIn?: ?(event: PressEvent) => mixed, - onPressOut?: ?(event: PressEvent) => mixed, - pressRetentionOffset?: ?EdgeInsetsProp, - rejectResponderTermination?: ?boolean, - testID?: ?string, - touchSoundDisabled?: ?boolean, - |}>; - - // Copied from react-native/Libraries/Image/ImageSource.js - declare type ImageURISource = $ReadOnly<{ - uri?: ?string, - bundle?: ?string, - method?: ?string, - headers?: ?Object, - body?: ?string, - cache?: ?('default' | 'reload' | 'force-cache' | 'only-if-cached'), - width?: ?number, - height?: ?number, - scale?: ?number, - ... - }>; - - /** - * The following is copied from react-native-gesture-handler's libdef - */ - - declare type StateUndetermined = 0; - declare type StateFailed = 1; - declare type StateBegan = 2; - declare type StateCancelled = 3; - declare type StateActive = 4; - declare type StateEnd = 5; - - declare type GestureHandlerState = - | StateUndetermined - | StateFailed - | StateBegan - | StateCancelled - | StateActive - | StateEnd; - - declare type $SyntheticEvent = { - +nativeEvent: $ReadOnly<$Exact>, - ... - }; - - declare type $Event = $SyntheticEvent<{ - handlerTag: number, - numberOfPointers: number, - state: GestureHandlerState, - oldState: GestureHandlerState, - ...$Exact, - ... - }>; - - declare type $EventHandlers = {| - onGestureEvent?: ($Event) => mixed, - onHandlerStateChange?: ($Event) => mixed, - onBegan?: ($Event) => mixed, - onFailed?: ($Event) => mixed, - onCancelled?: ($Event) => mixed, - onActivated?: ($Event) => mixed, - onEnded?: ($Event) => mixed, - |}; - - declare type HitSlop = - | number - | {| - left?: number, - top?: number, - right?: number, - bottom?: number, - vertical?: number, - horizontal?: number, - width?: number, - height?: number, - |} - | {| - width: number, - left: number, - |} - | {| - width: number, - right: number, - |} - | {| - height: number, - top: number, - |} - | {| - height: number, - bottom: number, - |}; - - declare type $GestureHandlerProps< - AdditionalProps: {...}, - ExtraEventsProps: {...} - > = $ReadOnly<{| - ...$Exact, - ...$EventHandlers, - id?: string, - enabled?: boolean, - waitFor?: React$Ref | Array>, - simultaneousHandlers?: React$Ref | Array>, - shouldCancelWhenOutside?: boolean, - minPointers?: number, - hitSlop?: HitSlop, - children?: React$Node, - |}>; - - declare type PanGestureHandlerProps = $GestureHandlerProps< - { - activeOffsetY?: number | [number, number], - activeOffsetX?: number | [number, number], - failOffsetY?: number | [number, number], - failOffsetX?: number | [number, number], - minDist?: number, - minVelocity?: number, - minVelocityX?: number, - minVelocityY?: number, - minPointers?: number, - maxPointers?: number, - avgTouches?: boolean, - ... - }, - { - x: number, - y: number, - absoluteX: number, - absoluteY: number, - translationX: number, - translationY: number, - velocityX: number, - velocityY: number, - ... - } - >; - - /** - * MAGIC - */ - - declare type $If = $Call< - ((true, Then, Else) => Then) & ((false, Then, Else) => Else), - Test, - Then, - Else, - >; - declare type $IsA = $Call< - (Y => true) & (mixed => false), - X, - >; - declare type $IsUndefined = $IsA; - - declare type $Partial = $ReadOnly<$Rest>; - - // If { ...T, ... } counts as a T, then we're inexact - declare type $IsExact = $Call< - (T => false) & (mixed => true), - { ...T, ... }, - >; - - /** - * Actions, state, etc. - */ - - declare export type ScreenParams = { +[key: string]: mixed, ... }; - - declare export type BackAction = {| - +type: 'GO_BACK', - +source?: string, - +target?: string, - |}; - declare export type NavigateAction = {| - +type: 'NAVIGATE', - +payload: - | {| +key: string, +params?: ScreenParams |} - | {| +name: string, +key?: string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type ResetAction = {| - +type: 'RESET', - +payload: StaleNavigationState, - +source?: string, - +target?: string, - |}; - declare export type SetParamsAction = {| - +type: 'SET_PARAMS', - +payload: {| +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type CommonAction = - | BackAction - | NavigateAction - | ResetAction - | SetParamsAction; - - declare type NavigateActionCreator = {| - (routeName: string, params?: ScreenParams): NavigateAction, - ( - | {| +key: string, +params?: ScreenParams |} - | {| +name: string, +key?: string, +params?: ScreenParams |}, - ): NavigateAction, - |}; - declare export type CommonActionsType = {| - +navigate: NavigateActionCreator, - +goBack: () => BackAction, - +reset: (state: PossiblyStaleNavigationState) => ResetAction, - +setParams: (params: ScreenParams) => SetParamsAction, - |}; - - declare export type GenericNavigationAction = {| - +type: string, - +payload?: { +[key: string]: mixed, ... }, - +source?: string, - +target?: string, - |}; - - declare export type LeafRoute = {| - +key: string, - +name: RouteName, - +params?: ScreenParams, - |}; - declare export type StateRoute = {| - ...LeafRoute, - +state: NavigationState | StaleNavigationState, - |}; - declare export type Route = - | LeafRoute - | StateRoute; - - declare export type NavigationState = {| - +key: string, - +index: number, - +routeNames: $ReadOnlyArray, - +history?: $ReadOnlyArray, - +routes: $ReadOnlyArray>, - +type: string, - +stale: false, - |}; - - declare export type StaleLeafRoute = {| - +key?: string, - +name: RouteName, - +params?: ScreenParams, - |}; - declare export type StaleStateRoute = {| - ...StaleLeafRoute, - +state: StaleNavigationState, - |}; - declare export type StaleRoute = - | StaleLeafRoute - | StaleStateRoute; - declare export type StaleNavigationState = {| - // It's possible to pass React Nav a StaleNavigationState with an undefined - // index, but React Nav will always return one with the index set. This is - // the same as for the type property below, but in the case of index we tend - // to rely on it being set more... - +index: number, - +history?: $ReadOnlyArray, - +routes: $ReadOnlyArray>, - +type?: string, - +stale?: true, - |}; - - declare export type PossiblyStaleNavigationState = - | NavigationState - | StaleNavigationState; - declare export type PossiblyStaleRoute = - | Route - | StaleRoute; - - /** - * Routers - */ - - declare type ActionCreators< - State: NavigationState, - Action: GenericNavigationAction, - > = { - +[key: string]: (...args: any) => (Action | State => Action), - ... - }; - - declare export type DefaultRouterOptions = { - +initialRouteName?: string, - ... - }; - - declare export type RouterFactory< - State: NavigationState, - Action: GenericNavigationAction, - RouterOptions: DefaultRouterOptions, - > = (options: RouterOptions) => Router; - - declare export type ParamListBase = { +[key: string]: ?ScreenParams, ... }; - - declare export type RouterConfigOptions = {| - +routeNames: $ReadOnlyArray, - +routeParamList: ParamListBase, - |}; - - declare export type Router< - State: NavigationState, - Action: GenericNavigationAction, - > = {| - +type: $PropertyType, - +getInitialState: (options: RouterConfigOptions) => State, - +getRehydratedState: ( - partialState: PossiblyStaleNavigationState, - options: RouterConfigOptions, - ) => State, - +getStateForRouteNamesChange: ( - state: State, - options: RouterConfigOptions, - ) => State, - +getStateForRouteFocus: (state: State, key: string) => State, - +getStateForAction: ( - state: State, - action: Action, - options: RouterConfigOptions, - ) => ?PossiblyStaleNavigationState; - +shouldActionChangeFocus: (action: GenericNavigationAction) => boolean, - +actionCreators?: ActionCreators, - |}; - - /** - * Stack actions and router - */ - - declare export type StackNavigationState = {| - ...NavigationState, - +type: 'stack', - |}; - - declare export type ReplaceAction = {| - +type: 'REPLACE', - +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type PushAction = {| - +type: 'PUSH', - +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type PopAction = {| - +type: 'POP', - +payload: {| +count: number |}, - +source?: string, - +target?: string, - |}; - declare export type PopToTopAction = {| - +type: 'POP_TO_TOP', - +source?: string, - +target?: string, - |}; - declare export type StackAction = - | CommonAction - | ReplaceAction - | PushAction - | PopAction - | PopToTopAction; - - declare export type StackActionsType = {| - +replace: (routeName: string, params?: ScreenParams) => ReplaceAction, - +push: (routeName: string, params?: ScreenParams) => PushAction, - +pop: (count?: number) => PopAction, - +popToTop: () => PopToTopAction, - |}; - - declare export type StackRouterOptions = $Exact; - - /** - * Tab actions and router - */ - - declare export type TabNavigationState = {| - ...NavigationState, - +type: 'tab', - +history: $ReadOnlyArray<{| type: 'route', key: string |}>, - |}; - - declare export type JumpToAction = {| - +type: 'JUMP_TO', - +payload: {| +name: string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type TabAction = - | CommonAction - | JumpToAction; - - declare export type TabActionsType = {| - +jumpTo: string => JumpToAction, - |}; - - declare export type TabRouterOptions = {| - ...$Exact, - +backBehavior?: 'initialRoute' | 'order' | 'history' | 'none', - |}; - - /** - * Drawer actions and router - */ - - declare type DrawerHistoryEntry = - | {| +type: 'route', +key: string |} - | {| +type: 'drawer' |}; - declare export type DrawerNavigationState = {| - ...NavigationState, - +type: 'drawer', - +history: $ReadOnlyArray, - |}; - - declare export type OpenDrawerAction = {| - +type: 'OPEN_DRAWER', - +source?: string, - +target?: string, - |}; - declare export type CloseDrawerAction = {| - +type: 'CLOSE_DRAWER', - +source?: string, - +target?: string, - |}; - declare export type ToggleDrawerAction = {| - +type: 'TOGGLE_DRAWER', - +source?: string, - +target?: string, - |}; - declare export type DrawerAction = - | TabAction - | OpenDrawerAction - | CloseDrawerAction - | ToggleDrawerAction; - - declare export type DrawerActionsType = {| - ...TabActionsType, - +openDrawer: () => OpenDrawerAction, - +closeDrawer: () => CloseDrawerAction, - +toggleDrawer: () => ToggleDrawerAction, - |}; - - declare export type DrawerRouterOptions = {| - ...TabRouterOptions, - +defaultStatus?: 'open' | 'closed', - |}; - - /** - * Events - */ - - declare export type EventMapBase = { - +[name: string]: {| - +data?: mixed, - +canPreventDefault?: boolean, - |}, - ... - }; - declare type EventPreventDefaultProperties = $If< - Test, - {| +defaultPrevented: boolean, +preventDefault: () => void |}, - {| |}, - >; - declare type EventDataProperties = $If< - $IsUndefined, - {| |}, - {| +data: Data |}, - >; - declare type EventArg< - EventName: string, - CanPreventDefault: ?boolean = false, - Data = void, - > = {| - ...EventPreventDefaultProperties, - ...EventDataProperties, - +type: EventName, - +target?: string, - |}; - declare type GlobalEventMap = {| - +state: {| +data: {| +state: State |}, +canPreventDefault: false |}, - |}; - declare type EventMapCore = {| - ...GlobalEventMap, - +focus: {| +data: void, +canPreventDefault: false |}, - +blur: {| +data: void, +canPreventDefault: false |}, - +beforeRemove: {| - +data: {| +action: GenericNavigationAction |}, - +canPreventDefault: true, - |}, - |}; - declare type EventListenerCallback< - EventName: string, - State: PossiblyStaleNavigationState = NavigationState, - EventMap: EventMapBase = EventMapCore, - > = (e: EventArg< - EventName, - $PropertyType< - $ElementType< - {| ...EventMap, ...EventMapCore |}, - EventName, - >, - 'canPreventDefault', - >, - $PropertyType< - $ElementType< - {| ...EventMap, ...EventMapCore |}, - EventName, - >, - 'data', - >, - >) => mixed; - - /** - * Navigation prop - */ - - declare type PartialWithMergeProperty = $If< - $IsExact, - { ...$Partial, +merge: true }, - { ...$Partial, +merge: true, ... }, - >; - - declare type EitherExactOrPartialWithMergeProperty = - | ParamsType - | PartialWithMergeProperty; - - declare export type SimpleNavigate = - >( - routeName: DestinationRouteName, - params: EitherExactOrPartialWithMergeProperty< - $ElementType, - >, - ) => void; - - declare export type Navigate = - & SimpleNavigate - & >( - route: $If< - $IsUndefined<$ElementType>, - | {| +key: string |} - | {| +name: DestinationRouteName, +key?: string |}, - | {| - +key: string, - +params?: EitherExactOrPartialWithMergeProperty< - $ElementType, - >, - |} - | {| - +name: DestinationRouteName, - +key?: string, - +params?: EitherExactOrPartialWithMergeProperty< - $ElementType, - >, - |}, - >, - ) => void; - - declare type CoreNavigationHelpers< - ParamList: ParamListBase, - State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, - EventMap: EventMapBase = EventMapCore, - > = { - +navigate: Navigate, - +dispatch: ( - action: - | GenericNavigationAction - | (State => GenericNavigationAction), - ) => void, - +reset: PossiblyStaleNavigationState => void, - +goBack: () => void, - +isFocused: () => boolean, - +canGoBack: () => boolean, - +getId: () => string | void, - +getParent: >(id?: string) => ?Parent, - +getState: () => NavigationState, - +addListener: |}, - >>( - name: EventName, - callback: EventListenerCallback, - ) => () => void, - +removeListener: |}, - >>( - name: EventName, - callback: EventListenerCallback, - ) => void, - ... - }; - - declare export type NavigationHelpers< - ParamList: ParamListBase, - State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, - EventMap: EventMapBase = EventMapCore, - > = { - ...$Exact>, - +setParams: (params: ScreenParams) => void, - ... - }; - - declare type SetParamsInput< - ParamList: ParamListBase, - RouteName: $Keys = $Keys, - > = $If< - $IsUndefined<$ElementType>, - empty, - $Partial<$NonMaybeType<$ElementType>>, - >; - - declare export type NavigationProp< - ParamList: ParamListBase, - RouteName: $Keys = $Keys, - State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = { - ...$Exact>, - +setOptions: (options: $Partial) => void, - +setParams: (params: SetParamsInput) => void, - ... - }; - - /** - * CreateNavigator - */ - - declare export type RouteProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - > = {| - ...LeafRoute, - +params: $ElementType, - +path?: string, - |}; - - declare type ScreenOptionsProp< - ScreenOptions: {...}, - RouteParam, - NavHelpers, - > = - | ScreenOptions - | ({| +route: RouteParam, +navigation: NavHelpers |}) => ScreenOptions; - declare export type ScreenListeners< - State: NavigationState = NavigationState, - EventMap: EventMapBase = EventMapCore, - > = $ObjMapi< - {| [name: $Keys]: empty |}, - >(K, empty) => EventListenerCallback, - >; - declare type ScreenListenersProp< - ScreenListenersParam: {...}, - RouteParam, - NavHelpers, - > = - | ScreenListenersParam - | ({| +route: RouteParam, +navigation: NavHelpers |}) => ScreenListenersParam; - - declare type BaseScreenProps< - ParamList: ParamListBase, - NavProp, - RouteName: $Keys = $Keys, - State: NavigationState = NavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = {| - +name: RouteName, - +options?: ScreenOptionsProp< - ScreenOptions, - RouteProp, - NavProp, - >, - +listeners?: ScreenListenersProp< - ScreenListeners, - RouteProp, - NavProp, - >, - +initialParams?: $Partial<$ElementType>, - +getId?: ({ - +params: $ElementType, - }) => string | void, - +navigationKey?: string, - |}; - - declare export type ScreenProps< - ParamList: ParamListBase, - NavProp, - RouteName: $Keys = $Keys, - State: NavigationState = NavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = - | {| - ...BaseScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >, - +component: React$ComponentType<{| - +route: RouteProp, - +navigation: NavProp, - |}>, - |} - | {| - ...BaseScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >, - +getComponent: () => React$ComponentType<{| - +route: RouteProp, - +navigation: NavProp, - |}>, - |} - | {| - ...BaseScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >, - +children: ({| - +route: RouteProp, - +navigation: NavProp, - |}) => React$Node, - |}; - - declare export type ScreenComponent< - GlobalParamList: ParamListBase, - ParamList: ParamListBase, - State: NavigationState = NavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = < - RouteName: $Keys, - NavProp: NavigationProp< - GlobalParamList, - RouteName, - State, - ScreenOptions, - EventMap, - >, - >(props: ScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >) => React$Node; - - declare type ScreenOptionsProps< - ScreenOptions: {...}, - RouteParam, - NavHelpers, - > = {| - +screenOptions?: ScreenOptionsProp, - |}; - declare type ScreenListenersProps< - ScreenListenersParam: {...}, - RouteParam, - NavHelpers, - > = {| - +screenListeners?: ScreenListenersProp< - ScreenListenersParam, - RouteParam, - NavHelpers, - >, - |}; - declare export type ExtraNavigatorPropsBase = { - ...$Exact, - +id?: string, - +children?: React$Node, - ... - }; - declare export type NavigatorProps< - ScreenOptions: {...}, - ScreenListenersParam, - RouteParam, - NavHelpers, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - > = { - ...$Exact, - ...ScreenOptionsProps, - ...ScreenListenersProps, - +defaultScreenOptions?: - | ScreenOptions - | ({| - +route: RouteParam, - +navigation: NavHelpers, - +options: ScreenOptions, - |}) => ScreenOptions, - ... - }; - declare export type NavigatorPropsBase< - ScreenOptions: {...}, - ScreenListenersParam: {...}, - NavHelpers, - > = NavigatorProps< - ScreenOptions, - ScreenListenersParam, - RouteProp<>, - NavHelpers, - ExtraNavigatorPropsBase, - >; - - declare export type CreateNavigator< - State: NavigationState, - ScreenOptions: {...}, - EventMap: EventMapBase, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - > = < - GlobalParamList: ParamListBase, - ParamList: ParamListBase, - NavHelpers: NavigationHelpers< - GlobalParamList, - State, - EventMap, - >, - >() => {| - +Screen: ScreenComponent< - GlobalParamList, - ParamList, - State, - ScreenOptions, - EventMap, - >, - +Navigator: React$ComponentType<$Exact, - RouteProp, - NavHelpers, - ExtraNavigatorProps, - >>>, - +Group: React$ComponentType<{| - ...ScreenOptionsProps, NavHelpers>, - +children: React$Node, - +navigationKey?: string, - |}>, - |}; - - declare export type CreateNavigatorFactory = < - State: NavigationState, - ScreenOptions: {...}, - EventMap: EventMapBase, - NavHelpers: NavigationHelpers< - ParamListBase, - State, - EventMap, - >, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - >( - navigator: React$ComponentType<$Exact, - RouteProp<>, - NavHelpers, - ExtraNavigatorProps, - >>>, - ) => CreateNavigator; - - - /** - * useNavigationBuilder - */ - - declare export type Descriptor< - NavHelpers, - ScreenOptions: {...} = {...}, - > = {| - +render: () => React$Node, - +options: $ReadOnly, - +navigation: NavHelpers, - |}; - - declare export type UseNavigationBuilder = < - State: NavigationState, - Action: GenericNavigationAction, - ScreenOptions: {...}, - RouterOptions: DefaultRouterOptions, - NavHelpers, - EventMap: EventMapBase, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - >( - routerFactory: RouterFactory, - options: $Exact, - RouteProp<>, - NavHelpers, - ExtraNavigatorProps, - >>, - ) => {| - +id?: string, - +state: State, - +descriptors: {| +[key: string]: Descriptor |}, - +navigation: NavHelpers, - |}; - - /** - * EdgeInsets - */ - - declare type EdgeInsets = {| - +top: number, - +right: number, - +bottom: number, - +left: number, - |}; - - /** - * TransitionPreset - */ - - declare export type TransitionSpec = - | {| - animation: 'spring', - config: $Diff< - SpringAnimationConfigSingle, - { toValue: number | AnimatedValue, ... }, - >, - |} - | {| - animation: 'timing', - config: $Diff< - TimingAnimationConfigSingle, - { toValue: number | AnimatedValue, ... }, - >, - |}; - - declare export type StackCardInterpolationProps = {| - +current: {| - +progress: AnimatedInterpolation, - |}, - +next?: {| - +progress: AnimatedInterpolation, - |}, - +index: number, - +closing: AnimatedInterpolation, - +swiping: AnimatedInterpolation, - +inverted: AnimatedInterpolation, - +layouts: {| - +screen: {| +width: number, +height: number |}, - |}, - +insets: EdgeInsets, - |}; - declare export type StackCardInterpolatedStyle = {| - containerStyle?: AnimatedViewStyleProp, - cardStyle?: AnimatedViewStyleProp, - overlayStyle?: AnimatedViewStyleProp, - shadowStyle?: AnimatedViewStyleProp, - |}; - declare export type StackCardStyleInterpolator = ( - props: StackCardInterpolationProps, - ) => StackCardInterpolatedStyle; - - declare export type StackHeaderInterpolationProps = {| - +current: {| - +progress: AnimatedInterpolation, - |}, - +next?: {| - +progress: AnimatedInterpolation, - |}, - +layouts: {| - +header: {| +width: number, +height: number |}, - +screen: {| +width: number, +height: number |}, - +title?: {| +width: number, +height: number |}, - +leftLabel?: {| +width: number, +height: number |}, - |}, - |}; - declare export type StackHeaderInterpolatedStyle = {| - leftLabelStyle?: AnimatedViewStyleProp, - leftButtonStyle?: AnimatedViewStyleProp, - rightButtonStyle?: AnimatedViewStyleProp, - titleStyle?: AnimatedViewStyleProp, - backgroundStyle?: AnimatedViewStyleProp, - |}; - declare export type StackHeaderStyleInterpolator = ( - props: StackHeaderInterpolationProps, - ) => StackHeaderInterpolatedStyle; - - declare type GestureDirection = - | 'horizontal' - | 'horizontal-inverted' - | 'vertical' - | 'vertical-inverted'; - - declare export type TransitionPreset = {| - +gestureDirection: GestureDirection, - +transitionSpec: {| - +open: TransitionSpec, - +close: TransitionSpec, - |}, - +cardStyleInterpolator: StackCardStyleInterpolator, - +headerStyleInterpolator: StackHeaderStyleInterpolator, - |}; - - /** - * Header common options - */ - - declare export type SceneProgress = {| - +current: AnimatedInterpolation, - +next?: AnimatedInterpolation, - +previous?: AnimatedInterpolation, - |}; - - declare export type HeaderProps = {| - +navigation: NavProp, - +route: RouteProp<>, - +options: ScreenOptions, - +layout: {| +width: number, +height: number |}, - |}; - - declare export type HeaderButtonProps = $Partial<{| - +tintColor: string, - +pressColor: string, - +pressOpacity: number, - |}>; - - declare export type HeaderLeftButtonProps = $Partial<{| - ...HeaderButtonProps, - +labelVisible: boolean, - |}>; - - declare type HeaderTitleInputBase = { - +onLayout: LayoutEvent => void, - +children: string, - +allowFontScaling: ?boolean, - +tintColor: ?string, - +style: ?AnimatedTextStyleProp, - ... - }; - - declare export type HeaderTitleInputProps = - $Exact; - - declare export type HeaderCommonOptions< - NavHeaderProps, - NavHeaderLeftProps, - NavHeaderRightProps, - > = $Partial<{| - +header: NavHeaderProps => React$Node, - +headerShown: boolean, - +headerTitle: string | ( HeaderTitleInputProps => React$Node), - +headerTitleAlign: 'left' | 'center', - +headerTitleStyle: AnimatedTextStyleProp, - +headerTitleContainerStyle: AnimatedViewStyleProp, - +headerTintColor: string, - +headerTitleAllowFontScaling: boolean, - +headerLeft: NavHeaderLeftProps => React$Node, - +headerLeftContainerStyle: AnimatedViewStyleProp, - +headerRight: NavHeaderRightProps => React$Node, - +headerRightContainerStyle: AnimatedViewStyleProp, - +headerBackground: ({| style: AnimatedViewStyleProp |}) => React$Node, - +headerStyle: AnimatedViewStyleProp, - +headerTransparent: boolean, - +headerStatusBarHeight: number, - +headerShadowVisible: boolean, - +headerBackgroundContainerStyle: AnimatedViewStyleProp, - +headerPressColor: string, - +headerPressOpacity: number, - |}>; - - /** - * Stack options - */ - - declare export type StackDescriptor = Descriptor< - StackNavigationHelpers<>, - StackOptions, - >; - - declare type Scene = {| - +route: T, - +descriptor: StackDescriptor, - +progress: SceneProgress, - |}; - - declare export type StackHeaderProps = {| - ...HeaderProps, StackOptions>, - +progress: SceneProgress, - +back?: {| +title: string |}, - +styleInterpolator: StackHeaderStyleInterpolator, - |}; - - declare export type StackHeaderButtonProps = $Partial<{| - ...HeaderButtonProps, - +canGoBack: boolean, - |}>; - - declare export type StackHeaderLeftButtonProps = $Partial<{| - ...StackHeaderButtonProps, - +onPress: (() => void), - +backImage: (props: {| tintColor: string |}) => React$Node, - +label: string, - +truncatedLabel: string, - +labelVisible: boolean, - +labelStyle: AnimatedTextStyleProp, - +allowFontScaling: boolean, - +onLabelLayout: LayoutEvent => void, - +screenLayout: {| +width: number, +height: number |}, - +titleLayout: {| +width: number, +height: number |}, - +disabled: boolean, - +accessibilityLabel: string, - +style: ViewStyleProp, - |}>; - - declare export type StackOptions = $Partial<{| - +title: string, - +cardShadowEnabled: boolean, - +cardOverlayEnabled: boolean, - +cardOverlay: {| style: ViewStyleProp |} => React$Node, - +cardStyle: ViewStyleProp, - +animationEnabled: boolean, - +animationTypeForReplace: 'push' | 'pop', - +gestureEnabled: boolean, - +gestureResponseDistance: number, - +gestureVelocityImpact: number, - +safeAreaInsets: $Partial, - +keyboardHandlingEnabled: boolean, - +presentation: 'card' | 'modal' | 'transparentModal', - // Transition - ...TransitionPreset, - // Header - ...HeaderCommonOptions< - StackHeaderProps, - StackHeaderLeftButtonProps, - StackHeaderButtonProps, - >, - +headerMode: 'float' | 'screen', - +headerBackAllowFontScaling: boolean, - +headerBackTitle: string | null, - +headerBackTitleStyle: TextStyleProp, - +headerBackTitleVisible: boolean, - +headerTruncatedBackTitle: string, - +headerBackImage: $PropertyType, - +headerBackAccessibilityLabel: string, - |}>; - - /** - * Stack navigation prop - */ - - declare export type StackNavigationEventMap = {| - ...EventMapCore, - +transitionStart: {| - +data: {| +closing: boolean |}, - +canPreventDefault: false, - |}, - +transitionEnd: {| - +data: {| +closing: boolean |}, - +canPreventDefault: false, - |}, - +gestureStart: {| +data: void, +canPreventDefault: false |}, - +gestureEnd: {| +data: void, +canPreventDefault: false |}, - +gestureCancel: {| +data: void, +canPreventDefault: false |}, - |}; - - declare type StackExtraNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - > = {| - +replace: SimpleNavigate, - +push: SimpleNavigate, - +pop: (count?: number) => void, - +popToTop: () => void, - |}; - - declare export type StackNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = StackNavigationEventMap, - > = { - ...$Exact>, - ...StackExtraNavigationHelpers, - ... - }; - - declare export type StackNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = StackOptions, - EventMap: EventMapBase = StackNavigationEventMap, - > = {| - ...$Exact>, - ...StackExtraNavigationHelpers, - |}; - - /** - * Miscellaneous stack exports - */ - - declare type StackNavigationConfig = {| - +detachInactiveScreens?: boolean, - |}; - - declare export type ExtraStackNavigatorProps = {| - ...$Exact, - ...StackRouterOptions, - ...StackNavigationConfig, - |}; - - declare export type StackNavigatorProps< - NavHelpers: StackNavigationHelpers<> = StackNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraStackNavigatorProps, - >>; - - /** - * Bottom tab options - */ - - declare export type BottomTabBarButtonProps = {| - ...$Diff< - TouchableWithoutFeedbackProps, - {| onPress?: ?(event: PressEvent) => mixed |}, - >, - +to?: string, - +children: React$Node, - +onPress?: (MouseEvent | PressEvent) => void, - |}; - - declare export type TabBarVisibilityAnimationConfig = - | {| - +animation: 'spring', - +config?: $Diff< - SpringAnimationConfigSingle, - { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, - >, - |} - | {| - +animation: 'timing', - +config?: $Diff< - TimingAnimationConfigSingle, - { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, - >, - |}; - - declare export type BottomTabOptions = $Partial<{| - +title: string, - +tabBarLabel: - | string - | ({| focused: boolean, color: string |}) => React$Node, - +tabBarIcon: ({| - focused: boolean, - color: string, - size: number, - |}) => React$Node, - +tabBarBadge: number | string, - +tabBarBadgeStyle: TextStyleProp, - +tabBarAccessibilityLabel: string, - +tabBarTestID: string, - +tabBarVisibilityAnimationConfig: $Partial<{| - +show: TabBarVisibilityAnimationConfig, - +hide: TabBarVisibilityAnimationConfig, - |}>, - +tabBarButton: BottomTabBarButtonProps => React$Node, - +tabBarHideOnKeyboard: boolean, - +tabBarActiveTintColor: string, - +tabBarInactiveTintColor: string, - +tabBarActiveBackgroundColor: string, - +tabBarInactiveBackgroundColor: string, - +tabBarAllowFontScaling: boolean, - +tabBarShowLabel: boolean, - +tabBarLabelStyle: TextStyleProp, - +tabBarIconStyle: TextStyleProp, - +tabBarItemStyle: ViewStyleProp, - +tabBarLabelPosition: 'beside-icon' | 'below-icon', - +tabBarStyle: ViewStyleProp, - +unmountOnBlur: boolean, - +lazy: boolean, - ...HeaderCommonOptions< - HeaderProps, BottomTabOptions>, - HeaderLeftButtonProps, - HeaderButtonProps, - >, - |}>; - - /** - * Bottom tab navigation prop - */ - - declare export type BottomTabNavigationEventMap = {| - ...EventMapCore, - +tabPress: {| +data: void, +canPreventDefault: true |}, - +tabLongPress: {| +data: void, +canPreventDefault: false |}, - |}; - - declare type TabExtraNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - > = {| - +jumpTo: SimpleNavigate, - |}; - - declare export type BottomTabNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = BottomTabNavigationEventMap, - > = { - ...$Exact>, - ...TabExtraNavigationHelpers, - ... - }; - - declare export type BottomTabNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = BottomTabOptions, - EventMap: EventMapBase = BottomTabNavigationEventMap, - > = {| - ...$Exact>, - ...TabExtraNavigationHelpers, - |}; - - /** - * Miscellaneous bottom tab exports - */ - - declare export type BottomTabDescriptor = Descriptor< - BottomTabNavigationHelpers<>, - BottomTabOptions, - >; - - declare type BottomTabNavigationBuilderResult = {| - +state: TabNavigationState, - +navigation: BottomTabNavigationHelpers<>, - +descriptors: {| +[key: string]: BottomTabDescriptor |}, - |}; - - declare export type BottomTabBarProps = BottomTabNavigationBuilderResult; - - declare type BottomTabNavigationConfig = {| - +tabBar?: BottomTabBarProps => React$Node, - +safeAreaInsets?: $Partial, - +detachInactiveScreens?: boolean, - |}; - - declare export type ExtraBottomTabNavigatorProps = {| - ...$Exact, - ...TabRouterOptions, - ...BottomTabNavigationConfig, - |}; - - declare export type BottomTabNavigatorProps< - NavHelpers: BottomTabNavigationHelpers<> = BottomTabNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraBottomTabNavigatorProps, - >>; - - /** - * Material bottom tab options - */ - - declare export type MaterialBottomTabOptions = $Partial<{| - +title: string, - +tabBarColor: string, - +tabBarLabel: string, - +tabBarIcon: - | string - | ({| +focused: boolean, +color: string |}) => React$Node, - +tabBarBadge: boolean | number | string, - +tabBarAccessibilityLabel: string, - +tabBarTestID: string, - |}>; - - /** - * Material bottom tab navigation prop - */ - - declare export type MaterialBottomTabNavigationEventMap = {| - ...EventMapCore, - +tabPress: {| +data: void, +canPreventDefault: true |}, - |}; - - declare export type MaterialBottomTabNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, - > = { - ...$Exact>, - ...TabExtraNavigationHelpers, - ... - }; - - declare export type MaterialBottomTabNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = MaterialBottomTabOptions, - EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, - > = {| - ...$Exact>, - ...TabExtraNavigationHelpers, - |}; - - /** - * Miscellaneous material bottom tab exports - */ - - declare export type PaperFont = {| - +fontFamily: string, - +fontWeight?: - | 'normal' - | 'bold' - | '100' - | '200' - | '300' - | '400' - | '500' - | '600' - | '700' - | '800' - | '900', - |}; - - declare export type PaperFonts = {| - +regular: PaperFont, - +medium: PaperFont, - +light: PaperFont, - +thin: PaperFont, - |}; - - declare export type PaperTheme = {| - +dark: boolean, - +mode?: 'adaptive' | 'exact', - +roundness: number, - +colors: {| - +primary: string, - +background: string, - +surface: string, - +accent: string, - +error: string, - +text: string, - +onSurface: string, - +onBackground: string, - +disabled: string, - +placeholder: string, - +backdrop: string, - +notification: string, - |}, - +fonts: PaperFonts, - +animation: {| - +scale: number, - |}, - |}; - - declare export type PaperRoute = {| - +key: string, - +title?: string, - +icon?: any, - +badge?: string | number | boolean, - +color?: string, - +accessibilityLabel?: string, - +testID?: string, - |}; - - declare export type PaperTouchableProps = {| - ...TouchableWithoutFeedbackProps, - +key: string, - +route: PaperRoute, - +children: React$Node, - +borderless?: boolean, - +centered?: boolean, - +rippleColor?: string, - |}; - - declare export type MaterialBottomTabNavigationConfig = {| - +shifting?: boolean, - +labeled?: boolean, - +renderTouchable?: PaperTouchableProps => React$Node, - +activeColor?: string, - +inactiveColor?: string, - +sceneAnimationEnabled?: boolean, - +keyboardHidesNavigationBar?: boolean, - +barStyle?: ViewStyleProp, - +style?: ViewStyleProp, - +theme?: PaperTheme, - |}; - - declare export type ExtraMaterialBottomTabNavigatorProps = {| - ...$Exact, - ...TabRouterOptions, - ...MaterialBottomTabNavigationConfig, - |}; - - declare export type MaterialBottomTabNavigatorProps< - NavHelpers: MaterialBottomTabNavigationHelpers<> = - MaterialBottomTabNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraMaterialBottomTabNavigatorProps, - >>; - - /** - * Material top tab options - */ - - declare export type MaterialTopTabOptions = $Partial<{| - +title: string, - +tabBarLabel: - | string - | ({| +focused: boolean, +color: string |}) => React$Node, - +tabBarIcon: ({| +focused: boolean, +color: string |}) => React$Node, - +tabBarAccessibilityLabel: string, - +tabBarTestID: string, - +tabBarActiveTintColor: string, - +tabBarInactiveTintColor: string, - +tabBarPressColor: string, - +tabBarPressOpacity: number, - +tabBarShowLabel: boolean, - +tabBarShowIcon: boolean, - +tabBarAllowFontScaling: boolean, - +tabBarBounces: boolean, - +tabBarScrollEnabled: boolean, - +tabBarIconStyle: ViewStyleProp, - +tabBarLabelStyle: TextStyleProp, - +tabBarItemStyle: ViewStyleProp, - +tabBarIndicatorStyle: ViewStyleProp, - +tabBarIndicatorContainerStyle: ViewStyleProp, - +tabBarContentContainerStyle: ViewStyleProp, - +tabBarStyle: ViewStyleProp, - +tabBarBadge: () => React$Node, - +tabBarIndicator: MaterialTopTabBarIndicatorProps => React$Node, - +lazy: boolean, - +lazyPlaceholder: ({| +route: Route<> |}) => React$Node, - |}>; - - /** - * Material top tab navigation prop - */ - - declare export type MaterialTopTabNavigationEventMap = {| - ...EventMapCore, - +tabPress: {| +data: void, +canPreventDefault: true |}, - +tabLongPress: {| +data: void, +canPreventDefault: false |}, - +swipeStart: {| +data: void, +canPreventDefault: false |}, - +swipeEnd: {| +data: void, +canPreventDefault: false |}, - |}; - - declare export type MaterialTopTabNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = MaterialTopTabNavigationEventMap, - > = { - ...$Exact>, - ...TabExtraNavigationHelpers, - ... - }; - - declare export type MaterialTopTabNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = MaterialTopTabOptions, - EventMap: EventMapBase = MaterialTopTabNavigationEventMap, - > = {| - ...$Exact>, - ...TabExtraNavigationHelpers, - |}; - - /** - * Miscellaneous material top tab exports - */ - - declare type MaterialTopTabPagerCommonProps = {| - +keyboardDismissMode: 'none' | 'on-drag' | 'auto', - +swipeEnabled: boolean, - +swipeVelocityImpact?: number, - +springVelocityScale?: number, - +springConfig: $Partial<{| - +damping: number, - +mass: number, - +stiffness: number, - +restSpeedThreshold: number, - +restDisplacementThreshold: number, - |}>, - +timingConfig: $Partial<{| - +duration: number, - |}>, - |}; - - declare export type MaterialTopTabPagerProps = {| - ...MaterialTopTabPagerCommonProps, - +onSwipeStart?: () => void, - +onSwipeEnd?: () => void, - +onIndexChange: (index: number) => void, - +navigationState: TabNavigationState, - +layout: {| +width: number, +height: number |}, - +removeClippedSubviews: boolean, - +children: ({| - +addListener: (type: 'enter', listener: number => void) => void, - +removeListener: (type: 'enter', listener: number => void) => void, - +position: any, // Reanimated.Node - +render: React$Node => React$Node, - +jumpTo: string => void, - |}) => React$Node, - +gestureHandlerProps: PanGestureHandlerProps, - |}; - - declare export type MaterialTopTabBarIndicatorProps = {| - +state: TabNavigationState, - +width: string, - +style?: ViewStyleProp, - +getTabWidth: number => number, - |}; - - declare export type MaterialTopTabDescriptor = Descriptor< - MaterialBottomTabNavigationHelpers<>, - MaterialBottomTabOptions, - >; - - declare type MaterialTopTabNavigationBuilderResult = {| - +state: TabNavigationState, - +navigation: MaterialTopTabNavigationHelpers<>, - +descriptors: {| +[key: string]: MaterialTopTabDescriptor |}, - |}; - - declare export type MaterialTopTabBarProps = {| - ...MaterialTopTabNavigationBuilderResult, - +layout: {| +width: number, +height: number |}, - +position: any, // Reanimated.Node - +jumpTo: string => void, - |}; - - declare export type MaterialTopTabNavigationConfig = {| - ...$Partial, - +position?: any, // Reanimated.Value - +tabBarPosition?: 'top' | 'bottom', - +initialLayout?: $Partial<{| +width: number, +height: number |}>, - +lazyPreloadDistance?: number, - +removeClippedSubviews?: boolean, - +sceneContainerStyle?: ViewStyleProp, - +style?: ViewStyleProp, - +gestureHandlerProps?: PanGestureHandlerProps, - +pager?: MaterialTopTabPagerProps => React$Node, - +tabBar?: MaterialTopTabBarProps => React$Node, - |}; - - declare export type ExtraMaterialTopTabNavigatorProps = {| - ...$Exact, - ...TabRouterOptions, - ...MaterialTopTabNavigationConfig, - |}; - - declare export type MaterialTopTabNavigatorProps< - NavHelpers: MaterialTopTabNavigationHelpers<> = - MaterialTopTabNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraMaterialTopTabNavigatorProps, - >>; - - /** - * Drawer options - */ - - declare export type DrawerOptions = $Partial<{| - +title: string, - +lazy: boolean, - +drawerLabel: - | string - | ({| +color: string, +focused: boolean |}) => React$Node, - +drawerIcon: ({| - +color: string, - +size: number, - +focused: boolean, - |}) => React$Node, - +drawerActiveTintColor: string, - +drawerActiveBackgroundColor: string, - +drawerInactiveTintColor: string, - +drawerInactiveBackgroundColor: string, - +drawerItemStyle: ViewStyleProp, - +drawerLabelStyle: TextStyleProp, - +drawerContentContainerStyle: ViewStyleProp, - +drawerContentStyle: ViewStyleProp, - +drawerStyle: ViewStyleProp, - +drawerPosition: 'left' | 'right', - +drawerType: 'front' | 'back' | 'slide' | 'permanent', - +drawerHideStatusBarOnOpen: boolean, - +drawerStatusBarAnimation: 'slide' | 'none' | 'fade', - +overlayColor: string, - +sceneContainerStyle: ViewStyleProp, - +gestureHandlerProps: PanGestureHandlerProps, - +swipeEnabled: boolean, - +swipeEdgeWidth: number, - +swipeMinDistance: number, - +keyboardDismissMode: 'on-drag' | 'none', - +unmountOnBlur: boolean, - ...HeaderCommonOptions< - HeaderProps, DrawerOptions>, - HeaderLeftButtonProps, - HeaderButtonProps, - >, - |}>; - - /** - * Drawer navigation prop - */ - - declare export type DrawerNavigationEventMap = - EventMapCore; - - declare type DrawerExtraNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - > = {| - +jumpTo: SimpleNavigate, - +openDrawer: () => void, - +closeDrawer: () => void, - +toggleDrawer: () => void, - |}; - - declare export type DrawerNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = DrawerNavigationEventMap, - > = { - ...$Exact>, - ...DrawerExtraNavigationHelpers, - ... - }; - - declare export type DrawerNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = DrawerOptions, - EventMap: EventMapBase = DrawerNavigationEventMap, - > = {| - ...$Exact>, - ...DrawerExtraNavigationHelpers, - |}; - - /** - * Miscellaneous drawer exports - */ - - declare export type DrawerDescriptor = Descriptor< - DrawerNavigationHelpers<>, - DrawerOptions, - >; - - declare type DrawerNavigationBuilderResult = {| - +state: DrawerNavigationState, - +navigation: DrawerNavigationHelpers<>, - +descriptors: {| +[key: string]: DrawerDescriptor |}, - |}; - - declare export type DrawerNavigationConfig = {| - +drawerContent?: DrawerNavigationBuilderResult => React$Node, - +detachInactiveScreens?: boolean, - +useLegacyImplementation?: boolean, - |}; - - declare export type ExtraDrawerNavigatorProps = {| - ...$Exact, - ...DrawerRouterOptions, - ...DrawerNavigationConfig, - |}; - - declare export type DrawerNavigatorProps< - NavHelpers: DrawerNavigationHelpers<> = DrawerNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, + DrawerNavigationEventMap, ExtraDrawerNavigatorProps, - >>; - - /** - * BaseNavigationContainer - */ - - declare export type BaseNavigationContainerProps = {| - +children: React$Node, - +initialState?: PossiblyStaleNavigationState, - +onStateChange?: (state: ?PossiblyStaleNavigationState) => void, - +independent?: boolean, - |}; - - declare export type ContainerEventMap = {| - ...GlobalEventMap, - +options: {| - +data: {| +options: { +[key: string]: mixed, ... } |}, - +canPreventDefault: false, - |}, - +__unsafe_action__: {| - +data: {| - +action: GenericNavigationAction, - +noop: boolean, - |}, - +canPreventDefault: false, - |}, - |}; - - declare export type BaseNavigationContainerInterface = {| - ...$Exact>, - +resetRoot: (state?: PossiblyStaleNavigationState) => void, - +getRootState: () => NavigationState, - +getCurrentRoute: () => RouteProp<> | void, - +getCurrentOptions: () => Object | void, - +isReady: () => boolean, - |}; - - declare type BaseNavigationContainerInterfaceRef = {| - ...BaseNavigationContainerInterface, - +current: BaseNavigationContainerInterface | null, - |}; - - /** - * State utils - */ - - declare export type GetStateFromPath = ( - path: string, - options?: LinkingConfig, - ) => PossiblyStaleNavigationState; - - declare export type GetPathFromState = ( - state?: ?PossiblyStaleNavigationState, - options?: LinkingConfig, - ) => string; - - declare export type GetFocusedRouteNameFromRoute = - PossiblyStaleRoute => ?string; - - /** - * Linking - */ - - declare export type ScreenLinkingConfig = {| - +path?: string, - +exact?: boolean, - +parse?: {| +[param: string]: string => mixed |}, - +stringify?: {| +[param: string]: mixed => string |}, - +screens?: ScreenLinkingConfigMap, - +initialRouteName?: string, - |}; - - declare export type ScreenLinkingConfigMap = {| - +[routeName: string]: string | ScreenLinkingConfig, - |}; - - declare export type LinkingConfig = {| - +initialRouteName?: string, - +screens: ScreenLinkingConfigMap, - |}; - - declare export type LinkingOptions = {| - +enabled?: boolean, - +prefixes: $ReadOnlyArray, - +config?: LinkingConfig, - +getStateFromPath?: GetStateFromPath, - +getPathFromState?: GetPathFromState, - |}; - - /** - * NavigationContainer - */ - - declare export type Theme = {| - +dark: boolean, - +colors: {| - +primary: string, - +background: string, - +card: string, - +text: string, - +border: string, - |}, - |}; - - declare export type NavigationContainerType = React$AbstractComponent< - {| - ...BaseNavigationContainerProps, - +theme?: Theme, - +linking?: LinkingOptions, - +fallback?: React$Node, - +onReady?: () => mixed, - |}, - BaseNavigationContainerInterface, - >; - - //--------------------------------------------------------------------------- - // SECTION 2: EXPORTED MODULE - // This section defines the module exports and contains exported types that - // are not present in any other React Navigation libdef. - //--------------------------------------------------------------------------- + DrawerNavigationConfig, + DrawerNavigationBuilderResult, + TextStyleProp, + ViewStyleProp, + PanGestureHandlerProps, + } from '@react-navigation/core'; /** * createDrawerNavigator diff --git a/native/flow-typed/npm/@react-navigation/elements_v1.x.x.js b/native/flow-typed/npm/@react-navigation/elements_v1.x.x.js --- a/native/flow-typed/npm/@react-navigation/elements_v1.x.x.js +++ b/native/flow-typed/npm/@react-navigation/elements_v1.x.x.js @@ -1,2262 +1,11 @@ declare module '@react-navigation/elements' { - //--------------------------------------------------------------------------- - // SECTION 1: IDENTICAL TYPE DEFINITIONS - // This section is identical across all React Navigation libdefs and contains - // shared definitions. We wish we could make it DRY and import from a shared - // definition, but that isn't yet possible. - //--------------------------------------------------------------------------- - - /** - * We start with some definitions that we have copy-pasted from React Native - * source files. - */ - - // This is a bastardization of the true StyleObj type located in - // react-native/Libraries/StyleSheet/StyleSheetTypes. We unfortunately can't - // import that here, and it's too lengthy (and consequently too brittle) to - // copy-paste here either. - declare type StyleObj = - | null - | void - | number - | false - | '' - | $ReadOnlyArray - | { [name: string]: any, ... }; - declare type ViewStyleProp = StyleObj; - declare type TextStyleProp = StyleObj; - declare type AnimatedViewStyleProp = StyleObj; - declare type AnimatedTextStyleProp = StyleObj; - - // Vaguely copied from - // react-native/Libraries/Animated/src/animations/Animation.js - declare type EndResult = { finished: boolean, ... }; - declare type EndCallback = (result: EndResult) => void; - declare interface Animation { - start( - fromValue: number, - onUpdate: (value: number) => void, - onEnd: ?EndCallback, - previousAnimation: ?Animation, - animatedValue: AnimatedValue, - ): void; - stop(): void; - } - declare type AnimationConfig = { - isInteraction?: boolean, - useNativeDriver: boolean, - onComplete?: ?EndCallback, - iterations?: number, - ... - }; - - // Vaguely copied from - // react-native/Libraries/Animated/src/nodes/AnimatedTracking.js - declare interface AnimatedTracking { - constructor( - value: AnimatedValue, - parent: any, - animationClass: any, - animationConfig: Object, - callback?: ?EndCallback, - ): void; - update(): void; - } - - // Vaguely copied from - // react-native/Libraries/Animated/src/nodes/AnimatedValue.js - declare type ValueListenerCallback = (state: { value: number, ... }) => void; - declare interface AnimatedValue { - constructor(value: number): void; - setValue(value: number): void; - setOffset(offset: number): void; - flattenOffset(): void; - extractOffset(): void; - addListener(callback: ValueListenerCallback): string; - removeListener(id: string): void; - removeAllListeners(): void; - stopAnimation(callback?: ?(value: number) => void): void; - resetAnimation(callback?: ?(value: number) => void): void; - interpolate(config: InterpolationConfigType): AnimatedInterpolation; - animate(animation: Animation, callback: ?EndCallback): void; - stopTracking(): void; - track(tracking: AnimatedTracking): void; - } - - // Copied from - // react-native/Libraries/Animated/src/animations/TimingAnimation.js - declare type TimingAnimationConfigSingle = AnimationConfig & { - toValue: number | AnimatedValue, - easing?: (value: number) => number, - duration?: number, - delay?: number, - ... - }; - - // Copied from - // react-native/Libraries/Animated/src/animations/SpringAnimation.js - declare type SpringAnimationConfigSingle = AnimationConfig & { - toValue: number | AnimatedValue, - overshootClamping?: boolean, - restDisplacementThreshold?: number, - restSpeedThreshold?: number, - velocity?: number, - bounciness?: number, - speed?: number, - tension?: number, - friction?: number, - stiffness?: number, - damping?: number, - mass?: number, - delay?: number, - ... - }; - - // Copied from react-native/Libraries/Types/CoreEventTypes.js - declare type SyntheticEvent = $ReadOnly<{| - bubbles: ?boolean, - cancelable: ?boolean, - currentTarget: number, - defaultPrevented: ?boolean, - dispatchConfig: $ReadOnly<{| - registrationName: string, - |}>, - eventPhase: ?number, - preventDefault: () => void, - isDefaultPrevented: () => boolean, - stopPropagation: () => void, - isPropagationStopped: () => boolean, - isTrusted: ?boolean, - nativeEvent: T, - persist: () => void, - target: ?number, - timeStamp: number, - type: ?string, - |}>; - declare type Layout = $ReadOnly<{| - x: number, - y: number, - width: number, - height: number, - |}>; - declare type LayoutEvent = SyntheticEvent< - $ReadOnly<{| - layout: Layout, - |}>, - >; - declare type BlurEvent = SyntheticEvent< - $ReadOnly<{| - target: number, - |}>, - >; - declare type FocusEvent = SyntheticEvent< - $ReadOnly<{| - target: number, - |}>, - >; - declare type ResponderSyntheticEvent = $ReadOnly<{| - ...SyntheticEvent, - touchHistory: $ReadOnly<{| - indexOfSingleActiveTouch: number, - mostRecentTimeStamp: number, - numberActiveTouches: number, - touchBank: $ReadOnlyArray< - $ReadOnly<{| - touchActive: boolean, - startPageX: number, - startPageY: number, - startTimeStamp: number, - currentPageX: number, - currentPageY: number, - currentTimeStamp: number, - previousPageX: number, - previousPageY: number, - previousTimeStamp: number, - |}>, - >, - |}>, - |}>; - declare type PressEvent = ResponderSyntheticEvent< - $ReadOnly<{| - changedTouches: $ReadOnlyArray<$PropertyType>, - force: number, - identifier: number, - locationX: number, - locationY: number, - pageX: number, - pageY: number, - target: ?number, - timestamp: number, - touches: $ReadOnlyArray<$PropertyType>, - |}>, - >; - - // Vaguely copied from - // react-native/Libraries/Animated/src/nodes/AnimatedInterpolation.js - declare type ExtrapolateType = 'extend' | 'identity' | 'clamp'; - declare type InterpolationConfigType = { - inputRange: Array, - outputRange: Array | Array, - easing?: (input: number) => number, - extrapolate?: ExtrapolateType, - extrapolateLeft?: ExtrapolateType, - extrapolateRight?: ExtrapolateType, - ... - }; - declare interface AnimatedInterpolation { - interpolate(config: InterpolationConfigType): AnimatedInterpolation; - } - - // Copied from react-native/Libraries/Components/View/ViewAccessibility.js - declare type AccessibilityRole = - | 'none' - | 'button' - | 'link' - | 'search' - | 'image' - | 'keyboardkey' - | 'text' - | 'adjustable' - | 'imagebutton' - | 'header' - | 'summary' - | 'alert' - | 'checkbox' - | 'combobox' - | 'menu' - | 'menubar' - | 'menuitem' - | 'progressbar' - | 'radio' - | 'radiogroup' - | 'scrollbar' - | 'spinbutton' - | 'switch' - | 'tab' - | 'tablist' - | 'timer' - | 'toolbar'; - declare type AccessibilityActionInfo = $ReadOnly<{ - name: string, - label?: string, - ... - }>; - declare type AccessibilityActionEvent = SyntheticEvent< - $ReadOnly<{actionName: string, ...}>, - >; - declare type AccessibilityState = { - disabled?: boolean, - selected?: boolean, - checked?: ?boolean | 'mixed', - busy?: boolean, - expanded?: boolean, - ... - }; - declare type AccessibilityValue = $ReadOnly<{| - min?: number, - max?: number, - now?: number, - text?: string, - |}>; - - // Copied from - // react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js - declare type Stringish = string; - declare type EdgeInsetsProp = $ReadOnly<$Partial>; - declare type TouchableWithoutFeedbackProps = $ReadOnly<{| - accessibilityActions?: ?$ReadOnlyArray, - accessibilityElementsHidden?: ?boolean, - accessibilityHint?: ?Stringish, - accessibilityIgnoresInvertColors?: ?boolean, - accessibilityLabel?: ?Stringish, - accessibilityLiveRegion?: ?('none' | 'polite' | 'assertive'), - accessibilityRole?: ?AccessibilityRole, - accessibilityState?: ?AccessibilityState, - accessibilityValue?: ?AccessibilityValue, - accessibilityViewIsModal?: ?boolean, - accessible?: ?boolean, - children?: ?React$Node, - delayLongPress?: ?number, - delayPressIn?: ?number, - delayPressOut?: ?number, - disabled?: ?boolean, - focusable?: ?boolean, - hitSlop?: ?EdgeInsetsProp, - importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'), - nativeID?: ?string, - onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed, - onBlur?: ?(event: BlurEvent) => mixed, - onFocus?: ?(event: FocusEvent) => mixed, - onLayout?: ?(event: LayoutEvent) => mixed, - onLongPress?: ?(event: PressEvent) => mixed, - onPress?: ?(event: PressEvent) => mixed, - onPressIn?: ?(event: PressEvent) => mixed, - onPressOut?: ?(event: PressEvent) => mixed, - pressRetentionOffset?: ?EdgeInsetsProp, - rejectResponderTermination?: ?boolean, - testID?: ?string, - touchSoundDisabled?: ?boolean, - |}>; - - // Copied from react-native/Libraries/Image/ImageSource.js - declare type ImageURISource = $ReadOnly<{ - uri?: ?string, - bundle?: ?string, - method?: ?string, - headers?: ?Object, - body?: ?string, - cache?: ?('default' | 'reload' | 'force-cache' | 'only-if-cached'), - width?: ?number, - height?: ?number, - scale?: ?number, - ... - }>; - - /** - * The following is copied from react-native-gesture-handler's libdef - */ - - declare type StateUndetermined = 0; - declare type StateFailed = 1; - declare type StateBegan = 2; - declare type StateCancelled = 3; - declare type StateActive = 4; - declare type StateEnd = 5; - - declare type GestureHandlerState = - | StateUndetermined - | StateFailed - | StateBegan - | StateCancelled - | StateActive - | StateEnd; - - declare type $SyntheticEvent = { - +nativeEvent: $ReadOnly<$Exact>, - ... - }; - - declare type $Event = $SyntheticEvent<{ - handlerTag: number, - numberOfPointers: number, - state: GestureHandlerState, - oldState: GestureHandlerState, - ...$Exact, - ... - }>; - - declare type $EventHandlers = {| - onGestureEvent?: ($Event) => mixed, - onHandlerStateChange?: ($Event) => mixed, - onBegan?: ($Event) => mixed, - onFailed?: ($Event) => mixed, - onCancelled?: ($Event) => mixed, - onActivated?: ($Event) => mixed, - onEnded?: ($Event) => mixed, - |}; - - declare type HitSlop = - | number - | {| - left?: number, - top?: number, - right?: number, - bottom?: number, - vertical?: number, - horizontal?: number, - width?: number, - height?: number, - |} - | {| - width: number, - left: number, - |} - | {| - width: number, - right: number, - |} - | {| - height: number, - top: number, - |} - | {| - height: number, - bottom: number, - |}; - - declare type $GestureHandlerProps< - AdditionalProps: {...}, - ExtraEventsProps: {...} - > = $ReadOnly<{| - ...$Exact, - ...$EventHandlers, - id?: string, - enabled?: boolean, - waitFor?: React$Ref | Array>, - simultaneousHandlers?: React$Ref | Array>, - shouldCancelWhenOutside?: boolean, - minPointers?: number, - hitSlop?: HitSlop, - children?: React$Node, - |}>; - - declare type PanGestureHandlerProps = $GestureHandlerProps< - { - activeOffsetY?: number | [number, number], - activeOffsetX?: number | [number, number], - failOffsetY?: number | [number, number], - failOffsetX?: number | [number, number], - minDist?: number, - minVelocity?: number, - minVelocityX?: number, - minVelocityY?: number, - minPointers?: number, - maxPointers?: number, - avgTouches?: boolean, - ... - }, - { - x: number, - y: number, - absoluteX: number, - absoluteY: number, - translationX: number, - translationY: number, - velocityX: number, - velocityY: number, - ... - } - >; - - /** - * MAGIC - */ - - declare type $If = $Call< - ((true, Then, Else) => Then) & ((false, Then, Else) => Else), - Test, - Then, - Else, - >; - declare type $IsA = $Call< - (Y => true) & (mixed => false), - X, - >; - declare type $IsUndefined = $IsA; - - declare type $Partial = $ReadOnly<$Rest>; - - // If { ...T, ... } counts as a T, then we're inexact - declare type $IsExact = $Call< - (T => false) & (mixed => true), - { ...T, ... }, - >; - - /** - * Actions, state, etc. - */ - - declare export type ScreenParams = { +[key: string]: mixed, ... }; - - declare export type BackAction = {| - +type: 'GO_BACK', - +source?: string, - +target?: string, - |}; - declare export type NavigateAction = {| - +type: 'NAVIGATE', - +payload: - | {| +key: string, +params?: ScreenParams |} - | {| +name: string, +key?: string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type ResetAction = {| - +type: 'RESET', - +payload: StaleNavigationState, - +source?: string, - +target?: string, - |}; - declare export type SetParamsAction = {| - +type: 'SET_PARAMS', - +payload: {| +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type CommonAction = - | BackAction - | NavigateAction - | ResetAction - | SetParamsAction; - - declare type NavigateActionCreator = {| - (routeName: string, params?: ScreenParams): NavigateAction, - ( - | {| +key: string, +params?: ScreenParams |} - | {| +name: string, +key?: string, +params?: ScreenParams |}, - ): NavigateAction, - |}; - declare export type CommonActionsType = {| - +navigate: NavigateActionCreator, - +goBack: () => BackAction, - +reset: (state: PossiblyStaleNavigationState) => ResetAction, - +setParams: (params: ScreenParams) => SetParamsAction, - |}; - - declare export type GenericNavigationAction = {| - +type: string, - +payload?: { +[key: string]: mixed, ... }, - +source?: string, - +target?: string, - |}; - - declare export type LeafRoute = {| - +key: string, - +name: RouteName, - +params?: ScreenParams, - |}; - declare export type StateRoute = {| - ...LeafRoute, - +state: NavigationState | StaleNavigationState, - |}; - declare export type Route = - | LeafRoute - | StateRoute; - - declare export type NavigationState = {| - +key: string, - +index: number, - +routeNames: $ReadOnlyArray, - +history?: $ReadOnlyArray, - +routes: $ReadOnlyArray>, - +type: string, - +stale: false, - |}; - - declare export type StaleLeafRoute = {| - +key?: string, - +name: RouteName, - +params?: ScreenParams, - |}; - declare export type StaleStateRoute = {| - ...StaleLeafRoute, - +state: StaleNavigationState, - |}; - declare export type StaleRoute = - | StaleLeafRoute - | StaleStateRoute; - declare export type StaleNavigationState = {| - // It's possible to pass React Nav a StaleNavigationState with an undefined - // index, but React Nav will always return one with the index set. This is - // the same as for the type property below, but in the case of index we tend - // to rely on it being set more... - +index: number, - +history?: $ReadOnlyArray, - +routes: $ReadOnlyArray>, - +type?: string, - +stale?: true, - |}; - - declare export type PossiblyStaleNavigationState = - | NavigationState - | StaleNavigationState; - declare export type PossiblyStaleRoute = - | Route - | StaleRoute; - - /** - * Routers - */ - - declare type ActionCreators< - State: NavigationState, - Action: GenericNavigationAction, - > = { - +[key: string]: (...args: any) => (Action | State => Action), - ... - }; - - declare export type DefaultRouterOptions = { - +initialRouteName?: string, - ... - }; - - declare export type RouterFactory< - State: NavigationState, - Action: GenericNavigationAction, - RouterOptions: DefaultRouterOptions, - > = (options: RouterOptions) => Router; - - declare export type ParamListBase = { +[key: string]: ?ScreenParams, ... }; - - declare export type RouterConfigOptions = {| - +routeNames: $ReadOnlyArray, - +routeParamList: ParamListBase, - |}; - - declare export type Router< - State: NavigationState, - Action: GenericNavigationAction, - > = {| - +type: $PropertyType, - +getInitialState: (options: RouterConfigOptions) => State, - +getRehydratedState: ( - partialState: PossiblyStaleNavigationState, - options: RouterConfigOptions, - ) => State, - +getStateForRouteNamesChange: ( - state: State, - options: RouterConfigOptions, - ) => State, - +getStateForRouteFocus: (state: State, key: string) => State, - +getStateForAction: ( - state: State, - action: Action, - options: RouterConfigOptions, - ) => ?PossiblyStaleNavigationState; - +shouldActionChangeFocus: (action: GenericNavigationAction) => boolean, - +actionCreators?: ActionCreators, - |}; - - /** - * Stack actions and router - */ - - declare export type StackNavigationState = {| - ...NavigationState, - +type: 'stack', - |}; - - declare export type ReplaceAction = {| - +type: 'REPLACE', - +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type PushAction = {| - +type: 'PUSH', - +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type PopAction = {| - +type: 'POP', - +payload: {| +count: number |}, - +source?: string, - +target?: string, - |}; - declare export type PopToTopAction = {| - +type: 'POP_TO_TOP', - +source?: string, - +target?: string, - |}; - declare export type StackAction = - | CommonAction - | ReplaceAction - | PushAction - | PopAction - | PopToTopAction; - - declare export type StackActionsType = {| - +replace: (routeName: string, params?: ScreenParams) => ReplaceAction, - +push: (routeName: string, params?: ScreenParams) => PushAction, - +pop: (count?: number) => PopAction, - +popToTop: () => PopToTopAction, - |}; - - declare export type StackRouterOptions = $Exact; - - /** - * Tab actions and router - */ - - declare export type TabNavigationState = {| - ...NavigationState, - +type: 'tab', - +history: $ReadOnlyArray<{| type: 'route', key: string |}>, - |}; - - declare export type JumpToAction = {| - +type: 'JUMP_TO', - +payload: {| +name: string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type TabAction = - | CommonAction - | JumpToAction; - - declare export type TabActionsType = {| - +jumpTo: string => JumpToAction, - |}; - - declare export type TabRouterOptions = {| - ...$Exact, - +backBehavior?: 'initialRoute' | 'order' | 'history' | 'none', - |}; - - /** - * Drawer actions and router - */ - - declare type DrawerHistoryEntry = - | {| +type: 'route', +key: string |} - | {| +type: 'drawer' |}; - declare export type DrawerNavigationState = {| - ...NavigationState, - +type: 'drawer', - +history: $ReadOnlyArray, - |}; - - declare export type OpenDrawerAction = {| - +type: 'OPEN_DRAWER', - +source?: string, - +target?: string, - |}; - declare export type CloseDrawerAction = {| - +type: 'CLOSE_DRAWER', - +source?: string, - +target?: string, - |}; - declare export type ToggleDrawerAction = {| - +type: 'TOGGLE_DRAWER', - +source?: string, - +target?: string, - |}; - declare export type DrawerAction = - | TabAction - | OpenDrawerAction - | CloseDrawerAction - | ToggleDrawerAction; - - declare export type DrawerActionsType = {| - ...TabActionsType, - +openDrawer: () => OpenDrawerAction, - +closeDrawer: () => CloseDrawerAction, - +toggleDrawer: () => ToggleDrawerAction, - |}; - - declare export type DrawerRouterOptions = {| - ...TabRouterOptions, - +defaultStatus?: 'open' | 'closed', - |}; - - /** - * Events - */ - - declare export type EventMapBase = { - +[name: string]: {| - +data?: mixed, - +canPreventDefault?: boolean, - |}, - ... - }; - declare type EventPreventDefaultProperties = $If< - Test, - {| +defaultPrevented: boolean, +preventDefault: () => void |}, - {| |}, - >; - declare type EventDataProperties = $If< - $IsUndefined, - {| |}, - {| +data: Data |}, - >; - declare type EventArg< - EventName: string, - CanPreventDefault: ?boolean = false, - Data = void, - > = {| - ...EventPreventDefaultProperties, - ...EventDataProperties, - +type: EventName, - +target?: string, - |}; - declare type GlobalEventMap = {| - +state: {| +data: {| +state: State |}, +canPreventDefault: false |}, - |}; - declare type EventMapCore = {| - ...GlobalEventMap, - +focus: {| +data: void, +canPreventDefault: false |}, - +blur: {| +data: void, +canPreventDefault: false |}, - +beforeRemove: {| - +data: {| +action: GenericNavigationAction |}, - +canPreventDefault: true, - |}, - |}; - declare type EventListenerCallback< - EventName: string, - State: PossiblyStaleNavigationState = NavigationState, - EventMap: EventMapBase = EventMapCore, - > = (e: EventArg< - EventName, - $PropertyType< - $ElementType< - {| ...EventMap, ...EventMapCore |}, - EventName, - >, - 'canPreventDefault', - >, - $PropertyType< - $ElementType< - {| ...EventMap, ...EventMapCore |}, - EventName, - >, - 'data', - >, - >) => mixed; - - /** - * Navigation prop - */ - - declare type PartialWithMergeProperty = $If< - $IsExact, - { ...$Partial, +merge: true }, - { ...$Partial, +merge: true, ... }, - >; - - declare type EitherExactOrPartialWithMergeProperty = - | ParamsType - | PartialWithMergeProperty; - - declare export type SimpleNavigate = - >( - routeName: DestinationRouteName, - params: EitherExactOrPartialWithMergeProperty< - $ElementType, - >, - ) => void; - - declare export type Navigate = - & SimpleNavigate - & >( - route: $If< - $IsUndefined<$ElementType>, - | {| +key: string |} - | {| +name: DestinationRouteName, +key?: string |}, - | {| - +key: string, - +params?: EitherExactOrPartialWithMergeProperty< - $ElementType, - >, - |} - | {| - +name: DestinationRouteName, - +key?: string, - +params?: EitherExactOrPartialWithMergeProperty< - $ElementType, - >, - |}, - >, - ) => void; - - declare type CoreNavigationHelpers< - ParamList: ParamListBase, - State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, - EventMap: EventMapBase = EventMapCore, - > = { - +navigate: Navigate, - +dispatch: ( - action: - | GenericNavigationAction - | (State => GenericNavigationAction), - ) => void, - +reset: PossiblyStaleNavigationState => void, - +goBack: () => void, - +isFocused: () => boolean, - +canGoBack: () => boolean, - +getId: () => string | void, - +getParent: >(id?: string) => ?Parent, - +getState: () => NavigationState, - +addListener: |}, - >>( - name: EventName, - callback: EventListenerCallback, - ) => () => void, - +removeListener: |}, - >>( - name: EventName, - callback: EventListenerCallback, - ) => void, - ... - }; - - declare export type NavigationHelpers< - ParamList: ParamListBase, - State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, - EventMap: EventMapBase = EventMapCore, - > = { - ...$Exact>, - +setParams: (params: ScreenParams) => void, - ... - }; - - declare type SetParamsInput< - ParamList: ParamListBase, - RouteName: $Keys = $Keys, - > = $If< - $IsUndefined<$ElementType>, - empty, - $Partial<$NonMaybeType<$ElementType>>, - >; - - declare export type NavigationProp< - ParamList: ParamListBase, - RouteName: $Keys = $Keys, - State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = { - ...$Exact>, - +setOptions: (options: $Partial) => void, - +setParams: (params: SetParamsInput) => void, - ... - }; - - /** - * CreateNavigator - */ - - declare export type RouteProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - > = {| - ...LeafRoute, - +params: $ElementType, - +path?: string, - |}; - - declare type ScreenOptionsProp< - ScreenOptions: {...}, - RouteParam, - NavHelpers, - > = - | ScreenOptions - | ({| +route: RouteParam, +navigation: NavHelpers |}) => ScreenOptions; - declare export type ScreenListeners< - State: NavigationState = NavigationState, - EventMap: EventMapBase = EventMapCore, - > = $ObjMapi< - {| [name: $Keys]: empty |}, - >(K, empty) => EventListenerCallback, - >; - declare type ScreenListenersProp< - ScreenListenersParam: {...}, - RouteParam, - NavHelpers, - > = - | ScreenListenersParam - | ({| +route: RouteParam, +navigation: NavHelpers |}) => ScreenListenersParam; - - declare type BaseScreenProps< - ParamList: ParamListBase, - NavProp, - RouteName: $Keys = $Keys, - State: NavigationState = NavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = {| - +name: RouteName, - +options?: ScreenOptionsProp< - ScreenOptions, - RouteProp, - NavProp, - >, - +listeners?: ScreenListenersProp< - ScreenListeners, - RouteProp, - NavProp, - >, - +initialParams?: $Partial<$ElementType>, - +getId?: ({ - +params: $ElementType, - }) => string | void, - +navigationKey?: string, - |}; - - declare export type ScreenProps< - ParamList: ParamListBase, - NavProp, - RouteName: $Keys = $Keys, - State: NavigationState = NavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = - | {| - ...BaseScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >, - +component: React$ComponentType<{| - +route: RouteProp, - +navigation: NavProp, - |}>, - |} - | {| - ...BaseScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >, - +getComponent: () => React$ComponentType<{| - +route: RouteProp, - +navigation: NavProp, - |}>, - |} - | {| - ...BaseScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >, - +children: ({| - +route: RouteProp, - +navigation: NavProp, - |}) => React$Node, - |}; - - declare export type ScreenComponent< - GlobalParamList: ParamListBase, - ParamList: ParamListBase, - State: NavigationState = NavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = < - RouteName: $Keys, - NavProp: NavigationProp< - GlobalParamList, - RouteName, - State, - ScreenOptions, - EventMap, - >, - >(props: ScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >) => React$Node; - - declare type ScreenOptionsProps< - ScreenOptions: {...}, - RouteParam, - NavHelpers, - > = {| - +screenOptions?: ScreenOptionsProp, - |}; - declare type ScreenListenersProps< - ScreenListenersParam: {...}, - RouteParam, - NavHelpers, - > = {| - +screenListeners?: ScreenListenersProp< - ScreenListenersParam, - RouteParam, - NavHelpers, - >, - |}; - declare export type ExtraNavigatorPropsBase = { - ...$Exact, - +id?: string, - +children?: React$Node, - ... - }; - declare export type NavigatorProps< - ScreenOptions: {...}, - ScreenListenersParam, - RouteParam, - NavHelpers, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - > = { - ...$Exact, - ...ScreenOptionsProps, - ...ScreenListenersProps, - +defaultScreenOptions?: - | ScreenOptions - | ({| - +route: RouteParam, - +navigation: NavHelpers, - +options: ScreenOptions, - |}) => ScreenOptions, - ... - }; - declare export type NavigatorPropsBase< - ScreenOptions: {...}, - ScreenListenersParam: {...}, - NavHelpers, - > = NavigatorProps< - ScreenOptions, - ScreenListenersParam, - RouteProp<>, - NavHelpers, - ExtraNavigatorPropsBase, - >; - - declare export type CreateNavigator< - State: NavigationState, - ScreenOptions: {...}, - EventMap: EventMapBase, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - > = < - GlobalParamList: ParamListBase, - ParamList: ParamListBase, - NavHelpers: NavigationHelpers< - GlobalParamList, - State, - EventMap, - >, - >() => {| - +Screen: ScreenComponent< - GlobalParamList, - ParamList, - State, - ScreenOptions, - EventMap, - >, - +Navigator: React$ComponentType<$Exact, - RouteProp, - NavHelpers, - ExtraNavigatorProps, - >>>, - +Group: React$ComponentType<{| - ...ScreenOptionsProps, NavHelpers>, - +children: React$Node, - +navigationKey?: string, - |}>, - |}; - - declare export type CreateNavigatorFactory = < - State: NavigationState, - ScreenOptions: {...}, - EventMap: EventMapBase, - NavHelpers: NavigationHelpers< - ParamListBase, - State, - EventMap, - >, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - >( - navigator: React$ComponentType<$Exact, - RouteProp<>, - NavHelpers, - ExtraNavigatorProps, - >>>, - ) => CreateNavigator; - - - /** - * useNavigationBuilder - */ - - declare export type Descriptor< - NavHelpers, - ScreenOptions: {...} = {...}, - > = {| - +render: () => React$Node, - +options: $ReadOnly, - +navigation: NavHelpers, - |}; - - declare export type UseNavigationBuilder = < - State: NavigationState, - Action: GenericNavigationAction, - ScreenOptions: {...}, - RouterOptions: DefaultRouterOptions, - NavHelpers, - EventMap: EventMapBase, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - >( - routerFactory: RouterFactory, - options: $Exact, - RouteProp<>, - NavHelpers, - ExtraNavigatorProps, - >>, - ) => {| - +id?: string, - +state: State, - +descriptors: {| +[key: string]: Descriptor |}, - +navigation: NavHelpers, - |}; - - /** - * EdgeInsets - */ - - declare type EdgeInsets = {| - +top: number, - +right: number, - +bottom: number, - +left: number, - |}; - - /** - * TransitionPreset - */ - - declare export type TransitionSpec = - | {| - animation: 'spring', - config: $Diff< - SpringAnimationConfigSingle, - { toValue: number | AnimatedValue, ... }, - >, - |} - | {| - animation: 'timing', - config: $Diff< - TimingAnimationConfigSingle, - { toValue: number | AnimatedValue, ... }, - >, - |}; - - declare export type StackCardInterpolationProps = {| - +current: {| - +progress: AnimatedInterpolation, - |}, - +next?: {| - +progress: AnimatedInterpolation, - |}, - +index: number, - +closing: AnimatedInterpolation, - +swiping: AnimatedInterpolation, - +inverted: AnimatedInterpolation, - +layouts: {| - +screen: {| +width: number, +height: number |}, - |}, - +insets: EdgeInsets, - |}; - declare export type StackCardInterpolatedStyle = {| - containerStyle?: AnimatedViewStyleProp, - cardStyle?: AnimatedViewStyleProp, - overlayStyle?: AnimatedViewStyleProp, - shadowStyle?: AnimatedViewStyleProp, - |}; - declare export type StackCardStyleInterpolator = ( - props: StackCardInterpolationProps, - ) => StackCardInterpolatedStyle; - - declare export type StackHeaderInterpolationProps = {| - +current: {| - +progress: AnimatedInterpolation, - |}, - +next?: {| - +progress: AnimatedInterpolation, - |}, - +layouts: {| - +header: {| +width: number, +height: number |}, - +screen: {| +width: number, +height: number |}, - +title?: {| +width: number, +height: number |}, - +leftLabel?: {| +width: number, +height: number |}, - |}, - |}; - declare export type StackHeaderInterpolatedStyle = {| - leftLabelStyle?: AnimatedViewStyleProp, - leftButtonStyle?: AnimatedViewStyleProp, - rightButtonStyle?: AnimatedViewStyleProp, - titleStyle?: AnimatedViewStyleProp, - backgroundStyle?: AnimatedViewStyleProp, - |}; - declare export type StackHeaderStyleInterpolator = ( - props: StackHeaderInterpolationProps, - ) => StackHeaderInterpolatedStyle; - - declare type GestureDirection = - | 'horizontal' - | 'horizontal-inverted' - | 'vertical' - | 'vertical-inverted'; - - declare export type TransitionPreset = {| - +gestureDirection: GestureDirection, - +transitionSpec: {| - +open: TransitionSpec, - +close: TransitionSpec, - |}, - +cardStyleInterpolator: StackCardStyleInterpolator, - +headerStyleInterpolator: StackHeaderStyleInterpolator, - |}; - - /** - * Header common options - */ - - declare export type SceneProgress = {| - +current: AnimatedInterpolation, - +next?: AnimatedInterpolation, - +previous?: AnimatedInterpolation, - |}; - - declare export type HeaderProps = {| - +navigation: NavProp, - +route: RouteProp<>, - +options: ScreenOptions, - +layout: {| +width: number, +height: number |}, - |}; - - declare export type HeaderButtonProps = $Partial<{| - +tintColor: string, - +pressColor: string, - +pressOpacity: number, - |}>; - - declare export type HeaderLeftButtonProps = $Partial<{| - ...HeaderButtonProps, - +labelVisible: boolean, - |}>; - - declare type HeaderTitleInputBase = { - +onLayout: LayoutEvent => void, - +children: string, - +allowFontScaling: ?boolean, - +tintColor: ?string, - +style: ?AnimatedTextStyleProp, - ... - }; - - declare export type HeaderTitleInputProps = - $Exact; - - declare export type HeaderCommonOptions< - NavHeaderProps, - NavHeaderLeftProps, - NavHeaderRightProps, - > = $Partial<{| - +header: NavHeaderProps => React$Node, - +headerShown: boolean, - +headerTitle: string | ( HeaderTitleInputProps => React$Node), - +headerTitleAlign: 'left' | 'center', - +headerTitleStyle: AnimatedTextStyleProp, - +headerTitleContainerStyle: AnimatedViewStyleProp, - +headerTintColor: string, - +headerTitleAllowFontScaling: boolean, - +headerLeft: NavHeaderLeftProps => React$Node, - +headerLeftContainerStyle: AnimatedViewStyleProp, - +headerRight: NavHeaderRightProps => React$Node, - +headerRightContainerStyle: AnimatedViewStyleProp, - +headerBackground: ({| style: AnimatedViewStyleProp |}) => React$Node, - +headerStyle: AnimatedViewStyleProp, - +headerTransparent: boolean, - +headerStatusBarHeight: number, - +headerShadowVisible: boolean, - +headerBackgroundContainerStyle: AnimatedViewStyleProp, - +headerPressColor: string, - +headerPressOpacity: number, - |}>; - - /** - * Stack options - */ - - declare export type StackDescriptor = Descriptor< - StackNavigationHelpers<>, - StackOptions, - >; - - declare type Scene = {| - +route: T, - +descriptor: StackDescriptor, - +progress: SceneProgress, - |}; - - declare export type StackHeaderProps = {| - ...HeaderProps, StackOptions>, - +progress: SceneProgress, - +back?: {| +title: string |}, - +styleInterpolator: StackHeaderStyleInterpolator, - |}; - - declare export type StackHeaderButtonProps = $Partial<{| - ...HeaderButtonProps, - +canGoBack: boolean, - |}>; - - declare export type StackHeaderLeftButtonProps = $Partial<{| - ...StackHeaderButtonProps, - +onPress: (() => void), - +backImage: (props: {| tintColor: string |}) => React$Node, - +label: string, - +truncatedLabel: string, - +labelVisible: boolean, - +labelStyle: AnimatedTextStyleProp, - +allowFontScaling: boolean, - +onLabelLayout: LayoutEvent => void, - +screenLayout: {| +width: number, +height: number |}, - +titleLayout: {| +width: number, +height: number |}, - +disabled: boolean, - +accessibilityLabel: string, - +style: ViewStyleProp, - |}>; - - declare export type StackOptions = $Partial<{| - +title: string, - +cardShadowEnabled: boolean, - +cardOverlayEnabled: boolean, - +cardOverlay: {| style: ViewStyleProp |} => React$Node, - +cardStyle: ViewStyleProp, - +animationEnabled: boolean, - +animationTypeForReplace: 'push' | 'pop', - +gestureEnabled: boolean, - +gestureResponseDistance: number, - +gestureVelocityImpact: number, - +safeAreaInsets: $Partial, - +keyboardHandlingEnabled: boolean, - +presentation: 'card' | 'modal' | 'transparentModal', - // Transition - ...TransitionPreset, - // Header - ...HeaderCommonOptions< - StackHeaderProps, - StackHeaderLeftButtonProps, - StackHeaderButtonProps, - >, - +headerMode: 'float' | 'screen', - +headerBackAllowFontScaling: boolean, - +headerBackTitle: string | null, - +headerBackTitleStyle: TextStyleProp, - +headerBackTitleVisible: boolean, - +headerTruncatedBackTitle: string, - +headerBackImage: $PropertyType, - +headerBackAccessibilityLabel: string, - |}>; - - /** - * Stack navigation prop - */ - - declare export type StackNavigationEventMap = {| - ...EventMapCore, - +transitionStart: {| - +data: {| +closing: boolean |}, - +canPreventDefault: false, - |}, - +transitionEnd: {| - +data: {| +closing: boolean |}, - +canPreventDefault: false, - |}, - +gestureStart: {| +data: void, +canPreventDefault: false |}, - +gestureEnd: {| +data: void, +canPreventDefault: false |}, - +gestureCancel: {| +data: void, +canPreventDefault: false |}, - |}; - - declare type StackExtraNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - > = {| - +replace: SimpleNavigate, - +push: SimpleNavigate, - +pop: (count?: number) => void, - +popToTop: () => void, - |}; - - declare export type StackNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = StackNavigationEventMap, - > = { - ...$Exact>, - ...StackExtraNavigationHelpers, - ... - }; - - declare export type StackNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = StackOptions, - EventMap: EventMapBase = StackNavigationEventMap, - > = {| - ...$Exact>, - ...StackExtraNavigationHelpers, - |}; - - /** - * Miscellaneous stack exports - */ - - declare type StackNavigationConfig = {| - +detachInactiveScreens?: boolean, - |}; - - declare export type ExtraStackNavigatorProps = {| - ...$Exact, - ...StackRouterOptions, - ...StackNavigationConfig, - |}; - - declare export type StackNavigatorProps< - NavHelpers: StackNavigationHelpers<> = StackNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraStackNavigatorProps, - >>; - - /** - * Bottom tab options - */ - - declare export type BottomTabBarButtonProps = {| - ...$Diff< - TouchableWithoutFeedbackProps, - {| onPress?: ?(event: PressEvent) => mixed |}, - >, - +to?: string, - +children: React$Node, - +onPress?: (MouseEvent | PressEvent) => void, - |}; - - declare export type TabBarVisibilityAnimationConfig = - | {| - +animation: 'spring', - +config?: $Diff< - SpringAnimationConfigSingle, - { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, - >, - |} - | {| - +animation: 'timing', - +config?: $Diff< - TimingAnimationConfigSingle, - { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, - >, - |}; - - declare export type BottomTabOptions = $Partial<{| - +title: string, - +tabBarLabel: - | string - | ({| focused: boolean, color: string |}) => React$Node, - +tabBarIcon: ({| - focused: boolean, - color: string, - size: number, - |}) => React$Node, - +tabBarBadge: number | string, - +tabBarBadgeStyle: TextStyleProp, - +tabBarAccessibilityLabel: string, - +tabBarTestID: string, - +tabBarVisibilityAnimationConfig: $Partial<{| - +show: TabBarVisibilityAnimationConfig, - +hide: TabBarVisibilityAnimationConfig, - |}>, - +tabBarButton: BottomTabBarButtonProps => React$Node, - +tabBarHideOnKeyboard: boolean, - +tabBarActiveTintColor: string, - +tabBarInactiveTintColor: string, - +tabBarActiveBackgroundColor: string, - +tabBarInactiveBackgroundColor: string, - +tabBarAllowFontScaling: boolean, - +tabBarShowLabel: boolean, - +tabBarLabelStyle: TextStyleProp, - +tabBarIconStyle: TextStyleProp, - +tabBarItemStyle: ViewStyleProp, - +tabBarLabelPosition: 'beside-icon' | 'below-icon', - +tabBarStyle: ViewStyleProp, - +unmountOnBlur: boolean, - +lazy: boolean, - ...HeaderCommonOptions< - HeaderProps, BottomTabOptions>, - HeaderLeftButtonProps, - HeaderButtonProps, - >, - |}>; - - /** - * Bottom tab navigation prop - */ - - declare export type BottomTabNavigationEventMap = {| - ...EventMapCore, - +tabPress: {| +data: void, +canPreventDefault: true |}, - +tabLongPress: {| +data: void, +canPreventDefault: false |}, - |}; - - declare type TabExtraNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - > = {| - +jumpTo: SimpleNavigate, - |}; - - declare export type BottomTabNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = BottomTabNavigationEventMap, - > = { - ...$Exact>, - ...TabExtraNavigationHelpers, - ... - }; - - declare export type BottomTabNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = BottomTabOptions, - EventMap: EventMapBase = BottomTabNavigationEventMap, - > = {| - ...$Exact>, - ...TabExtraNavigationHelpers, - |}; - - /** - * Miscellaneous bottom tab exports - */ - - declare export type BottomTabDescriptor = Descriptor< - BottomTabNavigationHelpers<>, - BottomTabOptions, - >; - - declare type BottomTabNavigationBuilderResult = {| - +state: TabNavigationState, - +navigation: BottomTabNavigationHelpers<>, - +descriptors: {| +[key: string]: BottomTabDescriptor |}, - |}; - - declare export type BottomTabBarProps = BottomTabNavigationBuilderResult; - - declare type BottomTabNavigationConfig = {| - +tabBar?: BottomTabBarProps => React$Node, - +safeAreaInsets?: $Partial, - +detachInactiveScreens?: boolean, - |}; - - declare export type ExtraBottomTabNavigatorProps = {| - ...$Exact, - ...TabRouterOptions, - ...BottomTabNavigationConfig, - |}; - - declare export type BottomTabNavigatorProps< - NavHelpers: BottomTabNavigationHelpers<> = BottomTabNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraBottomTabNavigatorProps, - >>; - - /** - * Material bottom tab options - */ - - declare export type MaterialBottomTabOptions = $Partial<{| - +title: string, - +tabBarColor: string, - +tabBarLabel: string, - +tabBarIcon: - | string - | ({| +focused: boolean, +color: string |}) => React$Node, - +tabBarBadge: boolean | number | string, - +tabBarAccessibilityLabel: string, - +tabBarTestID: string, - |}>; - - /** - * Material bottom tab navigation prop - */ - - declare export type MaterialBottomTabNavigationEventMap = {| - ...EventMapCore, - +tabPress: {| +data: void, +canPreventDefault: true |}, - |}; - - declare export type MaterialBottomTabNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, - > = { - ...$Exact>, - ...TabExtraNavigationHelpers, - ... - }; - - declare export type MaterialBottomTabNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = MaterialBottomTabOptions, - EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, - > = {| - ...$Exact>, - ...TabExtraNavigationHelpers, - |}; - - /** - * Miscellaneous material bottom tab exports - */ - - declare export type PaperFont = {| - +fontFamily: string, - +fontWeight?: - | 'normal' - | 'bold' - | '100' - | '200' - | '300' - | '400' - | '500' - | '600' - | '700' - | '800' - | '900', - |}; - - declare export type PaperFonts = {| - +regular: PaperFont, - +medium: PaperFont, - +light: PaperFont, - +thin: PaperFont, - |}; - - declare export type PaperTheme = {| - +dark: boolean, - +mode?: 'adaptive' | 'exact', - +roundness: number, - +colors: {| - +primary: string, - +background: string, - +surface: string, - +accent: string, - +error: string, - +text: string, - +onSurface: string, - +onBackground: string, - +disabled: string, - +placeholder: string, - +backdrop: string, - +notification: string, - |}, - +fonts: PaperFonts, - +animation: {| - +scale: number, - |}, - |}; - - declare export type PaperRoute = {| - +key: string, - +title?: string, - +icon?: any, - +badge?: string | number | boolean, - +color?: string, - +accessibilityLabel?: string, - +testID?: string, - |}; - - declare export type PaperTouchableProps = {| - ...TouchableWithoutFeedbackProps, - +key: string, - +route: PaperRoute, - +children: React$Node, - +borderless?: boolean, - +centered?: boolean, - +rippleColor?: string, - |}; - - declare export type MaterialBottomTabNavigationConfig = {| - +shifting?: boolean, - +labeled?: boolean, - +renderTouchable?: PaperTouchableProps => React$Node, - +activeColor?: string, - +inactiveColor?: string, - +sceneAnimationEnabled?: boolean, - +keyboardHidesNavigationBar?: boolean, - +barStyle?: ViewStyleProp, - +style?: ViewStyleProp, - +theme?: PaperTheme, - |}; - - declare export type ExtraMaterialBottomTabNavigatorProps = {| - ...$Exact, - ...TabRouterOptions, - ...MaterialBottomTabNavigationConfig, - |}; - - declare export type MaterialBottomTabNavigatorProps< - NavHelpers: MaterialBottomTabNavigationHelpers<> = - MaterialBottomTabNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraMaterialBottomTabNavigatorProps, - >>; - - /** - * Material top tab options - */ - - declare export type MaterialTopTabOptions = $Partial<{| - +title: string, - +tabBarLabel: - | string - | ({| +focused: boolean, +color: string |}) => React$Node, - +tabBarIcon: ({| +focused: boolean, +color: string |}) => React$Node, - +tabBarAccessibilityLabel: string, - +tabBarTestID: string, - +tabBarActiveTintColor: string, - +tabBarInactiveTintColor: string, - +tabBarPressColor: string, - +tabBarPressOpacity: number, - +tabBarShowLabel: boolean, - +tabBarShowIcon: boolean, - +tabBarAllowFontScaling: boolean, - +tabBarBounces: boolean, - +tabBarScrollEnabled: boolean, - +tabBarIconStyle: ViewStyleProp, - +tabBarLabelStyle: TextStyleProp, - +tabBarItemStyle: ViewStyleProp, - +tabBarIndicatorStyle: ViewStyleProp, - +tabBarIndicatorContainerStyle: ViewStyleProp, - +tabBarContentContainerStyle: ViewStyleProp, - +tabBarStyle: ViewStyleProp, - +tabBarBadge: () => React$Node, - +tabBarIndicator: MaterialTopTabBarIndicatorProps => React$Node, - +lazy: boolean, - +lazyPlaceholder: ({| +route: Route<> |}) => React$Node, - |}>; - - /** - * Material top tab navigation prop - */ - - declare export type MaterialTopTabNavigationEventMap = {| - ...EventMapCore, - +tabPress: {| +data: void, +canPreventDefault: true |}, - +tabLongPress: {| +data: void, +canPreventDefault: false |}, - +swipeStart: {| +data: void, +canPreventDefault: false |}, - +swipeEnd: {| +data: void, +canPreventDefault: false |}, - |}; - - declare export type MaterialTopTabNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = MaterialTopTabNavigationEventMap, - > = { - ...$Exact>, - ...TabExtraNavigationHelpers, - ... - }; - - declare export type MaterialTopTabNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = MaterialTopTabOptions, - EventMap: EventMapBase = MaterialTopTabNavigationEventMap, - > = {| - ...$Exact>, - ...TabExtraNavigationHelpers, - |}; - - /** - * Miscellaneous material top tab exports - */ - - declare type MaterialTopTabPagerCommonProps = {| - +keyboardDismissMode: 'none' | 'on-drag' | 'auto', - +swipeEnabled: boolean, - +swipeVelocityImpact?: number, - +springVelocityScale?: number, - +springConfig: $Partial<{| - +damping: number, - +mass: number, - +stiffness: number, - +restSpeedThreshold: number, - +restDisplacementThreshold: number, - |}>, - +timingConfig: $Partial<{| - +duration: number, - |}>, - |}; - - declare export type MaterialTopTabPagerProps = {| - ...MaterialTopTabPagerCommonProps, - +onSwipeStart?: () => void, - +onSwipeEnd?: () => void, - +onIndexChange: (index: number) => void, - +navigationState: TabNavigationState, - +layout: {| +width: number, +height: number |}, - +removeClippedSubviews: boolean, - +children: ({| - +addListener: (type: 'enter', listener: number => void) => void, - +removeListener: (type: 'enter', listener: number => void) => void, - +position: any, // Reanimated.Node - +render: React$Node => React$Node, - +jumpTo: string => void, - |}) => React$Node, - +gestureHandlerProps: PanGestureHandlerProps, - |}; - - declare export type MaterialTopTabBarIndicatorProps = {| - +state: TabNavigationState, - +width: string, - +style?: ViewStyleProp, - +getTabWidth: number => number, - |}; - - declare export type MaterialTopTabDescriptor = Descriptor< - MaterialBottomTabNavigationHelpers<>, - MaterialBottomTabOptions, - >; - - declare type MaterialTopTabNavigationBuilderResult = {| - +state: TabNavigationState, - +navigation: MaterialTopTabNavigationHelpers<>, - +descriptors: {| +[key: string]: MaterialTopTabDescriptor |}, - |}; - - declare export type MaterialTopTabBarProps = {| - ...MaterialTopTabNavigationBuilderResult, - +layout: {| +width: number, +height: number |}, - +position: any, // Reanimated.Node - +jumpTo: string => void, - |}; - - declare export type MaterialTopTabNavigationConfig = {| - ...$Partial, - +position?: any, // Reanimated.Value - +tabBarPosition?: 'top' | 'bottom', - +initialLayout?: $Partial<{| +width: number, +height: number |}>, - +lazyPreloadDistance?: number, - +removeClippedSubviews?: boolean, - +sceneContainerStyle?: ViewStyleProp, - +style?: ViewStyleProp, - +gestureHandlerProps?: PanGestureHandlerProps, - +pager?: MaterialTopTabPagerProps => React$Node, - +tabBar?: MaterialTopTabBarProps => React$Node, - |}; - - declare export type ExtraMaterialTopTabNavigatorProps = {| - ...$Exact, - ...TabRouterOptions, - ...MaterialTopTabNavigationConfig, - |}; - - declare export type MaterialTopTabNavigatorProps< - NavHelpers: MaterialTopTabNavigationHelpers<> = - MaterialTopTabNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraMaterialTopTabNavigatorProps, - >>; - - /** - * Drawer options - */ - - declare export type DrawerOptions = $Partial<{| - +title: string, - +lazy: boolean, - +drawerLabel: - | string - | ({| +color: string, +focused: boolean |}) => React$Node, - +drawerIcon: ({| - +color: string, - +size: number, - +focused: boolean, - |}) => React$Node, - +drawerActiveTintColor: string, - +drawerActiveBackgroundColor: string, - +drawerInactiveTintColor: string, - +drawerInactiveBackgroundColor: string, - +drawerItemStyle: ViewStyleProp, - +drawerLabelStyle: TextStyleProp, - +drawerContentContainerStyle: ViewStyleProp, - +drawerContentStyle: ViewStyleProp, - +drawerStyle: ViewStyleProp, - +drawerPosition: 'left' | 'right', - +drawerType: 'front' | 'back' | 'slide' | 'permanent', - +drawerHideStatusBarOnOpen: boolean, - +drawerStatusBarAnimation: 'slide' | 'none' | 'fade', - +overlayColor: string, - +sceneContainerStyle: ViewStyleProp, - +gestureHandlerProps: PanGestureHandlerProps, - +swipeEnabled: boolean, - +swipeEdgeWidth: number, - +swipeMinDistance: number, - +keyboardDismissMode: 'on-drag' | 'none', - +unmountOnBlur: boolean, - ...HeaderCommonOptions< - HeaderProps, DrawerOptions>, - HeaderLeftButtonProps, - HeaderButtonProps, - >, - |}>; - - /** - * Drawer navigation prop - */ - - declare export type DrawerNavigationEventMap = - EventMapCore; - - declare type DrawerExtraNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - > = {| - +jumpTo: SimpleNavigate, - +openDrawer: () => void, - +closeDrawer: () => void, - +toggleDrawer: () => void, - |}; - - declare export type DrawerNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = DrawerNavigationEventMap, - > = { - ...$Exact>, - ...DrawerExtraNavigationHelpers, - ... - }; - - declare export type DrawerNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = DrawerOptions, - EventMap: EventMapBase = DrawerNavigationEventMap, - > = {| - ...$Exact>, - ...DrawerExtraNavigationHelpers, - |}; - - /** - * Miscellaneous drawer exports - */ - - declare export type DrawerDescriptor = Descriptor< - DrawerNavigationHelpers<>, - DrawerOptions, - >; - - declare type DrawerNavigationBuilderResult = {| - +state: DrawerNavigationState, - +navigation: DrawerNavigationHelpers<>, - +descriptors: {| +[key: string]: DrawerDescriptor |}, - |}; - - declare export type DrawerNavigationConfig = {| - +drawerContent?: DrawerNavigationBuilderResult => React$Node, - +detachInactiveScreens?: boolean, - +useLegacyImplementation?: boolean, - |}; - - declare export type ExtraDrawerNavigatorProps = {| - ...$Exact, - ...DrawerRouterOptions, - ...DrawerNavigationConfig, - |}; - - declare export type DrawerNavigatorProps< - NavHelpers: DrawerNavigationHelpers<> = DrawerNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraDrawerNavigatorProps, - >>; - - /** - * BaseNavigationContainer - */ - - declare export type BaseNavigationContainerProps = {| - +children: React$Node, - +initialState?: PossiblyStaleNavigationState, - +onStateChange?: (state: ?PossiblyStaleNavigationState) => void, - +independent?: boolean, - |}; - - declare export type ContainerEventMap = {| - ...GlobalEventMap, - +options: {| - +data: {| +options: { +[key: string]: mixed, ... } |}, - +canPreventDefault: false, - |}, - +__unsafe_action__: {| - +data: {| - +action: GenericNavigationAction, - +noop: boolean, - |}, - +canPreventDefault: false, - |}, - |}; - - declare export type BaseNavigationContainerInterface = {| - ...$Exact>, - +resetRoot: (state?: PossiblyStaleNavigationState) => void, - +getRootState: () => NavigationState, - +getCurrentRoute: () => RouteProp<> | void, - +getCurrentOptions: () => Object | void, - +isReady: () => boolean, - |}; - - declare type BaseNavigationContainerInterfaceRef = {| - ...BaseNavigationContainerInterface, - +current: BaseNavigationContainerInterface | null, - |}; - - /** - * State utils - */ - - declare export type GetStateFromPath = ( - path: string, - options?: LinkingConfig, - ) => PossiblyStaleNavigationState; - - declare export type GetPathFromState = ( - state?: ?PossiblyStaleNavigationState, - options?: LinkingConfig, - ) => string; - - declare export type GetFocusedRouteNameFromRoute = - PossiblyStaleRoute => ?string; - - /** - * Linking - */ - - declare export type ScreenLinkingConfig = {| - +path?: string, - +exact?: boolean, - +parse?: {| +[param: string]: string => mixed |}, - +stringify?: {| +[param: string]: mixed => string |}, - +screens?: ScreenLinkingConfigMap, - +initialRouteName?: string, - |}; - - declare export type ScreenLinkingConfigMap = {| - +[routeName: string]: string | ScreenLinkingConfig, - |}; - - declare export type LinkingConfig = {| - +initialRouteName?: string, - +screens: ScreenLinkingConfigMap, - |}; - - declare export type LinkingOptions = {| - +enabled?: boolean, - +prefixes: $ReadOnlyArray, - +config?: LinkingConfig, - +getStateFromPath?: GetStateFromPath, - +getPathFromState?: GetPathFromState, - |}; - - /** - * NavigationContainer - */ - - declare export type Theme = {| - +dark: boolean, - +colors: {| - +primary: string, - +background: string, - +card: string, - +text: string, - +border: string, - |}, - |}; - - declare export type NavigationContainerType = React$AbstractComponent< - {| - ...BaseNavigationContainerProps, - +theme?: Theme, - +linking?: LinkingOptions, - +fallback?: React$Node, - +onReady?: () => mixed, - |}, - BaseNavigationContainerInterface, - >; - - //--------------------------------------------------------------------------- - // SECTION 2: EXPORTED MODULE - // This section defines the module exports and contains exported types that - // are not present in any other React Navigation libdef. - //--------------------------------------------------------------------------- + import type { + ImageURISource, + HeaderTitleInputBase, + StackHeaderLeftButtonProps, + AnimatedViewStyleProp, + } from '@react-navigation/core'; /** * Image assets @@ -2268,10 +17,10 @@ * Header components */ - declare export type StackHeaderTitleProps = $Partial; + declare export type StackHeaderTitleProps = Partial; declare export var HeaderTitle: React$ComponentType; - declare export type HeaderBackButtonProps = $Partial<{| + declare export type HeaderBackButtonProps = Partial<{| ...StackHeaderLeftButtonProps, +disabled: boolean, +accessibilityLabel: string, @@ -2280,7 +29,7 @@ HeaderBackButtonProps, >; - declare export type HeaderBackgroundProps = $Partial<{ + declare export type HeaderBackgroundProps = Partial<{ +children: React$Node, +style: AnimatedViewStyleProp, ... diff --git a/native/flow-typed/npm/@react-navigation/material-top-tabs_v6.x.x.js b/native/flow-typed/npm/@react-navigation/material-top-tabs_v6.x.x.js --- a/native/flow-typed/npm/@react-navigation/material-top-tabs_v6.x.x.js +++ b/native/flow-typed/npm/@react-navigation/material-top-tabs_v6.x.x.js @@ -3,2263 +3,16 @@ declare module '@react-navigation/material-top-tabs' { - //--------------------------------------------------------------------------- - // SECTION 1: IDENTICAL TYPE DEFINITIONS - // This section is identical across all React Navigation libdefs and contains - // shared definitions. We wish we could make it DRY and import from a shared - // definition, but that isn't yet possible. - //--------------------------------------------------------------------------- - - /** - * We start with some definitions that we have copy-pasted from React Native - * source files. - */ - - // This is a bastardization of the true StyleObj type located in - // react-native/Libraries/StyleSheet/StyleSheetTypes. We unfortunately can't - // import that here, and it's too lengthy (and consequently too brittle) to - // copy-paste here either. - declare type StyleObj = - | null - | void - | number - | false - | '' - | $ReadOnlyArray - | { [name: string]: any, ... }; - declare type ViewStyleProp = StyleObj; - declare type TextStyleProp = StyleObj; - declare type AnimatedViewStyleProp = StyleObj; - declare type AnimatedTextStyleProp = StyleObj; - - // Vaguely copied from - // react-native/Libraries/Animated/src/animations/Animation.js - declare type EndResult = { finished: boolean, ... }; - declare type EndCallback = (result: EndResult) => void; - declare interface Animation { - start( - fromValue: number, - onUpdate: (value: number) => void, - onEnd: ?EndCallback, - previousAnimation: ?Animation, - animatedValue: AnimatedValue, - ): void; - stop(): void; - } - declare type AnimationConfig = { - isInteraction?: boolean, - useNativeDriver: boolean, - onComplete?: ?EndCallback, - iterations?: number, - ... - }; - - // Vaguely copied from - // react-native/Libraries/Animated/src/nodes/AnimatedTracking.js - declare interface AnimatedTracking { - constructor( - value: AnimatedValue, - parent: any, - animationClass: any, - animationConfig: Object, - callback?: ?EndCallback, - ): void; - update(): void; - } - - // Vaguely copied from - // react-native/Libraries/Animated/src/nodes/AnimatedValue.js - declare type ValueListenerCallback = (state: { value: number, ... }) => void; - declare interface AnimatedValue { - constructor(value: number): void; - setValue(value: number): void; - setOffset(offset: number): void; - flattenOffset(): void; - extractOffset(): void; - addListener(callback: ValueListenerCallback): string; - removeListener(id: string): void; - removeAllListeners(): void; - stopAnimation(callback?: ?(value: number) => void): void; - resetAnimation(callback?: ?(value: number) => void): void; - interpolate(config: InterpolationConfigType): AnimatedInterpolation; - animate(animation: Animation, callback: ?EndCallback): void; - stopTracking(): void; - track(tracking: AnimatedTracking): void; - } - - // Copied from - // react-native/Libraries/Animated/src/animations/TimingAnimation.js - declare type TimingAnimationConfigSingle = AnimationConfig & { - toValue: number | AnimatedValue, - easing?: (value: number) => number, - duration?: number, - delay?: number, - ... - }; - - // Copied from - // react-native/Libraries/Animated/src/animations/SpringAnimation.js - declare type SpringAnimationConfigSingle = AnimationConfig & { - toValue: number | AnimatedValue, - overshootClamping?: boolean, - restDisplacementThreshold?: number, - restSpeedThreshold?: number, - velocity?: number, - bounciness?: number, - speed?: number, - tension?: number, - friction?: number, - stiffness?: number, - damping?: number, - mass?: number, - delay?: number, - ... - }; - - // Copied from react-native/Libraries/Types/CoreEventTypes.js - declare type SyntheticEvent = $ReadOnly<{| - bubbles: ?boolean, - cancelable: ?boolean, - currentTarget: number, - defaultPrevented: ?boolean, - dispatchConfig: $ReadOnly<{| - registrationName: string, - |}>, - eventPhase: ?number, - preventDefault: () => void, - isDefaultPrevented: () => boolean, - stopPropagation: () => void, - isPropagationStopped: () => boolean, - isTrusted: ?boolean, - nativeEvent: T, - persist: () => void, - target: ?number, - timeStamp: number, - type: ?string, - |}>; - declare type Layout = $ReadOnly<{| - x: number, - y: number, - width: number, - height: number, - |}>; - declare type LayoutEvent = SyntheticEvent< - $ReadOnly<{| - layout: Layout, - |}>, - >; - declare type BlurEvent = SyntheticEvent< - $ReadOnly<{| - target: number, - |}>, - >; - declare type FocusEvent = SyntheticEvent< - $ReadOnly<{| - target: number, - |}>, - >; - declare type ResponderSyntheticEvent = $ReadOnly<{| - ...SyntheticEvent, - touchHistory: $ReadOnly<{| - indexOfSingleActiveTouch: number, - mostRecentTimeStamp: number, - numberActiveTouches: number, - touchBank: $ReadOnlyArray< - $ReadOnly<{| - touchActive: boolean, - startPageX: number, - startPageY: number, - startTimeStamp: number, - currentPageX: number, - currentPageY: number, - currentTimeStamp: number, - previousPageX: number, - previousPageY: number, - previousTimeStamp: number, - |}>, - >, - |}>, - |}>; - declare type PressEvent = ResponderSyntheticEvent< - $ReadOnly<{| - changedTouches: $ReadOnlyArray<$PropertyType>, - force: number, - identifier: number, - locationX: number, - locationY: number, - pageX: number, - pageY: number, - target: ?number, - timestamp: number, - touches: $ReadOnlyArray<$PropertyType>, - |}>, - >; - - // Vaguely copied from - // react-native/Libraries/Animated/src/nodes/AnimatedInterpolation.js - declare type ExtrapolateType = 'extend' | 'identity' | 'clamp'; - declare type InterpolationConfigType = { - inputRange: Array, - outputRange: Array | Array, - easing?: (input: number) => number, - extrapolate?: ExtrapolateType, - extrapolateLeft?: ExtrapolateType, - extrapolateRight?: ExtrapolateType, - ... - }; - declare interface AnimatedInterpolation { - interpolate(config: InterpolationConfigType): AnimatedInterpolation; - } - - // Copied from react-native/Libraries/Components/View/ViewAccessibility.js - declare type AccessibilityRole = - | 'none' - | 'button' - | 'link' - | 'search' - | 'image' - | 'keyboardkey' - | 'text' - | 'adjustable' - | 'imagebutton' - | 'header' - | 'summary' - | 'alert' - | 'checkbox' - | 'combobox' - | 'menu' - | 'menubar' - | 'menuitem' - | 'progressbar' - | 'radio' - | 'radiogroup' - | 'scrollbar' - | 'spinbutton' - | 'switch' - | 'tab' - | 'tablist' - | 'timer' - | 'toolbar'; - declare type AccessibilityActionInfo = $ReadOnly<{ - name: string, - label?: string, - ... - }>; - declare type AccessibilityActionEvent = SyntheticEvent< - $ReadOnly<{actionName: string, ...}>, - >; - declare type AccessibilityState = { - disabled?: boolean, - selected?: boolean, - checked?: ?boolean | 'mixed', - busy?: boolean, - expanded?: boolean, - ... - }; - declare type AccessibilityValue = $ReadOnly<{| - min?: number, - max?: number, - now?: number, - text?: string, - |}>; - - // Copied from - // react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js - declare type Stringish = string; - declare type EdgeInsetsProp = $ReadOnly<$Partial>; - declare type TouchableWithoutFeedbackProps = $ReadOnly<{| - accessibilityActions?: ?$ReadOnlyArray, - accessibilityElementsHidden?: ?boolean, - accessibilityHint?: ?Stringish, - accessibilityIgnoresInvertColors?: ?boolean, - accessibilityLabel?: ?Stringish, - accessibilityLiveRegion?: ?('none' | 'polite' | 'assertive'), - accessibilityRole?: ?AccessibilityRole, - accessibilityState?: ?AccessibilityState, - accessibilityValue?: ?AccessibilityValue, - accessibilityViewIsModal?: ?boolean, - accessible?: ?boolean, - children?: ?React$Node, - delayLongPress?: ?number, - delayPressIn?: ?number, - delayPressOut?: ?number, - disabled?: ?boolean, - focusable?: ?boolean, - hitSlop?: ?EdgeInsetsProp, - importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'), - nativeID?: ?string, - onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed, - onBlur?: ?(event: BlurEvent) => mixed, - onFocus?: ?(event: FocusEvent) => mixed, - onLayout?: ?(event: LayoutEvent) => mixed, - onLongPress?: ?(event: PressEvent) => mixed, - onPress?: ?(event: PressEvent) => mixed, - onPressIn?: ?(event: PressEvent) => mixed, - onPressOut?: ?(event: PressEvent) => mixed, - pressRetentionOffset?: ?EdgeInsetsProp, - rejectResponderTermination?: ?boolean, - testID?: ?string, - touchSoundDisabled?: ?boolean, - |}>; - - // Copied from react-native/Libraries/Image/ImageSource.js - declare type ImageURISource = $ReadOnly<{ - uri?: ?string, - bundle?: ?string, - method?: ?string, - headers?: ?Object, - body?: ?string, - cache?: ?('default' | 'reload' | 'force-cache' | 'only-if-cached'), - width?: ?number, - height?: ?number, - scale?: ?number, - ... - }>; - - /** - * The following is copied from react-native-gesture-handler's libdef - */ - - declare type StateUndetermined = 0; - declare type StateFailed = 1; - declare type StateBegan = 2; - declare type StateCancelled = 3; - declare type StateActive = 4; - declare type StateEnd = 5; - - declare type GestureHandlerState = - | StateUndetermined - | StateFailed - | StateBegan - | StateCancelled - | StateActive - | StateEnd; - - declare type $SyntheticEvent = { - +nativeEvent: $ReadOnly<$Exact>, - ... - }; - - declare type $Event = $SyntheticEvent<{ - handlerTag: number, - numberOfPointers: number, - state: GestureHandlerState, - oldState: GestureHandlerState, - ...$Exact, - ... - }>; - - declare type $EventHandlers = {| - onGestureEvent?: ($Event) => mixed, - onHandlerStateChange?: ($Event) => mixed, - onBegan?: ($Event) => mixed, - onFailed?: ($Event) => mixed, - onCancelled?: ($Event) => mixed, - onActivated?: ($Event) => mixed, - onEnded?: ($Event) => mixed, - |}; - - declare type HitSlop = - | number - | {| - left?: number, - top?: number, - right?: number, - bottom?: number, - vertical?: number, - horizontal?: number, - width?: number, - height?: number, - |} - | {| - width: number, - left: number, - |} - | {| - width: number, - right: number, - |} - | {| - height: number, - top: number, - |} - | {| - height: number, - bottom: number, - |}; - - declare type $GestureHandlerProps< - AdditionalProps: {...}, - ExtraEventsProps: {...} - > = $ReadOnly<{| - ...$Exact, - ...$EventHandlers, - id?: string, - enabled?: boolean, - waitFor?: React$Ref | Array>, - simultaneousHandlers?: React$Ref | Array>, - shouldCancelWhenOutside?: boolean, - minPointers?: number, - hitSlop?: HitSlop, - children?: React$Node, - |}>; - - declare type PanGestureHandlerProps = $GestureHandlerProps< - { - activeOffsetY?: number | [number, number], - activeOffsetX?: number | [number, number], - failOffsetY?: number | [number, number], - failOffsetX?: number | [number, number], - minDist?: number, - minVelocity?: number, - minVelocityX?: number, - minVelocityY?: number, - minPointers?: number, - maxPointers?: number, - avgTouches?: boolean, - ... - }, - { - x: number, - y: number, - absoluteX: number, - absoluteY: number, - translationX: number, - translationY: number, - velocityX: number, - velocityY: number, - ... - } - >; - - /** - * MAGIC - */ - - declare type $If = $Call< - ((true, Then, Else) => Then) & ((false, Then, Else) => Else), - Test, - Then, - Else, - >; - declare type $IsA = $Call< - (Y => true) & (mixed => false), - X, - >; - declare type $IsUndefined = $IsA; - - declare type $Partial = $ReadOnly<$Rest>; - - // If { ...T, ... } counts as a T, then we're inexact - declare type $IsExact = $Call< - (T => false) & (mixed => true), - { ...T, ... }, - >; - - /** - * Actions, state, etc. - */ - - declare export type ScreenParams = { +[key: string]: mixed, ... }; - - declare export type BackAction = {| - +type: 'GO_BACK', - +source?: string, - +target?: string, - |}; - declare export type NavigateAction = {| - +type: 'NAVIGATE', - +payload: - | {| +key: string, +params?: ScreenParams |} - | {| +name: string, +key?: string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type ResetAction = {| - +type: 'RESET', - +payload: StaleNavigationState, - +source?: string, - +target?: string, - |}; - declare export type SetParamsAction = {| - +type: 'SET_PARAMS', - +payload: {| +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type CommonAction = - | BackAction - | NavigateAction - | ResetAction - | SetParamsAction; - - declare type NavigateActionCreator = {| - (routeName: string, params?: ScreenParams): NavigateAction, - ( - | {| +key: string, +params?: ScreenParams |} - | {| +name: string, +key?: string, +params?: ScreenParams |}, - ): NavigateAction, - |}; - declare export type CommonActionsType = {| - +navigate: NavigateActionCreator, - +goBack: () => BackAction, - +reset: (state: PossiblyStaleNavigationState) => ResetAction, - +setParams: (params: ScreenParams) => SetParamsAction, - |}; - - declare export type GenericNavigationAction = {| - +type: string, - +payload?: { +[key: string]: mixed, ... }, - +source?: string, - +target?: string, - |}; - - declare export type LeafRoute = {| - +key: string, - +name: RouteName, - +params?: ScreenParams, - |}; - declare export type StateRoute = {| - ...LeafRoute, - +state: NavigationState | StaleNavigationState, - |}; - declare export type Route = - | LeafRoute - | StateRoute; - - declare export type NavigationState = {| - +key: string, - +index: number, - +routeNames: $ReadOnlyArray, - +history?: $ReadOnlyArray, - +routes: $ReadOnlyArray>, - +type: string, - +stale: false, - |}; - - declare export type StaleLeafRoute = {| - +key?: string, - +name: RouteName, - +params?: ScreenParams, - |}; - declare export type StaleStateRoute = {| - ...StaleLeafRoute, - +state: StaleNavigationState, - |}; - declare export type StaleRoute = - | StaleLeafRoute - | StaleStateRoute; - declare export type StaleNavigationState = {| - // It's possible to pass React Nav a StaleNavigationState with an undefined - // index, but React Nav will always return one with the index set. This is - // the same as for the type property below, but in the case of index we tend - // to rely on it being set more... - +index: number, - +history?: $ReadOnlyArray, - +routes: $ReadOnlyArray>, - +type?: string, - +stale?: true, - |}; - - declare export type PossiblyStaleNavigationState = - | NavigationState - | StaleNavigationState; - declare export type PossiblyStaleRoute = - | Route - | StaleRoute; - - /** - * Routers - */ - - declare type ActionCreators< - State: NavigationState, - Action: GenericNavigationAction, - > = { - +[key: string]: (...args: any) => (Action | State => Action), - ... - }; - - declare export type DefaultRouterOptions = { - +initialRouteName?: string, - ... - }; - - declare export type RouterFactory< - State: NavigationState, - Action: GenericNavigationAction, - RouterOptions: DefaultRouterOptions, - > = (options: RouterOptions) => Router; - - declare export type ParamListBase = { +[key: string]: ?ScreenParams, ... }; - - declare export type RouterConfigOptions = {| - +routeNames: $ReadOnlyArray, - +routeParamList: ParamListBase, - |}; - - declare export type Router< - State: NavigationState, - Action: GenericNavigationAction, - > = {| - +type: $PropertyType, - +getInitialState: (options: RouterConfigOptions) => State, - +getRehydratedState: ( - partialState: PossiblyStaleNavigationState, - options: RouterConfigOptions, - ) => State, - +getStateForRouteNamesChange: ( - state: State, - options: RouterConfigOptions, - ) => State, - +getStateForRouteFocus: (state: State, key: string) => State, - +getStateForAction: ( - state: State, - action: Action, - options: RouterConfigOptions, - ) => ?PossiblyStaleNavigationState; - +shouldActionChangeFocus: (action: GenericNavigationAction) => boolean, - +actionCreators?: ActionCreators, - |}; - - /** - * Stack actions and router - */ - - declare export type StackNavigationState = {| - ...NavigationState, - +type: 'stack', - |}; - - declare export type ReplaceAction = {| - +type: 'REPLACE', - +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type PushAction = {| - +type: 'PUSH', - +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type PopAction = {| - +type: 'POP', - +payload: {| +count: number |}, - +source?: string, - +target?: string, - |}; - declare export type PopToTopAction = {| - +type: 'POP_TO_TOP', - +source?: string, - +target?: string, - |}; - declare export type StackAction = - | CommonAction - | ReplaceAction - | PushAction - | PopAction - | PopToTopAction; - - declare export type StackActionsType = {| - +replace: (routeName: string, params?: ScreenParams) => ReplaceAction, - +push: (routeName: string, params?: ScreenParams) => PushAction, - +pop: (count?: number) => PopAction, - +popToTop: () => PopToTopAction, - |}; - - declare export type StackRouterOptions = $Exact; - - /** - * Tab actions and router - */ - - declare export type TabNavigationState = {| - ...NavigationState, - +type: 'tab', - +history: $ReadOnlyArray<{| type: 'route', key: string |}>, - |}; - - declare export type JumpToAction = {| - +type: 'JUMP_TO', - +payload: {| +name: string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type TabAction = - | CommonAction - | JumpToAction; - - declare export type TabActionsType = {| - +jumpTo: string => JumpToAction, - |}; - - declare export type TabRouterOptions = {| - ...$Exact, - +backBehavior?: 'initialRoute' | 'order' | 'history' | 'none', - |}; - - /** - * Drawer actions and router - */ - - declare type DrawerHistoryEntry = - | {| +type: 'route', +key: string |} - | {| +type: 'drawer' |}; - declare export type DrawerNavigationState = {| - ...NavigationState, - +type: 'drawer', - +history: $ReadOnlyArray, - |}; - - declare export type OpenDrawerAction = {| - +type: 'OPEN_DRAWER', - +source?: string, - +target?: string, - |}; - declare export type CloseDrawerAction = {| - +type: 'CLOSE_DRAWER', - +source?: string, - +target?: string, - |}; - declare export type ToggleDrawerAction = {| - +type: 'TOGGLE_DRAWER', - +source?: string, - +target?: string, - |}; - declare export type DrawerAction = - | TabAction - | OpenDrawerAction - | CloseDrawerAction - | ToggleDrawerAction; - - declare export type DrawerActionsType = {| - ...TabActionsType, - +openDrawer: () => OpenDrawerAction, - +closeDrawer: () => CloseDrawerAction, - +toggleDrawer: () => ToggleDrawerAction, - |}; - - declare export type DrawerRouterOptions = {| - ...TabRouterOptions, - +defaultStatus?: 'open' | 'closed', - |}; - - /** - * Events - */ - - declare export type EventMapBase = { - +[name: string]: {| - +data?: mixed, - +canPreventDefault?: boolean, - |}, - ... - }; - declare type EventPreventDefaultProperties = $If< - Test, - {| +defaultPrevented: boolean, +preventDefault: () => void |}, - {| |}, - >; - declare type EventDataProperties = $If< - $IsUndefined, - {| |}, - {| +data: Data |}, - >; - declare type EventArg< - EventName: string, - CanPreventDefault: ?boolean = false, - Data = void, - > = {| - ...EventPreventDefaultProperties, - ...EventDataProperties, - +type: EventName, - +target?: string, - |}; - declare type GlobalEventMap = {| - +state: {| +data: {| +state: State |}, +canPreventDefault: false |}, - |}; - declare type EventMapCore = {| - ...GlobalEventMap, - +focus: {| +data: void, +canPreventDefault: false |}, - +blur: {| +data: void, +canPreventDefault: false |}, - +beforeRemove: {| - +data: {| +action: GenericNavigationAction |}, - +canPreventDefault: true, - |}, - |}; - declare type EventListenerCallback< - EventName: string, - State: PossiblyStaleNavigationState = NavigationState, - EventMap: EventMapBase = EventMapCore, - > = (e: EventArg< - EventName, - $PropertyType< - $ElementType< - {| ...EventMap, ...EventMapCore |}, - EventName, - >, - 'canPreventDefault', - >, - $PropertyType< - $ElementType< - {| ...EventMap, ...EventMapCore |}, - EventName, - >, - 'data', - >, - >) => mixed; - - /** - * Navigation prop - */ - - declare type PartialWithMergeProperty = $If< - $IsExact, - { ...$Partial, +merge: true }, - { ...$Partial, +merge: true, ... }, - >; - - declare type EitherExactOrPartialWithMergeProperty = - | ParamsType - | PartialWithMergeProperty; - - declare export type SimpleNavigate = - >( - routeName: DestinationRouteName, - params: EitherExactOrPartialWithMergeProperty< - $ElementType, - >, - ) => void; - - declare export type Navigate = - & SimpleNavigate - & >( - route: $If< - $IsUndefined<$ElementType>, - | {| +key: string |} - | {| +name: DestinationRouteName, +key?: string |}, - | {| - +key: string, - +params?: EitherExactOrPartialWithMergeProperty< - $ElementType, - >, - |} - | {| - +name: DestinationRouteName, - +key?: string, - +params?: EitherExactOrPartialWithMergeProperty< - $ElementType, - >, - |}, - >, - ) => void; - - declare type CoreNavigationHelpers< - ParamList: ParamListBase, - State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, - EventMap: EventMapBase = EventMapCore, - > = { - +navigate: Navigate, - +dispatch: ( - action: - | GenericNavigationAction - | (State => GenericNavigationAction), - ) => void, - +reset: PossiblyStaleNavigationState => void, - +goBack: () => void, - +isFocused: () => boolean, - +canGoBack: () => boolean, - +getId: () => string | void, - +getParent: >(id?: string) => ?Parent, - +getState: () => NavigationState, - +addListener: |}, - >>( - name: EventName, - callback: EventListenerCallback, - ) => () => void, - +removeListener: |}, - >>( - name: EventName, - callback: EventListenerCallback, - ) => void, - ... - }; - - declare export type NavigationHelpers< - ParamList: ParamListBase, - State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, - EventMap: EventMapBase = EventMapCore, - > = { - ...$Exact>, - +setParams: (params: ScreenParams) => void, - ... - }; - - declare type SetParamsInput< - ParamList: ParamListBase, - RouteName: $Keys = $Keys, - > = $If< - $IsUndefined<$ElementType>, - empty, - $Partial<$NonMaybeType<$ElementType>>, - >; - - declare export type NavigationProp< - ParamList: ParamListBase, - RouteName: $Keys = $Keys, - State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = { - ...$Exact>, - +setOptions: (options: $Partial) => void, - +setParams: (params: SetParamsInput) => void, - ... - }; - - /** - * CreateNavigator - */ - - declare export type RouteProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - > = {| - ...LeafRoute, - +params: $ElementType, - +path?: string, - |}; - - declare type ScreenOptionsProp< - ScreenOptions: {...}, - RouteParam, - NavHelpers, - > = - | ScreenOptions - | ({| +route: RouteParam, +navigation: NavHelpers |}) => ScreenOptions; - declare export type ScreenListeners< - State: NavigationState = NavigationState, - EventMap: EventMapBase = EventMapCore, - > = $ObjMapi< - {| [name: $Keys]: empty |}, - >(K, empty) => EventListenerCallback, - >; - declare type ScreenListenersProp< - ScreenListenersParam: {...}, - RouteParam, - NavHelpers, - > = - | ScreenListenersParam - | ({| +route: RouteParam, +navigation: NavHelpers |}) => ScreenListenersParam; - - declare type BaseScreenProps< - ParamList: ParamListBase, - NavProp, - RouteName: $Keys = $Keys, - State: NavigationState = NavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = {| - +name: RouteName, - +options?: ScreenOptionsProp< - ScreenOptions, - RouteProp, - NavProp, - >, - +listeners?: ScreenListenersProp< - ScreenListeners, - RouteProp, - NavProp, - >, - +initialParams?: $Partial<$ElementType>, - +getId?: ({ - +params: $ElementType, - }) => string | void, - +navigationKey?: string, - |}; - - declare export type ScreenProps< - ParamList: ParamListBase, - NavProp, - RouteName: $Keys = $Keys, - State: NavigationState = NavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = - | {| - ...BaseScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >, - +component: React$ComponentType<{| - +route: RouteProp, - +navigation: NavProp, - |}>, - |} - | {| - ...BaseScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >, - +getComponent: () => React$ComponentType<{| - +route: RouteProp, - +navigation: NavProp, - |}>, - |} - | {| - ...BaseScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >, - +children: ({| - +route: RouteProp, - +navigation: NavProp, - |}) => React$Node, - |}; - - declare export type ScreenComponent< - GlobalParamList: ParamListBase, - ParamList: ParamListBase, - State: NavigationState = NavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = < - RouteName: $Keys, - NavProp: NavigationProp< - GlobalParamList, - RouteName, - State, - ScreenOptions, - EventMap, - >, - >(props: ScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >) => React$Node; - - declare type ScreenOptionsProps< - ScreenOptions: {...}, - RouteParam, - NavHelpers, - > = {| - +screenOptions?: ScreenOptionsProp, - |}; - declare type ScreenListenersProps< - ScreenListenersParam: {...}, - RouteParam, - NavHelpers, - > = {| - +screenListeners?: ScreenListenersProp< - ScreenListenersParam, - RouteParam, - NavHelpers, - >, - |}; - declare export type ExtraNavigatorPropsBase = { - ...$Exact, - +id?: string, - +children?: React$Node, - ... - }; - declare export type NavigatorProps< - ScreenOptions: {...}, - ScreenListenersParam, - RouteParam, - NavHelpers, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - > = { - ...$Exact, - ...ScreenOptionsProps, - ...ScreenListenersProps, - +defaultScreenOptions?: - | ScreenOptions - | ({| - +route: RouteParam, - +navigation: NavHelpers, - +options: ScreenOptions, - |}) => ScreenOptions, - ... - }; - declare export type NavigatorPropsBase< - ScreenOptions: {...}, - ScreenListenersParam: {...}, - NavHelpers, - > = NavigatorProps< - ScreenOptions, - ScreenListenersParam, - RouteProp<>, - NavHelpers, - ExtraNavigatorPropsBase, - >; - - declare export type CreateNavigator< - State: NavigationState, - ScreenOptions: {...}, - EventMap: EventMapBase, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - > = < - GlobalParamList: ParamListBase, - ParamList: ParamListBase, - NavHelpers: NavigationHelpers< - GlobalParamList, - State, - EventMap, - >, - >() => {| - +Screen: ScreenComponent< - GlobalParamList, - ParamList, - State, - ScreenOptions, - EventMap, - >, - +Navigator: React$ComponentType<$Exact, - RouteProp, - NavHelpers, - ExtraNavigatorProps, - >>>, - +Group: React$ComponentType<{| - ...ScreenOptionsProps, NavHelpers>, - +children: React$Node, - +navigationKey?: string, - |}>, - |}; - - declare export type CreateNavigatorFactory = < - State: NavigationState, - ScreenOptions: {...}, - EventMap: EventMapBase, - NavHelpers: NavigationHelpers< - ParamListBase, - State, - EventMap, - >, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - >( - navigator: React$ComponentType<$Exact, - RouteProp<>, - NavHelpers, - ExtraNavigatorProps, - >>>, - ) => CreateNavigator; - - - /** - * useNavigationBuilder - */ - - declare export type Descriptor< - NavHelpers, - ScreenOptions: {...} = {...}, - > = {| - +render: () => React$Node, - +options: $ReadOnly, - +navigation: NavHelpers, - |}; - - declare export type UseNavigationBuilder = < - State: NavigationState, - Action: GenericNavigationAction, - ScreenOptions: {...}, - RouterOptions: DefaultRouterOptions, - NavHelpers, - EventMap: EventMapBase, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - >( - routerFactory: RouterFactory, - options: $Exact, - RouteProp<>, - NavHelpers, - ExtraNavigatorProps, - >>, - ) => {| - +id?: string, - +state: State, - +descriptors: {| +[key: string]: Descriptor |}, - +navigation: NavHelpers, - |}; - - /** - * EdgeInsets - */ - - declare type EdgeInsets = {| - +top: number, - +right: number, - +bottom: number, - +left: number, - |}; - - /** - * TransitionPreset - */ - - declare export type TransitionSpec = - | {| - animation: 'spring', - config: $Diff< - SpringAnimationConfigSingle, - { toValue: number | AnimatedValue, ... }, - >, - |} - | {| - animation: 'timing', - config: $Diff< - TimingAnimationConfigSingle, - { toValue: number | AnimatedValue, ... }, - >, - |}; - - declare export type StackCardInterpolationProps = {| - +current: {| - +progress: AnimatedInterpolation, - |}, - +next?: {| - +progress: AnimatedInterpolation, - |}, - +index: number, - +closing: AnimatedInterpolation, - +swiping: AnimatedInterpolation, - +inverted: AnimatedInterpolation, - +layouts: {| - +screen: {| +width: number, +height: number |}, - |}, - +insets: EdgeInsets, - |}; - declare export type StackCardInterpolatedStyle = {| - containerStyle?: AnimatedViewStyleProp, - cardStyle?: AnimatedViewStyleProp, - overlayStyle?: AnimatedViewStyleProp, - shadowStyle?: AnimatedViewStyleProp, - |}; - declare export type StackCardStyleInterpolator = ( - props: StackCardInterpolationProps, - ) => StackCardInterpolatedStyle; - - declare export type StackHeaderInterpolationProps = {| - +current: {| - +progress: AnimatedInterpolation, - |}, - +next?: {| - +progress: AnimatedInterpolation, - |}, - +layouts: {| - +header: {| +width: number, +height: number |}, - +screen: {| +width: number, +height: number |}, - +title?: {| +width: number, +height: number |}, - +leftLabel?: {| +width: number, +height: number |}, - |}, - |}; - declare export type StackHeaderInterpolatedStyle = {| - leftLabelStyle?: AnimatedViewStyleProp, - leftButtonStyle?: AnimatedViewStyleProp, - rightButtonStyle?: AnimatedViewStyleProp, - titleStyle?: AnimatedViewStyleProp, - backgroundStyle?: AnimatedViewStyleProp, - |}; - declare export type StackHeaderStyleInterpolator = ( - props: StackHeaderInterpolationProps, - ) => StackHeaderInterpolatedStyle; - - declare type GestureDirection = - | 'horizontal' - | 'horizontal-inverted' - | 'vertical' - | 'vertical-inverted'; - - declare export type TransitionPreset = {| - +gestureDirection: GestureDirection, - +transitionSpec: {| - +open: TransitionSpec, - +close: TransitionSpec, - |}, - +cardStyleInterpolator: StackCardStyleInterpolator, - +headerStyleInterpolator: StackHeaderStyleInterpolator, - |}; - - /** - * Header common options - */ - - declare export type SceneProgress = {| - +current: AnimatedInterpolation, - +next?: AnimatedInterpolation, - +previous?: AnimatedInterpolation, - |}; - - declare export type HeaderProps = {| - +navigation: NavProp, - +route: RouteProp<>, - +options: ScreenOptions, - +layout: {| +width: number, +height: number |}, - |}; - - declare export type HeaderButtonProps = $Partial<{| - +tintColor: string, - +pressColor: string, - +pressOpacity: number, - |}>; - - declare export type HeaderLeftButtonProps = $Partial<{| - ...HeaderButtonProps, - +labelVisible: boolean, - |}>; - - declare type HeaderTitleInputBase = { - +onLayout: LayoutEvent => void, - +children: string, - +allowFontScaling: ?boolean, - +tintColor: ?string, - +style: ?AnimatedTextStyleProp, - ... - }; - - declare export type HeaderTitleInputProps = - $Exact; - - declare export type HeaderCommonOptions< - NavHeaderProps, - NavHeaderLeftProps, - NavHeaderRightProps, - > = $Partial<{| - +header: NavHeaderProps => React$Node, - +headerShown: boolean, - +headerTitle: string | ( HeaderTitleInputProps => React$Node), - +headerTitleAlign: 'left' | 'center', - +headerTitleStyle: AnimatedTextStyleProp, - +headerTitleContainerStyle: AnimatedViewStyleProp, - +headerTintColor: string, - +headerTitleAllowFontScaling: boolean, - +headerLeft: NavHeaderLeftProps => React$Node, - +headerLeftContainerStyle: AnimatedViewStyleProp, - +headerRight: NavHeaderRightProps => React$Node, - +headerRightContainerStyle: AnimatedViewStyleProp, - +headerBackground: ({| style: AnimatedViewStyleProp |}) => React$Node, - +headerStyle: AnimatedViewStyleProp, - +headerTransparent: boolean, - +headerStatusBarHeight: number, - +headerShadowVisible: boolean, - +headerBackgroundContainerStyle: AnimatedViewStyleProp, - +headerPressColor: string, - +headerPressOpacity: number, - |}>; - - /** - * Stack options - */ - - declare export type StackDescriptor = Descriptor< - StackNavigationHelpers<>, - StackOptions, - >; - - declare type Scene = {| - +route: T, - +descriptor: StackDescriptor, - +progress: SceneProgress, - |}; - - declare export type StackHeaderProps = {| - ...HeaderProps, StackOptions>, - +progress: SceneProgress, - +back?: {| +title: string |}, - +styleInterpolator: StackHeaderStyleInterpolator, - |}; - - declare export type StackHeaderButtonProps = $Partial<{| - ...HeaderButtonProps, - +canGoBack: boolean, - |}>; - - declare export type StackHeaderLeftButtonProps = $Partial<{| - ...StackHeaderButtonProps, - +onPress: (() => void), - +backImage: (props: {| tintColor: string |}) => React$Node, - +label: string, - +truncatedLabel: string, - +labelVisible: boolean, - +labelStyle: AnimatedTextStyleProp, - +allowFontScaling: boolean, - +onLabelLayout: LayoutEvent => void, - +screenLayout: {| +width: number, +height: number |}, - +titleLayout: {| +width: number, +height: number |}, - +disabled: boolean, - +accessibilityLabel: string, - +style: ViewStyleProp, - |}>; - - declare export type StackOptions = $Partial<{| - +title: string, - +cardShadowEnabled: boolean, - +cardOverlayEnabled: boolean, - +cardOverlay: {| style: ViewStyleProp |} => React$Node, - +cardStyle: ViewStyleProp, - +animationEnabled: boolean, - +animationTypeForReplace: 'push' | 'pop', - +gestureEnabled: boolean, - +gestureResponseDistance: number, - +gestureVelocityImpact: number, - +safeAreaInsets: $Partial, - +keyboardHandlingEnabled: boolean, - +presentation: 'card' | 'modal' | 'transparentModal', - // Transition - ...TransitionPreset, - // Header - ...HeaderCommonOptions< - StackHeaderProps, - StackHeaderLeftButtonProps, - StackHeaderButtonProps, - >, - +headerMode: 'float' | 'screen', - +headerBackAllowFontScaling: boolean, - +headerBackTitle: string | null, - +headerBackTitleStyle: TextStyleProp, - +headerBackTitleVisible: boolean, - +headerTruncatedBackTitle: string, - +headerBackImage: $PropertyType, - +headerBackAccessibilityLabel: string, - |}>; - - /** - * Stack navigation prop - */ - - declare export type StackNavigationEventMap = {| - ...EventMapCore, - +transitionStart: {| - +data: {| +closing: boolean |}, - +canPreventDefault: false, - |}, - +transitionEnd: {| - +data: {| +closing: boolean |}, - +canPreventDefault: false, - |}, - +gestureStart: {| +data: void, +canPreventDefault: false |}, - +gestureEnd: {| +data: void, +canPreventDefault: false |}, - +gestureCancel: {| +data: void, +canPreventDefault: false |}, - |}; - - declare type StackExtraNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - > = {| - +replace: SimpleNavigate, - +push: SimpleNavigate, - +pop: (count?: number) => void, - +popToTop: () => void, - |}; - - declare export type StackNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = StackNavigationEventMap, - > = { - ...$Exact>, - ...StackExtraNavigationHelpers, - ... - }; - - declare export type StackNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = StackOptions, - EventMap: EventMapBase = StackNavigationEventMap, - > = {| - ...$Exact>, - ...StackExtraNavigationHelpers, - |}; - - /** - * Miscellaneous stack exports - */ - - declare type StackNavigationConfig = {| - +detachInactiveScreens?: boolean, - |}; - - declare export type ExtraStackNavigatorProps = {| - ...$Exact, - ...StackRouterOptions, - ...StackNavigationConfig, - |}; - - declare export type StackNavigatorProps< - NavHelpers: StackNavigationHelpers<> = StackNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraStackNavigatorProps, - >>; - - /** - * Bottom tab options - */ - - declare export type BottomTabBarButtonProps = {| - ...$Diff< - TouchableWithoutFeedbackProps, - {| onPress?: ?(event: PressEvent) => mixed |}, - >, - +to?: string, - +children: React$Node, - +onPress?: (MouseEvent | PressEvent) => void, - |}; - - declare export type TabBarVisibilityAnimationConfig = - | {| - +animation: 'spring', - +config?: $Diff< - SpringAnimationConfigSingle, - { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, - >, - |} - | {| - +animation: 'timing', - +config?: $Diff< - TimingAnimationConfigSingle, - { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, - >, - |}; - - declare export type BottomTabOptions = $Partial<{| - +title: string, - +tabBarLabel: - | string - | ({| focused: boolean, color: string |}) => React$Node, - +tabBarIcon: ({| - focused: boolean, - color: string, - size: number, - |}) => React$Node, - +tabBarBadge: number | string, - +tabBarBadgeStyle: TextStyleProp, - +tabBarAccessibilityLabel: string, - +tabBarTestID: string, - +tabBarVisibilityAnimationConfig: $Partial<{| - +show: TabBarVisibilityAnimationConfig, - +hide: TabBarVisibilityAnimationConfig, - |}>, - +tabBarButton: BottomTabBarButtonProps => React$Node, - +tabBarHideOnKeyboard: boolean, - +tabBarActiveTintColor: string, - +tabBarInactiveTintColor: string, - +tabBarActiveBackgroundColor: string, - +tabBarInactiveBackgroundColor: string, - +tabBarAllowFontScaling: boolean, - +tabBarShowLabel: boolean, - +tabBarLabelStyle: TextStyleProp, - +tabBarIconStyle: TextStyleProp, - +tabBarItemStyle: ViewStyleProp, - +tabBarLabelPosition: 'beside-icon' | 'below-icon', - +tabBarStyle: ViewStyleProp, - +unmountOnBlur: boolean, - +lazy: boolean, - ...HeaderCommonOptions< - HeaderProps, BottomTabOptions>, - HeaderLeftButtonProps, - HeaderButtonProps, - >, - |}>; - - /** - * Bottom tab navigation prop - */ - - declare export type BottomTabNavigationEventMap = {| - ...EventMapCore, - +tabPress: {| +data: void, +canPreventDefault: true |}, - +tabLongPress: {| +data: void, +canPreventDefault: false |}, - |}; - - declare type TabExtraNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - > = {| - +jumpTo: SimpleNavigate, - |}; - - declare export type BottomTabNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = BottomTabNavigationEventMap, - > = { - ...$Exact>, - ...TabExtraNavigationHelpers, - ... - }; - - declare export type BottomTabNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = BottomTabOptions, - EventMap: EventMapBase = BottomTabNavigationEventMap, - > = {| - ...$Exact>, - ...TabExtraNavigationHelpers, - |}; - - /** - * Miscellaneous bottom tab exports - */ - - declare export type BottomTabDescriptor = Descriptor< - BottomTabNavigationHelpers<>, - BottomTabOptions, - >; - - declare type BottomTabNavigationBuilderResult = {| - +state: TabNavigationState, - +navigation: BottomTabNavigationHelpers<>, - +descriptors: {| +[key: string]: BottomTabDescriptor |}, - |}; - - declare export type BottomTabBarProps = BottomTabNavigationBuilderResult; - - declare type BottomTabNavigationConfig = {| - +tabBar?: BottomTabBarProps => React$Node, - +safeAreaInsets?: $Partial, - +detachInactiveScreens?: boolean, - |}; - - declare export type ExtraBottomTabNavigatorProps = {| - ...$Exact, - ...TabRouterOptions, - ...BottomTabNavigationConfig, - |}; - - declare export type BottomTabNavigatorProps< - NavHelpers: BottomTabNavigationHelpers<> = BottomTabNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraBottomTabNavigatorProps, - >>; - - /** - * Material bottom tab options - */ - - declare export type MaterialBottomTabOptions = $Partial<{| - +title: string, - +tabBarColor: string, - +tabBarLabel: string, - +tabBarIcon: - | string - | ({| +focused: boolean, +color: string |}) => React$Node, - +tabBarBadge: boolean | number | string, - +tabBarAccessibilityLabel: string, - +tabBarTestID: string, - |}>; - - /** - * Material bottom tab navigation prop - */ - - declare export type MaterialBottomTabNavigationEventMap = {| - ...EventMapCore, - +tabPress: {| +data: void, +canPreventDefault: true |}, - |}; - - declare export type MaterialBottomTabNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, - > = { - ...$Exact>, - ...TabExtraNavigationHelpers, - ... - }; - - declare export type MaterialBottomTabNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = MaterialBottomTabOptions, - EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, - > = {| - ...$Exact>, - ...TabExtraNavigationHelpers, - |}; - - /** - * Miscellaneous material bottom tab exports - */ - - declare export type PaperFont = {| - +fontFamily: string, - +fontWeight?: - | 'normal' - | 'bold' - | '100' - | '200' - | '300' - | '400' - | '500' - | '600' - | '700' - | '800' - | '900', - |}; - - declare export type PaperFonts = {| - +regular: PaperFont, - +medium: PaperFont, - +light: PaperFont, - +thin: PaperFont, - |}; - - declare export type PaperTheme = {| - +dark: boolean, - +mode?: 'adaptive' | 'exact', - +roundness: number, - +colors: {| - +primary: string, - +background: string, - +surface: string, - +accent: string, - +error: string, - +text: string, - +onSurface: string, - +onBackground: string, - +disabled: string, - +placeholder: string, - +backdrop: string, - +notification: string, - |}, - +fonts: PaperFonts, - +animation: {| - +scale: number, - |}, - |}; - - declare export type PaperRoute = {| - +key: string, - +title?: string, - +icon?: any, - +badge?: string | number | boolean, - +color?: string, - +accessibilityLabel?: string, - +testID?: string, - |}; - - declare export type PaperTouchableProps = {| - ...TouchableWithoutFeedbackProps, - +key: string, - +route: PaperRoute, - +children: React$Node, - +borderless?: boolean, - +centered?: boolean, - +rippleColor?: string, - |}; - - declare export type MaterialBottomTabNavigationConfig = {| - +shifting?: boolean, - +labeled?: boolean, - +renderTouchable?: PaperTouchableProps => React$Node, - +activeColor?: string, - +inactiveColor?: string, - +sceneAnimationEnabled?: boolean, - +keyboardHidesNavigationBar?: boolean, - +barStyle?: ViewStyleProp, - +style?: ViewStyleProp, - +theme?: PaperTheme, - |}; - - declare export type ExtraMaterialBottomTabNavigatorProps = {| - ...$Exact, - ...TabRouterOptions, - ...MaterialBottomTabNavigationConfig, - |}; - - declare export type MaterialBottomTabNavigatorProps< - NavHelpers: MaterialBottomTabNavigationHelpers<> = - MaterialBottomTabNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraMaterialBottomTabNavigatorProps, - >>; - - /** - * Material top tab options - */ - - declare export type MaterialTopTabOptions = $Partial<{| - +title: string, - +tabBarLabel: - | string - | ({| +focused: boolean, +color: string |}) => React$Node, - +tabBarIcon: ({| +focused: boolean, +color: string |}) => React$Node, - +tabBarAccessibilityLabel: string, - +tabBarTestID: string, - +tabBarActiveTintColor: string, - +tabBarInactiveTintColor: string, - +tabBarPressColor: string, - +tabBarPressOpacity: number, - +tabBarShowLabel: boolean, - +tabBarShowIcon: boolean, - +tabBarAllowFontScaling: boolean, - +tabBarBounces: boolean, - +tabBarScrollEnabled: boolean, - +tabBarIconStyle: ViewStyleProp, - +tabBarLabelStyle: TextStyleProp, - +tabBarItemStyle: ViewStyleProp, - +tabBarIndicatorStyle: ViewStyleProp, - +tabBarIndicatorContainerStyle: ViewStyleProp, - +tabBarContentContainerStyle: ViewStyleProp, - +tabBarStyle: ViewStyleProp, - +tabBarBadge: () => React$Node, - +tabBarIndicator: MaterialTopTabBarIndicatorProps => React$Node, - +lazy: boolean, - +lazyPlaceholder: ({| +route: Route<> |}) => React$Node, - |}>; - - /** - * Material top tab navigation prop - */ - - declare export type MaterialTopTabNavigationEventMap = {| - ...EventMapCore, - +tabPress: {| +data: void, +canPreventDefault: true |}, - +tabLongPress: {| +data: void, +canPreventDefault: false |}, - +swipeStart: {| +data: void, +canPreventDefault: false |}, - +swipeEnd: {| +data: void, +canPreventDefault: false |}, - |}; - - declare export type MaterialTopTabNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = MaterialTopTabNavigationEventMap, - > = { - ...$Exact>, - ...TabExtraNavigationHelpers, - ... - }; - - declare export type MaterialTopTabNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = MaterialTopTabOptions, - EventMap: EventMapBase = MaterialTopTabNavigationEventMap, - > = {| - ...$Exact>, - ...TabExtraNavigationHelpers, - |}; - - /** - * Miscellaneous material top tab exports - */ - - declare type MaterialTopTabPagerCommonProps = {| - +keyboardDismissMode: 'none' | 'on-drag' | 'auto', - +swipeEnabled: boolean, - +swipeVelocityImpact?: number, - +springVelocityScale?: number, - +springConfig: $Partial<{| - +damping: number, - +mass: number, - +stiffness: number, - +restSpeedThreshold: number, - +restDisplacementThreshold: number, - |}>, - +timingConfig: $Partial<{| - +duration: number, - |}>, - |}; - - declare export type MaterialTopTabPagerProps = {| - ...MaterialTopTabPagerCommonProps, - +onSwipeStart?: () => void, - +onSwipeEnd?: () => void, - +onIndexChange: (index: number) => void, - +navigationState: TabNavigationState, - +layout: {| +width: number, +height: number |}, - +removeClippedSubviews: boolean, - +children: ({| - +addListener: (type: 'enter', listener: number => void) => void, - +removeListener: (type: 'enter', listener: number => void) => void, - +position: any, // Reanimated.Node - +render: React$Node => React$Node, - +jumpTo: string => void, - |}) => React$Node, - +gestureHandlerProps: PanGestureHandlerProps, - |}; - - declare export type MaterialTopTabBarIndicatorProps = {| - +state: TabNavigationState, - +width: string, - +style?: ViewStyleProp, - +getTabWidth: number => number, - |}; - - declare export type MaterialTopTabDescriptor = Descriptor< - MaterialBottomTabNavigationHelpers<>, - MaterialBottomTabOptions, - >; - - declare type MaterialTopTabNavigationBuilderResult = {| - +state: TabNavigationState, - +navigation: MaterialTopTabNavigationHelpers<>, - +descriptors: {| +[key: string]: MaterialTopTabDescriptor |}, - |}; - - declare export type MaterialTopTabBarProps = {| - ...MaterialTopTabNavigationBuilderResult, - +layout: {| +width: number, +height: number |}, - +position: any, // Reanimated.Node - +jumpTo: string => void, - |}; - - declare export type MaterialTopTabNavigationConfig = {| - ...$Partial, - +position?: any, // Reanimated.Value - +tabBarPosition?: 'top' | 'bottom', - +initialLayout?: $Partial<{| +width: number, +height: number |}>, - +lazyPreloadDistance?: number, - +removeClippedSubviews?: boolean, - +sceneContainerStyle?: ViewStyleProp, - +style?: ViewStyleProp, - +gestureHandlerProps?: PanGestureHandlerProps, - +pager?: MaterialTopTabPagerProps => React$Node, - +tabBar?: MaterialTopTabBarProps => React$Node, - |}; - - declare export type ExtraMaterialTopTabNavigatorProps = {| - ...$Exact, - ...TabRouterOptions, - ...MaterialTopTabNavigationConfig, - |}; - - declare export type MaterialTopTabNavigatorProps< - NavHelpers: MaterialTopTabNavigationHelpers<> = - MaterialTopTabNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, + MaterialTopTabNavigationEventMap, ExtraMaterialTopTabNavigatorProps, - >>; - - /** - * Drawer options - */ - - declare export type DrawerOptions = $Partial<{| - +title: string, - +lazy: boolean, - +drawerLabel: - | string - | ({| +color: string, +focused: boolean |}) => React$Node, - +drawerIcon: ({| - +color: string, - +size: number, - +focused: boolean, - |}) => React$Node, - +drawerActiveTintColor: string, - +drawerActiveBackgroundColor: string, - +drawerInactiveTintColor: string, - +drawerInactiveBackgroundColor: string, - +drawerItemStyle: ViewStyleProp, - +drawerLabelStyle: TextStyleProp, - +drawerContentContainerStyle: ViewStyleProp, - +drawerContentStyle: ViewStyleProp, - +drawerStyle: ViewStyleProp, - +drawerPosition: 'left' | 'right', - +drawerType: 'front' | 'back' | 'slide' | 'permanent', - +drawerHideStatusBarOnOpen: boolean, - +drawerStatusBarAnimation: 'slide' | 'none' | 'fade', - +overlayColor: string, - +sceneContainerStyle: ViewStyleProp, - +gestureHandlerProps: PanGestureHandlerProps, - +swipeEnabled: boolean, - +swipeEdgeWidth: number, - +swipeMinDistance: number, - +keyboardDismissMode: 'on-drag' | 'none', - +unmountOnBlur: boolean, - ...HeaderCommonOptions< - HeaderProps, DrawerOptions>, - HeaderLeftButtonProps, - HeaderButtonProps, - >, - |}>; - - /** - * Drawer navigation prop - */ - - declare export type DrawerNavigationEventMap = - EventMapCore; - - declare type DrawerExtraNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - > = {| - +jumpTo: SimpleNavigate, - +openDrawer: () => void, - +closeDrawer: () => void, - +toggleDrawer: () => void, - |}; - - declare export type DrawerNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = DrawerNavigationEventMap, - > = { - ...$Exact>, - ...DrawerExtraNavigationHelpers, - ... - }; - - declare export type DrawerNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = DrawerOptions, - EventMap: EventMapBase = DrawerNavigationEventMap, - > = {| - ...$Exact>, - ...DrawerExtraNavigationHelpers, - |}; - - /** - * Miscellaneous drawer exports - */ - - declare export type DrawerDescriptor = Descriptor< - DrawerNavigationHelpers<>, - DrawerOptions, - >; - - declare type DrawerNavigationBuilderResult = {| - +state: DrawerNavigationState, - +navigation: DrawerNavigationHelpers<>, - +descriptors: {| +[key: string]: DrawerDescriptor |}, - |}; - - declare export type DrawerNavigationConfig = {| - +drawerContent?: DrawerNavigationBuilderResult => React$Node, - +detachInactiveScreens?: boolean, - +useLegacyImplementation?: boolean, - |}; - - declare export type ExtraDrawerNavigatorProps = {| - ...$Exact, - ...DrawerRouterOptions, - ...DrawerNavigationConfig, - |}; - - declare export type DrawerNavigatorProps< - NavHelpers: DrawerNavigationHelpers<> = DrawerNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraDrawerNavigatorProps, - >>; - - /** - * BaseNavigationContainer - */ - - declare export type BaseNavigationContainerProps = {| - +children: React$Node, - +initialState?: PossiblyStaleNavigationState, - +onStateChange?: (state: ?PossiblyStaleNavigationState) => void, - +independent?: boolean, - |}; - - declare export type ContainerEventMap = {| - ...GlobalEventMap, - +options: {| - +data: {| +options: { +[key: string]: mixed, ... } |}, - +canPreventDefault: false, - |}, - +__unsafe_action__: {| - +data: {| - +action: GenericNavigationAction, - +noop: boolean, - |}, - +canPreventDefault: false, - |}, - |}; - - declare export type BaseNavigationContainerInterface = {| - ...$Exact>, - +resetRoot: (state?: PossiblyStaleNavigationState) => void, - +getRootState: () => NavigationState, - +getCurrentRoute: () => RouteProp<> | void, - +getCurrentOptions: () => Object | void, - +isReady: () => boolean, - |}; - - declare type BaseNavigationContainerInterfaceRef = {| - ...BaseNavigationContainerInterface, - +current: BaseNavigationContainerInterface | null, - |}; - - /** - * State utils - */ - - declare export type GetStateFromPath = ( - path: string, - options?: LinkingConfig, - ) => PossiblyStaleNavigationState; - - declare export type GetPathFromState = ( - state?: ?PossiblyStaleNavigationState, - options?: LinkingConfig, - ) => string; - - declare export type GetFocusedRouteNameFromRoute = - PossiblyStaleRoute => ?string; - - /** - * Linking - */ - - declare export type ScreenLinkingConfig = {| - +path?: string, - +exact?: boolean, - +parse?: {| +[param: string]: string => mixed |}, - +stringify?: {| +[param: string]: mixed => string |}, - +screens?: ScreenLinkingConfigMap, - +initialRouteName?: string, - |}; - - declare export type ScreenLinkingConfigMap = {| - +[routeName: string]: string | ScreenLinkingConfig, - |}; - - declare export type LinkingConfig = {| - +initialRouteName?: string, - +screens: ScreenLinkingConfigMap, - |}; - - declare export type LinkingOptions = {| - +enabled?: boolean, - +prefixes: $ReadOnlyArray, - +config?: LinkingConfig, - +getStateFromPath?: GetStateFromPath, - +getPathFromState?: GetPathFromState, - |}; - - /** - * NavigationContainer - */ - - declare export type Theme = {| - +dark: boolean, - +colors: {| - +primary: string, - +background: string, - +card: string, - +text: string, - +border: string, - |}, - |}; - - declare export type NavigationContainerType = React$AbstractComponent< - {| - ...BaseNavigationContainerProps, - +theme?: Theme, - +linking?: LinkingOptions, - +fallback?: React$Node, - +onReady?: () => mixed, - |}, - BaseNavigationContainerInterface, - >; - - //--------------------------------------------------------------------------- - // SECTION 2: EXPORTED MODULE - // This section defines the module exports and contains exported types that - // are not present in any other React Navigation libdef. - //--------------------------------------------------------------------------- + MaterialTopTabNavigationConfig, + MaterialTopTabNavigationBuilderResult, + MaterialTopTabBarProps, + } from '@react-navigation/core'; /** * createMaterialTopTabNavigator diff --git a/native/flow-typed/npm/@react-navigation/native_v6.x.x.js b/native/flow-typed/npm/@react-navigation/native_v6.x.x.js --- a/native/flow-typed/npm/@react-navigation/native_v6.x.x.js +++ b/native/flow-typed/npm/@react-navigation/native_v6.x.x.js @@ -3,2263 +3,44 @@ declare module '@react-navigation/native' { - //--------------------------------------------------------------------------- - // SECTION 1: IDENTICAL TYPE DEFINITIONS - // This section is identical across all React Navigation libdefs and contains - // shared definitions. We wish we could make it DRY and import from a shared - // definition, but that isn't yet possible. - //--------------------------------------------------------------------------- - - /** - * We start with some definitions that we have copy-pasted from React Native - * source files. - */ - - // This is a bastardization of the true StyleObj type located in - // react-native/Libraries/StyleSheet/StyleSheetTypes. We unfortunately can't - // import that here, and it's too lengthy (and consequently too brittle) to - // copy-paste here either. - declare type StyleObj = - | null - | void - | number - | false - | '' - | $ReadOnlyArray - | { [name: string]: any, ... }; - declare type ViewStyleProp = StyleObj; - declare type TextStyleProp = StyleObj; - declare type AnimatedViewStyleProp = StyleObj; - declare type AnimatedTextStyleProp = StyleObj; - - // Vaguely copied from - // react-native/Libraries/Animated/src/animations/Animation.js - declare type EndResult = { finished: boolean, ... }; - declare type EndCallback = (result: EndResult) => void; - declare interface Animation { - start( - fromValue: number, - onUpdate: (value: number) => void, - onEnd: ?EndCallback, - previousAnimation: ?Animation, - animatedValue: AnimatedValue, - ): void; - stop(): void; - } - declare type AnimationConfig = { - isInteraction?: boolean, - useNativeDriver: boolean, - onComplete?: ?EndCallback, - iterations?: number, - ... - }; - - // Vaguely copied from - // react-native/Libraries/Animated/src/nodes/AnimatedTracking.js - declare interface AnimatedTracking { - constructor( - value: AnimatedValue, - parent: any, - animationClass: any, - animationConfig: Object, - callback?: ?EndCallback, - ): void; - update(): void; - } - - // Vaguely copied from - // react-native/Libraries/Animated/src/nodes/AnimatedValue.js - declare type ValueListenerCallback = (state: { value: number, ... }) => void; - declare interface AnimatedValue { - constructor(value: number): void; - setValue(value: number): void; - setOffset(offset: number): void; - flattenOffset(): void; - extractOffset(): void; - addListener(callback: ValueListenerCallback): string; - removeListener(id: string): void; - removeAllListeners(): void; - stopAnimation(callback?: ?(value: number) => void): void; - resetAnimation(callback?: ?(value: number) => void): void; - interpolate(config: InterpolationConfigType): AnimatedInterpolation; - animate(animation: Animation, callback: ?EndCallback): void; - stopTracking(): void; - track(tracking: AnimatedTracking): void; - } - - // Copied from - // react-native/Libraries/Animated/src/animations/TimingAnimation.js - declare type TimingAnimationConfigSingle = AnimationConfig & { - toValue: number | AnimatedValue, - easing?: (value: number) => number, - duration?: number, - delay?: number, - ... - }; - - // Copied from - // react-native/Libraries/Animated/src/animations/SpringAnimation.js - declare type SpringAnimationConfigSingle = AnimationConfig & { - toValue: number | AnimatedValue, - overshootClamping?: boolean, - restDisplacementThreshold?: number, - restSpeedThreshold?: number, - velocity?: number, - bounciness?: number, - speed?: number, - tension?: number, - friction?: number, - stiffness?: number, - damping?: number, - mass?: number, - delay?: number, - ... - }; - - // Copied from react-native/Libraries/Types/CoreEventTypes.js - declare type SyntheticEvent = $ReadOnly<{| - bubbles: ?boolean, - cancelable: ?boolean, - currentTarget: number, - defaultPrevented: ?boolean, - dispatchConfig: $ReadOnly<{| - registrationName: string, - |}>, - eventPhase: ?number, - preventDefault: () => void, - isDefaultPrevented: () => boolean, - stopPropagation: () => void, - isPropagationStopped: () => boolean, - isTrusted: ?boolean, - nativeEvent: T, - persist: () => void, - target: ?number, - timeStamp: number, - type: ?string, - |}>; - declare type Layout = $ReadOnly<{| - x: number, - y: number, - width: number, - height: number, - |}>; - declare type LayoutEvent = SyntheticEvent< - $ReadOnly<{| - layout: Layout, - |}>, - >; - declare type BlurEvent = SyntheticEvent< - $ReadOnly<{| - target: number, - |}>, - >; - declare type FocusEvent = SyntheticEvent< - $ReadOnly<{| - target: number, - |}>, - >; - declare type ResponderSyntheticEvent = $ReadOnly<{| - ...SyntheticEvent, - touchHistory: $ReadOnly<{| - indexOfSingleActiveTouch: number, - mostRecentTimeStamp: number, - numberActiveTouches: number, - touchBank: $ReadOnlyArray< - $ReadOnly<{| - touchActive: boolean, - startPageX: number, - startPageY: number, - startTimeStamp: number, - currentPageX: number, - currentPageY: number, - currentTimeStamp: number, - previousPageX: number, - previousPageY: number, - previousTimeStamp: number, - |}>, - >, - |}>, - |}>; - declare type PressEvent = ResponderSyntheticEvent< - $ReadOnly<{| - changedTouches: $ReadOnlyArray<$PropertyType>, - force: number, - identifier: number, - locationX: number, - locationY: number, - pageX: number, - pageY: number, - target: ?number, - timestamp: number, - touches: $ReadOnlyArray<$PropertyType>, - |}>, - >; - - // Vaguely copied from - // react-native/Libraries/Animated/src/nodes/AnimatedInterpolation.js - declare type ExtrapolateType = 'extend' | 'identity' | 'clamp'; - declare type InterpolationConfigType = { - inputRange: Array, - outputRange: Array | Array, - easing?: (input: number) => number, - extrapolate?: ExtrapolateType, - extrapolateLeft?: ExtrapolateType, - extrapolateRight?: ExtrapolateType, - ... - }; - declare interface AnimatedInterpolation { - interpolate(config: InterpolationConfigType): AnimatedInterpolation; - } - - // Copied from react-native/Libraries/Components/View/ViewAccessibility.js - declare type AccessibilityRole = - | 'none' - | 'button' - | 'link' - | 'search' - | 'image' - | 'keyboardkey' - | 'text' - | 'adjustable' - | 'imagebutton' - | 'header' - | 'summary' - | 'alert' - | 'checkbox' - | 'combobox' - | 'menu' - | 'menubar' - | 'menuitem' - | 'progressbar' - | 'radio' - | 'radiogroup' - | 'scrollbar' - | 'spinbutton' - | 'switch' - | 'tab' - | 'tablist' - | 'timer' - | 'toolbar'; - declare type AccessibilityActionInfo = $ReadOnly<{ - name: string, - label?: string, - ... - }>; - declare type AccessibilityActionEvent = SyntheticEvent< - $ReadOnly<{actionName: string, ...}>, - >; - declare type AccessibilityState = { - disabled?: boolean, - selected?: boolean, - checked?: ?boolean | 'mixed', - busy?: boolean, - expanded?: boolean, - ... - }; - declare type AccessibilityValue = $ReadOnly<{| - min?: number, - max?: number, - now?: number, - text?: string, - |}>; - - // Copied from - // react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js - declare type Stringish = string; - declare type EdgeInsetsProp = $ReadOnly<$Partial>; - declare type TouchableWithoutFeedbackProps = $ReadOnly<{| - accessibilityActions?: ?$ReadOnlyArray, - accessibilityElementsHidden?: ?boolean, - accessibilityHint?: ?Stringish, - accessibilityIgnoresInvertColors?: ?boolean, - accessibilityLabel?: ?Stringish, - accessibilityLiveRegion?: ?('none' | 'polite' | 'assertive'), - accessibilityRole?: ?AccessibilityRole, - accessibilityState?: ?AccessibilityState, - accessibilityValue?: ?AccessibilityValue, - accessibilityViewIsModal?: ?boolean, - accessible?: ?boolean, - children?: ?React$Node, - delayLongPress?: ?number, - delayPressIn?: ?number, - delayPressOut?: ?number, - disabled?: ?boolean, - focusable?: ?boolean, - hitSlop?: ?EdgeInsetsProp, - importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'), - nativeID?: ?string, - onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed, - onBlur?: ?(event: BlurEvent) => mixed, - onFocus?: ?(event: FocusEvent) => mixed, - onLayout?: ?(event: LayoutEvent) => mixed, - onLongPress?: ?(event: PressEvent) => mixed, - onPress?: ?(event: PressEvent) => mixed, - onPressIn?: ?(event: PressEvent) => mixed, - onPressOut?: ?(event: PressEvent) => mixed, - pressRetentionOffset?: ?EdgeInsetsProp, - rejectResponderTermination?: ?boolean, - testID?: ?string, - touchSoundDisabled?: ?boolean, - |}>; - - // Copied from react-native/Libraries/Image/ImageSource.js - declare type ImageURISource = $ReadOnly<{ - uri?: ?string, - bundle?: ?string, - method?: ?string, - headers?: ?Object, - body?: ?string, - cache?: ?('default' | 'reload' | 'force-cache' | 'only-if-cached'), - width?: ?number, - height?: ?number, - scale?: ?number, - ... - }>; - - /** - * The following is copied from react-native-gesture-handler's libdef - */ - - declare type StateUndetermined = 0; - declare type StateFailed = 1; - declare type StateBegan = 2; - declare type StateCancelled = 3; - declare type StateActive = 4; - declare type StateEnd = 5; - - declare type GestureHandlerState = - | StateUndetermined - | StateFailed - | StateBegan - | StateCancelled - | StateActive - | StateEnd; - - declare type $SyntheticEvent = { - +nativeEvent: $ReadOnly<$Exact>, - ... - }; - - declare type $Event = $SyntheticEvent<{ - handlerTag: number, - numberOfPointers: number, - state: GestureHandlerState, - oldState: GestureHandlerState, - ...$Exact, - ... - }>; - - declare type $EventHandlers = {| - onGestureEvent?: ($Event) => mixed, - onHandlerStateChange?: ($Event) => mixed, - onBegan?: ($Event) => mixed, - onFailed?: ($Event) => mixed, - onCancelled?: ($Event) => mixed, - onActivated?: ($Event) => mixed, - onEnded?: ($Event) => mixed, - |}; - - declare type HitSlop = - | number - | {| - left?: number, - top?: number, - right?: number, - bottom?: number, - vertical?: number, - horizontal?: number, - width?: number, - height?: number, - |} - | {| - width: number, - left: number, - |} - | {| - width: number, - right: number, - |} - | {| - height: number, - top: number, - |} - | {| - height: number, - bottom: number, - |}; - - declare type $GestureHandlerProps< - AdditionalProps: {...}, - ExtraEventsProps: {...} - > = $ReadOnly<{| - ...$Exact, - ...$EventHandlers, - id?: string, - enabled?: boolean, - waitFor?: React$Ref | Array>, - simultaneousHandlers?: React$Ref | Array>, - shouldCancelWhenOutside?: boolean, - minPointers?: number, - hitSlop?: HitSlop, - children?: React$Node, - |}>; - - declare type PanGestureHandlerProps = $GestureHandlerProps< - { - activeOffsetY?: number | [number, number], - activeOffsetX?: number | [number, number], - failOffsetY?: number | [number, number], - failOffsetX?: number | [number, number], - minDist?: number, - minVelocity?: number, - minVelocityX?: number, - minVelocityY?: number, - minPointers?: number, - maxPointers?: number, - avgTouches?: boolean, - ... - }, - { - x: number, - y: number, - absoluteX: number, - absoluteY: number, - translationX: number, - translationY: number, - velocityX: number, - velocityY: number, - ... - } - >; - - /** - * MAGIC - */ - - declare type $If = $Call< - ((true, Then, Else) => Then) & ((false, Then, Else) => Else), - Test, - Then, - Else, - >; - declare type $IsA = $Call< - (Y => true) & (mixed => false), - X, - >; - declare type $IsUndefined = $IsA; - - declare type $Partial = $ReadOnly<$Rest>; - - // If { ...T, ... } counts as a T, then we're inexact - declare type $IsExact = $Call< - (T => false) & (mixed => true), - { ...T, ... }, - >; - - /** - * Actions, state, etc. - */ - - declare export type ScreenParams = { +[key: string]: mixed, ... }; - - declare export type BackAction = {| - +type: 'GO_BACK', - +source?: string, - +target?: string, - |}; - declare export type NavigateAction = {| - +type: 'NAVIGATE', - +payload: - | {| +key: string, +params?: ScreenParams |} - | {| +name: string, +key?: string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type ResetAction = {| - +type: 'RESET', - +payload: StaleNavigationState, - +source?: string, - +target?: string, - |}; - declare export type SetParamsAction = {| - +type: 'SET_PARAMS', - +payload: {| +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type CommonAction = - | BackAction - | NavigateAction - | ResetAction - | SetParamsAction; - - declare type NavigateActionCreator = {| - (routeName: string, params?: ScreenParams): NavigateAction, - ( - | {| +key: string, +params?: ScreenParams |} - | {| +name: string, +key?: string, +params?: ScreenParams |}, - ): NavigateAction, - |}; - declare export type CommonActionsType = {| - +navigate: NavigateActionCreator, - +goBack: () => BackAction, - +reset: (state: PossiblyStaleNavigationState) => ResetAction, - +setParams: (params: ScreenParams) => SetParamsAction, - |}; - - declare export type GenericNavigationAction = {| - +type: string, - +payload?: { +[key: string]: mixed, ... }, - +source?: string, - +target?: string, - |}; - - declare export type LeafRoute = {| - +key: string, - +name: RouteName, - +params?: ScreenParams, - |}; - declare export type StateRoute = {| - ...LeafRoute, - +state: NavigationState | StaleNavigationState, - |}; - declare export type Route = - | LeafRoute - | StateRoute; - - declare export type NavigationState = {| - +key: string, - +index: number, - +routeNames: $ReadOnlyArray, - +history?: $ReadOnlyArray, - +routes: $ReadOnlyArray>, - +type: string, - +stale: false, - |}; - - declare export type StaleLeafRoute = {| - +key?: string, - +name: RouteName, - +params?: ScreenParams, - |}; - declare export type StaleStateRoute = {| - ...StaleLeafRoute, - +state: StaleNavigationState, - |}; - declare export type StaleRoute = - | StaleLeafRoute - | StaleStateRoute; - declare export type StaleNavigationState = {| - // It's possible to pass React Nav a StaleNavigationState with an undefined - // index, but React Nav will always return one with the index set. This is - // the same as for the type property below, but in the case of index we tend - // to rely on it being set more... - +index: number, - +history?: $ReadOnlyArray, - +routes: $ReadOnlyArray>, - +type?: string, - +stale?: true, - |}; - - declare export type PossiblyStaleNavigationState = - | NavigationState - | StaleNavigationState; - declare export type PossiblyStaleRoute = - | Route - | StaleRoute; - - /** - * Routers - */ - - declare type ActionCreators< - State: NavigationState, - Action: GenericNavigationAction, - > = { - +[key: string]: (...args: any) => (Action | State => Action), - ... - }; - - declare export type DefaultRouterOptions = { - +initialRouteName?: string, - ... - }; - - declare export type RouterFactory< - State: NavigationState, - Action: GenericNavigationAction, - RouterOptions: DefaultRouterOptions, - > = (options: RouterOptions) => Router; - - declare export type ParamListBase = { +[key: string]: ?ScreenParams, ... }; - - declare export type RouterConfigOptions = {| - +routeNames: $ReadOnlyArray, - +routeParamList: ParamListBase, - |}; - - declare export type Router< - State: NavigationState, - Action: GenericNavigationAction, - > = {| - +type: $PropertyType, - +getInitialState: (options: RouterConfigOptions) => State, - +getRehydratedState: ( - partialState: PossiblyStaleNavigationState, - options: RouterConfigOptions, - ) => State, - +getStateForRouteNamesChange: ( - state: State, - options: RouterConfigOptions, - ) => State, - +getStateForRouteFocus: (state: State, key: string) => State, - +getStateForAction: ( - state: State, - action: Action, - options: RouterConfigOptions, - ) => ?PossiblyStaleNavigationState; - +shouldActionChangeFocus: (action: GenericNavigationAction) => boolean, - +actionCreators?: ActionCreators, - |}; - - /** - * Stack actions and router - */ - - declare export type StackNavigationState = {| - ...NavigationState, - +type: 'stack', - |}; - - declare export type ReplaceAction = {| - +type: 'REPLACE', - +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type PushAction = {| - +type: 'PUSH', - +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type PopAction = {| - +type: 'POP', - +payload: {| +count: number |}, - +source?: string, - +target?: string, - |}; - declare export type PopToTopAction = {| - +type: 'POP_TO_TOP', - +source?: string, - +target?: string, - |}; - declare export type StackAction = - | CommonAction - | ReplaceAction - | PushAction - | PopAction - | PopToTopAction; - - declare export type StackActionsType = {| - +replace: (routeName: string, params?: ScreenParams) => ReplaceAction, - +push: (routeName: string, params?: ScreenParams) => PushAction, - +pop: (count?: number) => PopAction, - +popToTop: () => PopToTopAction, - |}; - - declare export type StackRouterOptions = $Exact; - - /** - * Tab actions and router - */ - - declare export type TabNavigationState = {| - ...NavigationState, - +type: 'tab', - +history: $ReadOnlyArray<{| type: 'route', key: string |}>, - |}; - - declare export type JumpToAction = {| - +type: 'JUMP_TO', - +payload: {| +name: string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type TabAction = - | CommonAction - | JumpToAction; - - declare export type TabActionsType = {| - +jumpTo: string => JumpToAction, - |}; - - declare export type TabRouterOptions = {| - ...$Exact, - +backBehavior?: 'initialRoute' | 'order' | 'history' | 'none', - |}; - - /** - * Drawer actions and router - */ - - declare type DrawerHistoryEntry = - | {| +type: 'route', +key: string |} - | {| +type: 'drawer' |}; - declare export type DrawerNavigationState = {| - ...NavigationState, - +type: 'drawer', - +history: $ReadOnlyArray, - |}; - - declare export type OpenDrawerAction = {| - +type: 'OPEN_DRAWER', - +source?: string, - +target?: string, - |}; - declare export type CloseDrawerAction = {| - +type: 'CLOSE_DRAWER', - +source?: string, - +target?: string, - |}; - declare export type ToggleDrawerAction = {| - +type: 'TOGGLE_DRAWER', - +source?: string, - +target?: string, - |}; - declare export type DrawerAction = - | TabAction - | OpenDrawerAction - | CloseDrawerAction - | ToggleDrawerAction; - - declare export type DrawerActionsType = {| - ...TabActionsType, - +openDrawer: () => OpenDrawerAction, - +closeDrawer: () => CloseDrawerAction, - +toggleDrawer: () => ToggleDrawerAction, - |}; - - declare export type DrawerRouterOptions = {| - ...TabRouterOptions, - +defaultStatus?: 'open' | 'closed', - |}; - - /** - * Events - */ - - declare export type EventMapBase = { - +[name: string]: {| - +data?: mixed, - +canPreventDefault?: boolean, - |}, - ... - }; - declare type EventPreventDefaultProperties = $If< - Test, - {| +defaultPrevented: boolean, +preventDefault: () => void |}, - {| |}, - >; - declare type EventDataProperties = $If< - $IsUndefined, - {| |}, - {| +data: Data |}, - >; - declare type EventArg< - EventName: string, - CanPreventDefault: ?boolean = false, - Data = void, - > = {| - ...EventPreventDefaultProperties, - ...EventDataProperties, - +type: EventName, - +target?: string, - |}; - declare type GlobalEventMap = {| - +state: {| +data: {| +state: State |}, +canPreventDefault: false |}, - |}; - declare type EventMapCore = {| - ...GlobalEventMap, - +focus: {| +data: void, +canPreventDefault: false |}, - +blur: {| +data: void, +canPreventDefault: false |}, - +beforeRemove: {| - +data: {| +action: GenericNavigationAction |}, - +canPreventDefault: true, - |}, - |}; - declare type EventListenerCallback< - EventName: string, - State: PossiblyStaleNavigationState = NavigationState, - EventMap: EventMapBase = EventMapCore, - > = (e: EventArg< - EventName, - $PropertyType< - $ElementType< - {| ...EventMap, ...EventMapCore |}, - EventName, - >, - 'canPreventDefault', - >, - $PropertyType< - $ElementType< - {| ...EventMap, ...EventMapCore |}, - EventName, - >, - 'data', - >, - >) => mixed; - - /** - * Navigation prop - */ - - declare type PartialWithMergeProperty = $If< - $IsExact, - { ...$Partial, +merge: true }, - { ...$Partial, +merge: true, ... }, - >; - - declare type EitherExactOrPartialWithMergeProperty = - | ParamsType - | PartialWithMergeProperty; - - declare export type SimpleNavigate = - >( - routeName: DestinationRouteName, - params: EitherExactOrPartialWithMergeProperty< - $ElementType, - >, - ) => void; - - declare export type Navigate = - & SimpleNavigate - & >( - route: $If< - $IsUndefined<$ElementType>, - | {| +key: string |} - | {| +name: DestinationRouteName, +key?: string |}, - | {| - +key: string, - +params?: EitherExactOrPartialWithMergeProperty< - $ElementType, - >, - |} - | {| - +name: DestinationRouteName, - +key?: string, - +params?: EitherExactOrPartialWithMergeProperty< - $ElementType, - >, - |}, - >, - ) => void; - - declare type CoreNavigationHelpers< - ParamList: ParamListBase, - State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, - EventMap: EventMapBase = EventMapCore, - > = { - +navigate: Navigate, - +dispatch: ( - action: - | GenericNavigationAction - | (State => GenericNavigationAction), - ) => void, - +reset: PossiblyStaleNavigationState => void, - +goBack: () => void, - +isFocused: () => boolean, - +canGoBack: () => boolean, - +getId: () => string | void, - +getParent: >(id?: string) => ?Parent, - +getState: () => NavigationState, - +addListener: |}, - >>( - name: EventName, - callback: EventListenerCallback, - ) => () => void, - +removeListener: |}, - >>( - name: EventName, - callback: EventListenerCallback, - ) => void, - ... - }; - - declare export type NavigationHelpers< - ParamList: ParamListBase, - State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, - EventMap: EventMapBase = EventMapCore, - > = { - ...$Exact>, - +setParams: (params: ScreenParams) => void, - ... - }; - - declare type SetParamsInput< - ParamList: ParamListBase, - RouteName: $Keys = $Keys, - > = $If< - $IsUndefined<$ElementType>, - empty, - $Partial<$NonMaybeType<$ElementType>>, - >; - - declare export type NavigationProp< - ParamList: ParamListBase, - RouteName: $Keys = $Keys, - State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = { - ...$Exact>, - +setOptions: (options: $Partial) => void, - +setParams: (params: SetParamsInput) => void, - ... - }; - - /** - * CreateNavigator - */ - - declare export type RouteProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - > = {| - ...LeafRoute, - +params: $ElementType, - +path?: string, - |}; - - declare type ScreenOptionsProp< - ScreenOptions: {...}, - RouteParam, - NavHelpers, - > = - | ScreenOptions - | ({| +route: RouteParam, +navigation: NavHelpers |}) => ScreenOptions; - declare export type ScreenListeners< - State: NavigationState = NavigationState, - EventMap: EventMapBase = EventMapCore, - > = $ObjMapi< - {| [name: $Keys]: empty |}, - >(K, empty) => EventListenerCallback, - >; - declare type ScreenListenersProp< - ScreenListenersParam: {...}, - RouteParam, - NavHelpers, - > = - | ScreenListenersParam - | ({| +route: RouteParam, +navigation: NavHelpers |}) => ScreenListenersParam; - - declare type BaseScreenProps< - ParamList: ParamListBase, - NavProp, - RouteName: $Keys = $Keys, - State: NavigationState = NavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = {| - +name: RouteName, - +options?: ScreenOptionsProp< - ScreenOptions, - RouteProp, - NavProp, - >, - +listeners?: ScreenListenersProp< - ScreenListeners, - RouteProp, - NavProp, - >, - +initialParams?: $Partial<$ElementType>, - +getId?: ({ - +params: $ElementType, - }) => string | void, - +navigationKey?: string, - |}; - - declare export type ScreenProps< - ParamList: ParamListBase, - NavProp, - RouteName: $Keys = $Keys, - State: NavigationState = NavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = - | {| - ...BaseScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >, - +component: React$ComponentType<{| - +route: RouteProp, - +navigation: NavProp, - |}>, - |} - | {| - ...BaseScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >, - +getComponent: () => React$ComponentType<{| - +route: RouteProp, - +navigation: NavProp, - |}>, - |} - | {| - ...BaseScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >, - +children: ({| - +route: RouteProp, - +navigation: NavProp, - |}) => React$Node, - |}; - - declare export type ScreenComponent< - GlobalParamList: ParamListBase, - ParamList: ParamListBase, - State: NavigationState = NavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = < - RouteName: $Keys, - NavProp: NavigationProp< - GlobalParamList, - RouteName, - State, - ScreenOptions, - EventMap, - >, - >(props: ScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >) => React$Node; - - declare type ScreenOptionsProps< - ScreenOptions: {...}, - RouteParam, - NavHelpers, - > = {| - +screenOptions?: ScreenOptionsProp, - |}; - declare type ScreenListenersProps< - ScreenListenersParam: {...}, - RouteParam, - NavHelpers, - > = {| - +screenListeners?: ScreenListenersProp< - ScreenListenersParam, - RouteParam, - NavHelpers, - >, - |}; - declare export type ExtraNavigatorPropsBase = { - ...$Exact, - +id?: string, - +children?: React$Node, - ... - }; - declare export type NavigatorProps< - ScreenOptions: {...}, - ScreenListenersParam, - RouteParam, - NavHelpers, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - > = { - ...$Exact, - ...ScreenOptionsProps, - ...ScreenListenersProps, - +defaultScreenOptions?: - | ScreenOptions - | ({| - +route: RouteParam, - +navigation: NavHelpers, - +options: ScreenOptions, - |}) => ScreenOptions, - ... - }; - declare export type NavigatorPropsBase< - ScreenOptions: {...}, - ScreenListenersParam: {...}, - NavHelpers, - > = NavigatorProps< - ScreenOptions, - ScreenListenersParam, - RouteProp<>, - NavHelpers, - ExtraNavigatorPropsBase, - >; - - declare export type CreateNavigator< - State: NavigationState, - ScreenOptions: {...}, - EventMap: EventMapBase, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - > = < - GlobalParamList: ParamListBase, - ParamList: ParamListBase, - NavHelpers: NavigationHelpers< - GlobalParamList, - State, - EventMap, - >, - >() => {| - +Screen: ScreenComponent< - GlobalParamList, - ParamList, - State, - ScreenOptions, - EventMap, - >, - +Navigator: React$ComponentType<$Exact, - RouteProp, - NavHelpers, - ExtraNavigatorProps, - >>>, - +Group: React$ComponentType<{| - ...ScreenOptionsProps, NavHelpers>, - +children: React$Node, - +navigationKey?: string, - |}>, - |}; - - declare export type CreateNavigatorFactory = < - State: NavigationState, - ScreenOptions: {...}, - EventMap: EventMapBase, - NavHelpers: NavigationHelpers< - ParamListBase, - State, - EventMap, - >, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - >( - navigator: React$ComponentType<$Exact, - RouteProp<>, - NavHelpers, - ExtraNavigatorProps, - >>>, - ) => CreateNavigator; - - - /** - * useNavigationBuilder - */ - - declare export type Descriptor< - NavHelpers, - ScreenOptions: {...} = {...}, - > = {| - +render: () => React$Node, - +options: $ReadOnly, - +navigation: NavHelpers, - |}; - - declare export type UseNavigationBuilder = < - State: NavigationState, - Action: GenericNavigationAction, - ScreenOptions: {...}, - RouterOptions: DefaultRouterOptions, - NavHelpers, - EventMap: EventMapBase, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - >( - routerFactory: RouterFactory, - options: $Exact, - RouteProp<>, - NavHelpers, - ExtraNavigatorProps, - >>, - ) => {| - +id?: string, - +state: State, - +descriptors: {| +[key: string]: Descriptor |}, - +navigation: NavHelpers, - |}; - - /** - * EdgeInsets - */ - - declare type EdgeInsets = {| - +top: number, - +right: number, - +bottom: number, - +left: number, - |}; - - /** - * TransitionPreset - */ - - declare export type TransitionSpec = - | {| - animation: 'spring', - config: $Diff< - SpringAnimationConfigSingle, - { toValue: number | AnimatedValue, ... }, - >, - |} - | {| - animation: 'timing', - config: $Diff< - TimingAnimationConfigSingle, - { toValue: number | AnimatedValue, ... }, - >, - |}; - - declare export type StackCardInterpolationProps = {| - +current: {| - +progress: AnimatedInterpolation, - |}, - +next?: {| - +progress: AnimatedInterpolation, - |}, - +index: number, - +closing: AnimatedInterpolation, - +swiping: AnimatedInterpolation, - +inverted: AnimatedInterpolation, - +layouts: {| - +screen: {| +width: number, +height: number |}, - |}, - +insets: EdgeInsets, - |}; - declare export type StackCardInterpolatedStyle = {| - containerStyle?: AnimatedViewStyleProp, - cardStyle?: AnimatedViewStyleProp, - overlayStyle?: AnimatedViewStyleProp, - shadowStyle?: AnimatedViewStyleProp, - |}; - declare export type StackCardStyleInterpolator = ( - props: StackCardInterpolationProps, - ) => StackCardInterpolatedStyle; - - declare export type StackHeaderInterpolationProps = {| - +current: {| - +progress: AnimatedInterpolation, - |}, - +next?: {| - +progress: AnimatedInterpolation, - |}, - +layouts: {| - +header: {| +width: number, +height: number |}, - +screen: {| +width: number, +height: number |}, - +title?: {| +width: number, +height: number |}, - +leftLabel?: {| +width: number, +height: number |}, - |}, - |}; - declare export type StackHeaderInterpolatedStyle = {| - leftLabelStyle?: AnimatedViewStyleProp, - leftButtonStyle?: AnimatedViewStyleProp, - rightButtonStyle?: AnimatedViewStyleProp, - titleStyle?: AnimatedViewStyleProp, - backgroundStyle?: AnimatedViewStyleProp, - |}; - declare export type StackHeaderStyleInterpolator = ( - props: StackHeaderInterpolationProps, - ) => StackHeaderInterpolatedStyle; - - declare type GestureDirection = - | 'horizontal' - | 'horizontal-inverted' - | 'vertical' - | 'vertical-inverted'; - - declare export type TransitionPreset = {| - +gestureDirection: GestureDirection, - +transitionSpec: {| - +open: TransitionSpec, - +close: TransitionSpec, - |}, - +cardStyleInterpolator: StackCardStyleInterpolator, - +headerStyleInterpolator: StackHeaderStyleInterpolator, - |}; - - /** - * Header common options - */ - - declare export type SceneProgress = {| - +current: AnimatedInterpolation, - +next?: AnimatedInterpolation, - +previous?: AnimatedInterpolation, - |}; - - declare export type HeaderProps = {| - +navigation: NavProp, - +route: RouteProp<>, - +options: ScreenOptions, - +layout: {| +width: number, +height: number |}, - |}; - - declare export type HeaderButtonProps = $Partial<{| - +tintColor: string, - +pressColor: string, - +pressOpacity: number, - |}>; - - declare export type HeaderLeftButtonProps = $Partial<{| - ...HeaderButtonProps, - +labelVisible: boolean, - |}>; - - declare type HeaderTitleInputBase = { - +onLayout: LayoutEvent => void, - +children: string, - +allowFontScaling: ?boolean, - +tintColor: ?string, - +style: ?AnimatedTextStyleProp, - ... - }; - - declare export type HeaderTitleInputProps = - $Exact; - - declare export type HeaderCommonOptions< - NavHeaderProps, - NavHeaderLeftProps, - NavHeaderRightProps, - > = $Partial<{| - +header: NavHeaderProps => React$Node, - +headerShown: boolean, - +headerTitle: string | ( HeaderTitleInputProps => React$Node), - +headerTitleAlign: 'left' | 'center', - +headerTitleStyle: AnimatedTextStyleProp, - +headerTitleContainerStyle: AnimatedViewStyleProp, - +headerTintColor: string, - +headerTitleAllowFontScaling: boolean, - +headerLeft: NavHeaderLeftProps => React$Node, - +headerLeftContainerStyle: AnimatedViewStyleProp, - +headerRight: NavHeaderRightProps => React$Node, - +headerRightContainerStyle: AnimatedViewStyleProp, - +headerBackground: ({| style: AnimatedViewStyleProp |}) => React$Node, - +headerStyle: AnimatedViewStyleProp, - +headerTransparent: boolean, - +headerStatusBarHeight: number, - +headerShadowVisible: boolean, - +headerBackgroundContainerStyle: AnimatedViewStyleProp, - +headerPressColor: string, - +headerPressOpacity: number, - |}>; - - /** - * Stack options - */ - - declare export type StackDescriptor = Descriptor< - StackNavigationHelpers<>, - StackOptions, - >; - - declare type Scene = {| - +route: T, - +descriptor: StackDescriptor, - +progress: SceneProgress, - |}; - - declare export type StackHeaderProps = {| - ...HeaderProps, StackOptions>, - +progress: SceneProgress, - +back?: {| +title: string |}, - +styleInterpolator: StackHeaderStyleInterpolator, - |}; - - declare export type StackHeaderButtonProps = $Partial<{| - ...HeaderButtonProps, - +canGoBack: boolean, - |}>; - - declare export type StackHeaderLeftButtonProps = $Partial<{| - ...StackHeaderButtonProps, - +onPress: (() => void), - +backImage: (props: {| tintColor: string |}) => React$Node, - +label: string, - +truncatedLabel: string, - +labelVisible: boolean, - +labelStyle: AnimatedTextStyleProp, - +allowFontScaling: boolean, - +onLabelLayout: LayoutEvent => void, - +screenLayout: {| +width: number, +height: number |}, - +titleLayout: {| +width: number, +height: number |}, - +disabled: boolean, - +accessibilityLabel: string, - +style: ViewStyleProp, - |}>; - - declare export type StackOptions = $Partial<{| - +title: string, - +cardShadowEnabled: boolean, - +cardOverlayEnabled: boolean, - +cardOverlay: {| style: ViewStyleProp |} => React$Node, - +cardStyle: ViewStyleProp, - +animationEnabled: boolean, - +animationTypeForReplace: 'push' | 'pop', - +gestureEnabled: boolean, - +gestureResponseDistance: number, - +gestureVelocityImpact: number, - +safeAreaInsets: $Partial, - +keyboardHandlingEnabled: boolean, - +presentation: 'card' | 'modal' | 'transparentModal', - // Transition - ...TransitionPreset, - // Header - ...HeaderCommonOptions< - StackHeaderProps, - StackHeaderLeftButtonProps, - StackHeaderButtonProps, - >, - +headerMode: 'float' | 'screen', - +headerBackAllowFontScaling: boolean, - +headerBackTitle: string | null, - +headerBackTitleStyle: TextStyleProp, - +headerBackTitleVisible: boolean, - +headerTruncatedBackTitle: string, - +headerBackImage: $PropertyType, - +headerBackAccessibilityLabel: string, - |}>; - - /** - * Stack navigation prop - */ - - declare export type StackNavigationEventMap = {| - ...EventMapCore, - +transitionStart: {| - +data: {| +closing: boolean |}, - +canPreventDefault: false, - |}, - +transitionEnd: {| - +data: {| +closing: boolean |}, - +canPreventDefault: false, - |}, - +gestureStart: {| +data: void, +canPreventDefault: false |}, - +gestureEnd: {| +data: void, +canPreventDefault: false |}, - +gestureCancel: {| +data: void, +canPreventDefault: false |}, - |}; - - declare type StackExtraNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - > = {| - +replace: SimpleNavigate, - +push: SimpleNavigate, - +pop: (count?: number) => void, - +popToTop: () => void, - |}; - - declare export type StackNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = StackNavigationEventMap, - > = { - ...$Exact>, - ...StackExtraNavigationHelpers, - ... - }; - - declare export type StackNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = StackOptions, - EventMap: EventMapBase = StackNavigationEventMap, - > = {| - ...$Exact>, - ...StackExtraNavigationHelpers, - |}; - - /** - * Miscellaneous stack exports - */ - - declare type StackNavigationConfig = {| - +detachInactiveScreens?: boolean, - |}; - - declare export type ExtraStackNavigatorProps = {| - ...$Exact, - ...StackRouterOptions, - ...StackNavigationConfig, - |}; - - declare export type StackNavigatorProps< - NavHelpers: StackNavigationHelpers<> = StackNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraStackNavigatorProps, - >>; - - /** - * Bottom tab options - */ - - declare export type BottomTabBarButtonProps = {| - ...$Diff< - TouchableWithoutFeedbackProps, - {| onPress?: ?(event: PressEvent) => mixed |}, - >, - +to?: string, - +children: React$Node, - +onPress?: (MouseEvent | PressEvent) => void, - |}; - - declare export type TabBarVisibilityAnimationConfig = - | {| - +animation: 'spring', - +config?: $Diff< - SpringAnimationConfigSingle, - { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, - >, - |} - | {| - +animation: 'timing', - +config?: $Diff< - TimingAnimationConfigSingle, - { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, - >, - |}; - - declare export type BottomTabOptions = $Partial<{| - +title: string, - +tabBarLabel: - | string - | ({| focused: boolean, color: string |}) => React$Node, - +tabBarIcon: ({| - focused: boolean, - color: string, - size: number, - |}) => React$Node, - +tabBarBadge: number | string, - +tabBarBadgeStyle: TextStyleProp, - +tabBarAccessibilityLabel: string, - +tabBarTestID: string, - +tabBarVisibilityAnimationConfig: $Partial<{| - +show: TabBarVisibilityAnimationConfig, - +hide: TabBarVisibilityAnimationConfig, - |}>, - +tabBarButton: BottomTabBarButtonProps => React$Node, - +tabBarHideOnKeyboard: boolean, - +tabBarActiveTintColor: string, - +tabBarInactiveTintColor: string, - +tabBarActiveBackgroundColor: string, - +tabBarInactiveBackgroundColor: string, - +tabBarAllowFontScaling: boolean, - +tabBarShowLabel: boolean, - +tabBarLabelStyle: TextStyleProp, - +tabBarIconStyle: TextStyleProp, - +tabBarItemStyle: ViewStyleProp, - +tabBarLabelPosition: 'beside-icon' | 'below-icon', - +tabBarStyle: ViewStyleProp, - +unmountOnBlur: boolean, - +lazy: boolean, - ...HeaderCommonOptions< - HeaderProps, BottomTabOptions>, - HeaderLeftButtonProps, - HeaderButtonProps, - >, - |}>; - - /** - * Bottom tab navigation prop - */ - - declare export type BottomTabNavigationEventMap = {| - ...EventMapCore, - +tabPress: {| +data: void, +canPreventDefault: true |}, - +tabLongPress: {| +data: void, +canPreventDefault: false |}, - |}; - - declare type TabExtraNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - > = {| - +jumpTo: SimpleNavigate, - |}; - - declare export type BottomTabNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = BottomTabNavigationEventMap, - > = { - ...$Exact>, - ...TabExtraNavigationHelpers, - ... - }; - - declare export type BottomTabNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = BottomTabOptions, - EventMap: EventMapBase = BottomTabNavigationEventMap, - > = {| - ...$Exact>, - ...TabExtraNavigationHelpers, - |}; - - /** - * Miscellaneous bottom tab exports - */ - - declare export type BottomTabDescriptor = Descriptor< - BottomTabNavigationHelpers<>, - BottomTabOptions, - >; - - declare type BottomTabNavigationBuilderResult = {| - +state: TabNavigationState, - +navigation: BottomTabNavigationHelpers<>, - +descriptors: {| +[key: string]: BottomTabDescriptor |}, - |}; - - declare export type BottomTabBarProps = BottomTabNavigationBuilderResult; - - declare type BottomTabNavigationConfig = {| - +tabBar?: BottomTabBarProps => React$Node, - +safeAreaInsets?: $Partial, - +detachInactiveScreens?: boolean, - |}; - - declare export type ExtraBottomTabNavigatorProps = {| - ...$Exact, - ...TabRouterOptions, - ...BottomTabNavigationConfig, - |}; - - declare export type BottomTabNavigatorProps< - NavHelpers: BottomTabNavigationHelpers<> = BottomTabNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraBottomTabNavigatorProps, - >>; - - /** - * Material bottom tab options - */ - - declare export type MaterialBottomTabOptions = $Partial<{| - +title: string, - +tabBarColor: string, - +tabBarLabel: string, - +tabBarIcon: - | string - | ({| +focused: boolean, +color: string |}) => React$Node, - +tabBarBadge: boolean | number | string, - +tabBarAccessibilityLabel: string, - +tabBarTestID: string, - |}>; - - /** - * Material bottom tab navigation prop - */ - - declare export type MaterialBottomTabNavigationEventMap = {| - ...EventMapCore, - +tabPress: {| +data: void, +canPreventDefault: true |}, - |}; - - declare export type MaterialBottomTabNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, - > = { - ...$Exact>, - ...TabExtraNavigationHelpers, - ... - }; - - declare export type MaterialBottomTabNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = MaterialBottomTabOptions, - EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, - > = {| - ...$Exact>, - ...TabExtraNavigationHelpers, - |}; - - /** - * Miscellaneous material bottom tab exports - */ - - declare export type PaperFont = {| - +fontFamily: string, - +fontWeight?: - | 'normal' - | 'bold' - | '100' - | '200' - | '300' - | '400' - | '500' - | '600' - | '700' - | '800' - | '900', - |}; - - declare export type PaperFonts = {| - +regular: PaperFont, - +medium: PaperFont, - +light: PaperFont, - +thin: PaperFont, - |}; - - declare export type PaperTheme = {| - +dark: boolean, - +mode?: 'adaptive' | 'exact', - +roundness: number, - +colors: {| - +primary: string, - +background: string, - +surface: string, - +accent: string, - +error: string, - +text: string, - +onSurface: string, - +onBackground: string, - +disabled: string, - +placeholder: string, - +backdrop: string, - +notification: string, - |}, - +fonts: PaperFonts, - +animation: {| - +scale: number, - |}, - |}; - - declare export type PaperRoute = {| - +key: string, - +title?: string, - +icon?: any, - +badge?: string | number | boolean, - +color?: string, - +accessibilityLabel?: string, - +testID?: string, - |}; - - declare export type PaperTouchableProps = {| - ...TouchableWithoutFeedbackProps, - +key: string, - +route: PaperRoute, - +children: React$Node, - +borderless?: boolean, - +centered?: boolean, - +rippleColor?: string, - |}; - - declare export type MaterialBottomTabNavigationConfig = {| - +shifting?: boolean, - +labeled?: boolean, - +renderTouchable?: PaperTouchableProps => React$Node, - +activeColor?: string, - +inactiveColor?: string, - +sceneAnimationEnabled?: boolean, - +keyboardHidesNavigationBar?: boolean, - +barStyle?: ViewStyleProp, - +style?: ViewStyleProp, - +theme?: PaperTheme, - |}; - - declare export type ExtraMaterialBottomTabNavigatorProps = {| - ...$Exact, - ...TabRouterOptions, - ...MaterialBottomTabNavigationConfig, - |}; - - declare export type MaterialBottomTabNavigatorProps< - NavHelpers: MaterialBottomTabNavigationHelpers<> = - MaterialBottomTabNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraMaterialBottomTabNavigatorProps, - >>; - - /** - * Material top tab options - */ - - declare export type MaterialTopTabOptions = $Partial<{| - +title: string, - +tabBarLabel: - | string - | ({| +focused: boolean, +color: string |}) => React$Node, - +tabBarIcon: ({| +focused: boolean, +color: string |}) => React$Node, - +tabBarAccessibilityLabel: string, - +tabBarTestID: string, - +tabBarActiveTintColor: string, - +tabBarInactiveTintColor: string, - +tabBarPressColor: string, - +tabBarPressOpacity: number, - +tabBarShowLabel: boolean, - +tabBarShowIcon: boolean, - +tabBarAllowFontScaling: boolean, - +tabBarBounces: boolean, - +tabBarScrollEnabled: boolean, - +tabBarIconStyle: ViewStyleProp, - +tabBarLabelStyle: TextStyleProp, - +tabBarItemStyle: ViewStyleProp, - +tabBarIndicatorStyle: ViewStyleProp, - +tabBarIndicatorContainerStyle: ViewStyleProp, - +tabBarContentContainerStyle: ViewStyleProp, - +tabBarStyle: ViewStyleProp, - +tabBarBadge: () => React$Node, - +tabBarIndicator: MaterialTopTabBarIndicatorProps => React$Node, - +lazy: boolean, - +lazyPlaceholder: ({| +route: Route<> |}) => React$Node, - |}>; - - /** - * Material top tab navigation prop - */ - - declare export type MaterialTopTabNavigationEventMap = {| - ...EventMapCore, - +tabPress: {| +data: void, +canPreventDefault: true |}, - +tabLongPress: {| +data: void, +canPreventDefault: false |}, - +swipeStart: {| +data: void, +canPreventDefault: false |}, - +swipeEnd: {| +data: void, +canPreventDefault: false |}, - |}; - - declare export type MaterialTopTabNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = MaterialTopTabNavigationEventMap, - > = { - ...$Exact>, - ...TabExtraNavigationHelpers, - ... - }; - - declare export type MaterialTopTabNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = MaterialTopTabOptions, - EventMap: EventMapBase = MaterialTopTabNavigationEventMap, - > = {| - ...$Exact>, - ...TabExtraNavigationHelpers, - |}; - - /** - * Miscellaneous material top tab exports - */ - - declare type MaterialTopTabPagerCommonProps = {| - +keyboardDismissMode: 'none' | 'on-drag' | 'auto', - +swipeEnabled: boolean, - +swipeVelocityImpact?: number, - +springVelocityScale?: number, - +springConfig: $Partial<{| - +damping: number, - +mass: number, - +stiffness: number, - +restSpeedThreshold: number, - +restDisplacementThreshold: number, - |}>, - +timingConfig: $Partial<{| - +duration: number, - |}>, - |}; - - declare export type MaterialTopTabPagerProps = {| - ...MaterialTopTabPagerCommonProps, - +onSwipeStart?: () => void, - +onSwipeEnd?: () => void, - +onIndexChange: (index: number) => void, - +navigationState: TabNavigationState, - +layout: {| +width: number, +height: number |}, - +removeClippedSubviews: boolean, - +children: ({| - +addListener: (type: 'enter', listener: number => void) => void, - +removeListener: (type: 'enter', listener: number => void) => void, - +position: any, // Reanimated.Node - +render: React$Node => React$Node, - +jumpTo: string => void, - |}) => React$Node, - +gestureHandlerProps: PanGestureHandlerProps, - |}; - - declare export type MaterialTopTabBarIndicatorProps = {| - +state: TabNavigationState, - +width: string, - +style?: ViewStyleProp, - +getTabWidth: number => number, - |}; - - declare export type MaterialTopTabDescriptor = Descriptor< - MaterialBottomTabNavigationHelpers<>, - MaterialBottomTabOptions, - >; - - declare type MaterialTopTabNavigationBuilderResult = {| - +state: TabNavigationState, - +navigation: MaterialTopTabNavigationHelpers<>, - +descriptors: {| +[key: string]: MaterialTopTabDescriptor |}, - |}; - - declare export type MaterialTopTabBarProps = {| - ...MaterialTopTabNavigationBuilderResult, - +layout: {| +width: number, +height: number |}, - +position: any, // Reanimated.Node - +jumpTo: string => void, - |}; - - declare export type MaterialTopTabNavigationConfig = {| - ...$Partial, - +position?: any, // Reanimated.Value - +tabBarPosition?: 'top' | 'bottom', - +initialLayout?: $Partial<{| +width: number, +height: number |}>, - +lazyPreloadDistance?: number, - +removeClippedSubviews?: boolean, - +sceneContainerStyle?: ViewStyleProp, - +style?: ViewStyleProp, - +gestureHandlerProps?: PanGestureHandlerProps, - +pager?: MaterialTopTabPagerProps => React$Node, - +tabBar?: MaterialTopTabBarProps => React$Node, - |}; - - declare export type ExtraMaterialTopTabNavigatorProps = {| - ...$Exact, - ...TabRouterOptions, - ...MaterialTopTabNavigationConfig, - |}; - - declare export type MaterialTopTabNavigatorProps< - NavHelpers: MaterialTopTabNavigationHelpers<> = - MaterialTopTabNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraMaterialTopTabNavigatorProps, - >>; - - /** - * Drawer options - */ - - declare export type DrawerOptions = $Partial<{| - +title: string, - +lazy: boolean, - +drawerLabel: - | string - | ({| +color: string, +focused: boolean |}) => React$Node, - +drawerIcon: ({| - +color: string, - +size: number, - +focused: boolean, - |}) => React$Node, - +drawerActiveTintColor: string, - +drawerActiveBackgroundColor: string, - +drawerInactiveTintColor: string, - +drawerInactiveBackgroundColor: string, - +drawerItemStyle: ViewStyleProp, - +drawerLabelStyle: TextStyleProp, - +drawerContentContainerStyle: ViewStyleProp, - +drawerContentStyle: ViewStyleProp, - +drawerStyle: ViewStyleProp, - +drawerPosition: 'left' | 'right', - +drawerType: 'front' | 'back' | 'slide' | 'permanent', - +drawerHideStatusBarOnOpen: boolean, - +drawerStatusBarAnimation: 'slide' | 'none' | 'fade', - +overlayColor: string, - +sceneContainerStyle: ViewStyleProp, - +gestureHandlerProps: PanGestureHandlerProps, - +swipeEnabled: boolean, - +swipeEdgeWidth: number, - +swipeMinDistance: number, - +keyboardDismissMode: 'on-drag' | 'none', - +unmountOnBlur: boolean, - ...HeaderCommonOptions< - HeaderProps, DrawerOptions>, - HeaderLeftButtonProps, - HeaderButtonProps, - >, - |}>; - - /** - * Drawer navigation prop - */ - - declare export type DrawerNavigationEventMap = - EventMapCore; - - declare type DrawerExtraNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - > = {| - +jumpTo: SimpleNavigate, - +openDrawer: () => void, - +closeDrawer: () => void, - +toggleDrawer: () => void, - |}; - - declare export type DrawerNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = DrawerNavigationEventMap, - > = { - ...$Exact>, - ...DrawerExtraNavigationHelpers, - ... - }; - - declare export type DrawerNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = DrawerOptions, - EventMap: EventMapBase = DrawerNavigationEventMap, - > = {| - ...$Exact>, - ...DrawerExtraNavigationHelpers, - |}; - - /** - * Miscellaneous drawer exports - */ - - declare export type DrawerDescriptor = Descriptor< - DrawerNavigationHelpers<>, - DrawerOptions, - >; - - declare type DrawerNavigationBuilderResult = {| - +state: DrawerNavigationState, - +navigation: DrawerNavigationHelpers<>, - +descriptors: {| +[key: string]: DrawerDescriptor |}, - |}; - - declare export type DrawerNavigationConfig = {| - +drawerContent?: DrawerNavigationBuilderResult => React$Node, - +detachInactiveScreens?: boolean, - +useLegacyImplementation?: boolean, - |}; - - declare export type ExtraDrawerNavigatorProps = {| - ...$Exact, - ...DrawerRouterOptions, - ...DrawerNavigationConfig, - |}; - - declare export type DrawerNavigatorProps< - NavHelpers: DrawerNavigationHelpers<> = DrawerNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraDrawerNavigatorProps, - >>; - - /** - * BaseNavigationContainer - */ - - declare export type BaseNavigationContainerProps = {| - +children: React$Node, - +initialState?: PossiblyStaleNavigationState, - +onStateChange?: (state: ?PossiblyStaleNavigationState) => void, - +independent?: boolean, - |}; - - declare export type ContainerEventMap = {| - ...GlobalEventMap, - +options: {| - +data: {| +options: { +[key: string]: mixed, ... } |}, - +canPreventDefault: false, - |}, - +__unsafe_action__: {| - +data: {| - +action: GenericNavigationAction, - +noop: boolean, - |}, - +canPreventDefault: false, - |}, - |}; - - declare export type BaseNavigationContainerInterface = {| - ...$Exact>, - +resetRoot: (state?: PossiblyStaleNavigationState) => void, - +getRootState: () => NavigationState, - +getCurrentRoute: () => RouteProp<> | void, - +getCurrentOptions: () => Object | void, - +isReady: () => boolean, - |}; - - declare type BaseNavigationContainerInterfaceRef = {| - ...BaseNavigationContainerInterface, - +current: BaseNavigationContainerInterface | null, - |}; - - /** - * State utils - */ - - declare export type GetStateFromPath = ( - path: string, - options?: LinkingConfig, - ) => PossiblyStaleNavigationState; - - declare export type GetPathFromState = ( - state?: ?PossiblyStaleNavigationState, - options?: LinkingConfig, - ) => string; - - declare export type GetFocusedRouteNameFromRoute = - PossiblyStaleRoute => ?string; - - /** - * Linking - */ - - declare export type ScreenLinkingConfig = {| - +path?: string, - +exact?: boolean, - +parse?: {| +[param: string]: string => mixed |}, - +stringify?: {| +[param: string]: mixed => string |}, - +screens?: ScreenLinkingConfigMap, - +initialRouteName?: string, - |}; - - declare export type ScreenLinkingConfigMap = {| - +[routeName: string]: string | ScreenLinkingConfig, - |}; - - declare export type LinkingConfig = {| - +initialRouteName?: string, - +screens: ScreenLinkingConfigMap, - |}; - - declare export type LinkingOptions = {| - +enabled?: boolean, - +prefixes: $ReadOnlyArray, - +config?: LinkingConfig, - +getStateFromPath?: GetStateFromPath, - +getPathFromState?: GetPathFromState, - |}; - - /** - * NavigationContainer - */ - - declare export type Theme = {| - +dark: boolean, - +colors: {| - +primary: string, - +background: string, - +card: string, - +text: string, - +border: string, - |}, - |}; - - declare export type NavigationContainerType = React$AbstractComponent< - {| - ...BaseNavigationContainerProps, - +theme?: Theme, - +linking?: LinkingOptions, - +fallback?: React$Node, - +onReady?: () => mixed, - |}, + import type { + CommonActionsType, + StackActionsType, + TabActionsType, + DrawerActionsType, + RouterFactory, + NavigationState, + CommonAction, + DefaultRouterOptions, + StackNavigationState, + StackAction, + StackRouterOptions, + TabNavigationState, + TabAction, + TabRouterOptions, + DrawerNavigationState, + DrawerAction, + DrawerRouterOptions, + BaseNavigationContainerProps, BaseNavigationContainerInterface, - >; - - //--------------------------------------------------------------------------- - // SECTION 2: EXPORTED MODULE - // This section defines the module exports and contains exported types that - // are not present in any other React Navigation libdef. - //--------------------------------------------------------------------------- + CreateNavigatorFactory, + UseNavigationBuilder, + NavigationHelpers, + ParamListBase, + NavigationProp, + LeafRoute, + GetStateFromPath, + GetPathFromState, + PossiblyStaleNavigationState, + NavigateAction, + GetFocusedRouteNameFromRoute, + Theme, + GenericNavigationAction, + PressEvent, + ScreenParams, + NavigationContainerType, + BaseNavigationContainerInterfaceRef, + } from '@react-navigation/core'; /** * Actions and routers diff --git a/native/flow-typed/npm/@react-navigation/stack_v6.x.x.js b/native/flow-typed/npm/@react-navigation/stack_v6.x.x.js --- a/native/flow-typed/npm/@react-navigation/stack_v6.x.x.js +++ b/native/flow-typed/npm/@react-navigation/stack_v6.x.x.js @@ -3,2263 +3,23 @@ declare module '@react-navigation/stack' { - //--------------------------------------------------------------------------- - // SECTION 1: IDENTICAL TYPE DEFINITIONS - // This section is identical across all React Navigation libdefs and contains - // shared definitions. We wish we could make it DRY and import from a shared - // definition, but that isn't yet possible. - //--------------------------------------------------------------------------- - - /** - * We start with some definitions that we have copy-pasted from React Native - * source files. - */ - - // This is a bastardization of the true StyleObj type located in - // react-native/Libraries/StyleSheet/StyleSheetTypes. We unfortunately can't - // import that here, and it's too lengthy (and consequently too brittle) to - // copy-paste here either. - declare type StyleObj = - | null - | void - | number - | false - | '' - | $ReadOnlyArray - | { [name: string]: any, ... }; - declare type ViewStyleProp = StyleObj; - declare type TextStyleProp = StyleObj; - declare type AnimatedViewStyleProp = StyleObj; - declare type AnimatedTextStyleProp = StyleObj; - - // Vaguely copied from - // react-native/Libraries/Animated/src/animations/Animation.js - declare type EndResult = { finished: boolean, ... }; - declare type EndCallback = (result: EndResult) => void; - declare interface Animation { - start( - fromValue: number, - onUpdate: (value: number) => void, - onEnd: ?EndCallback, - previousAnimation: ?Animation, - animatedValue: AnimatedValue, - ): void; - stop(): void; - } - declare type AnimationConfig = { - isInteraction?: boolean, - useNativeDriver: boolean, - onComplete?: ?EndCallback, - iterations?: number, - ... - }; - - // Vaguely copied from - // react-native/Libraries/Animated/src/nodes/AnimatedTracking.js - declare interface AnimatedTracking { - constructor( - value: AnimatedValue, - parent: any, - animationClass: any, - animationConfig: Object, - callback?: ?EndCallback, - ): void; - update(): void; - } - - // Vaguely copied from - // react-native/Libraries/Animated/src/nodes/AnimatedValue.js - declare type ValueListenerCallback = (state: { value: number, ... }) => void; - declare interface AnimatedValue { - constructor(value: number): void; - setValue(value: number): void; - setOffset(offset: number): void; - flattenOffset(): void; - extractOffset(): void; - addListener(callback: ValueListenerCallback): string; - removeListener(id: string): void; - removeAllListeners(): void; - stopAnimation(callback?: ?(value: number) => void): void; - resetAnimation(callback?: ?(value: number) => void): void; - interpolate(config: InterpolationConfigType): AnimatedInterpolation; - animate(animation: Animation, callback: ?EndCallback): void; - stopTracking(): void; - track(tracking: AnimatedTracking): void; - } - - // Copied from - // react-native/Libraries/Animated/src/animations/TimingAnimation.js - declare type TimingAnimationConfigSingle = AnimationConfig & { - toValue: number | AnimatedValue, - easing?: (value: number) => number, - duration?: number, - delay?: number, - ... - }; - - // Copied from - // react-native/Libraries/Animated/src/animations/SpringAnimation.js - declare type SpringAnimationConfigSingle = AnimationConfig & { - toValue: number | AnimatedValue, - overshootClamping?: boolean, - restDisplacementThreshold?: number, - restSpeedThreshold?: number, - velocity?: number, - bounciness?: number, - speed?: number, - tension?: number, - friction?: number, - stiffness?: number, - damping?: number, - mass?: number, - delay?: number, - ... - }; - - // Copied from react-native/Libraries/Types/CoreEventTypes.js - declare type SyntheticEvent = $ReadOnly<{| - bubbles: ?boolean, - cancelable: ?boolean, - currentTarget: number, - defaultPrevented: ?boolean, - dispatchConfig: $ReadOnly<{| - registrationName: string, - |}>, - eventPhase: ?number, - preventDefault: () => void, - isDefaultPrevented: () => boolean, - stopPropagation: () => void, - isPropagationStopped: () => boolean, - isTrusted: ?boolean, - nativeEvent: T, - persist: () => void, - target: ?number, - timeStamp: number, - type: ?string, - |}>; - declare type Layout = $ReadOnly<{| - x: number, - y: number, - width: number, - height: number, - |}>; - declare type LayoutEvent = SyntheticEvent< - $ReadOnly<{| - layout: Layout, - |}>, - >; - declare type BlurEvent = SyntheticEvent< - $ReadOnly<{| - target: number, - |}>, - >; - declare type FocusEvent = SyntheticEvent< - $ReadOnly<{| - target: number, - |}>, - >; - declare type ResponderSyntheticEvent = $ReadOnly<{| - ...SyntheticEvent, - touchHistory: $ReadOnly<{| - indexOfSingleActiveTouch: number, - mostRecentTimeStamp: number, - numberActiveTouches: number, - touchBank: $ReadOnlyArray< - $ReadOnly<{| - touchActive: boolean, - startPageX: number, - startPageY: number, - startTimeStamp: number, - currentPageX: number, - currentPageY: number, - currentTimeStamp: number, - previousPageX: number, - previousPageY: number, - previousTimeStamp: number, - |}>, - >, - |}>, - |}>; - declare type PressEvent = ResponderSyntheticEvent< - $ReadOnly<{| - changedTouches: $ReadOnlyArray<$PropertyType>, - force: number, - identifier: number, - locationX: number, - locationY: number, - pageX: number, - pageY: number, - target: ?number, - timestamp: number, - touches: $ReadOnlyArray<$PropertyType>, - |}>, - >; - - // Vaguely copied from - // react-native/Libraries/Animated/src/nodes/AnimatedInterpolation.js - declare type ExtrapolateType = 'extend' | 'identity' | 'clamp'; - declare type InterpolationConfigType = { - inputRange: Array, - outputRange: Array | Array, - easing?: (input: number) => number, - extrapolate?: ExtrapolateType, - extrapolateLeft?: ExtrapolateType, - extrapolateRight?: ExtrapolateType, - ... - }; - declare interface AnimatedInterpolation { - interpolate(config: InterpolationConfigType): AnimatedInterpolation; - } - - // Copied from react-native/Libraries/Components/View/ViewAccessibility.js - declare type AccessibilityRole = - | 'none' - | 'button' - | 'link' - | 'search' - | 'image' - | 'keyboardkey' - | 'text' - | 'adjustable' - | 'imagebutton' - | 'header' - | 'summary' - | 'alert' - | 'checkbox' - | 'combobox' - | 'menu' - | 'menubar' - | 'menuitem' - | 'progressbar' - | 'radio' - | 'radiogroup' - | 'scrollbar' - | 'spinbutton' - | 'switch' - | 'tab' - | 'tablist' - | 'timer' - | 'toolbar'; - declare type AccessibilityActionInfo = $ReadOnly<{ - name: string, - label?: string, - ... - }>; - declare type AccessibilityActionEvent = SyntheticEvent< - $ReadOnly<{actionName: string, ...}>, - >; - declare type AccessibilityState = { - disabled?: boolean, - selected?: boolean, - checked?: ?boolean | 'mixed', - busy?: boolean, - expanded?: boolean, - ... - }; - declare type AccessibilityValue = $ReadOnly<{| - min?: number, - max?: number, - now?: number, - text?: string, - |}>; - - // Copied from - // react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js - declare type Stringish = string; - declare type EdgeInsetsProp = $ReadOnly<$Partial>; - declare type TouchableWithoutFeedbackProps = $ReadOnly<{| - accessibilityActions?: ?$ReadOnlyArray, - accessibilityElementsHidden?: ?boolean, - accessibilityHint?: ?Stringish, - accessibilityIgnoresInvertColors?: ?boolean, - accessibilityLabel?: ?Stringish, - accessibilityLiveRegion?: ?('none' | 'polite' | 'assertive'), - accessibilityRole?: ?AccessibilityRole, - accessibilityState?: ?AccessibilityState, - accessibilityValue?: ?AccessibilityValue, - accessibilityViewIsModal?: ?boolean, - accessible?: ?boolean, - children?: ?React$Node, - delayLongPress?: ?number, - delayPressIn?: ?number, - delayPressOut?: ?number, - disabled?: ?boolean, - focusable?: ?boolean, - hitSlop?: ?EdgeInsetsProp, - importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'), - nativeID?: ?string, - onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed, - onBlur?: ?(event: BlurEvent) => mixed, - onFocus?: ?(event: FocusEvent) => mixed, - onLayout?: ?(event: LayoutEvent) => mixed, - onLongPress?: ?(event: PressEvent) => mixed, - onPress?: ?(event: PressEvent) => mixed, - onPressIn?: ?(event: PressEvent) => mixed, - onPressOut?: ?(event: PressEvent) => mixed, - pressRetentionOffset?: ?EdgeInsetsProp, - rejectResponderTermination?: ?boolean, - testID?: ?string, - touchSoundDisabled?: ?boolean, - |}>; - - // Copied from react-native/Libraries/Image/ImageSource.js - declare type ImageURISource = $ReadOnly<{ - uri?: ?string, - bundle?: ?string, - method?: ?string, - headers?: ?Object, - body?: ?string, - cache?: ?('default' | 'reload' | 'force-cache' | 'only-if-cached'), - width?: ?number, - height?: ?number, - scale?: ?number, - ... - }>; - - /** - * The following is copied from react-native-gesture-handler's libdef - */ - - declare type StateUndetermined = 0; - declare type StateFailed = 1; - declare type StateBegan = 2; - declare type StateCancelled = 3; - declare type StateActive = 4; - declare type StateEnd = 5; - - declare type GestureHandlerState = - | StateUndetermined - | StateFailed - | StateBegan - | StateCancelled - | StateActive - | StateEnd; - - declare type $SyntheticEvent = { - +nativeEvent: $ReadOnly<$Exact>, - ... - }; - - declare type $Event = $SyntheticEvent<{ - handlerTag: number, - numberOfPointers: number, - state: GestureHandlerState, - oldState: GestureHandlerState, - ...$Exact, - ... - }>; - - declare type $EventHandlers = {| - onGestureEvent?: ($Event) => mixed, - onHandlerStateChange?: ($Event) => mixed, - onBegan?: ($Event) => mixed, - onFailed?: ($Event) => mixed, - onCancelled?: ($Event) => mixed, - onActivated?: ($Event) => mixed, - onEnded?: ($Event) => mixed, - |}; - - declare type HitSlop = - | number - | {| - left?: number, - top?: number, - right?: number, - bottom?: number, - vertical?: number, - horizontal?: number, - width?: number, - height?: number, - |} - | {| - width: number, - left: number, - |} - | {| - width: number, - right: number, - |} - | {| - height: number, - top: number, - |} - | {| - height: number, - bottom: number, - |}; - - declare type $GestureHandlerProps< - AdditionalProps: {...}, - ExtraEventsProps: {...} - > = $ReadOnly<{| - ...$Exact, - ...$EventHandlers, - id?: string, - enabled?: boolean, - waitFor?: React$Ref | Array>, - simultaneousHandlers?: React$Ref | Array>, - shouldCancelWhenOutside?: boolean, - minPointers?: number, - hitSlop?: HitSlop, - children?: React$Node, - |}>; - - declare type PanGestureHandlerProps = $GestureHandlerProps< - { - activeOffsetY?: number | [number, number], - activeOffsetX?: number | [number, number], - failOffsetY?: number | [number, number], - failOffsetX?: number | [number, number], - minDist?: number, - minVelocity?: number, - minVelocityX?: number, - minVelocityY?: number, - minPointers?: number, - maxPointers?: number, - avgTouches?: boolean, - ... - }, - { - x: number, - y: number, - absoluteX: number, - absoluteY: number, - translationX: number, - translationY: number, - velocityX: number, - velocityY: number, - ... - } - >; - - /** - * MAGIC - */ - - declare type $If = $Call< - ((true, Then, Else) => Then) & ((false, Then, Else) => Else), - Test, - Then, - Else, - >; - declare type $IsA = $Call< - (Y => true) & (mixed => false), - X, - >; - declare type $IsUndefined = $IsA; - - declare type $Partial = $ReadOnly<$Rest>; - - // If { ...T, ... } counts as a T, then we're inexact - declare type $IsExact = $Call< - (T => false) & (mixed => true), - { ...T, ... }, - >; - - /** - * Actions, state, etc. - */ - - declare export type ScreenParams = { +[key: string]: mixed, ... }; - - declare export type BackAction = {| - +type: 'GO_BACK', - +source?: string, - +target?: string, - |}; - declare export type NavigateAction = {| - +type: 'NAVIGATE', - +payload: - | {| +key: string, +params?: ScreenParams |} - | {| +name: string, +key?: string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type ResetAction = {| - +type: 'RESET', - +payload: StaleNavigationState, - +source?: string, - +target?: string, - |}; - declare export type SetParamsAction = {| - +type: 'SET_PARAMS', - +payload: {| +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type CommonAction = - | BackAction - | NavigateAction - | ResetAction - | SetParamsAction; - - declare type NavigateActionCreator = {| - (routeName: string, params?: ScreenParams): NavigateAction, - ( - | {| +key: string, +params?: ScreenParams |} - | {| +name: string, +key?: string, +params?: ScreenParams |}, - ): NavigateAction, - |}; - declare export type CommonActionsType = {| - +navigate: NavigateActionCreator, - +goBack: () => BackAction, - +reset: (state: PossiblyStaleNavigationState) => ResetAction, - +setParams: (params: ScreenParams) => SetParamsAction, - |}; - - declare export type GenericNavigationAction = {| - +type: string, - +payload?: { +[key: string]: mixed, ... }, - +source?: string, - +target?: string, - |}; - - declare export type LeafRoute = {| - +key: string, - +name: RouteName, - +params?: ScreenParams, - |}; - declare export type StateRoute = {| - ...LeafRoute, - +state: NavigationState | StaleNavigationState, - |}; - declare export type Route = - | LeafRoute - | StateRoute; - - declare export type NavigationState = {| - +key: string, - +index: number, - +routeNames: $ReadOnlyArray, - +history?: $ReadOnlyArray, - +routes: $ReadOnlyArray>, - +type: string, - +stale: false, - |}; - - declare export type StaleLeafRoute = {| - +key?: string, - +name: RouteName, - +params?: ScreenParams, - |}; - declare export type StaleStateRoute = {| - ...StaleLeafRoute, - +state: StaleNavigationState, - |}; - declare export type StaleRoute = - | StaleLeafRoute - | StaleStateRoute; - declare export type StaleNavigationState = {| - // It's possible to pass React Nav a StaleNavigationState with an undefined - // index, but React Nav will always return one with the index set. This is - // the same as for the type property below, but in the case of index we tend - // to rely on it being set more... - +index: number, - +history?: $ReadOnlyArray, - +routes: $ReadOnlyArray>, - +type?: string, - +stale?: true, - |}; - - declare export type PossiblyStaleNavigationState = - | NavigationState - | StaleNavigationState; - declare export type PossiblyStaleRoute = - | Route - | StaleRoute; - - /** - * Routers - */ - - declare type ActionCreators< - State: NavigationState, - Action: GenericNavigationAction, - > = { - +[key: string]: (...args: any) => (Action | State => Action), - ... - }; - - declare export type DefaultRouterOptions = { - +initialRouteName?: string, - ... - }; - - declare export type RouterFactory< - State: NavigationState, - Action: GenericNavigationAction, - RouterOptions: DefaultRouterOptions, - > = (options: RouterOptions) => Router; - - declare export type ParamListBase = { +[key: string]: ?ScreenParams, ... }; - - declare export type RouterConfigOptions = {| - +routeNames: $ReadOnlyArray, - +routeParamList: ParamListBase, - |}; - - declare export type Router< - State: NavigationState, - Action: GenericNavigationAction, - > = {| - +type: $PropertyType, - +getInitialState: (options: RouterConfigOptions) => State, - +getRehydratedState: ( - partialState: PossiblyStaleNavigationState, - options: RouterConfigOptions, - ) => State, - +getStateForRouteNamesChange: ( - state: State, - options: RouterConfigOptions, - ) => State, - +getStateForRouteFocus: (state: State, key: string) => State, - +getStateForAction: ( - state: State, - action: Action, - options: RouterConfigOptions, - ) => ?PossiblyStaleNavigationState; - +shouldActionChangeFocus: (action: GenericNavigationAction) => boolean, - +actionCreators?: ActionCreators, - |}; - - /** - * Stack actions and router - */ - - declare export type StackNavigationState = {| - ...NavigationState, - +type: 'stack', - |}; - - declare export type ReplaceAction = {| - +type: 'REPLACE', - +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type PushAction = {| - +type: 'PUSH', - +payload: {| +name: string, +key?: ?string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type PopAction = {| - +type: 'POP', - +payload: {| +count: number |}, - +source?: string, - +target?: string, - |}; - declare export type PopToTopAction = {| - +type: 'POP_TO_TOP', - +source?: string, - +target?: string, - |}; - declare export type StackAction = - | CommonAction - | ReplaceAction - | PushAction - | PopAction - | PopToTopAction; - - declare export type StackActionsType = {| - +replace: (routeName: string, params?: ScreenParams) => ReplaceAction, - +push: (routeName: string, params?: ScreenParams) => PushAction, - +pop: (count?: number) => PopAction, - +popToTop: () => PopToTopAction, - |}; - - declare export type StackRouterOptions = $Exact; - - /** - * Tab actions and router - */ - - declare export type TabNavigationState = {| - ...NavigationState, - +type: 'tab', - +history: $ReadOnlyArray<{| type: 'route', key: string |}>, - |}; - - declare export type JumpToAction = {| - +type: 'JUMP_TO', - +payload: {| +name: string, +params?: ScreenParams |}, - +source?: string, - +target?: string, - |}; - declare export type TabAction = - | CommonAction - | JumpToAction; - - declare export type TabActionsType = {| - +jumpTo: string => JumpToAction, - |}; - - declare export type TabRouterOptions = {| - ...$Exact, - +backBehavior?: 'initialRoute' | 'order' | 'history' | 'none', - |}; - - /** - * Drawer actions and router - */ - - declare type DrawerHistoryEntry = - | {| +type: 'route', +key: string |} - | {| +type: 'drawer' |}; - declare export type DrawerNavigationState = {| - ...NavigationState, - +type: 'drawer', - +history: $ReadOnlyArray, - |}; - - declare export type OpenDrawerAction = {| - +type: 'OPEN_DRAWER', - +source?: string, - +target?: string, - |}; - declare export type CloseDrawerAction = {| - +type: 'CLOSE_DRAWER', - +source?: string, - +target?: string, - |}; - declare export type ToggleDrawerAction = {| - +type: 'TOGGLE_DRAWER', - +source?: string, - +target?: string, - |}; - declare export type DrawerAction = - | TabAction - | OpenDrawerAction - | CloseDrawerAction - | ToggleDrawerAction; - - declare export type DrawerActionsType = {| - ...TabActionsType, - +openDrawer: () => OpenDrawerAction, - +closeDrawer: () => CloseDrawerAction, - +toggleDrawer: () => ToggleDrawerAction, - |}; - - declare export type DrawerRouterOptions = {| - ...TabRouterOptions, - +defaultStatus?: 'open' | 'closed', - |}; - - /** - * Events - */ - - declare export type EventMapBase = { - +[name: string]: {| - +data?: mixed, - +canPreventDefault?: boolean, - |}, - ... - }; - declare type EventPreventDefaultProperties = $If< - Test, - {| +defaultPrevented: boolean, +preventDefault: () => void |}, - {| |}, - >; - declare type EventDataProperties = $If< - $IsUndefined, - {| |}, - {| +data: Data |}, - >; - declare type EventArg< - EventName: string, - CanPreventDefault: ?boolean = false, - Data = void, - > = {| - ...EventPreventDefaultProperties, - ...EventDataProperties, - +type: EventName, - +target?: string, - |}; - declare type GlobalEventMap = {| - +state: {| +data: {| +state: State |}, +canPreventDefault: false |}, - |}; - declare type EventMapCore = {| - ...GlobalEventMap, - +focus: {| +data: void, +canPreventDefault: false |}, - +blur: {| +data: void, +canPreventDefault: false |}, - +beforeRemove: {| - +data: {| +action: GenericNavigationAction |}, - +canPreventDefault: true, - |}, - |}; - declare type EventListenerCallback< - EventName: string, - State: PossiblyStaleNavigationState = NavigationState, - EventMap: EventMapBase = EventMapCore, - > = (e: EventArg< - EventName, - $PropertyType< - $ElementType< - {| ...EventMap, ...EventMapCore |}, - EventName, - >, - 'canPreventDefault', - >, - $PropertyType< - $ElementType< - {| ...EventMap, ...EventMapCore |}, - EventName, - >, - 'data', - >, - >) => mixed; - - /** - * Navigation prop - */ - - declare type PartialWithMergeProperty = $If< - $IsExact, - { ...$Partial, +merge: true }, - { ...$Partial, +merge: true, ... }, - >; - - declare type EitherExactOrPartialWithMergeProperty = - | ParamsType - | PartialWithMergeProperty; - - declare export type SimpleNavigate = - >( - routeName: DestinationRouteName, - params: EitherExactOrPartialWithMergeProperty< - $ElementType, - >, - ) => void; - - declare export type Navigate = - & SimpleNavigate - & >( - route: $If< - $IsUndefined<$ElementType>, - | {| +key: string |} - | {| +name: DestinationRouteName, +key?: string |}, - | {| - +key: string, - +params?: EitherExactOrPartialWithMergeProperty< - $ElementType, - >, - |} - | {| - +name: DestinationRouteName, - +key?: string, - +params?: EitherExactOrPartialWithMergeProperty< - $ElementType, - >, - |}, - >, - ) => void; - - declare type CoreNavigationHelpers< - ParamList: ParamListBase, - State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, - EventMap: EventMapBase = EventMapCore, - > = { - +navigate: Navigate, - +dispatch: ( - action: - | GenericNavigationAction - | (State => GenericNavigationAction), - ) => void, - +reset: PossiblyStaleNavigationState => void, - +goBack: () => void, - +isFocused: () => boolean, - +canGoBack: () => boolean, - +getId: () => string | void, - +getParent: >(id?: string) => ?Parent, - +getState: () => NavigationState, - +addListener: |}, - >>( - name: EventName, - callback: EventListenerCallback, - ) => () => void, - +removeListener: |}, - >>( - name: EventName, - callback: EventListenerCallback, - ) => void, - ... - }; - - declare export type NavigationHelpers< - ParamList: ParamListBase, - State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, - EventMap: EventMapBase = EventMapCore, - > = { - ...$Exact>, - +setParams: (params: ScreenParams) => void, - ... - }; - - declare type SetParamsInput< - ParamList: ParamListBase, - RouteName: $Keys = $Keys, - > = $If< - $IsUndefined<$ElementType>, - empty, - $Partial<$NonMaybeType<$ElementType>>, - >; - - declare export type NavigationProp< - ParamList: ParamListBase, - RouteName: $Keys = $Keys, - State: PossiblyStaleNavigationState = PossiblyStaleNavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = { - ...$Exact>, - +setOptions: (options: $Partial) => void, - +setParams: (params: SetParamsInput) => void, - ... - }; - - /** - * CreateNavigator - */ - - declare export type RouteProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - > = {| - ...LeafRoute, - +params: $ElementType, - +path?: string, - |}; - - declare type ScreenOptionsProp< - ScreenOptions: {...}, - RouteParam, - NavHelpers, - > = - | ScreenOptions - | ({| +route: RouteParam, +navigation: NavHelpers |}) => ScreenOptions; - declare export type ScreenListeners< - State: NavigationState = NavigationState, - EventMap: EventMapBase = EventMapCore, - > = $ObjMapi< - {| [name: $Keys]: empty |}, - >(K, empty) => EventListenerCallback, - >; - declare type ScreenListenersProp< - ScreenListenersParam: {...}, - RouteParam, - NavHelpers, - > = - | ScreenListenersParam - | ({| +route: RouteParam, +navigation: NavHelpers |}) => ScreenListenersParam; - - declare type BaseScreenProps< - ParamList: ParamListBase, - NavProp, - RouteName: $Keys = $Keys, - State: NavigationState = NavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = {| - +name: RouteName, - +options?: ScreenOptionsProp< - ScreenOptions, - RouteProp, - NavProp, - >, - +listeners?: ScreenListenersProp< - ScreenListeners, - RouteProp, - NavProp, - >, - +initialParams?: $Partial<$ElementType>, - +getId?: ({ - +params: $ElementType, - }) => string | void, - +navigationKey?: string, - |}; - - declare export type ScreenProps< - ParamList: ParamListBase, - NavProp, - RouteName: $Keys = $Keys, - State: NavigationState = NavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = - | {| - ...BaseScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >, - +component: React$ComponentType<{| - +route: RouteProp, - +navigation: NavProp, - |}>, - |} - | {| - ...BaseScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >, - +getComponent: () => React$ComponentType<{| - +route: RouteProp, - +navigation: NavProp, - |}>, - |} - | {| - ...BaseScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >, - +children: ({| - +route: RouteProp, - +navigation: NavProp, - |}) => React$Node, - |}; - - declare export type ScreenComponent< - GlobalParamList: ParamListBase, - ParamList: ParamListBase, - State: NavigationState = NavigationState, - ScreenOptions: {...} = {...}, - EventMap: EventMapBase = EventMapCore, - > = < - RouteName: $Keys, - NavProp: NavigationProp< - GlobalParamList, - RouteName, - State, - ScreenOptions, - EventMap, - >, - >(props: ScreenProps< - ParamList, - NavProp, - RouteName, - State, - ScreenOptions, - EventMap, - >) => React$Node; - - declare type ScreenOptionsProps< - ScreenOptions: {...}, - RouteParam, - NavHelpers, - > = {| - +screenOptions?: ScreenOptionsProp, - |}; - declare type ScreenListenersProps< - ScreenListenersParam: {...}, - RouteParam, - NavHelpers, - > = {| - +screenListeners?: ScreenListenersProp< - ScreenListenersParam, - RouteParam, - NavHelpers, - >, - |}; - declare export type ExtraNavigatorPropsBase = { - ...$Exact, - +id?: string, - +children?: React$Node, - ... - }; - declare export type NavigatorProps< - ScreenOptions: {...}, - ScreenListenersParam, - RouteParam, - NavHelpers, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - > = { - ...$Exact, - ...ScreenOptionsProps, - ...ScreenListenersProps, - +defaultScreenOptions?: - | ScreenOptions - | ({| - +route: RouteParam, - +navigation: NavHelpers, - +options: ScreenOptions, - |}) => ScreenOptions, - ... - }; - declare export type NavigatorPropsBase< - ScreenOptions: {...}, - ScreenListenersParam: {...}, - NavHelpers, - > = NavigatorProps< - ScreenOptions, - ScreenListenersParam, - RouteProp<>, - NavHelpers, - ExtraNavigatorPropsBase, - >; - - declare export type CreateNavigator< - State: NavigationState, - ScreenOptions: {...}, - EventMap: EventMapBase, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - > = < - GlobalParamList: ParamListBase, - ParamList: ParamListBase, - NavHelpers: NavigationHelpers< - GlobalParamList, - State, - EventMap, - >, - >() => {| - +Screen: ScreenComponent< - GlobalParamList, - ParamList, - State, - ScreenOptions, - EventMap, - >, - +Navigator: React$ComponentType<$Exact, - RouteProp, - NavHelpers, - ExtraNavigatorProps, - >>>, - +Group: React$ComponentType<{| - ...ScreenOptionsProps, NavHelpers>, - +children: React$Node, - +navigationKey?: string, - |}>, - |}; - - declare export type CreateNavigatorFactory = < - State: NavigationState, - ScreenOptions: {...}, - EventMap: EventMapBase, - NavHelpers: NavigationHelpers< - ParamListBase, - State, - EventMap, - >, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - >( - navigator: React$ComponentType<$Exact, - RouteProp<>, - NavHelpers, - ExtraNavigatorProps, - >>>, - ) => CreateNavigator; - - - /** - * useNavigationBuilder - */ - - declare export type Descriptor< - NavHelpers, - ScreenOptions: {...} = {...}, - > = {| - +render: () => React$Node, - +options: $ReadOnly, - +navigation: NavHelpers, - |}; - - declare export type UseNavigationBuilder = < - State: NavigationState, - Action: GenericNavigationAction, - ScreenOptions: {...}, - RouterOptions: DefaultRouterOptions, - NavHelpers, - EventMap: EventMapBase, - ExtraNavigatorProps: ExtraNavigatorPropsBase, - >( - routerFactory: RouterFactory, - options: $Exact, - RouteProp<>, - NavHelpers, - ExtraNavigatorProps, - >>, - ) => {| - +id?: string, - +state: State, - +descriptors: {| +[key: string]: Descriptor |}, - +navigation: NavHelpers, - |}; - - /** - * EdgeInsets - */ - - declare type EdgeInsets = {| - +top: number, - +right: number, - +bottom: number, - +left: number, - |}; - - /** - * TransitionPreset - */ - - declare export type TransitionSpec = - | {| - animation: 'spring', - config: $Diff< - SpringAnimationConfigSingle, - { toValue: number | AnimatedValue, ... }, - >, - |} - | {| - animation: 'timing', - config: $Diff< - TimingAnimationConfigSingle, - { toValue: number | AnimatedValue, ... }, - >, - |}; - - declare export type StackCardInterpolationProps = {| - +current: {| - +progress: AnimatedInterpolation, - |}, - +next?: {| - +progress: AnimatedInterpolation, - |}, - +index: number, - +closing: AnimatedInterpolation, - +swiping: AnimatedInterpolation, - +inverted: AnimatedInterpolation, - +layouts: {| - +screen: {| +width: number, +height: number |}, - |}, - +insets: EdgeInsets, - |}; - declare export type StackCardInterpolatedStyle = {| - containerStyle?: AnimatedViewStyleProp, - cardStyle?: AnimatedViewStyleProp, - overlayStyle?: AnimatedViewStyleProp, - shadowStyle?: AnimatedViewStyleProp, - |}; - declare export type StackCardStyleInterpolator = ( - props: StackCardInterpolationProps, - ) => StackCardInterpolatedStyle; - - declare export type StackHeaderInterpolationProps = {| - +current: {| - +progress: AnimatedInterpolation, - |}, - +next?: {| - +progress: AnimatedInterpolation, - |}, - +layouts: {| - +header: {| +width: number, +height: number |}, - +screen: {| +width: number, +height: number |}, - +title?: {| +width: number, +height: number |}, - +leftLabel?: {| +width: number, +height: number |}, - |}, - |}; - declare export type StackHeaderInterpolatedStyle = {| - leftLabelStyle?: AnimatedViewStyleProp, - leftButtonStyle?: AnimatedViewStyleProp, - rightButtonStyle?: AnimatedViewStyleProp, - titleStyle?: AnimatedViewStyleProp, - backgroundStyle?: AnimatedViewStyleProp, - |}; - declare export type StackHeaderStyleInterpolator = ( - props: StackHeaderInterpolationProps, - ) => StackHeaderInterpolatedStyle; - - declare type GestureDirection = - | 'horizontal' - | 'horizontal-inverted' - | 'vertical' - | 'vertical-inverted'; - - declare export type TransitionPreset = {| - +gestureDirection: GestureDirection, - +transitionSpec: {| - +open: TransitionSpec, - +close: TransitionSpec, - |}, - +cardStyleInterpolator: StackCardStyleInterpolator, - +headerStyleInterpolator: StackHeaderStyleInterpolator, - |}; - - /** - * Header common options - */ - - declare export type SceneProgress = {| - +current: AnimatedInterpolation, - +next?: AnimatedInterpolation, - +previous?: AnimatedInterpolation, - |}; - - declare export type HeaderProps = {| - +navigation: NavProp, - +route: RouteProp<>, - +options: ScreenOptions, - +layout: {| +width: number, +height: number |}, - |}; - - declare export type HeaderButtonProps = $Partial<{| - +tintColor: string, - +pressColor: string, - +pressOpacity: number, - |}>; - - declare export type HeaderLeftButtonProps = $Partial<{| - ...HeaderButtonProps, - +labelVisible: boolean, - |}>; - - declare type HeaderTitleInputBase = { - +onLayout: LayoutEvent => void, - +children: string, - +allowFontScaling: ?boolean, - +tintColor: ?string, - +style: ?AnimatedTextStyleProp, - ... - }; - - declare export type HeaderTitleInputProps = - $Exact; - - declare export type HeaderCommonOptions< - NavHeaderProps, - NavHeaderLeftProps, - NavHeaderRightProps, - > = $Partial<{| - +header: NavHeaderProps => React$Node, - +headerShown: boolean, - +headerTitle: string | ( HeaderTitleInputProps => React$Node), - +headerTitleAlign: 'left' | 'center', - +headerTitleStyle: AnimatedTextStyleProp, - +headerTitleContainerStyle: AnimatedViewStyleProp, - +headerTintColor: string, - +headerTitleAllowFontScaling: boolean, - +headerLeft: NavHeaderLeftProps => React$Node, - +headerLeftContainerStyle: AnimatedViewStyleProp, - +headerRight: NavHeaderRightProps => React$Node, - +headerRightContainerStyle: AnimatedViewStyleProp, - +headerBackground: ({| style: AnimatedViewStyleProp |}) => React$Node, - +headerStyle: AnimatedViewStyleProp, - +headerTransparent: boolean, - +headerStatusBarHeight: number, - +headerShadowVisible: boolean, - +headerBackgroundContainerStyle: AnimatedViewStyleProp, - +headerPressColor: string, - +headerPressOpacity: number, - |}>; - - /** - * Stack options - */ - - declare export type StackDescriptor = Descriptor< - StackNavigationHelpers<>, - StackOptions, - >; - - declare type Scene = {| - +route: T, - +descriptor: StackDescriptor, - +progress: SceneProgress, - |}; - - declare export type StackHeaderProps = {| - ...HeaderProps, StackOptions>, - +progress: SceneProgress, - +back?: {| +title: string |}, - +styleInterpolator: StackHeaderStyleInterpolator, - |}; - - declare export type StackHeaderButtonProps = $Partial<{| - ...HeaderButtonProps, - +canGoBack: boolean, - |}>; - - declare export type StackHeaderLeftButtonProps = $Partial<{| - ...StackHeaderButtonProps, - +onPress: (() => void), - +backImage: (props: {| tintColor: string |}) => React$Node, - +label: string, - +truncatedLabel: string, - +labelVisible: boolean, - +labelStyle: AnimatedTextStyleProp, - +allowFontScaling: boolean, - +onLabelLayout: LayoutEvent => void, - +screenLayout: {| +width: number, +height: number |}, - +titleLayout: {| +width: number, +height: number |}, - +disabled: boolean, - +accessibilityLabel: string, - +style: ViewStyleProp, - |}>; - - declare export type StackOptions = $Partial<{| - +title: string, - +cardShadowEnabled: boolean, - +cardOverlayEnabled: boolean, - +cardOverlay: {| style: ViewStyleProp |} => React$Node, - +cardStyle: ViewStyleProp, - +animationEnabled: boolean, - +animationTypeForReplace: 'push' | 'pop', - +gestureEnabled: boolean, - +gestureResponseDistance: number, - +gestureVelocityImpact: number, - +safeAreaInsets: $Partial, - +keyboardHandlingEnabled: boolean, - +presentation: 'card' | 'modal' | 'transparentModal', - // Transition - ...TransitionPreset, - // Header - ...HeaderCommonOptions< - StackHeaderProps, - StackHeaderLeftButtonProps, - StackHeaderButtonProps, - >, - +headerMode: 'float' | 'screen', - +headerBackAllowFontScaling: boolean, - +headerBackTitle: string | null, - +headerBackTitleStyle: TextStyleProp, - +headerBackTitleVisible: boolean, - +headerTruncatedBackTitle: string, - +headerBackImage: $PropertyType, - +headerBackAccessibilityLabel: string, - |}>; - - /** - * Stack navigation prop - */ - - declare export type StackNavigationEventMap = {| - ...EventMapCore, - +transitionStart: {| - +data: {| +closing: boolean |}, - +canPreventDefault: false, - |}, - +transitionEnd: {| - +data: {| +closing: boolean |}, - +canPreventDefault: false, - |}, - +gestureStart: {| +data: void, +canPreventDefault: false |}, - +gestureEnd: {| +data: void, +canPreventDefault: false |}, - +gestureCancel: {| +data: void, +canPreventDefault: false |}, - |}; - - declare type StackExtraNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - > = {| - +replace: SimpleNavigate, - +push: SimpleNavigate, - +pop: (count?: number) => void, - +popToTop: () => void, - |}; - - declare export type StackNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = StackNavigationEventMap, - > = { - ...$Exact>, - ...StackExtraNavigationHelpers, - ... - }; - - declare export type StackNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = StackOptions, - EventMap: EventMapBase = StackNavigationEventMap, - > = {| - ...$Exact>, - ...StackExtraNavigationHelpers, - |}; - - /** - * Miscellaneous stack exports - */ - - declare type StackNavigationConfig = {| - +detachInactiveScreens?: boolean, - |}; - - declare export type ExtraStackNavigatorProps = {| - ...$Exact, - ...StackRouterOptions, - ...StackNavigationConfig, - |}; - - declare export type StackNavigatorProps< - NavHelpers: StackNavigationHelpers<> = StackNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, + StackNavigationEventMap, ExtraStackNavigatorProps, - >>; - - /** - * Bottom tab options - */ - - declare export type BottomTabBarButtonProps = {| - ...$Diff< - TouchableWithoutFeedbackProps, - {| onPress?: ?(event: PressEvent) => mixed |}, - >, - +to?: string, - +children: React$Node, - +onPress?: (MouseEvent | PressEvent) => void, - |}; - - declare export type TabBarVisibilityAnimationConfig = - | {| - +animation: 'spring', - +config?: $Diff< - SpringAnimationConfigSingle, - { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, - >, - |} - | {| - +animation: 'timing', - +config?: $Diff< - TimingAnimationConfigSingle, - { toValue: number | AnimatedValue, useNativeDriver: boolean, ... }, - >, - |}; - - declare export type BottomTabOptions = $Partial<{| - +title: string, - +tabBarLabel: - | string - | ({| focused: boolean, color: string |}) => React$Node, - +tabBarIcon: ({| - focused: boolean, - color: string, - size: number, - |}) => React$Node, - +tabBarBadge: number | string, - +tabBarBadgeStyle: TextStyleProp, - +tabBarAccessibilityLabel: string, - +tabBarTestID: string, - +tabBarVisibilityAnimationConfig: $Partial<{| - +show: TabBarVisibilityAnimationConfig, - +hide: TabBarVisibilityAnimationConfig, - |}>, - +tabBarButton: BottomTabBarButtonProps => React$Node, - +tabBarHideOnKeyboard: boolean, - +tabBarActiveTintColor: string, - +tabBarInactiveTintColor: string, - +tabBarActiveBackgroundColor: string, - +tabBarInactiveBackgroundColor: string, - +tabBarAllowFontScaling: boolean, - +tabBarShowLabel: boolean, - +tabBarLabelStyle: TextStyleProp, - +tabBarIconStyle: TextStyleProp, - +tabBarItemStyle: ViewStyleProp, - +tabBarLabelPosition: 'beside-icon' | 'below-icon', - +tabBarStyle: ViewStyleProp, - +unmountOnBlur: boolean, - +lazy: boolean, - ...HeaderCommonOptions< - HeaderProps, BottomTabOptions>, - HeaderLeftButtonProps, - HeaderButtonProps, - >, - |}>; - - /** - * Bottom tab navigation prop - */ - - declare export type BottomTabNavigationEventMap = {| - ...EventMapCore, - +tabPress: {| +data: void, +canPreventDefault: true |}, - +tabLongPress: {| +data: void, +canPreventDefault: false |}, - |}; - - declare type TabExtraNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - > = {| - +jumpTo: SimpleNavigate, - |}; - - declare export type BottomTabNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = BottomTabNavigationEventMap, - > = { - ...$Exact>, - ...TabExtraNavigationHelpers, - ... - }; - - declare export type BottomTabNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = BottomTabOptions, - EventMap: EventMapBase = BottomTabNavigationEventMap, - > = {| - ...$Exact>, - ...TabExtraNavigationHelpers, - |}; - - /** - * Miscellaneous bottom tab exports - */ - - declare export type BottomTabDescriptor = Descriptor< - BottomTabNavigationHelpers<>, - BottomTabOptions, - >; - - declare type BottomTabNavigationBuilderResult = {| - +state: TabNavigationState, - +navigation: BottomTabNavigationHelpers<>, - +descriptors: {| +[key: string]: BottomTabDescriptor |}, - |}; - - declare export type BottomTabBarProps = BottomTabNavigationBuilderResult; - - declare type BottomTabNavigationConfig = {| - +tabBar?: BottomTabBarProps => React$Node, - +safeAreaInsets?: $Partial, - +detachInactiveScreens?: boolean, - |}; - - declare export type ExtraBottomTabNavigatorProps = {| - ...$Exact, - ...TabRouterOptions, - ...BottomTabNavigationConfig, - |}; - - declare export type BottomTabNavigatorProps< - NavHelpers: BottomTabNavigationHelpers<> = BottomTabNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraBottomTabNavigatorProps, - >>; - - /** - * Material bottom tab options - */ - - declare export type MaterialBottomTabOptions = $Partial<{| - +title: string, - +tabBarColor: string, - +tabBarLabel: string, - +tabBarIcon: - | string - | ({| +focused: boolean, +color: string |}) => React$Node, - +tabBarBadge: boolean | number | string, - +tabBarAccessibilityLabel: string, - +tabBarTestID: string, - |}>; - - /** - * Material bottom tab navigation prop - */ - - declare export type MaterialBottomTabNavigationEventMap = {| - ...EventMapCore, - +tabPress: {| +data: void, +canPreventDefault: true |}, - |}; - - declare export type MaterialBottomTabNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, - > = { - ...$Exact>, - ...TabExtraNavigationHelpers, - ... - }; - - declare export type MaterialBottomTabNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = MaterialBottomTabOptions, - EventMap: EventMapBase = MaterialBottomTabNavigationEventMap, - > = {| - ...$Exact>, - ...TabExtraNavigationHelpers, - |}; - - /** - * Miscellaneous material bottom tab exports - */ - - declare export type PaperFont = {| - +fontFamily: string, - +fontWeight?: - | 'normal' - | 'bold' - | '100' - | '200' - | '300' - | '400' - | '500' - | '600' - | '700' - | '800' - | '900', - |}; - - declare export type PaperFonts = {| - +regular: PaperFont, - +medium: PaperFont, - +light: PaperFont, - +thin: PaperFont, - |}; - - declare export type PaperTheme = {| - +dark: boolean, - +mode?: 'adaptive' | 'exact', - +roundness: number, - +colors: {| - +primary: string, - +background: string, - +surface: string, - +accent: string, - +error: string, - +text: string, - +onSurface: string, - +onBackground: string, - +disabled: string, - +placeholder: string, - +backdrop: string, - +notification: string, - |}, - +fonts: PaperFonts, - +animation: {| - +scale: number, - |}, - |}; - - declare export type PaperRoute = {| - +key: string, - +title?: string, - +icon?: any, - +badge?: string | number | boolean, - +color?: string, - +accessibilityLabel?: string, - +testID?: string, - |}; - - declare export type PaperTouchableProps = {| - ...TouchableWithoutFeedbackProps, - +key: string, - +route: PaperRoute, - +children: React$Node, - +borderless?: boolean, - +centered?: boolean, - +rippleColor?: string, - |}; - - declare export type MaterialBottomTabNavigationConfig = {| - +shifting?: boolean, - +labeled?: boolean, - +renderTouchable?: PaperTouchableProps => React$Node, - +activeColor?: string, - +inactiveColor?: string, - +sceneAnimationEnabled?: boolean, - +keyboardHidesNavigationBar?: boolean, - +barStyle?: ViewStyleProp, - +style?: ViewStyleProp, - +theme?: PaperTheme, - |}; - - declare export type ExtraMaterialBottomTabNavigatorProps = {| - ...$Exact, - ...TabRouterOptions, - ...MaterialBottomTabNavigationConfig, - |}; - - declare export type MaterialBottomTabNavigatorProps< - NavHelpers: MaterialBottomTabNavigationHelpers<> = - MaterialBottomTabNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraMaterialBottomTabNavigatorProps, - >>; - - /** - * Material top tab options - */ - - declare export type MaterialTopTabOptions = $Partial<{| - +title: string, - +tabBarLabel: - | string - | ({| +focused: boolean, +color: string |}) => React$Node, - +tabBarIcon: ({| +focused: boolean, +color: string |}) => React$Node, - +tabBarAccessibilityLabel: string, - +tabBarTestID: string, - +tabBarActiveTintColor: string, - +tabBarInactiveTintColor: string, - +tabBarPressColor: string, - +tabBarPressOpacity: number, - +tabBarShowLabel: boolean, - +tabBarShowIcon: boolean, - +tabBarAllowFontScaling: boolean, - +tabBarBounces: boolean, - +tabBarScrollEnabled: boolean, - +tabBarIconStyle: ViewStyleProp, - +tabBarLabelStyle: TextStyleProp, - +tabBarItemStyle: ViewStyleProp, - +tabBarIndicatorStyle: ViewStyleProp, - +tabBarIndicatorContainerStyle: ViewStyleProp, - +tabBarContentContainerStyle: ViewStyleProp, - +tabBarStyle: ViewStyleProp, - +tabBarBadge: () => React$Node, - +tabBarIndicator: MaterialTopTabBarIndicatorProps => React$Node, - +lazy: boolean, - +lazyPlaceholder: ({| +route: Route<> |}) => React$Node, - |}>; - - /** - * Material top tab navigation prop - */ - - declare export type MaterialTopTabNavigationEventMap = {| - ...EventMapCore, - +tabPress: {| +data: void, +canPreventDefault: true |}, - +tabLongPress: {| +data: void, +canPreventDefault: false |}, - +swipeStart: {| +data: void, +canPreventDefault: false |}, - +swipeEnd: {| +data: void, +canPreventDefault: false |}, - |}; - - declare export type MaterialTopTabNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = MaterialTopTabNavigationEventMap, - > = { - ...$Exact>, - ...TabExtraNavigationHelpers, - ... - }; - - declare export type MaterialTopTabNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = MaterialTopTabOptions, - EventMap: EventMapBase = MaterialTopTabNavigationEventMap, - > = {| - ...$Exact>, - ...TabExtraNavigationHelpers, - |}; - - /** - * Miscellaneous material top tab exports - */ - - declare type MaterialTopTabPagerCommonProps = {| - +keyboardDismissMode: 'none' | 'on-drag' | 'auto', - +swipeEnabled: boolean, - +swipeVelocityImpact?: number, - +springVelocityScale?: number, - +springConfig: $Partial<{| - +damping: number, - +mass: number, - +stiffness: number, - +restSpeedThreshold: number, - +restDisplacementThreshold: number, - |}>, - +timingConfig: $Partial<{| - +duration: number, - |}>, - |}; - - declare export type MaterialTopTabPagerProps = {| - ...MaterialTopTabPagerCommonProps, - +onSwipeStart?: () => void, - +onSwipeEnd?: () => void, - +onIndexChange: (index: number) => void, - +navigationState: TabNavigationState, - +layout: {| +width: number, +height: number |}, - +removeClippedSubviews: boolean, - +children: ({| - +addListener: (type: 'enter', listener: number => void) => void, - +removeListener: (type: 'enter', listener: number => void) => void, - +position: any, // Reanimated.Node - +render: React$Node => React$Node, - +jumpTo: string => void, - |}) => React$Node, - +gestureHandlerProps: PanGestureHandlerProps, - |}; - - declare export type MaterialTopTabBarIndicatorProps = {| - +state: TabNavigationState, - +width: string, - +style?: ViewStyleProp, - +getTabWidth: number => number, - |}; - - declare export type MaterialTopTabDescriptor = Descriptor< - MaterialBottomTabNavigationHelpers<>, - MaterialBottomTabOptions, - >; - - declare type MaterialTopTabNavigationBuilderResult = {| - +state: TabNavigationState, - +navigation: MaterialTopTabNavigationHelpers<>, - +descriptors: {| +[key: string]: MaterialTopTabDescriptor |}, - |}; - - declare export type MaterialTopTabBarProps = {| - ...MaterialTopTabNavigationBuilderResult, - +layout: {| +width: number, +height: number |}, - +position: any, // Reanimated.Node - +jumpTo: string => void, - |}; - - declare export type MaterialTopTabNavigationConfig = {| - ...$Partial, - +position?: any, // Reanimated.Value - +tabBarPosition?: 'top' | 'bottom', - +initialLayout?: $Partial<{| +width: number, +height: number |}>, - +lazyPreloadDistance?: number, - +removeClippedSubviews?: boolean, - +sceneContainerStyle?: ViewStyleProp, - +style?: ViewStyleProp, - +gestureHandlerProps?: PanGestureHandlerProps, - +pager?: MaterialTopTabPagerProps => React$Node, - +tabBar?: MaterialTopTabBarProps => React$Node, - |}; - - declare export type ExtraMaterialTopTabNavigatorProps = {| - ...$Exact, - ...TabRouterOptions, - ...MaterialTopTabNavigationConfig, - |}; - - declare export type MaterialTopTabNavigatorProps< - NavHelpers: MaterialTopTabNavigationHelpers<> = - MaterialTopTabNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraMaterialTopTabNavigatorProps, - >>; - - /** - * Drawer options - */ - - declare export type DrawerOptions = $Partial<{| - +title: string, - +lazy: boolean, - +drawerLabel: - | string - | ({| +color: string, +focused: boolean |}) => React$Node, - +drawerIcon: ({| - +color: string, - +size: number, - +focused: boolean, - |}) => React$Node, - +drawerActiveTintColor: string, - +drawerActiveBackgroundColor: string, - +drawerInactiveTintColor: string, - +drawerInactiveBackgroundColor: string, - +drawerItemStyle: ViewStyleProp, - +drawerLabelStyle: TextStyleProp, - +drawerContentContainerStyle: ViewStyleProp, - +drawerContentStyle: ViewStyleProp, - +drawerStyle: ViewStyleProp, - +drawerPosition: 'left' | 'right', - +drawerType: 'front' | 'back' | 'slide' | 'permanent', - +drawerHideStatusBarOnOpen: boolean, - +drawerStatusBarAnimation: 'slide' | 'none' | 'fade', - +overlayColor: string, - +sceneContainerStyle: ViewStyleProp, - +gestureHandlerProps: PanGestureHandlerProps, - +swipeEnabled: boolean, - +swipeEdgeWidth: number, - +swipeMinDistance: number, - +keyboardDismissMode: 'on-drag' | 'none', - +unmountOnBlur: boolean, - ...HeaderCommonOptions< - HeaderProps, DrawerOptions>, - HeaderLeftButtonProps, - HeaderButtonProps, - >, - |}>; - - /** - * Drawer navigation prop - */ - - declare export type DrawerNavigationEventMap = - EventMapCore; - - declare type DrawerExtraNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - > = {| - +jumpTo: SimpleNavigate, - +openDrawer: () => void, - +closeDrawer: () => void, - +toggleDrawer: () => void, - |}; - - declare export type DrawerNavigationHelpers< - ParamList: ParamListBase = ParamListBase, - EventMap: EventMapBase = DrawerNavigationEventMap, - > = { - ...$Exact>, - ...DrawerExtraNavigationHelpers, - ... - }; - - declare export type DrawerNavigationProp< - ParamList: ParamListBase = ParamListBase, - RouteName: $Keys = $Keys, - Options: {...} = DrawerOptions, - EventMap: EventMapBase = DrawerNavigationEventMap, - > = {| - ...$Exact>, - ...DrawerExtraNavigationHelpers, - |}; - - /** - * Miscellaneous drawer exports - */ - - declare export type DrawerDescriptor = Descriptor< - DrawerNavigationHelpers<>, - DrawerOptions, - >; - - declare type DrawerNavigationBuilderResult = {| - +state: DrawerNavigationState, - +navigation: DrawerNavigationHelpers<>, - +descriptors: {| +[key: string]: DrawerDescriptor |}, - |}; - - declare export type DrawerNavigationConfig = {| - +drawerContent?: DrawerNavigationBuilderResult => React$Node, - +detachInactiveScreens?: boolean, - +useLegacyImplementation?: boolean, - |}; - - declare export type ExtraDrawerNavigatorProps = {| - ...$Exact, - ...DrawerRouterOptions, - ...DrawerNavigationConfig, - |}; - - declare export type DrawerNavigatorProps< - NavHelpers: DrawerNavigationHelpers<> = DrawerNavigationHelpers<>, - > = $Exact, - RouteProp<>, - NavHelpers, - ExtraDrawerNavigatorProps, - >>; - - /** - * BaseNavigationContainer - */ - - declare export type BaseNavigationContainerProps = {| - +children: React$Node, - +initialState?: PossiblyStaleNavigationState, - +onStateChange?: (state: ?PossiblyStaleNavigationState) => void, - +independent?: boolean, - |}; - - declare export type ContainerEventMap = {| - ...GlobalEventMap, - +options: {| - +data: {| +options: { +[key: string]: mixed, ... } |}, - +canPreventDefault: false, - |}, - +__unsafe_action__: {| - +data: {| - +action: GenericNavigationAction, - +noop: boolean, - |}, - +canPreventDefault: false, - |}, - |}; - - declare export type BaseNavigationContainerInterface = {| - ...$Exact>, - +resetRoot: (state?: PossiblyStaleNavigationState) => void, - +getRootState: () => NavigationState, - +getCurrentRoute: () => RouteProp<> | void, - +getCurrentOptions: () => Object | void, - +isReady: () => boolean, - |}; - - declare type BaseNavigationContainerInterfaceRef = {| - ...BaseNavigationContainerInterface, - +current: BaseNavigationContainerInterface | null, - |}; - - /** - * State utils - */ - - declare export type GetStateFromPath = ( - path: string, - options?: LinkingConfig, - ) => PossiblyStaleNavigationState; - - declare export type GetPathFromState = ( - state?: ?PossiblyStaleNavigationState, - options?: LinkingConfig, - ) => string; - - declare export type GetFocusedRouteNameFromRoute = - PossiblyStaleRoute => ?string; - - /** - * Linking - */ - - declare export type ScreenLinkingConfig = {| - +path?: string, - +exact?: boolean, - +parse?: {| +[param: string]: string => mixed |}, - +stringify?: {| +[param: string]: mixed => string |}, - +screens?: ScreenLinkingConfigMap, - +initialRouteName?: string, - |}; - - declare export type ScreenLinkingConfigMap = {| - +[routeName: string]: string | ScreenLinkingConfig, - |}; - - declare export type LinkingConfig = {| - +initialRouteName?: string, - +screens: ScreenLinkingConfigMap, - |}; - - declare export type LinkingOptions = {| - +enabled?: boolean, - +prefixes: $ReadOnlyArray, - +config?: LinkingConfig, - +getStateFromPath?: GetStateFromPath, - +getPathFromState?: GetPathFromState, - |}; - - /** - * NavigationContainer - */ - - declare export type Theme = {| - +dark: boolean, - +colors: {| - +primary: string, - +background: string, - +card: string, - +text: string, - +border: string, - |}, - |}; - - declare export type NavigationContainerType = React$AbstractComponent< - {| - ...BaseNavigationContainerProps, - +theme?: Theme, - +linking?: LinkingOptions, - +fallback?: React$Node, - +onReady?: () => mixed, - |}, - BaseNavigationContainerInterface, - >; - - //--------------------------------------------------------------------------- - // SECTION 2: EXPORTED MODULE - // This section defines the module exports and contains exported types that - // are not present in any other React Navigation libdef. - //--------------------------------------------------------------------------- + StackHeaderProps, + StackCardStyleInterpolator, + StackHeaderStyleInterpolator, + TransitionSpec, + TransitionPreset, + StackCardInterpolationProps, + PanGestureHandlerProps, + } from '@react-navigation/core'; /** * StackView @@ -2337,7 +97,7 @@ declare export var CardAnimationContext: React$Context< ?StackCardInterpolationProps, >; - declare export function useCardAnimation(): StackCardInterpolationProps + declare export function useCardAnimation(): StackCardInterpolationProps; /** * GestureHandler accessors diff --git a/native/invite-links/invite-links-navigator.react.js b/native/invite-links/invite-links-navigator.react.js --- a/native/invite-links/invite-links-navigator.react.js +++ b/native/invite-links/invite-links-navigator.react.js @@ -1,10 +1,10 @@ // @flow -import { - createStackNavigator, - type StackNavigationHelpers, - type StackNavigationProp, -} from '@react-navigation/stack'; +import type { + StackNavigationHelpers, + StackNavigationProp, +} from '@react-navigation/core'; +import { createStackNavigator } from '@react-navigation/stack'; import * as React from 'react'; import { SafeAreaView } from 'react-native-safe-area-context'; diff --git a/native/navigation/community-drawer-navigator.react.js b/native/navigation/community-drawer-navigator.react.js --- a/native/navigation/community-drawer-navigator.react.js +++ b/native/navigation/community-drawer-navigator.react.js @@ -1,10 +1,10 @@ // @flow -import { - createDrawerNavigator, - type DrawerNavigationHelpers, - type DrawerNavigationProp, -} from '@react-navigation/drawer'; +import type { + DrawerNavigationHelpers, + DrawerNavigationProp, +} from '@react-navigation/core'; +import { createDrawerNavigator } from '@react-navigation/drawer'; import * as React from 'react'; import { View, useWindowDimensions } from 'react-native'; diff --git a/native/navigation/default-state.js b/native/navigation/default-state.js --- a/native/navigation/default-state.js +++ b/native/navigation/default-state.js @@ -1,6 +1,6 @@ // @flow -import type { StaleNavigationState } from '@react-navigation/native'; +import type { StaleNavigationState } from '@react-navigation/core'; import type { BaseNavInfo } from 'lib/types/nav-types.js'; import { fifteenDaysEarlier, fifteenDaysLater } from 'lib/utils/date-utils.js'; diff --git a/native/navigation/header.react.js b/native/navigation/header.react.js --- a/native/navigation/header.react.js +++ b/native/navigation/header.react.js @@ -1,6 +1,7 @@ // @flow -import { Header, type StackHeaderProps } from '@react-navigation/stack'; +import type { StackHeaderProps } from '@react-navigation/core'; +import { Header } from '@react-navigation/stack'; import * as React from 'react'; import DisconnectedBar from './disconnected-bar.react.js'; diff --git a/native/navigation/modal-pruner.react.js b/native/navigation/modal-pruner.react.js --- a/native/navigation/modal-pruner.react.js +++ b/native/navigation/modal-pruner.react.js @@ -3,7 +3,7 @@ import type { PossiblyStaleNavigationState, PossiblyStaleRoute, -} from '@react-navigation/native'; +} from '@react-navigation/core'; import invariant from 'invariant'; import * as React from 'react'; diff --git a/native/navigation/nav-selectors.js b/native/navigation/nav-selectors.js --- a/native/navigation/nav-selectors.js +++ b/native/navigation/nav-selectors.js @@ -1,6 +1,6 @@ // @flow -import type { PossiblyStaleNavigationState } from '@react-navigation/native'; +import type { PossiblyStaleNavigationState } from '@react-navigation/core'; import { useRoute } from '@react-navigation/native'; import _memoize from 'lodash/memoize.js'; import * as React from 'react'; diff --git a/native/navigation/navigation-context.js b/native/navigation/navigation-context.js --- a/native/navigation/navigation-context.js +++ b/native/navigation/navigation-context.js @@ -3,7 +3,7 @@ import type { CommonAction, PossiblyStaleNavigationState, -} from '@react-navigation/native'; +} from '@react-navigation/core'; import * as React from 'react'; import type { OverlayRouterNavigationAction } from './overlay-router.js'; diff --git a/native/navigation/navigation-utils.js b/native/navigation/navigation-utils.js --- a/native/navigation/navigation-utils.js +++ b/native/navigation/navigation-utils.js @@ -5,7 +5,7 @@ PossiblyStaleRoute, StaleLeafRoute, ScreenParams, -} from '@react-navigation/native'; +} from '@react-navigation/core'; import invariant from 'invariant'; import { diff --git a/native/navigation/options.js b/native/navigation/options.js --- a/native/navigation/options.js +++ b/native/navigation/options.js @@ -1,6 +1,6 @@ // @flow -import type { StackOptions } from '@react-navigation/stack'; +import type { StackOptions } from '@react-navigation/core'; import { Platform } from 'react-native'; const defaultStackScreenOptions: StackOptions = { diff --git a/native/navigation/overlay-navigator.react.js b/native/navigation/overlay-navigator.react.js --- a/native/navigation/overlay-navigator.react.js +++ b/native/navigation/overlay-navigator.react.js @@ -9,7 +9,7 @@ ParamListBase, StackNavigationHelpers, ScreenListeners, -} from '@react-navigation/native'; +} from '@react-navigation/core'; import { useNavigationBuilder, createNavigatorFactory, diff --git a/native/navigation/overlay-router.js b/native/navigation/overlay-router.js --- a/native/navigation/overlay-router.js +++ b/native/navigation/overlay-router.js @@ -8,7 +8,7 @@ StackNavigationState, RouterConfigOptions, ScreenParams, -} from '@react-navigation/native'; +} from '@react-navigation/core'; import { StackRouter, CommonActions } from '@react-navigation/native'; import { diff --git a/native/navigation/root-navigator.react.js b/native/navigation/root-navigator.react.js --- a/native/navigation/root-navigator.react.js +++ b/native/navigation/root-navigator.react.js @@ -1,16 +1,18 @@ // @flow +import type { + StackNavigationState, + StackOptions, + StackNavigationEventMap, + StackNavigatorProps, + ExtraStackNavigatorProps, + ParamListBase, + StackNavigationHelpers, + StackNavigationProp, +} from '@react-navigation/core'; import { createNavigatorFactory, useNavigationBuilder, - type StackNavigationState, - type StackOptions, - type StackNavigationEventMap, - type StackNavigatorProps, - type ExtraStackNavigatorProps, - type ParamListBase, - type StackNavigationHelpers, - type StackNavigationProp, } from '@react-navigation/native'; import { StackView, TransitionPresets } from '@react-navigation/stack'; import * as React from 'react'; diff --git a/native/navigation/root-router.js b/native/navigation/root-router.js --- a/native/navigation/root-router.js +++ b/native/navigation/root-router.js @@ -9,7 +9,7 @@ StackNavigationState, RouterConfigOptions, PossiblyStaleNavigationState, -} from '@react-navigation/native'; +} from '@react-navigation/core'; import { StackRouter, CommonActions } from '@react-navigation/native'; import invariant from 'invariant'; import _isEqual from 'lodash/fp/isEqual.js'; diff --git a/native/navigation/route-names.js b/native/navigation/route-names.js --- a/native/navigation/route-names.js +++ b/native/navigation/route-names.js @@ -1,6 +1,6 @@ // @flow -import type { RouteProp } from '@react-navigation/native'; +import type { RouteProp } from '@react-navigation/core'; import type { ActionResultModalParams } from './action-result-modal.react.js'; import type { InviteLinkModalParams } from './invite-link-modal.react'; diff --git a/native/navigation/tab-navigator.react.js b/native/navigation/tab-navigator.react.js --- a/native/navigation/tab-navigator.react.js +++ b/native/navigation/tab-navigator.react.js @@ -1,10 +1,6 @@ // @flow import { BottomTabView } from '@react-navigation/bottom-tabs'; -import { - createNavigatorFactory, - useNavigationBuilder, -} from '@react-navigation/native'; import type { BottomTabNavigationEventMap, BottomTabOptions, @@ -15,6 +11,10 @@ BottomTabNavigationProp, ExtraBottomTabNavigatorProps, BottomTabNavigatorProps, +} from '@react-navigation/core'; +import { + createNavigatorFactory, + useNavigationBuilder, } from '@react-navigation/native'; import * as React from 'react'; diff --git a/native/navigation/tab-router.js b/native/navigation/tab-router.js --- a/native/navigation/tab-router.js +++ b/native/navigation/tab-router.js @@ -5,7 +5,7 @@ RouterConfigOptions, TabRouterOptions, TabNavigationState, -} from '@react-navigation/native'; +} from '@react-navigation/core'; import { TabRouter } from '@react-navigation/native'; import { diff --git a/native/profile/profile-header.react.js b/native/profile/profile-header.react.js --- a/native/profile/profile-header.react.js +++ b/native/profile/profile-header.react.js @@ -1,6 +1,6 @@ // @flow -import type { StackHeaderProps } from '@react-navigation/stack'; +import type { StackHeaderProps } from '@react-navigation/core'; import * as React from 'react'; import Header from '../navigation/header.react.js'; diff --git a/native/profile/profile.react.js b/native/profile/profile.react.js --- a/native/profile/profile.react.js +++ b/native/profile/profile.react.js @@ -1,11 +1,11 @@ // @flow -import { - createStackNavigator, - type StackNavigationProp, - type StackNavigationHelpers, - type StackHeaderProps, -} from '@react-navigation/stack'; +import type { + StackNavigationProp, + StackNavigationHelpers, + StackHeaderProps, +} from '@react-navigation/core'; +import { createStackNavigator } from '@react-navigation/stack'; import * as React from 'react'; import { View, useWindowDimensions } from 'react-native'; diff --git a/native/qr-code/qr-code-sign-in-navigator.react.js b/native/qr-code/qr-code-sign-in-navigator.react.js --- a/native/qr-code/qr-code-sign-in-navigator.react.js +++ b/native/qr-code/qr-code-sign-in-navigator.react.js @@ -1,10 +1,10 @@ // @flow -import { - createStackNavigator, - type StackNavigationProp, - type StackNavigationHelpers, -} from '@react-navigation/stack'; +import type { + StackNavigationProp, + StackNavigationHelpers, +} from '@react-navigation/core'; +import { createStackNavigator } from '@react-navigation/stack'; import * as React from 'react'; import { SafeAreaView } from 'react-native-safe-area-context'; diff --git a/native/roles/roles-navigator.react.js b/native/roles/roles-navigator.react.js --- a/native/roles/roles-navigator.react.js +++ b/native/roles/roles-navigator.react.js @@ -1,10 +1,10 @@ // @flow -import { - createStackNavigator, - type StackNavigationProp, - type StackNavigationHelpers, -} from '@react-navigation/stack'; +import type { + StackNavigationProp, + StackNavigationHelpers, +} from '@react-navigation/core'; +import { createStackNavigator } from '@react-navigation/stack'; import * as React from 'react'; import { SafeAreaView } from 'react-native-safe-area-context'; diff --git a/native/root.react.js b/native/root.react.js --- a/native/root.react.js +++ b/native/root.react.js @@ -3,9 +3,9 @@ import { ActionSheetProvider } from '@expo/react-native-action-sheet'; import { BottomSheetModalProvider } from '@gorhom/bottom-sheet'; import AsyncStorage from '@react-native-async-storage/async-storage'; +import type { PossiblyStaleNavigationState } from '@react-navigation/core'; import { useReduxDevToolsExtension } from '@react-navigation/devtools'; import { NavigationContainer } from '@react-navigation/native'; -import type { PossiblyStaleNavigationState } from '@react-navigation/native'; import * as SplashScreen from 'expo-splash-screen'; import invariant from 'invariant'; import * as React from 'react'; diff --git a/native/tooltip/tooltip.react.js b/native/tooltip/tooltip.react.js --- a/native/tooltip/tooltip.react.js +++ b/native/tooltip/tooltip.react.js @@ -1,6 +1,6 @@ // @flow -import type { RouteProp } from '@react-navigation/native'; +import type { RouteProp } from '@react-navigation/core'; import * as Haptics from 'expo-haptics'; import invariant from 'invariant'; import * as React from 'react';