/
react-native-material-dropdown-tests.tsx
55 lines (49 loc) · 1.43 KB
/
react-native-material-dropdown-tests.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
import * as React from 'react';
import { Dropdown, DropDownData, RenderBaseProps } from 'react-native-material-dropdown';
import { LayoutChangeEvent, LayoutRectangle, Text, View } from 'react-native';
interface DropdownTestProps {
title: string;
}
class DropdownTest extends React.Component<DropdownTestProps> {
private layout: LayoutRectangle;
private isFocused: boolean;
private curText: string;
render(): JSX.Element {
const dropdownData: DropDownData[] = [
{
label: 'Apple',
value: 'apple'
},
{
label: 'Orange',
value: 'orange'
},
{
label: 'Peach',
value: 'peach',
props: { disabled: true },
}
];
return (
<div>
<Text>{this.props.title}</Text>
<Dropdown
data={dropdownData}
value={'orange'}
label='Fruits'
propsExtractor={(item, index) => item.props ? item.props : {}}
onLayout={(event: LayoutChangeEvent) => this.layout = event.nativeEvent.layout}
onFocus={() => this.isFocused = true}
onBlur={() => this.isFocused = false}
onChangeText={(value: string) => this.curText = value}
/>
<Dropdown
data={dropdownData}
containerStyle={{backgroundColor: '#fff'}}
renderBase={(props: RenderBaseProps) => <Text>{props.title}</Text>}
/>
</div>
);
}
}
export default DropdownTest;