|
@@ -1,3 +1,4 @@
|
|
1
|
+import 'package:farmer_client/widgets/DefaultButton.dart';
|
1
|
2
|
import 'package:flutter/material.dart';
|
2
|
3
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
3
|
4
|
import 'package:fluttertoast/fluttertoast.dart';
|
|
@@ -12,9 +13,34 @@ class UserInfo extends StatefulWidget {
|
12
|
13
|
|
13
|
14
|
class _UserInfo extends State<UserInfo> {
|
14
|
15
|
String name = '';
|
|
16
|
+ String phone = '';
|
|
17
|
+ late TextEditingController _cName;
|
|
18
|
+ late TextEditingController _cPhone;
|
|
19
|
+ @override
|
|
20
|
+ void initState() {
|
|
21
|
+ _cName = new TextEditingController(text: name);
|
|
22
|
+ _cPhone = new TextEditingController(text: phone);
|
|
23
|
+ }
|
|
24
|
+
|
|
25
|
+ bool disableLogin = false;
|
|
26
|
+ RegExp exp = RegExp(r'^1[3456789]\d{9}$');
|
|
27
|
+
|
|
28
|
+ void handleOk() {
|
|
29
|
+ if (name == '' && phone == '') {
|
|
30
|
+ Fluttertoast.showToast(msg: '请输入您的信息');
|
|
31
|
+ } else if (phone!=''&&!exp.hasMatch(phone)) {
|
|
32
|
+ Fluttertoast.showToast(msg: '请输入正确的手机号');
|
|
33
|
+ } else {
|
|
34
|
+ Fluttertoast.showToast(msg: '保存成功');
|
|
35
|
+ Get.back();
|
|
36
|
+ }
|
|
37
|
+ }
|
|
38
|
+
|
15
|
39
|
@override
|
16
|
40
|
Widget build(BuildContext context) {
|
17
|
41
|
return Scaffold(
|
|
42
|
+ //防止键盘弹起引起页面高度溢出
|
|
43
|
+ resizeToAvoidBottomInset: false,
|
18
|
44
|
appBar: AppBar(
|
19
|
45
|
elevation: 0,
|
20
|
46
|
centerTitle: true,
|
|
@@ -29,7 +55,7 @@ class _UserInfo extends State<UserInfo> {
|
29
|
55
|
),
|
30
|
56
|
),
|
31
|
57
|
body: Container(
|
32
|
|
- color: Color(0xFFffffff),
|
|
58
|
+ color: const Color(0xFFffffff),
|
33
|
59
|
padding: EdgeInsets.all(15.w),
|
34
|
60
|
child: Column(
|
35
|
61
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
@@ -74,7 +100,7 @@ class _UserInfo extends State<UserInfo> {
|
74
|
100
|
fontWeight: FontWeight.bold),
|
75
|
101
|
),
|
76
|
102
|
Container(
|
77
|
|
- margin: EdgeInsets.fromLTRB(0, 20.h, 0, 40.h),
|
|
103
|
+ margin: EdgeInsets.fromLTRB(0, 10.h, 0, 40.h),
|
78
|
104
|
padding: EdgeInsets.symmetric(vertical: 19.h, horizontal: 0),
|
79
|
105
|
decoration: BoxDecoration(
|
80
|
106
|
color: const Color(0xFFFFFFFF),
|
|
@@ -93,10 +119,10 @@ class _UserInfo extends State<UserInfo> {
|
93
|
119
|
children: [
|
94
|
120
|
Container(
|
95
|
121
|
width: 327.w,
|
96
|
|
- child: TextFormField(
|
97
|
|
- initialValue: name,
|
|
122
|
+ child: TextField(
|
|
123
|
+ controller: _cName,
|
98
|
124
|
style: TextStyle(
|
99
|
|
- color: Color(0xFF333333),
|
|
125
|
+ color: const Color(0xFF333333),
|
100
|
126
|
fontSize: 17.sp,
|
101
|
127
|
letterSpacing: 2,
|
102
|
128
|
fontWeight: FontWeight.bold),
|
|
@@ -108,18 +134,109 @@ class _UserInfo extends State<UserInfo> {
|
108
|
134
|
floatingLabelBehavior:
|
109
|
135
|
FloatingLabelBehavior.never,
|
110
|
136
|
),
|
111
|
|
- onChanged: (e) {},
|
|
137
|
+ onChanged: (e) {
|
|
138
|
+ setState(() {
|
|
139
|
+ name = e;
|
|
140
|
+ });
|
|
141
|
+ },
|
|
142
|
+ ),
|
|
143
|
+ ),
|
|
144
|
+ GestureDetector(
|
|
145
|
+ onTap: () {
|
|
146
|
+ setState(() {
|
|
147
|
+ name = '';
|
|
148
|
+ });
|
|
149
|
+ _cName.clear();
|
|
150
|
+ },
|
|
151
|
+ child: Image.asset(
|
|
152
|
+ 'images/icons/cancel.png',
|
|
153
|
+ width: 18.w,
|
|
154
|
+ height: 18.w,
|
|
155
|
+ ),
|
|
156
|
+ ),
|
|
157
|
+ ]),
|
|
158
|
+ ],
|
|
159
|
+ )),
|
|
160
|
+ Text(
|
|
161
|
+ '手机号:',
|
|
162
|
+ style: TextStyle(
|
|
163
|
+ color: const Color(0xFF333333),
|
|
164
|
+ fontSize: 17.sp,
|
|
165
|
+ letterSpacing: 2,
|
|
166
|
+ fontWeight: FontWeight.bold),
|
|
167
|
+ ),
|
|
168
|
+ Container(
|
|
169
|
+ margin: EdgeInsets.fromLTRB(0, 10.h, 0, 40.h),
|
|
170
|
+ padding: EdgeInsets.symmetric(vertical: 19.h, horizontal: 0),
|
|
171
|
+ decoration: BoxDecoration(
|
|
172
|
+ color: const Color(0xFFFFFFFF),
|
|
173
|
+ boxShadow: [
|
|
174
|
+ BoxShadow(
|
|
175
|
+ color: const Color(0x1F000000),
|
|
176
|
+ offset: Offset(0, 1.w),
|
|
177
|
+ blurRadius: 0,
|
|
178
|
+ ),
|
|
179
|
+ ],
|
|
180
|
+ ),
|
|
181
|
+ child: Column(
|
|
182
|
+ children: [
|
|
183
|
+ Row(
|
|
184
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
185
|
+ children: [
|
|
186
|
+ SizedBox(
|
|
187
|
+ width: 327.w,
|
|
188
|
+ child: TextField(
|
|
189
|
+ keyboardType: TextInputType.number,
|
|
190
|
+ controller: _cPhone,
|
|
191
|
+ maxLength: 11,
|
|
192
|
+ style: TextStyle(
|
|
193
|
+ color: const Color(0xFF333333),
|
|
194
|
+ fontSize: 17.sp,
|
|
195
|
+ letterSpacing: 2,
|
|
196
|
+ fontWeight: FontWeight.bold),
|
|
197
|
+ decoration: const InputDecoration(
|
|
198
|
+ isCollapsed: true,
|
|
199
|
+ hintText: '请输入您的手机号',
|
|
200
|
+ border: InputBorder.none,
|
|
201
|
+ counterText: '', //去掉计数
|
|
202
|
+ floatingLabelBehavior:
|
|
203
|
+ FloatingLabelBehavior.never,
|
|
204
|
+ ),
|
|
205
|
+ onChanged: (e) {
|
|
206
|
+ setState(() {
|
|
207
|
+ phone = e;
|
|
208
|
+ });
|
|
209
|
+ },
|
|
210
|
+ ),
|
|
211
|
+ ),
|
|
212
|
+ GestureDetector(
|
|
213
|
+ onTap: () {
|
|
214
|
+ setState(() {
|
|
215
|
+ phone = '';
|
|
216
|
+ });
|
|
217
|
+ _cPhone.clear();
|
|
218
|
+ },
|
|
219
|
+ child: Image.asset(
|
|
220
|
+ 'images/icons/cancel.png',
|
|
221
|
+ width: 18.w,
|
|
222
|
+ height: 18.w,
|
112
|
223
|
),
|
113
|
224
|
),
|
114
|
|
- GestureDetector()
|
115
|
|
- Image.asset(
|
116
|
|
- 'images/icons/cancel.png',
|
117
|
|
- width: 18.w,
|
118
|
|
- height: 18.w,
|
119
|
|
- )
|
120
|
225
|
]),
|
121
|
226
|
],
|
122
|
227
|
)),
|
|
228
|
+ const Spacer(),
|
|
229
|
+ DefaultButton(
|
|
230
|
+ color: const Color(0xffffffff),
|
|
231
|
+ backColor: const Color(0xFFFF703B),
|
|
232
|
+ width: 345.w,
|
|
233
|
+ height: 49.h,
|
|
234
|
+ text: '保存',
|
|
235
|
+ onPressed: handleOk,
|
|
236
|
+ margin: const EdgeInsets.all(0),
|
|
237
|
+ fontSize: 20.sp,
|
|
238
|
+ radius: 24.5.w,
|
|
239
|
+ ),
|
123
|
240
|
],
|
124
|
241
|
),
|
125
|
242
|
),
|