import { Options } from '@ulangi/react-native-navigation' ; import { ScreenName } from '@ulangi/ulangi-common/enums' ; import { Vocabulary } from '@ulangi/ulangi-common/interfaces' ; import { ObservableAtomGameState , ObservableAtomGameStats , ObservableAtomPlayScreen , ObservableOrigin , ObservableScreenLayout , } from '@ulangi/ulangi-observable' ; import * as _ from 'lodash' ; import { observer } from 'mobx-react' ; import * as React from 'react' ; import { Container } from '../../Container' ; import { config } from '../../constants/config' ; import { AtomPlayScreenFactory } from '../../factories/atom/AtomPlayScreenFactory' ; import { AtomQuestionIterator } from '../../iterators/AtomQuestionIterator' ; import { atomStyles } from '../../styles/AtomStyles' ; import { AtomPlayScreen } from './AtomPlayScreen' ; export interface AtomPlayScreenPassedProps { readonly firstVocabularyBatch : readonly Vocabulary [ ] ; readonly noMoreVocabulary : boolean ; readonly startGame : ( ) => void ; } @ observer export class AtomPlayScreenContainer extends Container < AtomPlayScreenPassedProps > { public static options ( ) { return atomStyles . getScreenStyle ( { popGesture : false , } ) ; } private atomPlayScreenFactory = new AtomPlayScreenFactory ( this . props , this . eventBus , this . observer ) ; private questionIterator = new AtomQuestionIterator ( new Map ( this . props . passedProps . firstVocabularyBatch . map ( ( vocabulary ) : [ string , Vocabulary ] => [ vocabulary . vocabularyId , vocabulary , ] ) ) ) ; private screenLayout = new ObservableScreenLayout ( 0 , 0 ) ; protected observableScreen = new ObservableAtomPlayScreen ( new ObservableAtomGameState ( false , false ) , new ObservableAtomGameStats ( 10 , 0 , 0 ) , this . props . passedProps . noMoreVocabulary , this . questionIterator . next ( ) , new ObservableOrigin ( this . screenLayout , config . atom . bottomOffset , config . atom . outerShellDiameter , config . atom . particleSize ) , [ ] , [ ] , [ ] , this . props . componentId , ScreenName . ATOM_PLAY_SCREEN , this . screenLayout ) ; private screenDelegate = this . atomPlayScreenFactory . createScreenDelegate ( this . observableScreen , this . questionIterator , this . props . passedProps . startGame ) ; public componentWillUnmount ( ) { this . screenDelegate . clearGame ( ) ; } public componentDidMount ( ) { this . screenDelegate . initializeShellsAndParticles ( ) ; this . screenDelegate . autoUnhighlightArcsOnOriginPositionChange ( ) ; this . screenDelegate . autoMoveParticlesOnOriginPositionChange ( ) ; } protected onThemeChanged ( ) { _ . noop ( ) ; } public render ( ) { return ( < AtomPlayScreen themeStore = { this . props . rootStore . themeStore } observableScreen = { this . observableScreen } screenDelegate = { this . screenDelegate } / > ) ; } }