import { ActionType } from '@ulangi/ulangi-action' ; import { ScreenName } from '@ulangi/ulangi-common/enums' ; import { EventBus , on } from '@ulangi/ulangi-event' ; import { ObservableProgressScreen } from '@ulangi/ulangi-observable' ; import { boundClass } from 'autobind-decorator' ; import { PrimaryScreenStyle } from '../../styles/PrimaryScreenStyle' ; import { NavigatorDelegate } from '../navigator/NavigatorDelegate' ; import { HeatMapDelegate } from './HeatMapDelegate' ; import { StatisticsDelegate } from './StatisticsDelegate' ; @ boundClass export class ProgressScreenDelegate { private eventBus : EventBus ; private observableScreen : ObservableProgressScreen ; private statisticsDelegate : StatisticsDelegate ; private heatMapDelegate : HeatMapDelegate ; private navigatorDelegate : NavigatorDelegate ; public constructor ( eventBus , observableScreen , statisticsDelegate , heatMapDelegate , navigatorDelegate ) { this . eventBus = eventBus ; this . observableScreen = observableScreen ; this . statisticsDelegate = statisticsDelegate ; this . heatMapDelegate = heatMapDelegate ; this . navigatorDelegate = navigatorDelegate ; } public getStatistics ( ) { this . statisticsDelegate . getStatistics ( ) ; } public getHeatMapData ( ) { this . heatMapDelegate . getHeatMapData ( ) ; } public refresh ( ) { this . clear ( ) ; this . statisticsDelegate . getStatistics ( ) ; this . heatMapDelegate . getHeatMapData ( ) ; } public clear ( ) { this . observableScreen . heatMapState . data = null ; this . observableScreen . statisticsState . statistics = null ; this . observableScreen . shouldShowRefreshNotice . set ( false ) ; } public showHeatMapDataPoint ( date , value ) { this . navigatorDelegate . showLightBox ( ScreenName . HEAT_MAP_DATA_POINT_SCREEN , { date , value , } , PrimaryScreenStyle . LIGHT_BOX_SCREEN_STYLES ) ; } public showFullHeatMap ( ) { this . navigatorDelegate . push ( ScreenName . HEAT_MAP_SCREEN , { } ) ; } public autoShowRefreshNotice ( ) { this . eventBus . subscribe ( on ( ActionType . LESSON_RESULTS__UPLOAD_SUCCEEDED , ( ) : void => { this . observableScreen . shouldShowRefreshNotice . set ( true ) ; } ) ) ; } }