liuyuqi-dellpc 1 year ago
parent
commit
55fbc74635

+ 0 - 4
README.md

@@ -17,7 +17,3 @@
 * [Flutter从头到尾设计一款简单的五子棋游戏(五) | UI代码](https://juejin.cn/post/7179611086872641597)
 
 有任何的问题欢迎提issue。
-
-# 结语
-
-由于这份代码已经是2022年初的东西了,那会写Flutter还不是很规范,因此会有挺多的问题。欢迎大家提出指证,或者提pull request。

+ 1 - 2
lib/main.dart

@@ -1,9 +1,8 @@
-import 'dart:io';
 
 import 'package:flutter/material.dart';
 import 'package:flutter/services.dart';
 
-import 'home_page.dart';
+import 'pages/home_page.dart';
 
 void main() {
   WidgetsFlutterBinding.ensureInitialized();

+ 19 - 0
lib/model/config.dart

@@ -0,0 +1,19 @@
+
+/// Description: global config
+/// Time       : 02/20/2024 Tuesday
+/// Author     : liuyuqi.gov@msn.cn
+class Config {
+  static const String appName = 'Flutter App';
+  static const String version = '1.0.0';
+  static const int versionCode = 211;
+  static const bool debug = true;
+
+  // dev
+  static const String baseUrl = 'https://api.github.com/';
+
+  static const double dessignWidth = 375.0;
+  static const double dessignHeight = 1335.0;
+
+
+
+}

+ 3 - 0
lib/pages/about_page.dart

@@ -2,6 +2,9 @@ import 'package:flutter/src/foundation/key.dart';
 import 'package:flutter/src/widgets/framework.dart';
 import 'package:flutter/src/widgets/placeholder.dart';
 
+/// Description: about page
+/// Time       : 02/20/2024 Tuesday
+/// Author     : liuyuqi.gov@msn.cn
 class AboutPage extends StatefulWidget {
   const AboutPage({Key? key}) : super(key: key);
 

+ 5 - 6
lib/home_page.dart → lib/pages/home_page.dart

@@ -9,10 +9,10 @@ import 'package:gobang/memorandum/Checkerboard.dart';
 import 'package:gobang/utils/TipsDialog.dart';
 import 'package:gobang/viewModel/GameViewModel.dart';
 
-import 'bridge/CircleShape.dart';
-import 'factory/BlackThemeFactory.dart';
-import 'factory/BlueThemeFactory.dart';
-import 'flyweight/Position.dart';
+import '../bridge/CircleShape.dart';
+import '../factory/BlackThemeFactory.dart';
+import '../factory/BlueThemeFactory.dart';
+import '../flyweight/Position.dart';
 
 var width = 0.0;
 
@@ -286,7 +286,7 @@ class ChessPainter extends CustomPainter {
         }
       }
     }
-    WidgetsBinding.instance!.addPostFrameCallback((_) {
+    WidgetsBinding.instance.addPostFrameCallback((_) {
       if (add && _position!.chess is WhiteChess) {
         _function();
       }
@@ -302,7 +302,6 @@ class ChessPainter extends CustomPainter {
 
 class CheckerBoardPainter extends CustomPainter {
   static List<CrossOverBean> _crossOverBeanList = [];
-  static int _state = 0;
 
   @override
   void paint(Canvas canvas, Size size) {

+ 3 - 0
lib/pages/login_page.dart

@@ -2,6 +2,9 @@ import 'package:flutter/src/foundation/key.dart';
 import 'package:flutter/src/widgets/framework.dart';
 import 'package:flutter/src/widgets/placeholder.dart';
 
+/// Description: login page
+/// Time       : 02/20/2024 Tuesday
+/// Author     : liuyuqi.gov@msn.cn
 class LoginPage extends StatefulWidget {
   const LoginPage({Key? key}) : super(key: key);
 

+ 3 - 0
lib/pages/register_page.dart

@@ -2,6 +2,9 @@ import 'package:flutter/src/foundation/key.dart';
 import 'package:flutter/src/widgets/framework.dart';
 import 'package:flutter/src/widgets/placeholder.dart';
 
+/// Description: register page
+/// Time       : 02/20/2024 Tuesday
+/// Author     : liuyuqi.gov@msn.cn
 class RegisgerPage extends StatefulWidget {
   const RegisgerPage({Key? key}) : super(key: key);
 

+ 3 - 0
lib/pages/splash_page.dart

@@ -1,6 +1,9 @@
 import 'package:flutter/src/widgets/framework.dart';
 import 'package:flutter/src/widgets/placeholder.dart';
 
+/// Description: splash page
+/// Time       : 02/20/2024 Tuesday
+/// Author     : liuyuqi.gov@msn.cn
 class SpalshPage extends StatefulWidget {
   const SpalshPage({Key? key}) : super(key: key);
 

+ 33 - 0
lib/service/user_dao.dart

@@ -0,0 +1,33 @@
+/// Description: user dao
+/// Time       : 02/20/2024 Tuesday
+/// Author     : liuyuqi.gov@msn.cn
+class UserDao {
+  /// login
+  /// @param username
+  /// @param password
+  /// @return Future<String> 
+  static Future<String> login(String username, String password) async {
+    await Future.delayed(Duration(seconds: 2));
+    if (username == 'admin' && password == 'admin') {
+      return 'token';
+    } else {
+      throw Exception('username or password is incorrect');
+    }
+  }
+
+  /// logout
+  static Future<bool> logout() async {
+    await Future.delayed(Duration(seconds: 2));
+    return true;
+  }
+
+  /// register
+  /// @param username
+  /// @param password
+  /// @return Future<String> 
+  static Future<String> register(String username, String password) async {
+    await Future.delayed(Duration(seconds: 2));
+    return 'success';
+  }
+
+}

+ 14 - 0
lib/utils/str_util.dart

@@ -0,0 +1,14 @@
+/// Description: string util
+/// Time       : 02/20/2024 Tuesday
+/// Author     : liuyuqi.gov@msn.cn
+class StrUtil {
+
+  /// is email
+  /// @param value
+  /// @return bool
+  static bool isEmail(String value) {
+    return RegExp(r'^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$')
+        .hasMatch(value);
+  }
+  
+}

+ 2 - 1
pubspec.yaml

@@ -8,7 +8,8 @@ environment:
 dependencies:
   flutter:
     sdk: flutter
-  cupertino_icons: ^1.0.2
+  cupertino_icons: ^1.0.5
+
 dev_dependencies:
   flutter_test:
     sdk: flutter