import React from 'react'; import { StyleSheet, Text } from 'react-native'; import { TActionSheetOptionsItem, useActionSheet } from '../../containers/ActionSheet'; import { CustomIcon } from '../../containers/CustomIcon'; import * as List from '../../containers/List'; import I18n from '../../i18n'; import { useTheme } from '../../theme'; import sharedStyles from '../Styles'; import { MediaDownloadOption } from '../../lib/constants'; const styles = StyleSheet.create({ title: { ...sharedStyles.textRegular, fontSize: 16 } }); const OPTIONS: { label: string; value: MediaDownloadOption }[] = [ { label: 'Wi_Fi_and_mobile_data', value: MediaDownloadOption.WIFI_MOBILE_DATA }, { label: 'Wi_Fi', value: MediaDownloadOption.WIFI }, { label: 'Never', value: MediaDownloadOption.NEVER } ]; interface IBaseParams { value: string; onChangeValue: (value: MediaDownloadOption) => void; } const ListPicker = ({ value, title, testID, onChangeValue }: { title: string; testID: string; } & IBaseParams) => { const { showActionSheet, hideActionSheet } = useActionSheet(); const { colors } = useTheme(); const option = OPTIONS.find(option => option.value === value); const getOptions = (): TActionSheetOptionsItem[] => OPTIONS.map(i => ({ title: I18n.t(i.label, { defaultValue: i.label }), onPress: () => { hideActionSheet(); onChangeValue(i.value); }, right: option?.value === i.value ? () => : undefined })); return ( showActionSheet({ options: getOptions() })} right={() => ( {option?.label ? I18n.t(option?.label, { defaultValue: option?.label }) : option?.label} )} /> ); }; export default ListPicker;