Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
N
netrain_flutter_app
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
邹志胜
netrain_flutter_app
Commits
713d82dd
Commit
713d82dd
authored
Jul 13, 2021
by
laishanqi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
注册页输入框换成TextFormField
parent
ec19dac5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
53 deletions
+97
-53
DoctorHomePage.dart
...ain_flutter_app/lib/laishanqi/netrain/DoctorHomePage.dart
+25
-0
RegisterPage.dart
..._flutter_app/lib/laishanqi/netrain/user/RegisterPage.dart
+72
-53
No files found.
netrain_flutter_app/lib/laishanqi/netrain/DoctorHomePage.dart
0 → 100644
View file @
713d82dd
import
'package:flutter/material.dart'
;
class
DoctorHomePage
extends
StatefulWidget
{
@override
_DoctorHomePageState
createState
()
=>
_DoctorHomePageState
();
}
class
_DoctorHomePageState
extends
State
<
DoctorHomePage
>{
@override
void
initState
()
{
super
.
initState
();
}
@override
void
dispose
()
{
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
Container
();
}
}
netrain_flutter_app/lib/laishanqi/netrain/user/RegisterPage.dart
View file @
713d82dd
...
...
@@ -18,12 +18,13 @@ class _RegisterState extends State {
final
passwordController
=
TextEditingController
();
var
isShowPassword
=
false
;
var
isShowClean
=
false
;
final
GlobalKey
<
FormState
>
_formKey
=
GlobalKey
();
@override
void
initState
()
{
super
.
initState
();
nameController
.
addListener
(()
{
/*
nameController.addListener(() {
setState(() {});
});
phoneController.addListener(() {
...
...
@@ -31,7 +32,7 @@ class _RegisterState extends State {
});
codeController.addListener(() {
setState(() {});
});
});
*/
passwordController
.
addListener
(()
{
print
(
"密码
${passwordController.text}
"
);
setState
(()
{
...
...
@@ -70,52 +71,61 @@ class _RegisterState extends State {
),
body:
Container
(
margin:
EdgeInsets
.
fromLTRB
(
16
,
0
,
16
,
0
),
child:
ListView
(
children:
[
_getTextField
(
TextInputType
.
text
,
"请输入姓名"
,
nameController
,
10
,
false
),
_getTextField
(
TextInputType
.
number
,
"请输入手机号码"
,
phoneController
,
11
,
false
),
Stack
(
child:
Form
(
key:
_formKey
,
child:
ListView
(
children:
[
_getTextField
(
TextInputType
.
number
,
"请输入验证码"
,
codeController
,
8
,
false
),
Positioned
(
child:
Text
(
"获取验证码"
),
right:
16
,
top:
20
,
)
],
),
_getPassWordField
(),
Text
(
"密码由9-16位大小写字母、数字加特殊符号组成"
,
style:
_getTextField
(
TextInputType
.
text
,
"请输入姓名"
,
nameController
,
10
,
false
),
_getTextField
(
TextInputType
.
number
,
"请输入手机号码"
,
phoneController
,
11
,
false
),
Stack
(
children:
[
_getTextField
(
TextInputType
.
number
,
"请输入验证码"
,
codeController
,
8
,
false
),
Positioned
(
child:
Text
(
"获取验证码"
),
right:
16
,
top:
20
,
)
],
),
_getPassWordField
(),
Text
(
"密码由9-16位大小写字母、数字加特殊符号组成"
,
style:
TextStyle
(
color:
Color
(
AppColors
.
mainColor
),
fontSize:
12
),
),
Container
(
margin:
EdgeInsets
.
only
(
top:
20
),
height:
40
,
child:
ElevatedButton
(
style:
ButtonStyle
(
backgroundColor:
),
Container
(
margin:
EdgeInsets
.
only
(
top:
20
),
height:
40
,
child:
ElevatedButton
(
style:
ButtonStyle
(
backgroundColor:
MaterialStateProperty
.
resolveWith
((
states
)
{
if
(
states
.
contains
(
MaterialState
.
disabled
))
{
return
Color
(
AppColors
.
disabledColor
);
}
return
Color
(
AppColors
.
mainColor
);
}),
),
child:
Text
(
"注册"
,
style:
TextStyle
(
color:
Colors
.
white
),
),
onPressed:
checkIsAllEmpty
()
?
null
:
onRegisterClick
),
)
],
)),
if
(
states
.
contains
(
MaterialState
.
disabled
))
{
return
Color
(
AppColors
.
disabledColor
);
}
return
Color
(
AppColors
.
mainColor
);
}),
),
child:
Text
(
"注册"
,
style:
TextStyle
(
color:
Colors
.
white
),
),
onPressed
:
onRegisterClick
),
)
],
)
)),
);
}
onRegisterClick
()
{
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
Text
(
"注册"
)));
if
(
_formKey
.
currentState
.
validate
()){
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
Text
(
"请求注册"
)));
}
}
/// 校验是否全部为空
...
...
@@ -130,8 +140,8 @@ class _RegisterState extends State {
}
Widget
_getPassWordField
()
{
TextF
ield
password
=
_getTextField
(
TextInputType
.
number
,
"请输入9-16位密码"
,
passwordController
,
16
,
isShowPassword
);
TextF
ormField
password
=
_getTextField
(
TextInputType
.
number
,
"请输入9-16位密码"
,
passwordController
,
16
,
isShowPassword
);
return
Stack
(
children:
[
password
,
...
...
@@ -159,7 +169,8 @@ class _RegisterState extends State {
:
Icon
(
Icons
.
visibility
),
onPressed:
()
{
setState
(()
{
isShowPassword
=
!
password
.
obscureText
;
isShowPassword
=
!
isShowPassword
;
// isShowPassword = !password.obscureText;
});
},
))),
...
...
@@ -168,29 +179,37 @@ class _RegisterState extends State {
}
/// 输入框
Widget
_getTextField
(
TextInputType
keyboardType
,
String
hintText
,
TextEditingController
controller
,
int
maxLength
,
bool
isPassword
)
{
return
TextField
(
Widget
_getTextField
(
TextInputType
keyboardType
,
String
hintText
,
TextEditingController
controller
,
int
maxLength
,
bool
isPassword
)
{
return
TextFormField
(
validator:
(
value
)
{
if
(
value
.
isEmpty
){
return
"
${hintText}
不能为空"
;
}
else
{
return
null
;
}
},
keyboardType:
keyboardType
,
obscureText:
isPassword
,
buildCounter:
(
context
,
{
currentLength
,
isFocused
,
maxLength
})
=>
null
,
maxLength:
maxLength
,
autofocus:
false
,
// 自动获取焦点
autofocus:
false
,
// 自动获取焦点
decoration:
InputDecoration
(
labelStyle:
TextStyle
(
height:
0.5
),
//装饰
alignLabelWithHint:
true
,
contentPadding:
EdgeInsets
.
only
(
top:
20
,
bottom:
10
),
enabledBorder:
UnderlineInputBorder
(
// 默认输入
状态的下划线边框
// 默认
状态的下划线边框
borderSide:
BorderSide
(
color:
Color
(
AppColors
.
dividerColor
),
width:
0.5
)),
BorderSide
(
color:
Color
(
AppColors
.
dividerColor
),
width:
0.5
)),
focusedBorder:
UnderlineInputBorder
(
//
获取焦点后
// 输入框
获取焦点后
borderSide:
BorderSide
(
color:
Color
(
AppColors
.
mainColor
),
width:
0.5
)),
BorderSide
(
color:
Color
(
AppColors
.
mainColor
),
width:
0.5
)),
errorBorder:
UnderlineInputBorder
(
// 错误的时候
// 错误的时候
borderSide:
BorderSide
(
color:
Colors
.
red
,
width:
0.5
)),
hintText:
hintText
,
// labelText: hintText.substring(3)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment