Parcourir la source

Appbar 的调整

liukai il y a 2 semaines
Parent
commit
e029544124

+ 98 - 64
app/lib/main.dart

@@ -9,11 +9,14 @@ import 'package:flutter_localizations/flutter_localizations.dart';
 import 'package:hooks_riverpod/hooks_riverpod.dart';
 import 'package:initializer/app_initializer.dart';
 import 'package:plugin_basic/basic_export.dart';
+import 'package:plugin_basic/constants/app_constant.dart';
 import 'package:plugin_basic/provider/app_config/app_config_service.dart';
 import 'package:plugin_basic/provider/global_provider_container.dart';
+import 'package:plugin_platform/engine/sp/sp_util.dart';
 import 'package:router/componentRouter/component_service_manager.dart';
 import 'package:cpt_profile/router/component/profile_service_provider.dart';
 import 'package:plugin_basic/obs/my_navigator_observer.dart';
+import 'package:shared/utils/device_utils.dart';
 import 'package:shared/utils/log_utils.dart';
 import 'package:widgets/dialog/custom_toast_widget.dart';
 import 'package:widgets/dialog/custom_error_widget.dart';
@@ -117,6 +120,35 @@ class MyApp extends HookConsumerWidget {
   Widget build(BuildContext context, WidgetRef ref) {
     final themeMode = ref.watch(themeProvider);
 
+    //根据主题配置对应的状态栏
+    int? darkModel = SPUtil.getInt(AppConstant.storageDarkModel, defValue: 0);
+    late SystemUiOverlayStyle systemUiOverlayStyle;
+
+    if (DeviceUtils.isAndroid) {
+      //根据SP存入的暗色模式,指定全局页面的状态栏,导航栏等设置
+      switch (darkModel) {
+        case 1:
+          Log.d("main.dart - 指定亮色模式");
+          systemUiOverlayStyle = ThemeConfig.systemUiOverlayStyleLightThemeBlack;
+          break;
+        case 2:
+          Log.d("main.dart - 指定暗色模式");
+          systemUiOverlayStyle = ThemeConfig.systemUiOverlayStyleDarkTheme;
+          break;
+        default:
+          Brightness currentBrightness = MediaQuery.of(context).platformBrightness;
+          if (currentBrightness == Brightness.dark) {
+            Log.d("main.dart - 跟随系统模式-暗色模式");
+            systemUiOverlayStyle = ThemeConfig.systemUiOverlayStyleDarkTheme;
+          } else {
+            Log.d("main.dart - 跟随系统模式-亮色模式");
+            systemUiOverlayStyle = ThemeConfig.systemUiOverlayStyleLightThemeBlack;
+          }
+          break;
+      }
+    }
+    SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
+
     useEffect(() {
       // 组件挂载时执行
       WidgetsBinding.instance.addPostFrameCallback((_) {
@@ -128,76 +160,78 @@ class MyApp extends HookConsumerWidget {
       };
     }, []);
 
-    //设置全局的状态栏文本样式
-    SystemChrome.setSystemUIOverlayStyle(ThemeConfig.systemUiOverlayStyleLightThemeWhite);
+    //全局入口
+    // return AnnotatedRegion<SystemUiOverlayStyle>(
+    //   value: systemUiOverlayStyle,
+    //   child:
 
-    //路由管理,状态管理,依赖管理一切都始于GetMaterialApp
-    return KeyboardVisibilityBuilder(builder: (context, isKeyboardVisible) {
-      return KeyboardDismissOnTap(
-        dismissOnCapturedTaps: false,
-        child: MaterialApp.router(
-          title: 'PropertyManagementSystem',
-          debugShowCheckedModeBanner: true,
+   return   KeyboardVisibilityBuilder(builder: (context, isKeyboardVisible) {
+        return KeyboardDismissOnTap(
+          dismissOnCapturedTaps: false,
+          child: MaterialApp.router(
+            title: 'PropertyManagementSystem',
+            debugShowCheckedModeBanner: true,
 
-          //主题配置
-          theme: ThemeData(
-            colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
-            useMaterial3: false,
-          ).copyWith(extensions: [
-            AppColorsTheme.light(),
-          ]),
-          darkTheme: ThemeData(
-            colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple, brightness: Brightness.dark),
-            useMaterial3: false,
-          ).copyWith(extensions: [
-            AppColorsTheme.dark(),
-          ]),
-          themeMode: themeMode == ThemeMode.system ? ThemeMode.system : themeMode,
+            //主题配置
+            theme: ThemeData(
+              colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xFF4161D0)),
+              useMaterial3: false,
+            ).copyWith(extensions: [
+              AppColorsTheme.light(),
+            ]),
+            darkTheme: ThemeData(
+              colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xFF4161D0), brightness: Brightness.dark),
+              useMaterial3: false,
+            ).copyWith(extensions: [
+              AppColorsTheme.dark(),
+            ]),
+            themeMode: themeMode == ThemeMode.system ? ThemeMode.system : themeMode,
 
-          //国际化配置
-          localizationsDelegates: const [
-            S.delegate,
-            GlobalMaterialLocalizations.delegate,
-            GlobalCupertinoLocalizations.delegate,
-            GlobalWidgetsLocalizations.delegate,
-          ],
-          //国际化英语为首选项
-          supportedLocales: [const Locale('en', ''), ...S.delegate.supportedLocales],
-          localeResolutionCallback: (locale, supportLocales) {
-            // 中文 简繁体处理
-            if (locale?.languageCode == 'zh') {
-              if (locale?.scriptCode == 'Hant') {
-                return const Locale('zh', 'HK'); //繁体
-              } else {
-                return const Locale('zh', 'CN'); //简体
-              }
-            }
-            return null;
-          },
-          //AutoRouter的配置
-          routerConfig: appRouter.config(
-            navigatorObservers: () => [
-              MyNavigatorObserver(),
+            //国际化配置
+            localizationsDelegates: const [
+              S.delegate,
+              GlobalMaterialLocalizations.delegate,
+              GlobalCupertinoLocalizations.delegate,
+              GlobalWidgetsLocalizations.delegate,
             ],
-          ),
-          //SmartDialog初始化默认Loading与Toast
-          builder: FlutterSmartDialog.init(
-            toastBuilder: (String msg) {
-              return CustomToastWidget(msg: msg);
-            },
-            loadingBuilder: (String msg) {
-              return CustomLoadingWidget(msg: msg == 'loading...' ? 'Loading...' : msg);
+            //国际化英语为首选项
+            supportedLocales: [const Locale('en', ''), ...S.delegate.supportedLocales],
+            localeResolutionCallback: (locale, supportLocales) {
+              // 中文 简繁体处理
+              if (locale?.languageCode == 'zh') {
+                if (locale?.scriptCode == 'Hant') {
+                  return const Locale('zh', 'HK'); //繁体
+                } else {
+                  return const Locale('zh', 'CN'); //简体
+                }
+              }
+              return null;
             },
-            notifyStyle: FlutterSmartNotifyStyle(
-              successBuilder: (String msg) => CustomSuccessWidget(msg: msg),
-              failureBuilder: (String msg) => CustomFailureWidget(msg: msg),
-              errorBuilder: (String msg) => CustomErrorWidget(msg: msg),
-              alertBuilder: (String msg) => CustomErrorWidget(msg: msg),
-              warningBuilder: (String msg) => CustomErrorWidget(msg: msg),
+            //AutoRouter的配置
+            routerConfig: appRouter.config(
+              navigatorObservers: () => [
+                MyNavigatorObserver(),
+              ],
+            ),
+            //SmartDialog初始化默认Loading与Toast
+            builder: FlutterSmartDialog.init(
+              toastBuilder: (String msg) {
+                return CustomToastWidget(msg: msg);
+              },
+              loadingBuilder: (String msg) {
+                return CustomLoadingWidget(msg: msg == 'loading...' ? 'Loading...' : msg);
+              },
+              notifyStyle: FlutterSmartNotifyStyle(
+                successBuilder: (String msg) => CustomSuccessWidget(msg: msg),
+                failureBuilder: (String msg) => CustomFailureWidget(msg: msg),
+                errorBuilder: (String msg) => CustomErrorWidget(msg: msg),
+                alertBuilder: (String msg) => CustomErrorWidget(msg: msg),
+                warningBuilder: (String msg) => CustomErrorWidget(msg: msg),
+              ),
             ),
           ),
-        ),
-      );
-    });
+        );
+      });
+    // );
   }
 }

+ 15 - 4
packages/cpt_payment/lib/modules/payment/page/payment_page.dart

@@ -1,7 +1,10 @@
+import 'package:cs_resources/theme/theme_config.dart';
 import 'package:flutter/material.dart';
 import 'package:auto_route/auto_route.dart';
+import 'package:flutter/services.dart';
 import 'package:hooks_riverpod/hooks_riverpod.dart';
 import 'package:router/ext/auto_router_extensions.dart';
+import 'package:widgets/my_appbar.dart';
 
 import '../../../router/page/payment_page_router.dart';
 import '../../payment/vm/payment_view_model.dart';
@@ -22,11 +25,19 @@ class PaymentPage extends HookConsumerWidget {
   @override
   Widget build(BuildContext context, WidgetRef ref) {
     final _viewModel = ref.read(paymentViewModelProvider.notifier);
-
     return Scaffold(
-      appBar: AppBar(title: Text("支付")),
-      body: Center(
-        child: Text("支付的主页面"),
+      // appBar: MyAppBar.appBar(context, "Payment", systemUiOverlayStyle: ThemeConfig.systemUiOverlayStyleLightThemeBlack),
+      appBar: MyAppBar.searchAppBar(context, systemUiOverlayStyle: ThemeConfig.systemUiOverlayStyleLightThemeBlack),
+      body: Container(
+        width: double.infinity,
+        child: Column(
+          crossAxisAlignment: CrossAxisAlignment.center,
+          children: [
+            MyAppBar.titleBar(context, "Test Title"),
+            Text("支付的主页面"),
+            MyAppBar.searchTitleBar(context),
+          ],
+        ),
       ),
     );
   }

+ 1 - 0
packages/cs_plugin_basic/lib/constants/app_constant.dart

@@ -15,6 +15,7 @@ class AppConstant {
   static const storageToken = 'storage_token'; //用户的Token
   static const storageNotificationEnable = 'storage_notification_enable'; //应用设置的推送是否开启
   static const storageDeviceUUID = 'storage_device_uuid'; //设备的UUID
+  static const storageDarkModel = 'storage_dark_model'; //设备当前配置的模式
 
   //消息通知Key
   static const eventProfile2Refresh = 'event_profile_refresh'; //通知用户信息需要刷新

+ 9 - 2
packages/cs_resources/lib/theme/app_colors_theme.dart

@@ -11,9 +11,11 @@ extension AppColorsThemeExtensions on BuildContext {
 
 class AppColorsTheme extends ThemeExtension<AppColorsTheme> {
   //亮色主题的自定义颜色值
+  static const _colorPrimary = Color(0xFF4161D0); //主题色
   static const _colorB0B0B0 = Color(0xFFB0B0B0);
   static const _color6C6C6C = Color(0xFF6C6C6C);
   static const _colorF9F9F9 = Color(0xffF9F9F9);
+  static const _colorD7DBE7 = Color(0xffD7DBE7);
 
   //暗色主题的一些自定义颜色值
   static const _darkBlackBg = Color(0xFF0F0F0F);
@@ -23,21 +25,24 @@ class AppColorsTheme extends ThemeExtension<AppColorsTheme> {
   static const _darkBlackItemDivider = Color(0xFF3B3B3F);
 
   // 页面中真正使用到的颜色名称
-  final Color backgroundDefault; //动态颜色
+  final Color backgroundDefault; //页面背景颜色
   final Color btnBgDefault;
+  final Color searchFiledBorder; //搜索框的边框颜色
 
 
   // 私有的构造函数
   const AppColorsTheme._internal({
     required this.backgroundDefault,
     required this.btnBgDefault,
+    required this.searchFiledBorder,
   });
 
   // 浅色主题工厂方法
   factory AppColorsTheme.light() {
     return const AppColorsTheme._internal(
       backgroundDefault: _colorF9F9F9,
-      btnBgDefault: Colors.deepPurple,
+      btnBgDefault: _colorPrimary,
+      searchFiledBorder: _colorD7DBE7,
     );
   }
 
@@ -46,6 +51,7 @@ class AppColorsTheme extends ThemeExtension<AppColorsTheme> {
     return const AppColorsTheme._internal(
       backgroundDefault: _darkBlackBg,
       btnBgDefault: _darkBlackItem,
+      searchFiledBorder: _darkBlackItem,
     );
   }
 
@@ -63,6 +69,7 @@ class AppColorsTheme extends ThemeExtension<AppColorsTheme> {
     return AppColorsTheme._internal(
       backgroundDefault: Color.lerp(backgroundDefault, other.backgroundDefault, t)!,
       btnBgDefault: Color.lerp(btnBgDefault, other.btnBgDefault, t)!,
+      searchFiledBorder: Color.lerp(searchFiledBorder, other.searchFiledBorder, t)!,
     );
   }
 }

+ 128 - 94
packages/cs_widgets/lib/my_appbar.dart

@@ -5,6 +5,7 @@ import 'package:flutter/widgets.dart';
 import 'package:cs_resources/generated/assets.dart';
 import 'package:cs_resources/constants/color_constants.dart';
 import 'package:router/ext/auto_router_extensions.dart';
+import 'package:widgets/ext/ex_widget.dart';
 import 'my_load_image.dart';
 import 'search_app_bar.dart';
 
@@ -16,31 +17,35 @@ class MyAppBar {
       double? backIconWidth,
       double? backIconHeight,
       String? subTitle,
-      Color? subTitleColor,
-      Color textColor = Colors.white,
       Color backgroundColor = Colors.transparent,
       SystemUiOverlayStyle? systemUiOverlayStyle,
+      bool showBottomDivider = false,
       List<Widget>? actions}) {
+    // 检查当前主题是亮色还是暗色
+    final bool isDarkMode = Theme.of(context).brightness == Brightness.dark;
+
     return AppBar(
       //设置变色与背景颜色一致,避免滚动的时候AppBar变色
       backgroundColor: backgroundColor,
       surfaceTintColor: backgroundColor,
       systemOverlayStyle: systemUiOverlayStyle,
-      leading: IconButton(
-        icon: MyAssetImage(backIconPath ?? Assets.baseLibWhiteBack, width: backIconWidth ?? 11, height: backIconHeight ?? 18),
-        onPressed: () {
-          if (backCallback != null) {
-            backCallback();
-          } else {
-            appRouter.maybePop();
-          }
-        },
-      ),
+      // 如果没有自带的返回按钮,直接使用系统自带的返回图标
+      leading: backIconPath != null
+          ? IconButton(
+              icon: MyAssetImage(
+                backIconPath,
+                width: backIconWidth ?? 11,
+                height: backIconHeight ?? 18,
+              ),
+              onPressed: backCallback,
+            )
+          : null,
+      iconTheme: IconThemeData(color: isDarkMode ? Colors.white : Theme.of(context).colorScheme.primary),
       centerTitle: true,
       title: subTitle == null
           ? Text(
               title,
-              style: const TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.w500),
+              style: TextStyle(color: isDarkMode ? Colors.white : Colors.black, fontSize: 17, fontWeight: FontWeight.w500),
             )
           : Column(
               mainAxisSize: MainAxisSize.max,
@@ -49,64 +54,65 @@ class MyAppBar {
               children: [
                 Text(
                   title,
-                  style: const TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.w500),
+                  style: TextStyle(color: isDarkMode ? Colors.white : Colors.black, fontSize: 17, fontWeight: FontWeight.w500),
                 ),
                 Text(
                   subTitle,
-                  style: TextStyle(color: subTitleColor ?? Colors.white, fontSize: 15, fontWeight: FontWeight.w400),
+                  style: TextStyle(color: isDarkMode ? Colors.white : Colors.black, fontSize: 15, fontWeight: FontWeight.w400),
                 )
               ],
             ),
       actions: actions,
       elevation: 0.0,
-      bottom: const PreferredSize(
-          preferredSize: Size.fromHeight(0.5),
-          child: Divider(
-            height: 0.5,
-            indent: 0.0,
-            color: ColorConstants.dividerBar,
-          )),
+      bottom: showBottomDivider // 根据变量控制 bottom 的显示
+          ? const PreferredSize(
+              preferredSize: Size.fromHeight(0.5),
+              child: Divider(
+                height: 0.5,
+                indent: 0.0,
+                color: ColorConstants.dividerBar,
+              ))
+          : null,
     );
   }
 
-  //自定义高度快
-  static SizedBox rowHeight({double height = 30}) {
-    return SizedBox(height: height);
-  }
-
-  //自定义宽度快
-  static SizedBox rowWidth({double width = 30}) {
-    return SizedBox(width: width);
-  }
-
   /// 带搜索的AppBar
-  static AppBar appSearchBar(BuildContext context,
+  static AppBar searchAppBar(BuildContext context,
       {void Function()? backCallback,
       String? value,
       String? hintText,
-      Color textColor = Colors.white,
+      String? backIconPath,
+      double? backIconWidth,
+      double? backIconHeight,
+      Color textColor = Colors.black,
       Color backgroundColor = Colors.transparent,
       ValueChanged<String>? onSearch,
       ValueChanged<String>? onChanged,
       SystemUiOverlayStyle? systemUiOverlayStyle,
       TextEditingController? controller,
+      bool showBottomDivider = false,
       List<Widget>? actions}) {
+    // 检查当前主题是亮色还是暗色
+    final bool isDarkMode = Theme.of(context).brightness == Brightness.dark;
+
     return AppBar(
       backgroundColor: backgroundColor,
       surfaceTintColor: backgroundColor,
       systemOverlayStyle: systemUiOverlayStyle,
       // 标题与其他控件的间隔
       titleSpacing: 0,
-      leading: IconButton(
-        icon: const MyAssetImage(Assets.baseLibWhiteBack, width: 11, height: 18),
-        onPressed: () {
-          if (backCallback != null) {
-            backCallback();
-          } else {
-           appRouter.maybePop();
-          }
-        },
-      ),
+      // 如果没有自带的返回按钮,直接使用系统自带的返回图标
+      leading: backIconPath != null
+          ? IconButton(
+              icon: MyAssetImage(
+                backIconPath,
+                width: backIconWidth ?? 11,
+                height: backIconHeight ?? 18,
+              ),
+              onPressed: backCallback,
+            )
+          : null,
+      iconTheme: IconThemeData(color: isDarkMode ? Colors.white : Theme.of(context).colorScheme.primary),
       centerTitle: true,
       title: SearchAppBar(
         onSearch: onSearch,
@@ -117,13 +123,15 @@ class MyAppBar {
       ),
       actions: actions,
       elevation: 0.0,
-      bottom: const PreferredSize(
-          preferredSize: Size.fromHeight(0.5),
-          child: Divider(
-            height: 0.5,
-            indent: 0.0,
-            color: ColorConstants.dividerBar,
-          )),
+      bottom: showBottomDivider // 根据变量控制 bottom 的显示
+          ? const PreferredSize(
+              preferredSize: Size.fromHeight(0.5),
+              child: Divider(
+                height: 0.5,
+                indent: 0.0,
+                color: ColorConstants.dividerBar,
+              ))
+          : null,
     );
   }
 
@@ -136,14 +144,14 @@ class MyAppBar {
     double? backIconWidth,
     double? backIconHeight,
     String? subTitle,
-    Color? subTitleColor,
-    bool needBottomDivider = true,
-    Color textColor = Colors.white,
     Color backgroundColor = Colors.transparent,
+    bool showBottomDivider = false,
     List<Widget>? actions,
   }) {
     // 计算左侧和右侧固定容器的宽度
     double sideWidth = 55;
+    // 检查当前主题是亮色还是暗色
+    final bool isDarkMode = Theme.of(context).brightness == Brightness.dark;
 
     return Column(
       children: [
@@ -160,20 +168,31 @@ class MyAppBar {
                 child: Container(
                   width: sideWidth,
                   alignment: Alignment.center,
-                  child: IconButton(
-                    icon: MyAssetImage(
-                      backIconPath ?? Assets.baseLibWhiteBack,
-                      width: backIconWidth ?? 11,
-                      height: backIconHeight ?? 18,
-                    ),
-                    onPressed: () {
-                      if (backCallback != null) {
-                        backCallback();
-                      } else {
-                        appRouter.maybePop();
-                      }
-                    },
-                  ),
+                  child: backIconPath != null
+                      ? IconButton(
+                          icon: MyAssetImage(
+                            backIconPath,
+                            width: backIconWidth ?? 11,
+                            height: backIconHeight ?? 18,
+                          ),
+                          onPressed: () {
+                            if (backCallback != null) {
+                              backCallback();
+                            } else {
+                              appRouter.maybePop();
+                            }
+                          },
+                        )
+                      : BackButton(
+                          color: isDarkMode ? Colors.white : Theme.of(context).colorScheme.primary,
+                          onPressed: () {
+                            if (backCallback != null) {
+                              backCallback();
+                            } else {
+                              appRouter.maybePop();
+                            }
+                          },
+                        ),
                 ),
               ),
               // 标题在中间
@@ -186,7 +205,7 @@ class MyAppBar {
                     child: subTitle == null
                         ? Text(
                             title,
-                            style: TextStyle(color: textColor, fontSize: 18, fontWeight: FontWeight.w500),
+                            style: TextStyle(color: isDarkMode ? Colors.white : Colors.black, fontSize: 17, fontWeight: FontWeight.w500),
                             overflow: TextOverflow.ellipsis,
                           )
                         : Column(
@@ -196,12 +215,12 @@ class MyAppBar {
                             children: [
                               Text(
                                 title,
-                                style: TextStyle(color: textColor, fontSize: 18, fontWeight: FontWeight.w500),
+                                style: TextStyle(color: isDarkMode ? Colors.white : Colors.black, fontSize: 17, fontWeight: FontWeight.w500),
                                 overflow: TextOverflow.ellipsis,
                               ),
                               Text(
-                                subTitle!,
-                                style: TextStyle(color: subTitleColor ?? textColor, fontSize: 15, fontWeight: FontWeight.w400),
+                                subTitle,
+                                style: TextStyle(color: isDarkMode ? Colors.white : Colors.black, fontSize: 15, fontWeight: FontWeight.w400),
                               ),
                             ],
                           ),
@@ -225,8 +244,8 @@ class MyAppBar {
           ),
         ),
         // 底部的分割线
-        if (needBottomDivider)
-          Divider(
+        if (showBottomDivider)
+          const Divider(
             height: 0.5,
             color: ColorConstants.dividerBar,
           ),
@@ -235,18 +254,24 @@ class MyAppBar {
   }
 
   /// 当前App中的自定义TitleBar用于沉浸式处理,不是用在 Scaffold 下面的,直接放在 Column 下面即可
-  static Widget searchTitleBar(BuildContext context, {
+  static Widget searchTitleBar(
+    BuildContext context, {
     void Function()? backCallback,
     String? value,
     String? hintText,
-    Color textColor = Colors.white,
+    String? backIconPath,
+    double? backIconWidth,
+    double? backIconHeight,
     Color backgroundColor = Colors.transparent,
     ValueChanged<String>? onSearch,
     ValueChanged<String>? onChanged,
-    bool needBottomDivider = true,
     TextEditingController? controller,
+    bool showBottomDivider = false,
     List<Widget>? actions,
   }) {
+    // 检查当前主题是亮色还是暗色
+    final bool isDarkMode = Theme.of(context).brightness == Brightness.dark;
+
     return Column(
       children: [
         Container(
@@ -259,20 +284,31 @@ class MyAppBar {
               Container(
                 width: 55,
                 alignment: Alignment.center,
-                child: IconButton(
-                  icon: MyAssetImage(
-                    Assets.baseLibWhiteBack,
-                    width: 11,
-                    height: 18,
-                  ),
-                  onPressed: () {
-                    if (backCallback != null) {
-                      backCallback();
-                    } else {
-                      appRouter.maybePop();
-                    }
-                  },
-                ),
+                child: backIconPath != null
+                    ? IconButton(
+                        icon: MyAssetImage(
+                          backIconPath,
+                          width: backIconWidth ?? 11,
+                          height: backIconHeight ?? 18,
+                        ),
+                        onPressed: () {
+                          if (backCallback != null) {
+                            backCallback();
+                          } else {
+                            appRouter.maybePop();
+                          }
+                        },
+                      )
+                    : BackButton(
+                        color: isDarkMode ? Colors.white : Theme.of(context).colorScheme.primary,
+                        onPressed: () {
+                          if (backCallback != null) {
+                            backCallback();
+                          } else {
+                            appRouter.maybePop();
+                          }
+                        },
+                      ),
               ),
               // 搜索栏
               Expanded(
@@ -296,7 +332,7 @@ class MyAppBar {
           ),
         ),
         // 底部的分割线
-        if (needBottomDivider)
+        if (showBottomDivider)
           const Divider(
             height: 0.5,
             indent: 0.0,
@@ -305,6 +341,4 @@ class MyAppBar {
       ],
     );
   }
-
-
 }

+ 10 - 6
packages/cs_widgets/lib/search_app_bar.dart

@@ -1,3 +1,4 @@
+import 'package:cs_resources/theme/app_colors_theme.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
@@ -17,13 +18,13 @@ class SearchAppBar extends StatefulWidget {
     this.actions = const [],
     this.hintText,
     this.onTap,
-    this.searchBarHeight = 35,
+    this.searchBarHeight = 33,
     this.searchBarBorderRadius = 17.25,
-    this.searchBarBgColor,
+    this.searchBarBorderColor,
     this.textHintColor,
     this.searchBarBorder,
     this.margin,
-    this.textColor = Colors.white,
+    this.textColor = Colors.black,
     this.onChanged,
     this.onSearch,
   }) : super(key: key);
@@ -47,7 +48,7 @@ class SearchAppBar extends StatefulWidget {
 
   EdgeInsetsGeometry? margin;
 
-  Color? searchBarBgColor;
+  Color? searchBarBorderColor;
 
   Color? textHintColor;
 
@@ -118,9 +119,12 @@ class _SearchAppBarState extends State<SearchAppBar> {
       padding: const EdgeInsets.only(left: 15, right: 11),
       margin: widget.margin ?? const EdgeInsets.only(right: 15),
       decoration: BoxDecoration(
-        color: widget.searchBarBgColor ?? Color(0xFF4DCFF6).withOpacity(0.2), // 设置// 背景颜色和不透明度
+        color: Colors.transparent,
         borderRadius: BorderRadius.circular(widget.searchBarBorderRadius), // 设置圆角
-        border: widget.searchBarBorder,
+        border: widget.searchBarBorder ?? Border.all(
+          color: widget.searchBarBorderColor ?? context.appColors.searchFiledBorder, // 边框颜色
+          width: 1.0, // 边框宽度
+        ),
       ),
       child: Row(
         mainAxisSize: MainAxisSize.max,