|
1 | 1 | import React, {useState} from 'react';
|
2 |
| -import {Assets, View, Icon, Text, Slider, Switch, GradientSlider} from 'react-native-ui-lib'; |
| 2 | +import {Assets, View, Icon, Text, Slider, GradientSlider, Colors} from 'react-native-ui-lib'; |
| 3 | +import {renderBooleanOption} from '../ExampleScreenPresenter'; |
| 4 | + |
| 5 | +const DEFAULT_BADGE_SIZE = 20; |
| 6 | +const DEFAULT_PIMPLE_SIZE = 10; |
3 | 7 |
|
4 | 8 | const IconScreen = () => {
|
5 | 9 | const [size, setSize] = useState(24);
|
| 10 | + const [badgeSize, setBadgeSize] = useState(20); |
6 | 11 | const [customSize, setCustomSize] = useState(false);
|
| 12 | + const [customBadgeSize, setCustomBadgeSize] = useState(false); |
7 | 13 | const [color, setColor] = useState<string | number>();
|
8 | 14 | const [customColor, setCustomColor] = useState(false);
|
| 15 | + const [useBadge, setUseBadge] = useState(false); |
| 16 | + const [usePimple, setUsePimple] = useState(false); |
9 | 17 |
|
10 | 18 | return (
|
11 | 19 | <View padding-page>
|
12 | 20 | <Text h1 marginB-s4>
|
13 | 21 | Icon Screen
|
14 | 22 | </Text>
|
15 |
| - <View center> |
| 23 | + <View center margin-page> |
16 | 24 | <Icon
|
17 |
| - margin-30 |
18 | 25 | size={customSize ? size : undefined}
|
19 |
| - tintColor={customColor ? color as string : undefined} |
| 26 | + tintColor={customColor ? (color as string) : undefined} |
20 | 27 | source={Assets.icons.search}
|
| 28 | + badgeProps={ |
| 29 | + useBadge |
| 30 | + ? { |
| 31 | + size: customBadgeSize ? badgeSize : usePimple ? DEFAULT_PIMPLE_SIZE : DEFAULT_BADGE_SIZE, |
| 32 | + backgroundColor: Colors.red30, |
| 33 | + label: !usePimple ? '5' : undefined |
| 34 | + } |
| 35 | + : undefined |
| 36 | + } |
21 | 37 | />
|
22 | 38 | </View>
|
23 | 39 |
|
24 |
| - <View marginB-s3 row> |
25 |
| - <Text marginR-s2>Custom Size</Text> |
26 |
| - <Switch value={customSize} onValueChange={setCustomSize}/> |
27 |
| - </View> |
| 40 | + {renderBooleanOption('Custom Size', 'customSize', {spread: false, state: customSize, setState: setCustomSize})} |
28 | 41 | <Slider maximumValue={100} value={24} step={1} onValueChange={setSize}/>
|
29 | 42 | <Text marginB-50 marginT-s2>
|
30 | 43 | Custom size: {size}
|
31 | 44 | </Text>
|
32 | 45 |
|
33 |
| - <View marginB-s3 row> |
34 |
| - <Text marginR-s2>Custom Color</Text> |
35 |
| - <Switch value={customColor} onValueChange={setCustomColor}/> |
36 |
| - </View> |
| 46 | + {renderBooleanOption('Custom Badge Size', 'customBadgeSize', { |
| 47 | + spread: false, |
| 48 | + state: customBadgeSize, |
| 49 | + setState: setCustomBadgeSize |
| 50 | + })} |
| 51 | + <Slider maximumValue={100} value={20} step={1} onValueChange={setBadgeSize}/> |
| 52 | + <Text marginB-50 marginT-s2> |
| 53 | + Custom badge size: {badgeSize} |
| 54 | + </Text> |
| 55 | + |
| 56 | + {renderBooleanOption('Custom Color', 'customColor', { |
| 57 | + spread: false, |
| 58 | + state: customColor, |
| 59 | + setState: setCustomColor |
| 60 | + })} |
37 | 61 | <GradientSlider type={GradientSlider.types.HUE} color={color as string} onValueChange={setColor}/>
|
38 | 62 | <Text marginT-s2>Custom color: {color || '#000000'}</Text>
|
| 63 | + |
| 64 | + <View marginV-s5> |
| 65 | + <Text marginR-s2 marginB-s2 text80BO> |
| 66 | + Badge Settings: |
| 67 | + </Text> |
| 68 | + {renderBooleanOption('Use Badge:', 'useBadge', {spread: false, state: useBadge, setState: setUseBadge})} |
| 69 | + {renderBooleanOption('Pimple Badge', 'showLabel', {spread: false, state: usePimple, setState: setUsePimple})} |
| 70 | + </View> |
39 | 71 | </View>
|
40 | 72 | );
|
41 | 73 | };
|
|
0 commit comments