-
Notifications
You must be signed in to change notification settings - Fork 0
/
keyboard.tsx
74 lines (73 loc) · 1.89 KB
/
keyboard.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
import React, { useState } from 'react'
import { Text } from 'react-native'
import {
Screen,
Keyboard,
S,
Toast,
FlexView,
Button,
} from '../../packages/components'
const PRECISIONS = [2, 4, 6]
const MAXLENS = [10, 12, 14]
function KeyboardDemo() {
const [value, setValue] = useState('0')
const [precision, setPrecision] = useState(4)
const [maxLen, setmaxLen] = useState(14)
return (
<Screen style={S.bgDefault}>
<Text
style={[
S.textBlack,
S.textCenter,
S.marginBottom12,
S.bgWhite,
S.paddingVertical8,
]}>
数值为: {value}
</Text>
<FlexView row paddingVertical12 alignCenter>
<Text>选择精度precision</Text>
<FlexView row flex justifyAround>
{PRECISIONS.map((item) => (
<Button
key={item}
type={precision === item ? 'primaryBg' : 'default'}
onPress={() => {
setPrecision(item)
setValue('0')
}}
style={[S.border]}>
{item}
</Button>
))}
</FlexView>
</FlexView>
<FlexView row paddingVertical12 alignCenter>
<Text>选择最大长度 maxLen</Text>
<FlexView row flex justifyAround>
{MAXLENS.map((item) => (
<Button
key={item}
type={maxLen === item ? 'primaryBg' : 'default'}
onPress={() => {
setmaxLen(item)
setValue('0')
}}
style={[S.border]}>
{item}
</Button>
))}
</FlexView>
</FlexView>
<Keyboard
onChange={setValue}
value={value}
precision={precision}
onConfirm={(comfirmValue) => Toast.info(comfirmValue)}
maxLen={maxLen}
/>
</Screen>
)
}
export default KeyboardDemo