/
SelectBoxStory.tsx
116 lines (104 loc) · 2.78 KB
/
SelectBoxStory.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import React, {useState} from 'react';
import {SelectBox, useTheme} from '../../../main';
import type {FC} from 'react';
import {View} from 'react-native';
import styled from '@emotion/native';
import {useFonts} from 'expo-font';
const fakeData1 = ['Item1', 'Item2', 'Item3', 'Item4'];
const fakeDate2 = [
{index: 1, value: 'Item1'},
{index: 2, value: 'Item2'},
{index: 3, value: 'Item3'},
{index: 4, value: 'Item4'},
];
const Container = styled.View`
flex: 1;
align-self: stretch;
align-items: center;
justify-content: center;
`;
const Divider = styled.View`
height: 50px;
width: 50px;
`;
const SelectBoxStory: FC = () => {
const {
theme,
media: {isMobile},
} = useTheme();
const [value1, setValue1] = useState(0);
const [value2, setValue2] = useState(0);
const [value3, setValue3] = useState(0);
const [fontsLoaded] = useFonts({
IcoMoon: require('../../../main/Icon/doobooui.ttf'),
});
if (!fontsLoaded) return <View />;
return (
<Container style={{flexDirection: isMobile ? 'column' : 'row'}}>
<SelectBox
data={fakeData1}
style={{zIndex: 999}}
onSelect={(_, index) => setValue1(index)}
selectedIndex={value1}
styles={{
titleContainer: {
backgroundColor: theme.success,
borderTopWidth: 0,
borderBottomWidth: 0,
borderLeftWidth: 0,
borderRightWidth: 0,
borderRadius: 40,
height: 40,
},
itemContainer: {
borderTopWidth: 0,
borderBottomWidth: 0,
borderLeftWidth: 0,
borderRightWidth: 0,
backgroundColor: theme.paper,
height: 40,
},
rightElementContainer: {
right: 15,
},
}}
/>
<Divider />
<SelectBox
data={fakeData1}
style={{zIndex: 998}}
onSelect={(_, index) => setValue2(index)}
selectedIndex={value2}
isRightElemAnimated={false}
styles={{
titleContainer: {
backgroundColor: theme.info,
borderTopWidth: 0,
borderBottomWidth: 0,
borderLeftWidth: 0,
borderRightWidth: 0,
},
itemContainer: {
backgroundColor: theme.paper,
borderTopWidth: 0,
borderBottomWidth: 0,
borderLeftWidth: 0,
borderRightWidth: 0,
},
hovered: {
backgroundColor: theme.secondary,
},
}}
/>
<Divider />
<SelectBox
data={fakeDate2}
style={{zIndex: 997}}
onSelect={(_, index) => setValue3(index)}
selectedIndex={value3}
rightElement={null}
/>
</Container>
);
};
export default SelectBoxStory;