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
bb0767b2
Commit
bb0767b2
authored
Jul 09, 2021
by
laishanqi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
路由传值
parent
0c56b7ac
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
126 additions
and
58 deletions
+126
-58
AppColors.dart
netrain_flutter_app/lib/common/AppColors.dart
+10
-0
Images.dart
netrain_flutter_app/lib/common/Images.dart
+0
-0
dwMain.dart
netrain_flutter_app/lib/douwen/dwMain.dart
+1
-1
layout_page.dart
netrain_flutter_app/lib/laishanqi/layout_page.dart
+4
-2
HomePage.dart
netrain_flutter_app/lib/laishanqi/netrain/HomePage.dart
+1
-1
RegisterPage.dart
..._flutter_app/lib/laishanqi/netrain/user/RegisterPage.dart
+61
-21
loginPage.dart
...ain_flutter_app/lib/laishanqi/netrain/user/loginPage.dart
+16
-4
main.dart
netrain_flutter_app/lib/main.dart
+33
-29
No files found.
netrain_flutter_app/lib/common/AppColors.dart
0 → 100644
View file @
bb0767b2
/// 项目颜色配置
class
AppColors
{
/// 主色
static
const
mainColor
=
0xff2893FF
;
/// hint颜色
static
const
hintText
=
0xffb4b4b4
;
/// 输入框字体颜色
static
const
EditTextColor
=
0xff333333
;
}
\ No newline at end of file
netrain_flutter_app/lib/
laishanqi/netrai
n/Images.dart
→
netrain_flutter_app/lib/
commo
n/Images.dart
View file @
bb0767b2
File moved
netrain_flutter_app/lib/douwen/dwMain.dart
View file @
bb0767b2
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:fluttertoast/fluttertoast.dart'
;
import
'package:fluttertoast/fluttertoast.dart'
;
import
'package:netrain_flutter_app/
laishanqi/netrai
n/Images.dart'
;
import
'package:netrain_flutter_app/
commo
n/Images.dart'
;
import
'secondpage.dart'
;
import
'secondpage.dart'
;
...
...
netrain_flutter_app/lib/laishanqi/layout_page.dart
View file @
bb0767b2
...
@@ -42,9 +42,11 @@ class _LayoutGroupState extends State<LayoutPage> {
...
@@ -42,9 +42,11 @@ class _LayoutGroupState extends State<LayoutPage> {
blurRadius:
15
,
blurRadius:
15
,
spreadRadius:
-
5
)
spreadRadius:
-
5
)
]),
]),
child:
Rais
edButton
(
child:
Elevat
edButton
(
child:
Text
(
"按钮"
),
child:
Text
(
"按钮"
),
onPressed:
()
{},
onPressed:
()
{
Navigator
.
pushNamed
(
context
,
"register"
);
},
)),
)),
Container
(
Container
(
margin:
EdgeInsets
.
all
(
10
),
margin:
EdgeInsets
.
all
(
10
),
...
...
netrain_flutter_app/lib/laishanqi/netrain/HomePage.dart
View file @
bb0767b2
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'Images.dart'
;
import
'
../../common/
Images.dart'
;
class
HomePage
extends
StatefulWidget
{
class
HomePage
extends
StatefulWidget
{
@override
@override
...
...
netrain_flutter_app/lib/laishanqi/netrain/user/RegisterPage.dart
View file @
bb0767b2
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:netrain_flutter_app/common/AppColors.dart'
;
import
'package:netrain_flutter_app/douwen/dwMain.dart'
;
/**
/**
* 注册页
* 注册页
*/
*/
class
RegisterPage
extends
StatefulWidget
{
class
RegisterPage
extends
StatefulWidget
{
@override
@override
State
createState
()
=>
_RegisterState
();
State
createState
()
=>
_RegisterState
();
}
}
class
_RegisterState
extends
State
{
class
_RegisterState
extends
State
{
// 输入框控制器
final
nameController
=
TextEditingController
();
final
phoneController
=
TextEditingController
();
final
codeController
=
TextEditingController
();
final
passwordController
=
TextEditingController
();
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
// 获取上一个页面的传值
List
<
String
>
args
=
ModalRoute
.
of
(
context
).
settings
.
arguments
;
phoneController
.
text
=
args
.
first
;
return
registerWidget
();
return
registerWidget
();
}
}
Widget
registerWidget
()
{
@override
void
dispose
()
{
super
.
dispose
();
nameController
.
dispose
();
phoneController
.
dispose
();
codeController
.
dispose
();
passwordController
.
dispose
();
}
Widget
registerWidget
()
{
return
MaterialApp
(
return
MaterialApp
(
theme:
ThemeData
(
theme:
ThemeData
(
primaryColor:
Colors
.
white
,
primaryColor:
Colors
.
white
,
...
@@ -27,22 +46,43 @@ class _RegisterState extends State{
...
@@ -27,22 +46,43 @@ class _RegisterState extends State{
appBar:
AppBar
(
appBar:
AppBar
(
leading:
IconButton
(
leading:
IconButton
(
icon:
Icon
(
Icons
.
arrow_back
),
icon:
Icon
(
Icons
.
arrow_back
),
onPressed:
(){
onPressed:
()
{
Navigator
.
of
(
context
).
pushNamed
(
"/"
);
Navigator
.
of
(
context
).
popUntil
(
ModalRoute
.
withName
(
"main"
));
// Navigator.of(context).pushNamed("login2");
},
},
),
),
centerTitle:
true
,
centerTitle:
true
,
title:
Text
(
"注册"
),
title:
Text
(
"注册"
),
elevation:
0
,
elevation:
0
,
),
),
body:
ListView
(
body:
Container
(
margin:
EdgeInsets
.
fromLTRB
(
16
,
16
,
16
,
0
),
child:
ListView
(
children:
[
children:
[
_getTextField
(
"请输入姓名"
,
nameController
),
_getTextField
(
"请输入手机号码"
,
phoneController
),
Stack
(
children:
[
_getTextField
(
"请输入验证码"
,
codeController
),
// Positioned(child: )
],),
_getTextField
(
"请输入9-16位密码"
,
passwordController
),
],
],
),
),
),
)
),
);
);
}
}
/// 输入框
Widget
_getTextField
(
String
hintText
,
TextEditingController
controller
){
return
TextField
(
style:
TextStyle
(
color:
Color
(
AppColors
.
EditTextColor
),
fontSize:
16
),
decoration:
InputDecoration
(
hintText:
hintText
,
hintStyle:
TextStyle
(
color:
Color
(
AppColors
.
hintText
)),
),
controller:
controller
,
);
}
}
}
\ No newline at end of file
netrain_flutter_app/lib/laishanqi/netrain/user/loginPage.dart
View file @
bb0767b2
...
@@ -6,7 +6,7 @@ import 'package:netrain_flutter_app/laishanqi/netrain/Http/HttpUtil.dart';
...
@@ -6,7 +6,7 @@ import 'package:netrain_flutter_app/laishanqi/netrain/Http/HttpUtil.dart';
import
'package:netrain_flutter_app/laishanqi/netrain/user/RegisterPage.dart'
;
import
'package:netrain_flutter_app/laishanqi/netrain/user/RegisterPage.dart'
;
import
'../HomePage.dart'
;
import
'../HomePage.dart'
;
import
'../Images.dart'
;
import
'../
../../common/
Images.dart'
;
/// 登录页
/// 登录页
class
LoginPage
extends
StatefulWidget
{
class
LoginPage
extends
StatefulWidget
{
...
@@ -22,10 +22,11 @@ class _LoginState extends State<LoginPage> {
...
@@ -22,10 +22,11 @@ class _LoginState extends State<LoginPage> {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
print
(
"loginPage.dart initState"
);
var
mqtt
=
MqttClient
();
var
mqtt
=
MqttClient
();
mqtt
.
connect
();
mqtt
.
connect
();
HttpUtil
.
get
(
HttpUtil
.
global_config
).
then
((
Response
value
)
{
HttpUtil
.
get
(
HttpUtil
.
global_config
).
then
((
Response
value
)
{
Fluttertoast
.
showToast
(
msg:
"global_config 请求成功 "
);
Fluttertoast
.
showToast
(
msg:
"global_config 请求成功 "
);
});
});
...
@@ -107,7 +108,9 @@ class _LoginState extends State<LoginPage> {
...
@@ -107,7 +108,9 @@ class _LoginState extends State<LoginPage> {
children:
[
children:
[
MaterialButton
(
MaterialButton
(
onPressed:
()
{
onPressed:
()
{
Navigator
.
pushNamed
(
context
,
"register"
);
// 跳转到注册页,把手机号传递过去
Navigator
.
pushNamed
(
context
,
"register"
,
arguments:
[
phoneController
.
text
]);
// Navigator.push(context,MaterialPageRoute(builder: (context) => RegisterPage()));
// Navigator.push(context,MaterialPageRoute(builder: (context) => RegisterPage()));
},
},
child:
Text
(
child:
Text
(
...
@@ -116,7 +119,16 @@ class _LoginState extends State<LoginPage> {
...
@@ -116,7 +119,16 @@ class _LoginState extends State<LoginPage> {
),
),
),
),
Text
(
" | "
,
style:
TextStyle
(
color:
Colors
.
blue
)),
Text
(
" | "
,
style:
TextStyle
(
color:
Colors
.
blue
)),
Text
(
"忘记密码"
,
style:
TextStyle
(
color:
Colors
.
blue
))
MaterialButton
(
onPressed:
()
{
Navigator
.
pushNamed
(
context
,
"layout"
);
// Navigator.push(context,MaterialPageRoute(builder: (context) => RegisterPage()));
},
child:
Text
(
"忘记密码"
,
style:
TextStyle
(
color:
Colors
.
blue
),
),
),
],
],
),
),
),
),
...
...
netrain_flutter_app/lib/main.dart
View file @
bb0767b2
...
@@ -22,34 +22,39 @@ class MyApp extends StatelessWidget {
...
@@ -22,34 +22,39 @@ class MyApp extends StatelessWidget {
// This widget is the root of your application.
// This widget is the root of your application.
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
WillPopScope
(
child:
MaterialApp
(
return
WillPopScope
(
child:
MaterialApp
(
title:
'Flutter Demo'
,
title:
'Flutter Demo'
,
initialRoute:
"/
"
,
initialRoute:
"main
"
,
theme:
ThemeData
(
theme:
ThemeData
(
primarySwatch:
Colors
.
blue
,
primarySwatch:
Colors
.
blue
,
visualDensity:
VisualDensity
.
adaptivePlatformDensity
,
visualDensity:
VisualDensity
.
adaptivePlatformDensity
,
),
),
home:
Scaffold
(
appBar:
AppBar
(
title:
Text
(
"路由"
),
),
body:
RouterNavigator
(
title:
'Flutter Demo Home Page'
),
),
routes:
<
String
,
WidgetBuilder
>{
routes:
<
String
,
WidgetBuilder
>{
"less"
:
(
context
)
=>
LessGroupPage
(),
"less"
:
(
context
)
=>
LessGroupPage
(),
"ful"
:
(
context
)
=>
FulGroupPage
(),
"ful"
:
(
context
)
=>
FulGroupPage
(),
"layout"
:
(
context
)
=>
LayoutPage
(),
"layout"
:
(
context
)
=>
LayoutPage
(),
"photo"
:
(
context
)
=>
PhotoApp
(),
"photo"
:
(
context
)
=>
PhotoApp
(),
"register"
:
(
context
)
=>
RegisterPage
(),
"register"
:
(
context
)
=>
RegisterPage
(),
"login"
:
(
context
)
=>
LoginPage
(),
"listPage"
:(
context
)
=>
List_Page
(),
"listPage"
:(
context
)
=>
List_Page
(),
"main"
:
(
context
)
=>
mainPage
(),
},
},
),
onWillPop:
()
async
{
),
onWillPop:
()
async
{
Fluttertoast
.
showToast
(
msg:
"退出"
);
Fluttertoast
.
showToast
(
msg:
"退出"
);
return
true
;
return
true
;
});
});
}
}
}
Widget
mainPage
(
){
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
"路由"
),
),
body:
RouterNavigator
(
title:
'Flutter Demo Home Page'
),
);
}
}
class
RouterNavigator
extends
StatefulWidget
{
class
RouterNavigator
extends
StatefulWidget
{
...
@@ -61,7 +66,7 @@ class RouterNavigator extends StatefulWidget {
...
@@ -61,7 +66,7 @@ class RouterNavigator extends StatefulWidget {
}
}
class
_RouterNavigatorState
extends
State
<
RouterNavigator
>
{
class
_RouterNavigatorState
extends
State
<
RouterNavigator
>
{
bool
byName
=
fals
e
;
bool
byName
=
tru
e
;
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
...
@@ -90,13 +95,12 @@ class _RouterNavigatorState extends State<RouterNavigator> {
...
@@ -90,13 +95,12 @@ class _RouterNavigatorState extends State<RouterNavigator> {
_item
(
String
title
,
page
,
String
routeName
)
{
_item
(
String
title
,
page
,
String
routeName
)
{
return
Container
(
return
Container
(
child:
Rais
edButton
(
child:
Elevat
edButton
(
onPressed:
()
{
onPressed:
()
{
if
(
byName
)
{
if
(
byName
)
{
Navigator
.
pushNamed
(
context
,
routeName
);
Navigator
.
pushNamed
(
context
,
routeName
);
}
else
{
}
else
{
Navigator
.
push
(
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
page
,));
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
page
));
}
}
},
},
child:
Text
(
title
),
child:
Text
(
title
),
...
...
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