diff --git a/packages/core/lib/presentation/widget/app_bar/r_app_bar.dart b/packages/core/lib/presentation/widget/app_bar/r_app_bar.dart index e04ebaf..edfeaea 100644 --- a/packages/core/lib/presentation/widget/app_bar/r_app_bar.dart +++ b/packages/core/lib/presentation/widget/app_bar/r_app_bar.dart @@ -11,7 +11,7 @@ class RAppBar extends StatelessWidget implements PreferredSizeWidget { final TextStyle? titleTextStyle; final VoidCallback? onBackPressed; final List? additionalActions; - final int? leadingWidth; + final double? leadingWidth; final Widget? leading; final PreferredSizeWidget? bottom; @@ -80,3 +80,78 @@ class RAppBar extends StatelessWidget implements PreferredSizeWidget { @override Size get preferredSize => const Size.fromHeight(kToolbarHeight); } + +class RAppBar2 extends StatelessWidget implements PreferredSizeWidget { + final String? title; + final String? iconTitle; + final Color backgroundColor; + final Color iconColor; + final bool hasBack; + final bool centerTitle; + final TextStyle? titleTextStyle; + final VoidCallback? onBackPressed; + final List? additionalActions; + final double? leadingWidth; + final Widget? leading; + final PreferredSizeWidget? bottom; + + const RAppBar2({ + super.key, + this.title, + this.iconTitle, + this.backgroundColor = AppColor.blueNormal, + this.iconColor = Colors.white, + this.titleTextStyle, + this.onBackPressed, + this.additionalActions, + this.leading, + this.hasBack = true, + this.centerTitle = false, + this.leadingWidth, + this.bottom, + }); + + @override + Widget build(BuildContext context) { + return AppBar( + automaticallyImplyLeading: false, + backgroundColor: backgroundColor, + elevation: 0, + excludeHeaderSemantics: true, + scrolledUnderElevation: 0, + centerTitle: centerTitle, + titleTextStyle: titleTextStyle ?? AppFonts.yekan16.copyWith(color: Colors.white), + title: Row( + children: [ + if (leading != null) ...{ + Padding(padding: const EdgeInsets.only(right: 6), child: leading), + }, + if (title != null) ...[Text(title!), if (iconTitle != null) const SizedBox(width: 8)], + if (iconTitle != null) ...{const SizedBox(width: 8)}, + if (iconTitle != null) ...{SvgGenImage.vec(iconTitle!).svg(width: 24, height: 24)}, + ], + ), + titleSpacing: 8, + actions: [ + if (additionalActions != null) ...additionalActions!, + if (hasBack) ...{ + GestureDetector( + onTap: onBackPressed ?? () => Get.back(), + child: Padding( + padding: const EdgeInsets.fromLTRB(10, 0, 2, 0), + child: Assets.vec.arrowLeftSvg.svg( + width: 24.w, + height: 24.h, + colorFilter: ColorFilter.mode(iconColor ?? Colors.white, BlendMode.srcIn), + ), + ), + ), + }, + ], + bottom: bottom, + ); + } + + @override + Size get preferredSize => const Size.fromHeight(kToolbarHeight); +} diff --git a/packages/livestock/lib/presentation/widgets/app_bar/i_app_bar.dart b/packages/livestock/lib/presentation/widgets/app_bar/i_app_bar.dart index 2d776c5..0960fe8 100644 --- a/packages/livestock/lib/presentation/widgets/app_bar/i_app_bar.dart +++ b/packages/livestock/lib/presentation/widgets/app_bar/i_app_bar.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:rasadyar_core/core.dart'; import 'package:rasadyar_livestock/presentation/widgets/base_page/logic.dart'; -RAppBar liveStockAppBar({ +RAppBar2 liveStockAppBar({ bool hasBack = true, bool hasFilter = true, bool hasSearch = true, @@ -10,16 +10,17 @@ RAppBar liveStockAppBar({ VoidCallback? onBackPressed, GestureTapCallback? onFilterTap, GestureTapCallback? onSearchTap, + String? title, }) { - return RAppBar( + return RAppBar2( hasBack: isBase == true ? false : hasBack, onBackPressed: onBackPressed, - leadingWidth: 155, + leadingWidth: 180.w, leading: Row( mainAxisSize: MainAxisSize.min, spacing: 6, children: [ - Text('رصددام', style: AppFonts.yekan16Bold.copyWith(color: Colors.white)), + Text(title ?? 'رصددام', style: AppFonts.yekan16Bold.copyWith(color: Colors.white)), Assets.vec.appBarInspectionSvg.svg(width: 24, height: 24), ], ),