From fa705507ba574c857b1667553737d23b1b7ff495 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 12 五月 2022 12:06:31 +0800
Subject: [PATCH] 后端模板代码优化

---
 src/main/resources/code/flutter_module/lib/ui/widget/nav.dart |   61 +++++++++++++++++++++---------
 1 files changed, 42 insertions(+), 19 deletions(-)

diff --git a/src/main/resources/code/flutter_module/lib/ui/widget/nav.dart b/src/main/resources/code/flutter_module/lib/ui/widget/nav.dart
index 191c1f4..30afd58 100644
--- a/src/main/resources/code/flutter_module/lib/ui/widget/nav.dart
+++ b/src/main/resources/code/flutter_module/lib/ui/widget/nav.dart
@@ -18,9 +18,12 @@
 class TopNavBar extends StatelessWidget {
   final String title;
   GestureTapCallback? back;
+  GestureTapCallback? leftWidgetClick;
   String? rightText;
   String? leftText;
+  Widget? leftWidget;
   Icon? rightIcon;
+  Image? rightImage;
   GestureTapCallback? rightClick;
   final Color textColor;
   final Color backGround;
@@ -31,6 +34,9 @@
       this.back,
       this.rightText,
       this.rightIcon,
+      this.leftWidget,
+      this.leftWidgetClick,
+      this.rightImage,
       this.leftText = "",
       this.rightClick,
       this.textColor = const Color(0xFF333333),
@@ -77,7 +83,9 @@
                         )
                       ],
                     ))),
-            ((rightText != null && rightText!.isNotEmpty) || rightIcon != null)
+            ((rightText != null && rightText!.isNotEmpty) ||
+                    rightIcon != null ||
+                    rightImage != null)
                 ? Positioned(
                     right: 0,
                     top: 0,
@@ -90,11 +98,12 @@
                           alignment: Alignment.center,
                           padding: const EdgeInsets.only(right: 10),
                           child: rightIcon ??
-                              Text(
-                                rightText!,
-                                style:
-                                    TextStyle(fontSize: 15, color: textColor),
-                              ),
+                              (rightImage ??
+                                  Text(
+                                    rightText!,
+                                    style: TextStyle(
+                                        fontSize: 15, color: textColor),
+                                  )),
                         )))
                 : Container(),
             InkWell(
@@ -102,24 +111,38 @@
                   if (back != null) {
                     back!();
                   } else {
-                   popPage(context);
+                    popPage(context);
                   }
                 },
                 child: Container(
                   padding: const EdgeInsets.only(left: 10),
                   height: 48,
-                  child: Row(mainAxisSize: MainAxisSize.min,crossAxisAlignment: CrossAxisAlignment.center, children: [
-                    Icon(
-                      Icons.arrow_back_ios,
-                      color: textColor,
-                    ),
-                    leftText!.isNotEmpty
-                        ? Text(
-                            leftText!,
-                            style: const TextStyle(fontSize: 16),
-                          )
-                        : Container()
-                  ]),
+                  child: Row(
+                      mainAxisSize: MainAxisSize.min,
+                      crossAxisAlignment: CrossAxisAlignment.center,
+                      children: [
+                        Icon(
+                          Icons.arrow_back_ios,
+                          color: textColor,
+                        ),
+                        leftText!.isNotEmpty
+                            ? Text(
+                                leftText!,
+                                style: const TextStyle(fontSize: 16),
+                              )
+                            : Container(),
+                        leftWidget == null
+                            ? Container()
+                            : InkWell(
+                                onTap: () {
+                                  if (leftWidgetClick == null) {
+                                    return;
+                                  }
+                                  leftWidgetClick!();
+                                },
+                                child: leftWidget!,
+                              )
+                      ]),
                 ))
           ],
         ),

--
Gitblit v1.8.0