liuyuqi-dellpc 1 year ago
parent
commit
71f5a577b6
4 changed files with 53 additions and 7 deletions
  1. 1 1
      lib/pages/about_page.dart
  2. 2 3
      lib/pages/index_page.dart
  3. 50 2
      lib/pages/login_page.dart
  4. 0 1
      lib/routes.dart

+ 1 - 1
lib/pages/about_page.dart

@@ -15,7 +15,7 @@ class _AboutPageState extends State<AboutPage> {
   @override
   Widget build(BuildContext context) {
     return Container(
-       child: Text("xx"),
+       child: Text("About Me"),
     );
   }
 }

+ 2 - 3
lib/pages/index_page.dart

@@ -18,8 +18,7 @@ import '../store/game_state.dart';
 class IndexPage extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
-    //ScreenUtil 初始化实例
-    ScreenUtil.init(context, designSize: Size(360, 640)); // 竖屏
+    ScreenUtil.init(context, designSize: Size(360, 640));
 
     return StoreProvider(
       store: Store<GameState>(
@@ -64,4 +63,4 @@ class GameProps {
   bool started;
 
   GameProps({required this.started});
-}
+}

+ 50 - 2
lib/pages/login_page.dart

@@ -11,10 +11,58 @@ class LoginPage extends StatefulWidget {
 }
 
 class _LoginPageState extends State<LoginPage> {
+  TextEditingController userNameController = TextEditingController();
+  TextEditingController passwordController = TextEditingController();
+
   @override
   Widget build(BuildContext context) {
-    return Container(
-      child: Container(child: Text("xx")),
+    return Scaffold(
+      appBar: AppBar(
+        title: Text("登录"),
+        centerTitle: true,
+      ),
+      body: Container(
+        padding: EdgeInsets.all(20),
+        child: Column(
+          mainAxisAlignment: MainAxisAlignment.center,
+          children: [
+            TextFormField(
+              controller: userNameController,
+              decoration: InputDecoration(
+                labelText: "用户名",
+                hintText: "请输入用户名",
+                prefixIcon: Icon(Icons.person),
+              ),
+            ),
+            TextFormField(
+              controller: passwordController,
+              decoration: InputDecoration(
+                labelText: "密码",
+                hintText: "请输入密码",
+                prefixIcon: Icon(Icons.lock),
+              ),
+              validator: (value) {
+                if (value == null || value.isEmpty) {
+                  return "密码不能为空";
+                }
+                return null;
+              },
+            ),
+            SizedBox(height: 20),
+            ElevatedButton(
+              onPressed: () {
+                print("用户名:${userNameController.text}");
+                print("密码:${passwordController.text}");
+              },
+              child: Text("登录"),
+            ),
+          ],
+        ),
+      ),
     );
   }
+
+  void login() async {
+    // if form.validate()验证表单
+  }
 }

+ 0 - 1
lib/routes.dart

@@ -1,4 +1,3 @@
-import 'package:flutter/cupertino.dart';
 
 class Routes {
   static const ROOT = '/';