import React, {useCallback, useState} from 'react'; import {StyleSheet} from 'react-native'; import { Text, View, Colors, SegmentedControl, Assets, Spacings, BorderRadiuses, Typography, SegmentedControlItemProps } from 'react-native-ui-lib'; const segments: Record> = { first: [{label: 'Default'}, {label: 'Form'}], second: [{label: '1'}, {label: '2'}, {label: '3'}, {label: Assets.emojis.airplane}, {label: '5'}], third: [ { label: 'Very Long Label with icon', iconSource: Assets.icons.demo.search, iconStyle: {marginLeft: Spacings.s1, width: 16, height: 16}, iconOnRight: true }, {label: 'Short'} ], forth: [{label: 'With'}, {label: 'Custom'}, {label: 'Style'}], fifth: [{label: 'Full'}, {label: 'Width'}], sixth: [{label: 'Full'}, {label: 'Width'}, {label: 'With'}, {label: 'A'}, {label: 'Very Long Segment'}], seventh: [{label: '$'}, {label: '%'}], eighth: [ {label: 'Plus', iconSource: Assets.icons.demo.plus}, {label: 'Minus', iconSource: Assets.icons.demo.minus}, {label: 'Check', iconSource: Assets.icons.demo.check} ], ninth: [{label: 'with'}, {label: 'a'}, {label: 'label'}] }; const SegmentedControlScreen = () => { const onChangeIndex = useCallback((index: number) => { console.warn('Index ' + index + ' of the second segmentedControl was pressed'); }, []); const [screenPreset, setScreenPreset] = useState(SegmentedControl.presets.DEFAULT); return ( Segmented Control Preset: setScreenPreset(index === 0 ? SegmentedControl.presets.DEFAULT : SegmentedControl.presets.FORM) } initialIndex={screenPreset === SegmentedControl.presets.DEFAULT ? 0 : 1} /> Custom Typography With Icons Custom Styling With a label ); }; const styles = StyleSheet.create({ container: { marginTop: 20 }, customStyle: { height: 50, width: 300 }, customSegmentsStyle: { height: 50 }, customTypography: { ...Typography.text80BO } }); export default SegmentedControlScreen;