From 48f050a122bbefa6fe2cd711d5aa40e340340b72 Mon Sep 17 00:00:00 2001 From: "mr.mojtaba" Date: Mon, 30 Jun 2025 09:11:33 +0330 Subject: [PATCH] fix : Appbar chicken --- .../lib/presentation/pages/home/view.dart | 13 ++--- .../lib/presentation/widget/app_bar.dart | 57 +++++++++++++++++++ .../widget/app_bar/r_app_bar.dart | 39 +++++++------ 3 files changed, 83 insertions(+), 26 deletions(-) create mode 100644 packages/chicken/lib/presentation/widget/app_bar.dart diff --git a/packages/chicken/lib/presentation/pages/home/view.dart b/packages/chicken/lib/presentation/pages/home/view.dart index 718a0c8..a3df02f 100644 --- a/packages/chicken/lib/presentation/pages/home/view.dart +++ b/packages/chicken/lib/presentation/pages/home/view.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:rasadyar_chicken/data/models/response/inventory/inventory_model.dart'; import 'package:rasadyar_chicken/data/models/response/kill_house_distribution_info/kill_house_distribution_info.dart'; import 'package:rasadyar_chicken/presentation/routes/routes.dart'; +import 'package:rasadyar_chicken/presentation/widget/app_bar.dart'; import 'package:rasadyar_core/core.dart'; import 'logic.dart'; @@ -14,15 +15,11 @@ class HomePage extends GetView { Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColor.bgLight, - appBar: RAppBar( - title: 'رصدطیور', - iconTitle: Assets.vec.chickenSvg.path, - titleTextStyle: AppFonts.yekan16Bold.copyWith(color: Colors.white), - centerTitle: true, + appBar: chickenAppBar( hasBack: false, - leading: Row( - children: [Text('مباشر', style: AppFonts.yekan16Bold.copyWith(color: Colors.white))], - ), + hasFilter: false, + hasSearch: false + ), body: Column( spacing: 8, diff --git a/packages/chicken/lib/presentation/widget/app_bar.dart b/packages/chicken/lib/presentation/widget/app_bar.dart new file mode 100644 index 0000000..bd77879 --- /dev/null +++ b/packages/chicken/lib/presentation/widget/app_bar.dart @@ -0,0 +1,57 @@ +import 'package:flutter/material.dart'; +import 'package:rasadyar_core/core.dart'; + +RAppBar chickenAppBar({ + bool hasBack = true, + bool hasFilter = true, + bool hasSearch = true, + VoidCallback? onBackPressed, + GestureTapCallback? onFilterTap, + GestureTapCallback? onSearchTap, +}) { + return RAppBar( + hasBack: hasBack, + onBackPressed: onBackPressed, + leadingWidth: 155, + leading: Row( + mainAxisSize: MainAxisSize.min, + spacing: 6, + children: [ + Text('رصدطیور', style: AppFonts.yekan16Bold.copyWith(color: Colors.white)), + Assets.vec.chickenSvg.svg( + width: 24, + height: 24, + colorFilter: const ColorFilter.mode(Colors.white, BlendMode.srcIn), + ), + ], + ), + additionalActions: [ + if (hasFilter) filterWidget(onFilterTap), + SizedBox(width: 8), + if (hasSearch) searchWidget(onSearchTap), + SizedBox(width: 8), + ], + ); +} + +GestureDetector searchWidget(GestureTapCallback? onSearchTap) { + return GestureDetector( + onTap: onSearchTap, + child: Assets.vec.filterOutlineSvg.svg( + width: 20, + height: 20, + colorFilter: const ColorFilter.mode(Colors.white, BlendMode.srcIn), + ), + ); +} + +GestureDetector filterWidget(GestureTapCallback? onFilterTap) { + return GestureDetector( + onTap: onFilterTap, + child: Assets.vec.searchSvg.svg( + width: 24, + height: 24, + colorFilter: const ColorFilter.mode(Colors.white, BlendMode.srcIn), + ), + ); +} 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 b14fe91..d6b921b 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 @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:rasadyar_core/core.dart'; @@ -18,7 +17,7 @@ class RAppBar extends StatelessWidget implements PreferredSizeWidget { const RAppBar({ super.key, - this.title, + this.title, this.iconTitle, this.backgroundColor = AppColor.blueNormal, this.iconColor = Colors.white, @@ -41,29 +40,33 @@ class RAppBar extends StatelessWidget implements PreferredSizeWidget { excludeHeaderSemantics: true, scrolledUnderElevation: 0, centerTitle: centerTitle, - titleTextStyle: titleTextStyle ?? AppFonts.yekan16.copyWith(color: Colors.white), - title:title != null ? Row( - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - Text(title!), - if (iconTitle != null) ...{const SizedBox(width: 8)}, - if (iconTitle != null) ...{SvgGenImage.vec(iconTitle!).svg(width: 24, height: 24)}, - ], - ): null, + title: title != null + ? Row( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Text(title!), + if (iconTitle != null) ...{const SizedBox(width: 8)}, + if (iconTitle != null) ...{SvgGenImage.vec(iconTitle!).svg(width: 24, height: 24)}, + ], + ) + : null, leadingWidth: leadingWidth?.toDouble(), leading: leading != null ? Padding(padding: const EdgeInsets.only(right: 6), child: leading) : null, titleSpacing: 8, actions: [ if (additionalActions != null) ...additionalActions!, if (hasBack) ...{ - Padding( - padding: const EdgeInsets.symmetric(horizontal: 8), - child: IconButton( - onPressed: onBackPressed ?? () => Get.back(), - icon: const Icon(CupertinoIcons.chevron_back), - color: iconColor, + 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), + ), ), ), },