Browse Source

顶部状态栏

Melon 1 year ago
parent
commit
59445d3006

+ 9 - 5
lib/pages/help/help_dialog.dart

@@ -15,10 +15,14 @@ class HelpDialog extends StatefulWidget {
   static void show() {
     Get.dialog(
       const VAlertDialog(
-        width: 600,
-        title: "帮助",
-        showCancel: false,
-        content: HelpDialog(),
+        width: 520,
+        title: "帮助中心",
+        contentPadding: EdgeInsets.symmetric(horizontal: 24),
+        content: SizedBox(
+          height: 280,
+          child: HelpDialog(),
+        ),
+        // showCancel: false,
       ),
       barrierDismissible: true,
     );
@@ -38,7 +42,7 @@ class _HelpDialogState extends State<HelpDialog> {
 
   Future<void> _loadItems() async {
     try {
-      final jsonText = await rootBundle.loadString("assets/doc/help.json");
+      final jsonText = await rootBundle.loadString("assets/docs/help.json");
       final jsonMap = jsonDecode(jsonText);
 
       setState(() {

+ 33 - 17
lib/pages/home/view.dart

@@ -12,6 +12,8 @@ import 'package:fis_common/helpers/color.dart';
 import 'package:path_provider/path_provider.dart';
 import 'widgets/menus.dart';
 import 'widgets/navigator.dart';
+import 'widgets/patient.dart';
+import 'widgets/status_bar.dart';
 
 class HomePage extends GetView<HomeController> {
   const HomePage({super.key});
@@ -206,22 +208,26 @@ class HomePage extends GetView<HomeController> {
           mainAxisAlignment: MainAxisAlignment.spaceBetween,
           children: [
             Expanded(
+              flex: 4,
               child: Align(
                 alignment: Alignment.centerLeft,
                 child: _buildHeaderLeft(),
               ),
             ),
-            Align(
-              alignment: Alignment.center,
-              child: _buildHeaderCenter(),
+            Flexible(
+              flex: 4,
+              child: Align(
+                alignment: Alignment.center,
+                child: _buildHeaderCenter(),
+              ),
+            ),
+            Expanded(
+              flex: 4,
+              child: Align(
+                alignment: Alignment.centerRight,
+                child: _buildHeaderRight(context),
+              ),
             ),
-            const Spacer(),
-            // Expanded(
-            //   child: Align(
-            //     alignment: Alignment.centerRight,
-            //     child: _buildHeaderRight(),
-            //   ),
-            // ),
           ],
         ),
       ),
@@ -286,8 +292,8 @@ class HomePage extends GetView<HomeController> {
         if (kDebugMode) ...[
           InkWell(
             child: const Text(
-              '                             ',
-              style: TextStyle(fontSize: 35, color: Colors.white),
+              ' CP DB ',
+              style: TextStyle(fontSize: 20, color: Colors.white),
             ),
             onTap: () async {
               var sPath = "/data/user/0/com.vinno.vitalapp/databases/vital.db";
@@ -308,11 +314,21 @@ class HomePage extends GetView<HomeController> {
     );
   }
 
-  Widget _buildHeaderRight() {
-    return Image.asset(
-      "assets/images/iflyrobot.png",
-      height: 80,
-      fit: BoxFit.fitHeight,
+  Widget _buildHeaderRight(BuildContext context) {
+    return Row(
+      mainAxisSize: MainAxisSize.min,
+      children: const [
+        HeaderPatientPlace(),
+        Padding(
+          padding: EdgeInsets.symmetric(horizontal: 8),
+          child: VerticalDivider(
+            indent: 12,
+            endIndent: 12,
+            color: Colors.white,
+          ),
+        ),
+        HeaderStatusBar(),
+      ],
     );
   }
 }

+ 26 - 0
lib/pages/home/widgets/patient.dart

@@ -0,0 +1,26 @@
+import 'package:flutter/material.dart';
+import 'package:get/get.dart';
+import 'package:vitalapp/store/store.dart';
+
+class HeaderPatientPlace extends StatelessWidget {
+  const HeaderPatientPlace({super.key});
+
+  @override
+  Widget build(BuildContext context) {
+    return Obx(() {
+      final patient = Store.user.currentSelectPatientInfo;
+      if (patient == null) {
+        return const SizedBox();
+      } else {
+        return Container(
+          alignment: Alignment.centerRight,
+          width: 200,
+          child: Text(
+            patient.patientName!,
+            style: const TextStyle(fontSize: 18, color: Colors.white),
+          ),
+        );
+      }
+    });
+  }
+}

+ 67 - 0
lib/pages/home/widgets/status_bar.dart

@@ -0,0 +1,67 @@
+import 'package:flutter/material.dart';
+import 'package:vitalapp/architecture/network_connectivity.dart';
+import 'package:vitalapp/global.dart';
+import 'package:vitalapp/pages/help/help_dialog.dart';
+
+class HeaderStatusBar extends StatelessWidget {
+  const HeaderStatusBar({super.key});
+
+  @override
+  Widget build(BuildContext context) {
+    return Row(
+      mainAxisSize: MainAxisSize.min,
+      children: [
+        _NetStatusWidget(),
+        const SizedBox(width: 2),
+        IconButton(
+          onPressed: () {
+            HelpDialog.show();
+          },
+          icon: const Icon(Icons.help, color: Colors.white),
+        ),
+      ],
+    );
+  }
+}
+
+class _NetStatusWidget extends StatefulWidget {
+  @override
+  State<StatefulWidget> createState() => _NetStatusWidgetState();
+}
+
+class _NetStatusWidgetState extends State<_NetStatusWidget> {
+  @override
+  void initState() {
+    super.initState();
+    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
+      netChecker.onlineChangedEvent.addListener(_onlineChanged);
+    });
+  }
+
+  @override
+  void dispose() {
+    netChecker.onlineChangedEvent.removeListener(_onlineChanged);
+    super.dispose();
+  }
+
+  void _onlineChanged(_, e) {
+    setState(() {});
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    if (kIsOnline) {
+      return const Tooltip(
+        triggerMode: TooltipTriggerMode.tap,
+        message: "网络已连接",
+        child: Icon(Icons.wifi, color: Colors.green),
+      );
+    } else {
+      return const Tooltip(
+        triggerMode: TooltipTriggerMode.tap,
+        message: "网络已断开",
+        child: Icon(Icons.wifi_off_outlined, color: Colors.red),
+      );
+    }
+  }
+}