alroyso 1 year ago
parent
commit
a4f3d8e443

+ 12 - 0
lib/app/modules/home/bindings/home_binding.dart

@@ -0,0 +1,12 @@
+import 'package:get/get.dart';
+
+import '../controllers/home_controller.dart';
+
+class HomeBinding extends Bindings {
+  @override
+  void dependencies() {
+    Get.lazyPut<HomeController>(
+      () => HomeController(),
+    );
+  }
+}

+ 23 - 0
lib/app/modules/home/controllers/home_controller.dart

@@ -0,0 +1,23 @@
+import 'package:get/get.dart';
+
+class HomeController extends GetxController {
+  //TODO: Implement HomeController
+
+  final count = 0.obs;
+  @override
+  void onInit() {
+    super.onInit();
+  }
+
+  @override
+  void onReady() {
+    super.onReady();
+  }
+
+  @override
+  void onClose() {
+    super.onClose();
+  }
+
+  void increment() => count.value++;
+}

+ 104 - 0
lib/app/modules/home/views/home_view.dart

@@ -0,0 +1,104 @@
+import 'dart:io';
+
+import 'package:flutter/foundation.dart';
+import 'package:flutter/material.dart';
+
+import 'package:get/get.dart';
+import 'package:window_manager/window_manager.dart';
+
+import '../controllers/home_controller.dart';
+
+class HomeView extends GetView<HomeController> {
+  const HomeView({Key? key}) : super(key: key);
+  @override
+  Widget build(BuildContext context) {
+    final _usernameController = TextEditingController();
+    final _passwordController = TextEditingController();
+    return Container(
+      decoration: const BoxDecoration(
+        image: DecorationImage(
+          image: AssetImage("images/login/login.png"),
+          fit: BoxFit.fill,
+        ),
+      ),
+      child: Scaffold(
+        backgroundColor: Colors.transparent,
+        appBar: PreferredSize(
+          preferredSize: const Size.fromHeight(64),
+          child: GestureDetector(
+            behavior: HitTestBehavior.translucent,
+            onPanStart: (details) {
+              if (Platform.isWindows || Platform.isMacOS) windowManager.startDragging();
+            },
+            onDoubleTap: () {}, //双击不实现任何
+            child: AppBar(
+              elevation: 0.0,
+              backgroundColor: Colors.transparent,
+              title: const Text(""),
+              centerTitle: false,
+            ),
+          ),
+        ),
+
+        body:
+        ListView(
+          children: [
+            Container(
+              color: Colors.transparent, // 这里设置背景颜色
+              child: const SizedBox(
+                width: 375,
+                height: 200.0,
+                child: Center(
+                  child: Text(""),
+                ),
+              ),
+            ),
+
+            Padding(
+              padding: const EdgeInsets.fromLTRB(55, 0, 20, 0),
+              child: TextField(
+                controller: _usernameController,
+                decoration: const InputDecoration(
+                  labelText: '用户名',
+                  hintText: '请输入用户名',
+                  border: InputBorder.none,
+                ),
+              ),
+            ),
+            const SizedBox(height: 6.5), // 添加一些间距
+            Padding(
+              padding: const EdgeInsets.fromLTRB(55, 0, 20, 0),
+              child: TextField(
+                controller: _passwordController,
+                decoration: const InputDecoration(
+                  labelText: '密码',
+                  hintText: '请输入密码',
+                  border: InputBorder.none,
+                ),
+                obscureText: true,
+              ),
+            ),
+            const SizedBox(height: 20,),
+            Padding(
+              padding: const EdgeInsets.fromLTRB(55, 0, 55, 0),
+              child: SizedBox(
+                  width: 150,
+                  height: 40,
+                  child: ElevatedButton(onPressed: (){
+                    if (kDebugMode) {
+                      print(_usernameController.text);
+                    }
+                    if (kDebugMode) {
+                      print(_passwordController.text);
+                    }
+                    //Modular.to.navigate("/home/main");
+                  }, child: const Text("登录"))
+              ),
+            )
+          ],
+        ),
+
+      ),
+    );
+  }
+}

+ 20 - 0
lib/app/routes/app_pages.dart

@@ -0,0 +1,20 @@
+import 'package:get/get.dart';
+
+import '../modules/home/bindings/home_binding.dart';
+import '../modules/home/views/home_view.dart';
+
+part 'app_routes.dart';
+
+class AppPages {
+  AppPages._();
+
+  static const INITIAL = Routes.HOME;
+
+  static final routes = [
+    GetPage(
+      name: _Paths.HOME,
+      page: () => const HomeView(),
+      binding: HomeBinding(),
+    ),
+  ];
+}

+ 12 - 0
lib/app/routes/app_routes.dart

@@ -0,0 +1,12 @@
+part of 'app_pages.dart';
+// DO NOT EDIT. This is code generated via package:get_cli/get_cli.dart
+
+abstract class Routes {
+  Routes._();
+  static const HOME = _Paths.HOME;
+}
+
+abstract class _Paths {
+  _Paths._();
+  static const HOME = '/home';
+}

+ 21 - 1
lib/main.dart

@@ -1,10 +1,30 @@
 import 'package:flutter/material.dart';
 
 import 'package:get/get.dart';
+import 'package:window_manager/window_manager.dart';
 
 import 'app/routes/app_pages.dart';
 
-void main() {
+void main() async {
+  const width = 375.0;
+  const height = 680.0;
+  WidgetsFlutterBinding.ensureInitialized();
+  await windowManager.ensureInitialized();
+  WindowOptions windowOptions = const WindowOptions(
+    minimumSize: Size(width, height),
+    maximumSize: Size(width, height),
+    size: Size(width, height),
+    center: true,
+    backgroundColor: Colors.transparent,
+    skipTaskbar: false,
+    titleBarStyle: TitleBarStyle.hidden,
+  );
+
+  await windowManager.waitUntilReadyToShow(windowOptions, () async {
+    await windowManager.show();
+    await windowManager.focus();
+  });
+
   runApp(
     GetMaterialApp(
       title: "Application",