import { Layout , Navigation , Options } from 'react-native-navigation' ; import createLayout from './createLayout' ; import setRoot , { SetRootCommand } from './setRoot' ; import showModal , { ShowModalCommand } from './showModal' ; import showOverlay , { ShowOverlayCommand } from './showOverlay' ; interface SetStackRootCommand { < P = { } > ( layout ) : Promise < any > ; < P = { } > ( name , passProps ? , options ? ) : Promise < any > ; } interface PushCommand { < P = { } > ( layout ) : Promise < any > ; ( name ) : Promise < any > ; < P = { } > ( name , passProps ? ) : Promise < any > ; < P = { } > ( name , passProps ? , options ? ) : Promise < any > ; } export type NavigationCommands = { setStackRoot : SetStackRootCommand ; push : PushCommand ; mergeOptions : ( options : Options ) => void ; updateProps : ( props : object ) => void ; dismissModal : ( mergeOptions ? : Options ) => Promise < any > ; pop : ( mergeOptions ? : Options ) => Promise < any > ; popTo : ( mergeOptions ? : Options ) => Promise < any > ; popToRoot : ( mergeOptions ? : Options ) => Promise < any > ; dismissOverlay : ( ) => Promise < any > ; deprecated setRoot : SetRootCommand ; deprecated showModal : ShowModalCommand ; deprecated showOverlay : ShowOverlayCommand ; deprecated setDefaultOptions : ( options : Options ) => void ; deprecated dismissAllModals : ( mergeOptions ? : Options ) => Promise < any > ; deprecated getLaunchArgs : ( ) => Promise < any > ; } ; /**
 * Creates a set of action helpers for
 * [component](https://wix.github.io/react-native-navigation/api/component),
 * [root](https://wix.github.io/react-native-navigation/api/root),
 * [stack](https://wix.github.io/react-native-navigation/api/stack),
 * [modal](https://wix.github.io/react-native-navigation/api/modal),
 * [overlay](https://wix.github.io/react-native-navigation/api/overlay)
 * Navigation API exposing multiple function types for the each function as a list of overloads.
 */ function createNavigationCommands ( /**
 * Component reference id. Used to give context to the Navigation functions that requires componentId parameter.
 */ componentId ) { function setStackRoot < P = { } > ( nameOrLayout , passProps ? , options ? ) { const layout = typeof nameOrLayout === 'string' ? createLayout < P > ( nameOrLayout , passProps , options ) : nameOrLayout ; return Navigation . setStackRoot ( componentId , layout ) ; } function push < P = { } > ( nameOrLayout , passProps ? , options ? ) { const layout = typeof nameOrLayout === 'string' ? createLayout < P > ( nameOrLayout , passProps , options ) : nameOrLayout ; return Navigation . push ( componentId , layout ) ; } function mergeOptions ( options ) { return Navigation . mergeOptions ( componentId , options ) ; } function updateProps ( props ) { return Navigation . updateProps ( componentId , props ) ; } function dismissModal ( mergeOptions ? ) { return mergeOptions ? Navigation . dismissModal ( componentId , mergeOptions ) : Navigation . dismissModal ( componentId ) ; } function pop ( mergeOptions ? ) { return mergeOptions ? Navigation . pop ( componentId , mergeOptions ) : Navigation . pop ( componentId ) ; } function popTo ( mergeOptions ? ) { return mergeOptions ? Navigation . popTo ( componentId , mergeOptions ) : Navigation . popTo ( componentId ) ; } function popToRoot ( mergeOptions ? ) { return mergeOptions ? Navigation . popToRoot ( componentId , mergeOptions ) : Navigation . popToRoot ( componentId ) ; } function dismissOverlay ( ) { return Navigation . dismissOverlay ( componentId ) ; } const { setDefaultOptions , dismissAllModals , getLaunchArgs } = Navigation ; return { setStackRoot , push , mergeOptions , updateProps , dismissModal , pop , popTo , popToRoot , dismissOverlay , setRoot , showModal , showOverlay , setDefaultOptions , dismissAllModals , getLaunchArgs , } ; } export default createNavigationCommands ;