import { Options } from '@ulangi/react-native-navigation' ; import { CategorySortType } from '@ulangi/ulangi-common/enums' ; import { SelectionItem } from '@ulangi/ulangi-common/interfaces' ; import * as _ from 'lodash' ; import { config } from '../../constants/config' ; import { CategorySortMenuIds } from '../../constants/ids/CategorySortMenuIds' ; import { NavigatorDelegate } from '../navigator/NavigatorDelegate' ; export class CategorySortMenuDelegate { private navigatorDelegate : NavigatorDelegate ; private styles : { light : Options ; dark : Options ; } ; public constructor ( navigatorDelegate , styles ) { this . navigatorDelegate = navigatorDelegate ; this . styles = styles ; } public show ( selectedSortType , onSelect ) { this . navigatorDelegate . showSelectionMenu ( { testID : CategorySortMenuIds . SORT_MENU , items : new Map ( _ . toPairs ( config . category . sortMap ) . map ( ( [ filterType , { name } ] ) : [ CategorySortType , SelectionItem ] => { return [ filterType as CategorySortType , { testID : CategorySortMenuIds . SORT_BTN_BY_SORT_TYPE ( filterType as CategorySortType ) , text : _ . upperFirst ( name ) , onPress : ( ) : void => { onSelect ( filterType as CategorySortType ) ; this . navigatorDelegate . dismissLightBox ( ) ; } , } , ] ; } ) ) , selectedIds : [ selectedSortType ] , title : 'Sort' , } , this . styles ) ; } }