import { Options } from '@ulangi/react-native-navigation' ; import { ScreenName , Theme } from '@ulangi/ulangi-common/enums' ; import { ObservableScreen } from '@ulangi/ulangi-observable' ; import { observer } from 'mobx-react' ; import * as React from 'react' ; import { BackHandler } from 'react-native' ; import { Container , ContainerPassedProps } from '../../Container' ; import { ScreenFactory } from '../../factories/ScreenFactory' ; import { LightBoxDialogScreen } from './LightBoxDialogScreen' ; @ observer export class LightBoxDialogScreenContainer extends Container { public static options ( props ) { if ( props . theme === Theme . LIGHT ) { return props . styles ? props . styles . light : { } ; } else { return props . styles ? props . styles . dark : { } ; } } protected observableLightBox = this . props . observableLightBox ; protected observableScreen = new ObservableScreen ( this . props . componentId , ScreenName . LIGHT_BOX_DIALOG_SCREEN , null ) ; private screenFactory = new ScreenFactory ( this . props , this . eventBus , this . observer ) ; private navigatorDelegate = this . screenFactory . createNavigatorDelegate ( ) ; public componentDidMount ( ) { BackHandler . addEventListener ( 'hardwareBackPress' , this . handleBackButton ) ; } public componentWillUnmount ( ) { BackHandler . removeEventListener ( 'hardwareBackPress' , this . handleBackButton ) ; } protected onThemeChanged ( theme ) { this . navigatorDelegate . mergeOptions ( theme === Theme . LIGHT ? this . props . styles ? this . props . styles . light : { } : this . props . styles ? this . props . styles . dark : { } ) ; } private handleBackButton = ( ) : boolean => { if ( this . observableLightBox . dialog !== null && ( this . observableLightBox . dialog . showCloseButton === true || this . observableLightBox . dialog . closeOnTouchOutside === true ) ) { this . navigatorDelegate . dismissLightBox ( ) ; } return true ; } ; public render ( ) { return ( < LightBoxDialogScreen themeStore = { this . props . rootStore . themeStore } observableLightBox = { this . observableLightBox } observableScreen = { this . observableScreen } navigatorDelegate = { this . navigatorDelegate } / > ) ; } }