import { Options } from '@ulangi/react-native-navigation' ; import { ScreenName } from '@ulangi/ulangi-common/enums' ; import { ObservableReflexGameState , ObservableReflexGameStats , ObservableReflexScreen , } from '@ulangi/ulangi-observable' ; import * as _ from 'lodash' ; import { observable } from 'mobx' ; import { observer } from 'mobx-react' ; import * as React from 'react' ; import { Container } from '../../Container' ; import { config } from '../../constants/config' ; import { ReflexScreenFactory } from '../../factories/reflex/ReflexScreenFactory' ; import { ReflexQuestionIterator } from '../../iterators/ReflexQuestionIterator' ; import { reflexStyles } from '../../styles/ReflexStyles' ; import { ReflexScreen } from './ReflexScreen' ; export interface ReflexScreenPassedProps { readonly selectedCategoryNames : undefined | string [ ] ; } @ observer export class ReflexScreenContainer extends Container < ReflexScreenPassedProps > { public static options ( ) { return reflexStyles . getScreenStyle ( ) ; } private screenFactory = new ReflexScreenFactory ( this . props , this . eventBus , this . observer ) ; private questionIterator = new ReflexQuestionIterator ( ) ; protected observableScreen = new ObservableReflexScreen ( typeof this . props . passedProps . selectedCategoryNames !== 'undefined' ? observable . array ( this . props . passedProps . selectedCategoryNames . slice ( ) ) : undefined , new ObservableReflexGameState ( false , config . reflex . timePerQuestion , false ) , new ObservableReflexGameStats ( 0 ) , false , this . props . componentId , ScreenName . REFLEX_SCREEN ) ; private screenDelegate = this . screenFactory . createScreenDelegate ( this . observableScreen , this . questionIterator ) ; public componentWillUnmount ( ) { this . screenDelegate . clearGame ( ) ; } protected onThemeChanged ( ) { _ . noop ( ) ; } public render ( ) { return ( < ReflexScreen themeStore = { this . props . rootStore . themeStore } observableScreen = { this . observableScreen } screenDelegate = { this . screenDelegate } / > ) ; } }