import { EventSubscription , Navigation } from 'react-native-navigation' ; import { NavLayout , NavModal , NavOptions , Tab } from '../types' ; export interface GenericNavProp { componentId : string ; tabs : Tab [ ] ; } export default class Navigator { componentId : string ; tabs : Tab [ ] ; constructor ( props , updateModals ? ) { this . componentId = props . componentId ; this . tabs = props . tabs ; } async push ( layout , alternateId ? ) { return Navigation . push ( alternateId || this . componentId , layout ) ; } async pop ( options ? , alternateId ? ) { return Navigation . pop ( alternateId || this . componentId , options ) ; } async popToRoot ( options ? , alternateId ? ) { return Navigation . popToRoot ( alternateId || this . componentId , options ) ; } async popTo ( options ? , alternateId ? ) { return Navigation . popTo ( alternateId || this . componentId , options ) ; } async setStackRoot ( layout , alternateId ? ) { return Navigation . setStackRoot ( alternateId || this . componentId , layout ) ; } async showModal ( layout ) { return Navigation . showModal ( layout ) ; } async dismissModal ( options ? , alternateId ? ) { return Navigation . dismissModal ( alternateId || this . componentId , options ) ; } async dismissAllModals ( options ? ) { return Navigation . dismissAllModals ( options ) ; } async updateProps ( newProps , alternateId ? ) { return Navigation . updateProps ( alternateId || this . componentId , newProps ) ; } mergeOptions ( options , alternateId ? ) { return Navigation . mergeOptions ( alternateId || this . componentId , options ) ; } bindNavigation ( bindee , alternateId ? ) { return Navigation . events ( ) . bindComponent ( bindee , alternateId || this . componentId ) ; } handleDeepLink ( options ) { console . error ( 'handleDeepLink is no longer part of react-native-navigation' ) ; } setOnNavigatorEvent ( ) { console . error ( 'setOnNavigatorEvent is no longer part of react-native-navigation. ' + 'Please use navigator.bindNavigation(this) to bind events, then reference ' + 'https://wix.github.io/react-native-navigation/#/docs/events' ) ; } resetTo ( options ) { console . warn ( 'resetTo has been deprecated. ' + 'Please use setStackRoot' ) ; this . setStackRoot ( { component : { name : options . screen , options : { topBar : { title : { text : options . title } } } } } ) . catch ( e => { console . error ( e ) ; } ) ; } setStyle ( options ) { console . warn ( 'setStyle has been deprecated. ' + 'Please use mergeOptions({\n  topBar: {\n    alignment: \'center\'\n  }\n}) instead' ) ; this . mergeOptions ( { topBar : { title : { alignment : options . navBarTitleTextCentered ? 'center' : 'fill' } } } ) ; } setTabBadge ( options ) { console . warn ( 'setTabBadge has been deprecated. ' + 'Please use mergeOptions({\n  bottomTab: {\n    badge: \'1\',\n    ' + 'badgeColor: \'rgb(255, 255, 255)\',\n    ' + 'icon: iconImageSource\n  }\n}, componentIdOfTab) instead' ) ; const icon = this . tabs [ options . tabIndex ] . icon || this . tabs [ options . tabIndex ] . options ?. bottomTab ?. icon ; if ( icon ) { this . mergeOptions ( { bottomTab : { badge : options . badge !== null ? options . badge . toString ( ) : undefined , badgeColor : options . badgeColor , icon } } , this . tabs [ options . tabIndex ] . id ) ; } } setTitle ( options ) { console . warn ( 'setTitle has been deprecated. ' + 'Please use mergeOptions({\n  topBar: {\n    title: \'title\\n  }\n}) instead' ) ; this . mergeOptions ( { topBar : { title : { text : options . title } } } ) ; } switchToTab ( options ) { console . warn ( 'switchToTab has been deprecated. ' + 'Please use mergeOptions({\n  bottomTabs: {\n    currentTabIndex: 0\n  }\n}) instead' ) ; this . mergeOptions ( { bottomTabs : { currentTabIndex : options . tabIndex } } ) ; } }