import _ from 'lodash'; import React, {Component} from 'react'; import {ScrollView} from 'react-native'; import { Assets, Colors, Typography, Dialog, View, Text, Button, Icon, Avatar, Picker, PickerProps, RenderCustomModalProps, PickerMethods, SegmentedControl, PickerSelectionStatusProps } from 'react-native-ui-lib'; //eslint-disable-line import contactsData from '../../data/conversations'; import {longOptions} from './PickerScreenLongOptions'; const tagIcon = require('../../assets/icons/tags.png'); const dropdown = require('../../assets/icons/chevronDown.png'); const dropdownIcon = ; const selectAllSegment = [{label: 'button'}, {label: 'checkbox'}]; const buttonProps = { onPress: (selectionValue: any) => console.log('onPress', selectionValue) }; const checkboxProps = { onValueChange: (value: boolean) => console.log('onValueChange', value) }; const renderContact = (contactValue: any, props: any) => { const contact = contacts[contactValue as number]; return ( {contact?.name} {props.isSelected && } ); }; const contacts = _.map(contactsData, (c, index) => ({...c, value: index, label: c.name, renderItem: renderContact})); const options = [ {label: 'JavaScript', value: 'js', labelStyle: Typography.text65}, {label: 'Java', value: 'java', labelStyle: Typography.text65}, {label: 'Python', value: 'python', labelStyle: Typography.text65}, {label: 'C++', value: 'c++', disabled: true, labelStyle: Typography.text65}, {label: 'Perl', value: 'perl', labelStyle: Typography.text65} ]; const filters = [ {label: 'All', value: 0}, {label: 'Draft', value: 1}, {label: 'Published', value: 2}, {label: 'Scheduled', value: 3} ]; const schemes = [ {label: 'Default', value: 1}, {label: 'Light', value: 2}, {label: 'Dark', value: 3} ]; const dialogOptions = [ {label: 'Option 1', value: 0}, {label: 'Option 2', value: 1}, {label: 'Option 3', value: 2}, {label: 'Option 4', value: 3, disabled: true}, {label: 'Option 5', value: 4}, {label: 'Option 6', value: 5}, {label: 'Option 7', value: 6}, {label: 'Option 8', value: 6} ]; const statusOptions = [ {label: 'Overview', value: 'overview'}, {label: 'In Progress', value: 'inProgress'}, {label: 'Completed', value: 'completed'}, {label: 'Pending Review', value: 'pendingReview'}, {label: 'Approved', value: 'approved'}, {label: 'Rejected', value: 'rejected'} ]; export default class PickerScreen extends Component { picker = React.createRef(); state = { itemsCount: 1, // language: {value: 'java', label: 'Java'}, language: undefined, language2: options[2].value, languages: [], option: undefined, wheelPickerValue: 'java', dialogPickerValue: 'java', customModalValues: [], filter: undefined, statOption: [], scheme: undefined, contact: 0, selectAllType: 'button' as PickerSelectionStatusProps['selectAllType'] }; onSegmentChange = (index: number) => { this.setState({selectAllType: selectAllSegment[index].label}); }; renderDialog: PickerProps['renderOverlay'] = (modalProps: RenderCustomModalProps) => { const {visible, children, toggleModal, onDone} = modalProps; return ( { onDone(); toggleModal(); }} width="100%" height="45%" bottom useSafeArea containerStyle={{backgroundColor: Colors.$backgroundDefault}} direction={Dialog.directions.DOWN} headerProps={{title: 'Custom modal'}} > {children} ); }; onTopElementPress = (allOptionsSelected: boolean) => { if (allOptionsSelected) { this.setState({statOption: []}); } else { const allValues = statusOptions.map(option => option.value); this.setState({statOption: allValues}); } }; render() { return ( Picker this.setState({language: item})} topBarProps={{title: 'Languages'}} // style={{color: Colors.red20}} showSearch searchPlaceholder={'Search a language'} searchStyle={{color: Colors.blue30, placeholderTextColor: Colors.grey50}} // onSearchChange={value => console.warn('value', value)} items={longOptions} /> this.setState({languages: items})} mode={Picker.modes.MULTI} selectionLimit={3} trailingAccessory={dropdownIcon} items={options} /> this.setState({wheelPickerValue})} trailingAccessory={} items={options} /> this.setState({customModalValues: items})} mode={Picker.modes.MULTI} trailingAccessory={dropdownIcon} renderOverlay={this.renderDialog} items={options} /> this.setState({option: item})} topBarProps={{title: 'Languages'}} useDialog renderHeader={({onDone, onCancel}) => (