import { Theme } from '@ulangi/ulangi-common/enums' ; import * as _ from 'lodash' ; import * as RNDarkMode from 'react-native-dark-mode' ; import { EventChannel , eventChannel } from 'redux-saga' ; export class SystemThemeAdapter { public systemTheme : typeof RNDarkMode ; public constructor ( systemTheme ) { this . systemTheme = systemTheme ; } public createEventChannel ( ) { return eventChannel ( ( emit ) : ( ( ) => void ) => { this . systemTheme . eventEmitter . on ( 'currentModeChanged' , ( newMode ) : void => { if ( newMode === 'light' ) { emit ( Theme . LIGHT ) ; } else if ( newMode === 'dark' ) { emit ( Theme . DARK ) ; } else { emit ( newMode ) ; } } ) ; return _ . noop ; } ) ; } }