liuyuqi-dellpc 1 year ago
parent
commit
28dcdff558
6 changed files with 77 additions and 8 deletions
  1. 2 1
      lib/main.dart
  2. 26 2
      lib/models/config.dart
  3. 17 0
      lib/pages/profile_page.dart
  4. 1 3
      lib/pages/splash_page.dart
  5. 29 0
      lib/routes.dart
  6. 2 2
      pubspec.yaml

+ 2 - 1
lib/main.dart

@@ -1,8 +1,9 @@
 import 'package:flutter/material.dart';
+import 'package:hmssdk_demo/models/config.dart';
 import 'package:hmssdk_demo/pages/home_page.dart';
 
 void main() {
-  runApp(const MyApp());
+  Config.init(() => runApp(const MyApp()));
 }
 
 class MyApp extends StatelessWidget {

+ 26 - 2
lib/models/config.dart

@@ -1,3 +1,27 @@
+import 'dart:io';
+
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+
 class Config {
-  
-}
+  static String cachePath = "";
+
+  static Future<void> init(Function() runApp) async {
+    WidgetsFlutterBinding.ensureInitialized();
+    // cachePath= await getApplicationDocumentsDirectory().then((value) => value.path);
+    // await SpUtil.getInstance();
+
+    runApp();
+
+    SystemChrome.setPreferredOrientations(
+        [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);
+
+    // 状态栏透明(Android)
+    var brightness = Platform.isAndroid ? Brightness.dark : Brightness.light;
+    SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
+      statusBarColor: Colors.transparent,
+      statusBarBrightness: brightness,
+      statusBarIconBrightness: brightness,
+    ));
+  }
+}

+ 17 - 0
lib/pages/profile_page.dart

@@ -0,0 +1,17 @@
+import 'package:flutter/material.dart';
+/// Description:  proifle page
+/// Time       : 08/09/2023 Wednesday
+/// Author     : liuyuqi.gov@msn.cn
+class ProfilePage extends StatefulWidget {
+  const ProfilePage({super.key});
+
+  @override
+  State<ProfilePage> createState() => _ProfilePageState();
+}
+
+class _ProfilePageState extends State<ProfilePage> {
+  @override
+  Widget build(BuildContext context) {
+    return Scaffold();
+  }
+}

+ 1 - 3
lib/pages/splash_page.dart

@@ -15,6 +15,4 @@ class _SplashPageState extends State<SplashPage> {
   Widget build(BuildContext context) {
     return Scaffold();
   }
-
-  
-}
+}

+ 29 - 0
lib/routes.dart

@@ -1,3 +1,32 @@
+import 'package:flutter/material.dart';
+import 'package:hmssdk_demo/pages/home_page.dart';
+import 'package:hmssdk_demo/pages/login_page.dart';
+import 'package:hmssdk_demo/pages/profile_page.dart';
+
+/// Description: routes
+/// Time       : 08/09/2023 Wednesday
+/// Author     : liuyuqi.gov@msn.cn
 class Routes {
   static const String home = "/home";
+  static const String login = "/login";
+  static const String register = "/register";
+  static const String profile = "/profile";
+  static const String editProfile = "/editProfile";
+
+  static onGenerateRoute(RouteSettings settings) {
+    switch (settings.name) {
+      case home:
+        return MaterialPageRoute(builder: (_) => HomePage());
+      case login:
+        return MaterialPageRoute(builder: (_) => LoginPage());
+      // case register:
+      //   return MaterialPageRoute(builder: (_) => Register());
+      case profile:
+        return MaterialPageRoute(builder: (_) => ProfilePage());
+      // case editProfile:
+      //   return MaterialPageRoute(builder: (_) => EditProfile());
+      default:
+        return MaterialPageRoute(builder: (_) => HomePage());
+    }
+  }
 }

+ 2 - 2
pubspec.yaml

@@ -10,8 +10,8 @@ dependencies:
   flutter:
     sdk: flutter
   cupertino_icons: ^1.0.5
-  hmssdk_flutter:
-    path: ../
+  # hmssdk_flutter:
+  #   path: ../
     
   # provider:
   # http: