import React, {Component} from 'react'; import {StyleSheet, ScrollView} from 'react-native'; import {Colors, View, Text, Incubator, TouchableOpacity, ExpandableOverlayMethods, PickerMethods} from 'react-native-ui-lib'; import _ from 'lodash'; const COLOR_OPTIONS: {[key: string]: string} = { red: Colors.red30, green: Colors.green30, yellow: Colors.yellow30, blue: Colors.blue30 }; export default class TextFieldScreen extends Component { expandableInputRef = React.createRef(); expandablePickerRef = React.createRef(); state = { textFieldValueDraft: '', textFieldValue: '', selectedColor: 'red' }; updateText = (value: string) => this.setState({textFieldValueDraft: value}); onDone = () => { this.setState({textFieldValue: this.state.textFieldValueDraft}); this.expandableInputRef.current?.closeExpandable(); }; onCancel = () => { this.setState({textFieldValueDraft: this.state.textFieldValue}); this.expandableInputRef.current?.closeExpandable(); }; onPickItem = ({customValue: color}: {customValue: string}) => { this.setState({selectedColor: color}); this.expandablePickerRef.current?.closeExpandable(); }; renderInputModal = () => { const {textFieldValueDraft} = this.state; return ( <> ); }; renderColorRow = (colorKey: string) => { return ( {colorKey} ); }; renderPickerContent = () => { return ( {_.map(COLOR_OPTIONS, (_color, key) => { return ( {this.renderColorRow(key)} ); })} ); }; renderExpandableFieldExample() { const {textFieldValue} = this.state; return ( <> Expandable TextField console.warn('Modal is dismissed')}} expandableContent={this.renderInputModal()} showTopBar topBarProps={{title: 'Edit Input', doneLabel: 'Done', onCancel: this.onCancel, onDone: this.onDone}} > ); } renderExpandablePickerExample() { const {selectedColor} = this.state; return ( <> Expandable Picker console.warn('Dialog is dismissed')}} > {this.renderColorRow(selectedColor)} ); } render() { return ( ExpandableOverlay {this.renderExpandableFieldExample()} {this.renderExpandablePickerExample()} ); } } const styles = StyleSheet.create({ colorRowText: { textTransform: 'capitalize' } });