1
- import React , { Component , useState } from 'react' ;
2
- import { VerificationCode } from '@uiw/react-native' ;
3
- import Layout , { Container } from '../../Layout' ;
4
- import { ComProps } from '../../routes' ;
1
+ import React , { Component , useState } from 'react' ;
2
+ import { VerificationCode } from '@uiw/react-native' ;
3
+ import Layout , { Container } from '../../Layout' ;
4
+ import { ComProps } from '../../routes' ;
5
5
6
- const { Header, Body, Card, Footer } = Layout ;
6
+ const { Header, Body, Card, Footer} = Layout ;
7
7
8
8
export interface VerificationCodeProps extends ComProps {
9
9
onBefore ?: ( ) => Promise < boolean > ;
10
10
onSend ?: ( ) => Promise < boolean > | boolean ;
11
11
}
12
12
13
- const VerificationCodeDemo : React . FC < VerificationCodeProps > = ( { route } ) => {
13
+ const VerificationCodeDemo : React . FC < VerificationCodeProps > = ( { route} ) => {
14
14
const [ value , setValue ] = useState ( '' ) ;
15
15
const description = route . params . description ;
16
16
const title = route . params . title ;
17
17
18
18
const onChange = ( val : string ) => {
19
19
console . log ( 'onChange--> 输入改变事件 ' , val ) ;
20
- setValue ( val )
20
+ setValue ( val ) ;
21
21
} ;
22
22
23
23
const onBefore = async ( ) => {
24
24
console . log ( 'onBefore--> 发验证码之前的回调 ' ) ;
25
25
return true ;
26
- }
26
+ } ;
27
27
28
28
const onSend = async ( ) => {
29
29
console . log ( 'onSend--> 发送验证码' ) ;
30
30
return true ;
31
- }
31
+ } ;
32
32
33
33
const onEnd = ( ) => {
34
34
console . log ( 'onEnd--> 倒计时结束后的回调' ) ;
35
- }
35
+ } ;
36
36
37
37
return (
38
38
< Container >
39
39
< Layout >
40
40
< Header title = { title } description = { description } />
41
- < Body style = { { paddingLeft : 16 , paddingRight : 16 } } >
41
+ < Body style = { { paddingLeft : 16 , paddingRight : 16 } } >
42
42
< Card title = "基础实例" >
43
- < VerificationCode
44
- value = { value }
45
- count = { 3 }
46
- onChange = { ( text : string ) => onChange ( text ) }
47
- outerStyle = { { borderWidth : 1 , borderColor : "#ccc" } }
48
-
49
- />
43
+ < VerificationCode value = { value } count = { 3 } onChange = { ( text : string ) => onChange ( text ) } outerStyle = { { borderWidth : 1 , borderColor : '#ccc' } } />
50
44
</ Card >
51
45
< Card title = "无边框" >
52
46
< VerificationCode
53
47
bordered = { false }
54
- label = ' 我没框框哦'
48
+ label = " 我没框框哦"
55
49
count = { 3 }
56
50
onChange = { ( text : string ) => onChange ( text ) }
57
- outerStyle = { { backgroundColor : '#FFF' } }
51
+ outerStyle = { { backgroundColor : '#FFF' } }
52
+ buttonStyle = { { backgroundColor : '#fff' } }
58
53
/>
59
54
</ Card >
60
55
< Card title = "自定义倒计时文字和重新发送文字" >
61
56
< VerificationCode
62
- label = '点我'
63
- resendLabel = '好了'
57
+ label = "点我"
58
+ resendLabel = "好了"
64
59
value = { value }
65
60
count = { 3 }
66
61
onChange = { ( text : string ) => onChange ( text ) }
67
- outerStyle = { { borderWidth : 1 , borderColor : " #ccc" } }
62
+ outerStyle = { { borderWidth : 1 , borderColor : ' #ccc' } }
68
63
/>
69
64
</ Card >
70
65
< Card title = "自定义倒计时时长" >
71
- < VerificationCode
72
- count = { 10 }
73
- value = { value }
74
- onChange = { ( text : string ) => onChange ( text ) }
75
- outerStyle = { { borderWidth : 1 , borderColor : "#ccc" } }
76
- />
66
+ < VerificationCode count = { 10 } value = { value } onChange = { ( text : string ) => onChange ( text ) } outerStyle = { { borderWidth : 1 , borderColor : '#ccc' } } />
77
67
</ Card >
78
68
< Card title = "输入改变事件" >
79
- < VerificationCode
80
- value = { value }
81
- count = { 3 }
82
- onChange = { ( text : string ) => onChange ( text ) }
83
- outerStyle = { { borderWidth : 1 , borderColor : "#ccc" } }
84
- />
69
+ < VerificationCode value = { value } count = { 3 } onChange = { ( text : string ) => onChange ( text ) } outerStyle = { { borderWidth : 1 , borderColor : '#ccc' } } />
85
70
</ Card >
86
71
< Card title = "发验证码之前的回调" >
87
72
< VerificationCode
88
73
value = { value }
89
74
count = { 3 }
90
75
onChange = { ( text : string ) => onChange ( text ) }
91
76
onBefore = { onBefore }
92
- outerStyle = { { borderWidth : 1 , borderColor : " #ccc" } }
77
+ outerStyle = { { borderWidth : 1 , borderColor : ' #ccc' } }
93
78
/>
94
79
</ Card >
95
80
< Card title = "发送验证码" >
@@ -98,7 +83,7 @@ const VerificationCodeDemo: React.FC<VerificationCodeProps> = ({ route }) => {
98
83
count = { 3 }
99
84
onChange = { ( text : string ) => onChange ( text ) }
100
85
onSend = { onSend }
101
- outerStyle = { { borderWidth : 1 , borderColor : " #ccc" } }
86
+ outerStyle = { { borderWidth : 1 , borderColor : ' #ccc' } }
102
87
/>
103
88
</ Card >
104
89
< Card title = "倒计时结束后的回调" >
@@ -107,15 +92,15 @@ const VerificationCodeDemo: React.FC<VerificationCodeProps> = ({ route }) => {
107
92
count = { 3 }
108
93
onChange = { ( text : string ) => onChange ( text ) }
109
94
onEnd = { onEnd }
110
- outerStyle = { { borderWidth : 1 , borderColor : " #ccc" } }
95
+ outerStyle = { { borderWidth : 1 , borderColor : ' #ccc' } }
111
96
/>
112
97
</ Card >
113
98
< Card title = "自定义外层输入框样式" >
114
99
< VerificationCode
115
100
value = { value }
116
101
count = { 3 }
117
102
onChange = { ( text : string ) => onChange ( text ) }
118
- outerStyle = { { backgroundColor : '#FFD21D' , borderWidth : 1 , borderColor : " #ccc" } }
103
+ outerStyle = { { backgroundColor : '#FFD21D' , borderWidth : 1 , borderColor : ' #ccc' } }
119
104
/>
120
105
</ Card >
121
106
< Card title = "自定义内层按钮样式" >
@@ -124,34 +109,28 @@ const VerificationCodeDemo: React.FC<VerificationCodeProps> = ({ route }) => {
124
109
value = { value }
125
110
count = { 3 }
126
111
onChange = { ( text : string ) => onChange ( text ) }
127
- buttonStyle = { { backgroundColor : '#F86E21' } }
128
- outerStyle = { { borderWidth : 1 , borderColor : " #ccc" } }
112
+ buttonStyle = { { backgroundColor : '#F86E21' } }
113
+ outerStyle = { { borderWidth : 1 , borderColor : ' #ccc' } }
129
114
/>
130
115
</ Card >
131
116
< Card title = "自定义按钮文字样式" >
132
- < VerificationCode
133
- value = { value }
134
- count = { 3 }
135
- onChange = { ( text : string ) => onChange ( text ) }
136
- outerStyle = { { borderWidth : 1 , borderColor : "#ccc" } }
137
- />
117
+ < VerificationCode value = { value } count = { 3 } onChange = { ( text : string ) => onChange ( text ) } outerStyle = { { borderWidth : 1 , borderColor : '#ccc' } } />
138
118
</ Card >
139
119
< Card title = "自定义输入框提示文字" >
140
120
< VerificationCode
141
121
bordered = { false }
142
122
value = { value }
143
123
count = { 3 }
144
124
onChange = { ( text : string ) => onChange ( text ) }
145
- placeholder = ' 请输入112233.....'
146
- outerStyle = { { borderBottomWidth : 1 , borderBottomColor : '#CCC' } }
125
+ placeholder = " 请输入112233....."
126
+ outerStyle = { { borderBottomWidth : 1 , borderBottomColor : '#CCC' } }
147
127
/>
148
128
</ Card >
149
129
</ Body >
150
130
< Footer />
151
131
</ Layout >
152
132
</ Container >
153
133
) ;
154
- }
134
+ } ;
155
135
156
136
export default VerificationCodeDemo ;
157
-
0 commit comments