Commit 8d709232 authored by “Icebear”'s avatar “Icebear”
parents 35e87f95 bb0767b2
/// 项目颜色配置
class AppColors{
/// 主色
static const mainColor = 0xff2893FF;
/// hint颜色
static const hintText = 0xffb4b4b4;
/// 输入框字体颜色
static const EditTextColor = 0xff333333;
}
\ No newline at end of file
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/netrain/Images.dart'; import 'package:netrain_flutter_app/common/Images.dart';
import 'secondpage.dart'; import 'secondpage.dart';
......
...@@ -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: RaisedButton( child: ElevatedButton(
child: Text("按钮"), child: Text("按钮"),
onPressed: () {}, onPressed: () {
Navigator.pushNamed(context, "register");
},
)), )),
Container( Container(
margin: EdgeInsets.all(10), margin: EdgeInsets.all(10),
......
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
......
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,
), ),
home: Scaffold( home: Scaffold(
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,
title: Text("注册"),
elevation: 0,
), ),
centerTitle: true, body: Container(
title: Text("注册"), margin: EdgeInsets.fromLTRB(16, 16, 16, 0),
elevation: 0, child: ListView(
), children: [
body: ListView( _getTextField("请输入姓名",nameController),
children: [ _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
...@@ -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),
),
),
], ],
), ),
), ),
......
...@@ -24,34 +24,39 @@ class MyApp extends StatelessWidget { ...@@ -24,34 +24,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(
title: 'Flutter Demo', child: MaterialApp(
initialRoute: "/", title: 'Flutter Demo',
theme: ThemeData( initialRoute: "main",
primarySwatch: Colors.blue, theme: ThemeData(
visualDensity: VisualDensity.adaptivePlatformDensity, primarySwatch: Colors.blue,
), visualDensity: VisualDensity.adaptivePlatformDensity,
home: Scaffold(
appBar: AppBar(
title: Text("路由"),
), ),
body: RouterNavigator(title: 'Flutter Demo Home Page'), routes: <String, WidgetBuilder>{
"less": (context) => LessGroupPage(),
"ful": (context) => FulGroupPage(),
"layout": (context) => LayoutPage(),
"photo": (context) => PhotoApp(),
"register": (context) => RegisterPage(),
"login": (context) => LoginPage(),
"listPage":(context) => List_Page(),
"main": (context) => mainPage(),
},
), ),
routes: <String, WidgetBuilder>{ onWillPop: () async {
"less": (context) => LessGroupPage(), Fluttertoast.showToast(msg: "退出");
"ful": (context) => FulGroupPage(), return true;
"layout": (context) => LayoutPage(), });
"photo": (context) => PhotoApp(),
"register": (context) => RegisterPage(),
"listPage":(context) => List_Page(),
},
), onWillPop: ()async{
Fluttertoast.showToast(msg: "退出");
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 {
...@@ -63,7 +68,7 @@ class RouterNavigator extends StatefulWidget { ...@@ -63,7 +68,7 @@ class RouterNavigator extends StatefulWidget {
} }
class _RouterNavigatorState extends State<RouterNavigator> { class _RouterNavigatorState extends State<RouterNavigator> {
bool byName = false; bool byName = true;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -92,13 +97,12 @@ class _RouterNavigatorState extends State<RouterNavigator> { ...@@ -92,13 +97,12 @@ class _RouterNavigatorState extends State<RouterNavigator> {
_item(String title, page, String routeName) { _item(String title, page, String routeName) {
return Container( return Container(
child: RaisedButton( child: ElevatedButton(
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),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment