alroyso 1 年之前
父節點
當前提交
f9493835f2

+ 35 - 0
lib/app/component/sys_app_bar.dart

@@ -0,0 +1,35 @@
+import 'dart:io';
+import 'package:flutter/material.dart';
+import 'package:window_manager/window_manager.dart';
+
+class SysAppBar extends StatelessWidget implements PreferredSizeWidget {
+  final double? toolbarHeight;
+
+  final Widget? title;
+
+  final List<Widget>? actions;
+
+  const SysAppBar({Key? key, this.toolbarHeight, this.title, this.actions}) : super(key: key);
+
+  @override
+  Widget build(BuildContext context) {
+    List<Widget> acs = [];
+    if (actions != null) {
+      acs.addAll(actions!);
+    }
+    if (Platform.isWindows || Platform.isLinux) {
+      acs.add(CloseButton(onPressed: () => windowManager.close()));
+    }
+    return GestureDetector(
+      onPanStart: (_) => windowManager.startDragging(),
+      child: AppBar(
+        toolbarHeight: preferredSize.height,
+        title: title,
+        actions: acs,
+      ),
+    );
+  }
+
+  @override
+  Size get preferredSize => Size.fromHeight(toolbarHeight ?? kToolbarHeight);
+}

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

@@ -1,3 +1,4 @@
+import 'package:flutter/cupertino.dart';
 import 'package:get/get.dart';
 
 class HomeController extends GetxController {
@@ -6,6 +7,9 @@ class HomeController extends GetxController {
   final count = 0.obs;
   @override
   void onInit() {
+
+
+
     super.onInit();
   }
 

+ 5 - 75
lib/app/modules/home/views/home_view.dart

@@ -4,6 +4,7 @@ import 'package:flutter/foundation.dart';
 import 'package:flutter/material.dart';
 
 import 'package:get/get.dart';
+import 'package:naiyouwl/app/component/sys_app_bar.dart';
 import 'package:window_manager/window_manager.dart';
 
 import '../controllers/home_controller.dart';
@@ -12,6 +13,7 @@ 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(
@@ -21,83 +23,11 @@ class HomeView extends GetView<HomeController> {
           fit: BoxFit.fill,
         ),
       ),
-      child: Scaffold(
+      child: const 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("登录"))
-              ),
-            )
-          ],
-        ),
+        appBar: SysAppBar(title: Text("首页"),),
 
+        body: Text("111111"),
       ),
     );
   }

+ 1 - 1
lib/main.dart

@@ -17,7 +17,7 @@ void main() async {
     center: true,
     backgroundColor: Colors.transparent,
     skipTaskbar: false,
-    titleBarStyle: TitleBarStyle.normal,
+    titleBarStyle: TitleBarStyle.hidden,
   );
 
   await windowManager.waitUntilReadyToShow(windowOptions, () async {