refactor : base page
This commit is contained in:
@@ -1,99 +1,37 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/base_page/logic.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/search/logic.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
/// Creates a customized AppBar for the Rasadyar Chicken app.
|
||||
RAppBar chickenAppBar({
|
||||
bool hasBack = true,
|
||||
bool hasFilter = true,
|
||||
bool hasSearch = true,
|
||||
bool isBase = false,
|
||||
VoidCallback? onBackPressed,
|
||||
GestureTapCallback? onFilterTap,
|
||||
GestureTapCallback? onSearchTap,
|
||||
List<Widget>? additionalActions,
|
||||
bool hasNotification = false,
|
||||
bool hasNews = false,
|
||||
int? backId,
|
||||
VoidCallback? onBackTap,
|
||||
VoidCallback? onFilterTap,
|
||||
VoidCallback? onSearchTap,
|
||||
VoidCallback? onNewsTap,
|
||||
VoidCallback? onNotificationTap,
|
||||
}) {
|
||||
return RAppBar(
|
||||
hasBack: isBase == true ? false : 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,
|
||||
),
|
||||
],
|
||||
),
|
||||
additionalActions: [
|
||||
if (!isBase && hasSearch) searchWidget(onSearchTap),
|
||||
SizedBox(width: 8),
|
||||
if (!isBase && hasFilter) filterWidget(onFilterTap),
|
||||
SizedBox(width: 8),
|
||||
if (additionalActions != null) ...additionalActions,
|
||||
hasBack: hasBack,
|
||||
hasSearch: hasSearch,
|
||||
hasNotification: hasNotification,
|
||||
hasNews: hasNews,
|
||||
isBase: isBase,
|
||||
backId: backId,
|
||||
onSearchTap: onSearchTap,
|
||||
onBackTap: onBackTap,
|
||||
onNotificationTap: onNotificationTap,
|
||||
onNewsTap: onNewsTap,
|
||||
backgroundColor: AppColor.blueNormal,
|
||||
children: [
|
||||
Text('رصدطیور', style: AppFonts.yekan16Bold),
|
||||
const SizedBox(width: 6),
|
||||
Assets.vec.chickenSvg.svg(height: 24, width: 24),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
GestureDetector filterWidget(GestureTapCallback? onFilterTap) {
|
||||
return GestureDetector(
|
||||
onTap: onFilterTap,
|
||||
child: Stack(
|
||||
alignment: Alignment.topRight,
|
||||
children: [
|
||||
Assets.vec.filterOutlineSvg.svg(
|
||||
width: 20,
|
||||
height: 20,
|
||||
colorFilter: const ColorFilter.mode(Colors.white, BlendMode.srcIn),
|
||||
),
|
||||
Obx(() {
|
||||
final controller = Get.find<BaseLogic>();
|
||||
return Visibility(
|
||||
visible: controller.isFilterSelected.value,
|
||||
child: Container(
|
||||
width: 8,
|
||||
height: 8,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.red,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
GestureDetector searchWidget(GestureTapCallback? onSearchTap) {
|
||||
return GestureDetector(
|
||||
onTap: onSearchTap,
|
||||
child: Stack(
|
||||
alignment: Alignment.topRight,
|
||||
children: [
|
||||
Assets.vec.searchSvg.svg(
|
||||
width: 24,
|
||||
height: 24,
|
||||
colorFilter: const ColorFilter.mode(Colors.white, BlendMode.srcIn),
|
||||
),
|
||||
Obx(() {
|
||||
final controller = Get.find<SearchLogic>();
|
||||
return Visibility(
|
||||
visible: controller.searchValue.value!=null,
|
||||
child: Container(
|
||||
width: 8,
|
||||
height: 8,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.red,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user