import { SetFormPickerType } from '@ulangi/ulangi-common/enums' ; import { ObservableSetPickerState , Observer } from '@ulangi/ulangi-observable' ; import { Keyboard } from 'react-native' ; export class PickerDelegate { private observer : Observer ; private pickerState : ObservableSetPickerState ; public constructor ( observer , pickerState ) { this . observer = observer ; this . pickerState = pickerState ; } public showPicker ( pickerType ) { Keyboard . dismiss ( ) ; if ( pickerType !== this . pickerState . currentPicker ) { if ( this . pickerState . currentPicker !== null ) { this . hidePicker ( ) ; } this . observer . when ( ( ) : boolean => this . pickerState . currentPicker === null , ( ) : void => { this . pickerState . currentPicker = pickerType ; } ) ; } } public hidePicker ( ) { if ( this . pickerState . currentPicker !== null ) { this . pickerState . languagePickerShouldRunCloseAnimation = true ; this . observer . when ( ( ) : boolean => this . pickerState . languagePickerShouldRunCloseAnimation === false , ( ) : void => { this . pickerState . currentPicker = null ; } ) ; } } }