import React, {PureComponent} from 'react'; import {ScrollView, StyleSheet} from 'react-native'; import {Text, View, ExpandableSection, SegmentedControl, Colors, Icon} from 'react-native-ui-lib'; const chevronDown = require('../../assets/icons/chevronDown.png'); const chevronUp = require('../../assets/icons/chevronUp.png'); const infoIcon = require('../../assets/icons/info.png'); const DEFAULT = undefined; const PARTIALLY_EXPANDED_HEIGHT = 100; const FULLY_EXPANDED_HEIGHT = 300; class ExpandableSectionScreen extends PureComponent { state = { expanded: false, minHeight: DEFAULT }; onExpand = () => { this.setState({ expanded: !this.state.expanded }); }; getChevron(expanded: boolean) { return expanded ? chevronUp : chevronDown; } renderReadMoreHeader = () => { const {expanded} = this.state; return ( Read More ); }; renderHeader = (text: string, expanded: boolean, {disabled, showInfo}: {disabled?: boolean; showInfo?: boolean} = {}) => { return ( {showInfo ? : null} {text} ); }; renderContent() { return ( If you have any questions, comments, or concerns, please don't hesitate to get in touch with us. You can easily reach out to us through our contact form on our website. Alternatively, you can reach us via email at help@help.com, where our team is ready to assist you promptly. If you prefer speaking with someone directly, feel free to give us a call at 1-833-350-1066. ); } renderOptions = () => { return ( Minimum Height The expandable section can be either fully collapsed, partially expanded to reveal some of the items, or fully expanded by default. { switch (index) { case 0: return this.setState({minHeight: DEFAULT}); case 1: return this.setState({minHeight: PARTIALLY_EXPANDED_HEIGHT}); case 2: return this.setState({minHeight: FULLY_EXPANDED_HEIGHT}); } }} /> ); }; renderExpandableSection = () => { const {expanded, minHeight} = this.state; return ( {this.renderContent()} ); }; renderNextItem() { return this.renderHeader('Where are you located?', false, {disabled: true, showInfo: true}); } render() { const {minHeight} = this.state; return ( ExpandableSection {this.renderOptions()} {this.renderExpandableSection()} {minHeight !== PARTIALLY_EXPANDED_HEIGHT ? this.renderNextItem() : null} ); } } export default ExpandableSectionScreen; const styles = StyleSheet.create({ icon: { alignSelf: 'center' } });