diff --git a/packages/chicken/lib/data/models/response/hatching_report/hatching_report.dart b/packages/chicken/lib/data/models/response/hatching_report/hatching_report.dart index 3d61620..417bae5 100644 --- a/packages/chicken/lib/data/models/response/hatching_report/hatching_report.dart +++ b/packages/chicken/lib/data/models/response/hatching_report/hatching_report.dart @@ -96,7 +96,7 @@ abstract class Poultry with _$Poultry { String? key, String? fullname, String? mobile, - String? city, + int? city, String? unitName, int? killingAveAge, int? activeLeftOver, diff --git a/packages/chicken/lib/data/models/response/hatching_report/hatching_report.freezed.dart b/packages/chicken/lib/data/models/response/hatching_report/hatching_report.freezed.dart index 7d878a4..3cb9d32 100644 --- a/packages/chicken/lib/data/models/response/hatching_report/hatching_report.freezed.dart +++ b/packages/chicken/lib/data/models/response/hatching_report/hatching_report.freezed.dart @@ -1619,7 +1619,7 @@ as String?, /// @nodoc mixin _$Poultry { - String? get key; String? get fullname; String? get mobile; String? get city; String? get unitName; int? get killingAveAge; int? get activeLeftOver; int? get killingAveCount; double? get realKillingAveWeight; double? get realKillingLiveWeight; double? get realKillingCarcassesWeight; double? get realKillingLossWeightPercent; + String? get key; String? get fullname; String? get mobile; int? get city; String? get unitName; int? get killingAveAge; int? get activeLeftOver; int? get killingAveCount; double? get realKillingAveWeight; double? get realKillingLiveWeight; double? get realKillingCarcassesWeight; double? get realKillingLossWeightPercent; /// Create a copy of Poultry /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -1652,7 +1652,7 @@ abstract mixin class $PoultryCopyWith<$Res> { factory $PoultryCopyWith(Poultry value, $Res Function(Poultry) _then) = _$PoultryCopyWithImpl; @useResult $Res call({ - String? key, String? fullname, String? mobile, String? city, String? unitName, int? killingAveAge, int? activeLeftOver, int? killingAveCount, double? realKillingAveWeight, double? realKillingLiveWeight, double? realKillingCarcassesWeight, double? realKillingLossWeightPercent + String? key, String? fullname, String? mobile, int? city, String? unitName, int? killingAveAge, int? activeLeftOver, int? killingAveCount, double? realKillingAveWeight, double? realKillingLiveWeight, double? realKillingCarcassesWeight, double? realKillingLossWeightPercent }); @@ -1675,7 +1675,7 @@ key: freezed == key ? _self.key : key // ignore: cast_nullable_to_non_nullable as String?,fullname: freezed == fullname ? _self.fullname : fullname // ignore: cast_nullable_to_non_nullable as String?,mobile: freezed == mobile ? _self.mobile : mobile // ignore: cast_nullable_to_non_nullable as String?,city: freezed == city ? _self.city : city // ignore: cast_nullable_to_non_nullable -as String?,unitName: freezed == unitName ? _self.unitName : unitName // ignore: cast_nullable_to_non_nullable +as int?,unitName: freezed == unitName ? _self.unitName : unitName // ignore: cast_nullable_to_non_nullable as String?,killingAveAge: freezed == killingAveAge ? _self.killingAveAge : killingAveAge // ignore: cast_nullable_to_non_nullable as int?,activeLeftOver: freezed == activeLeftOver ? _self.activeLeftOver : activeLeftOver // ignore: cast_nullable_to_non_nullable as int?,killingAveCount: freezed == killingAveCount ? _self.killingAveCount : killingAveCount // ignore: cast_nullable_to_non_nullable @@ -1768,7 +1768,7 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( String? key, String? fullname, String? mobile, String? city, String? unitName, int? killingAveAge, int? activeLeftOver, int? killingAveCount, double? realKillingAveWeight, double? realKillingLiveWeight, double? realKillingCarcassesWeight, double? realKillingLossWeightPercent)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( String? key, String? fullname, String? mobile, int? city, String? unitName, int? killingAveAge, int? activeLeftOver, int? killingAveCount, double? realKillingAveWeight, double? realKillingLiveWeight, double? realKillingCarcassesWeight, double? realKillingLossWeightPercent)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _Poultry() when $default != null: return $default(_that.key,_that.fullname,_that.mobile,_that.city,_that.unitName,_that.killingAveAge,_that.activeLeftOver,_that.killingAveCount,_that.realKillingAveWeight,_that.realKillingLiveWeight,_that.realKillingCarcassesWeight,_that.realKillingLossWeightPercent);case _: @@ -1789,7 +1789,7 @@ return $default(_that.key,_that.fullname,_that.mobile,_that.city,_that.unitName, /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( String? key, String? fullname, String? mobile, String? city, String? unitName, int? killingAveAge, int? activeLeftOver, int? killingAveCount, double? realKillingAveWeight, double? realKillingLiveWeight, double? realKillingCarcassesWeight, double? realKillingLossWeightPercent) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( String? key, String? fullname, String? mobile, int? city, String? unitName, int? killingAveAge, int? activeLeftOver, int? killingAveCount, double? realKillingAveWeight, double? realKillingLiveWeight, double? realKillingCarcassesWeight, double? realKillingLossWeightPercent) $default,) {final _that = this; switch (_that) { case _Poultry(): return $default(_that.key,_that.fullname,_that.mobile,_that.city,_that.unitName,_that.killingAveAge,_that.activeLeftOver,_that.killingAveCount,_that.realKillingAveWeight,_that.realKillingLiveWeight,_that.realKillingCarcassesWeight,_that.realKillingLossWeightPercent);case _: @@ -1809,7 +1809,7 @@ return $default(_that.key,_that.fullname,_that.mobile,_that.city,_that.unitName, /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( String? key, String? fullname, String? mobile, String? city, String? unitName, int? killingAveAge, int? activeLeftOver, int? killingAveCount, double? realKillingAveWeight, double? realKillingLiveWeight, double? realKillingCarcassesWeight, double? realKillingLossWeightPercent)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String? key, String? fullname, String? mobile, int? city, String? unitName, int? killingAveAge, int? activeLeftOver, int? killingAveCount, double? realKillingAveWeight, double? realKillingLiveWeight, double? realKillingCarcassesWeight, double? realKillingLossWeightPercent)? $default,) {final _that = this; switch (_that) { case _Poultry() when $default != null: return $default(_that.key,_that.fullname,_that.mobile,_that.city,_that.unitName,_that.killingAveAge,_that.activeLeftOver,_that.killingAveCount,_that.realKillingAveWeight,_that.realKillingLiveWeight,_that.realKillingCarcassesWeight,_that.realKillingLossWeightPercent);case _: @@ -1830,7 +1830,7 @@ class _Poultry implements Poultry { @override final String? key; @override final String? fullname; @override final String? mobile; -@override final String? city; +@override final int? city; @override final String? unitName; @override final int? killingAveAge; @override final int? activeLeftOver; @@ -1873,7 +1873,7 @@ abstract mixin class _$PoultryCopyWith<$Res> implements $PoultryCopyWith<$Res> { factory _$PoultryCopyWith(_Poultry value, $Res Function(_Poultry) _then) = __$PoultryCopyWithImpl; @override @useResult $Res call({ - String? key, String? fullname, String? mobile, String? city, String? unitName, int? killingAveAge, int? activeLeftOver, int? killingAveCount, double? realKillingAveWeight, double? realKillingLiveWeight, double? realKillingCarcassesWeight, double? realKillingLossWeightPercent + String? key, String? fullname, String? mobile, int? city, String? unitName, int? killingAveAge, int? activeLeftOver, int? killingAveCount, double? realKillingAveWeight, double? realKillingLiveWeight, double? realKillingCarcassesWeight, double? realKillingLossWeightPercent }); @@ -1896,7 +1896,7 @@ key: freezed == key ? _self.key : key // ignore: cast_nullable_to_non_nullable as String?,fullname: freezed == fullname ? _self.fullname : fullname // ignore: cast_nullable_to_non_nullable as String?,mobile: freezed == mobile ? _self.mobile : mobile // ignore: cast_nullable_to_non_nullable as String?,city: freezed == city ? _self.city : city // ignore: cast_nullable_to_non_nullable -as String?,unitName: freezed == unitName ? _self.unitName : unitName // ignore: cast_nullable_to_non_nullable +as int?,unitName: freezed == unitName ? _self.unitName : unitName // ignore: cast_nullable_to_non_nullable as String?,killingAveAge: freezed == killingAveAge ? _self.killingAveAge : killingAveAge // ignore: cast_nullable_to_non_nullable as int?,activeLeftOver: freezed == activeLeftOver ? _self.activeLeftOver : activeLeftOver // ignore: cast_nullable_to_non_nullable as int?,killingAveCount: freezed == killingAveCount ? _self.killingAveCount : killingAveCount // ignore: cast_nullable_to_non_nullable diff --git a/packages/chicken/lib/data/models/response/hatching_report/hatching_report.g.dart b/packages/chicken/lib/data/models/response/hatching_report/hatching_report.g.dart index f486439..e5164f4 100644 --- a/packages/chicken/lib/data/models/response/hatching_report/hatching_report.g.dart +++ b/packages/chicken/lib/data/models/response/hatching_report/hatching_report.g.dart @@ -158,7 +158,7 @@ _Poultry _$PoultryFromJson(Map json) => _Poultry( key: json['key'] as String?, fullname: json['fullname'] as String?, mobile: json['mobile'] as String?, - city: json['city'] as String?, + city: (json['city'] as num?)?.toInt(), unitName: json['unit_name'] as String?, killingAveAge: (json['killing_ave_age'] as num?)?.toInt(), activeLeftOver: (json['active_left_over'] as num?)?.toInt(), diff --git a/packages/chicken/lib/presentation/pages/poultry_science/inspection/logic.dart b/packages/chicken/lib/presentation/pages/poultry_science/inspection/logic.dart index 3f275b1..5f7bd0a 100644 --- a/packages/chicken/lib/presentation/pages/poultry_science/inspection/logic.dart +++ b/packages/chicken/lib/presentation/pages/poultry_science/inspection/logic.dart @@ -2,9 +2,11 @@ import 'package:flutter/material.dart'; import 'package:rasadyar_chicken/data/models/response/hatching/hatching_models.dart'; import 'package:rasadyar_chicken/data/models/response/hatching_report/hatching_report.dart'; import 'package:rasadyar_chicken/presentation/pages/poultry_science/root/logic.dart'; +import 'package:rasadyar_chicken/presentation/utils/utils.dart'; import 'package:rasadyar_core/core.dart'; class InspectionPoultryScienceLogic extends GetxController { + BaseLogic baseLogic = Get.find(); Rx>> hatchingList = Resource>.loading().obs; @@ -41,6 +43,8 @@ class InspectionPoultryScienceLogic extends GetxController { routesName.removeLast(); routesName.add(callback == 0 ? 'بازرسی' : 'بایگانی'); }); + + } @override @@ -63,7 +67,9 @@ class InspectionPoultryScienceLogic extends GetxController { @override void onClose() { - // TODO: implement onClose + baseLogic.isSearchSelected.value=false; + baseLogic.textEditingController.clear(); + baseLogic.searchValue.value=null; super.onClose(); } @@ -247,8 +253,9 @@ class InspectionPoultryScienceLogic extends GetxController { } void setSearchValue(String? data) { + dLog('Search Value: $data'); searchedValue.value = data?.trim(); - final isReporter = selectedSegmentIndex.value == 0; + final isReporter = selectedSegmentIndex.value == 1; if (isReporter) { getHatchingReport(); } else { @@ -256,3 +263,4 @@ class InspectionPoultryScienceLogic extends GetxController { } } } + diff --git a/packages/chicken/lib/presentation/pages/poultry_science/inspection/view.dart b/packages/chicken/lib/presentation/pages/poultry_science/inspection/view.dart index 7441061..39a23d1 100644 --- a/packages/chicken/lib/presentation/pages/poultry_science/inspection/view.dart +++ b/packages/chicken/lib/presentation/pages/poultry_science/inspection/view.dart @@ -18,12 +18,12 @@ class InspectionPoultrySciencePage extends GetView controller.setSearchValue(data), backId: poultryFirstKey, routes: controller.routesName, - - //routesWidget: ObxValue((route) => buildContainerPageRoute(route), controller.routesName), widgets: [ SizedBox(height: 50, child: segmentWidget()), ObxValue((data) { diff --git a/packages/chicken/lib/presentation/widget/app_bar.dart b/packages/chicken/lib/presentation/widget/app_bar.dart index 7ed79c3..feca79f 100644 --- a/packages/chicken/lib/presentation/widget/app_bar.dart +++ b/packages/chicken/lib/presentation/widget/app_bar.dart @@ -24,6 +24,7 @@ RAppBar chickenAppBar({ isBase: isBase, backId: backId, hasFilter: hasFilter, + onFilterTap: onFilterTap, onSearchTap: onSearchTap, onBackTap: onBackTap, onNotificationTap: onNotificationTap, diff --git a/packages/chicken/lib/presentation/widget/base_page/view.dart b/packages/chicken/lib/presentation/widget/base_page/view.dart index c5df49c..b801fbe 100644 --- a/packages/chicken/lib/presentation/widget/base_page/view.dart +++ b/packages/chicken/lib/presentation/widget/base_page/view.dart @@ -84,6 +84,7 @@ class ChickenBasePage extends GetView { widgets: widgets, child: child, scrollable: scrollable, + onSearchChanged: onSearchChanged, floatingActionButtonLocation: floatingActionButtonLocation, floatingActionButton: floatingActionButton, backGroundWidget: backGroundWidget ?? chickenBackground(), @@ -100,8 +101,8 @@ class ChickenBasePage extends GetView { onBackTap: onBackTap, hasNotification: hasNotification, onNotificationTap: onNotificationTap, - onFilterTap: hasFilter ? _onFilterTap : null, - //onSearchTap: widget.hasSearch ? controller.toggleSearch : null, + onFilterTap: onFilterTap ?? _onFilterTap, + onSearchTap: hasSearch ? controller.toggleSearch : null, ), ); } diff --git a/packages/core/lib/presentation/widget/base_page/logic.dart b/packages/core/lib/presentation/widget/base_page/logic.dart index bccafe7..c74daf6 100644 --- a/packages/core/lib/presentation/widget/base_page/logic.dart +++ b/packages/core/lib/presentation/widget/base_page/logic.dart @@ -8,6 +8,7 @@ class BaseLogic extends GetxController { final TextEditingController textEditingController = TextEditingController(); void setSearchCallback(void Function(String?)? onSearchChanged) { + fLog("sssssssssssssssssssssssssssssssss"); debounce(searchValue, (val) { if (val != null && val.trim().isNotEmpty) { onSearchChanged?.call(val); diff --git a/packages/core/lib/presentation/widget/base_page/view.dart b/packages/core/lib/presentation/widget/base_page/view.dart index a2657e0..8897275 100644 --- a/packages/core/lib/presentation/widget/base_page/view.dart +++ b/packages/core/lib/presentation/widget/base_page/view.dart @@ -15,6 +15,7 @@ class BasePage extends GetView { this.backGroundWidget, this.onPopScopTaped, this.backId, + this.onSearchChanged, }); final List? routes; @@ -28,13 +29,18 @@ class BasePage extends GetView { final Widget? floatingActionButton; final VoidCallback? onPopScopTaped; final int? backId; + final void Function(String?)? onSearchChanged; Widget _buildHeader() { + if (appBar?.hasSearch == true) { + controller.setSearchCallback(onSearchChanged); + } + return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - routesWidget ?? TextBreadcrumb(routes: routes!), - if (controller.isSearchSelected.value) ...{SearchWidget()}, + routesWidget ?? ContainerBreadcrumb(routes: routes!), + SearchWidget(), ], ); } diff --git a/packages/core/lib/presentation/widget/base_page/widgets/breadcrumb.dart b/packages/core/lib/presentation/widget/base_page/widgets/breadcrumb.dart index e5f93a1..42d8f55 100644 --- a/packages/core/lib/presentation/widget/base_page/widgets/breadcrumb.dart +++ b/packages/core/lib/presentation/widget/base_page/widgets/breadcrumb.dart @@ -22,7 +22,6 @@ class TextBreadcrumb extends Breadcrumb { } } - class ContainerBreadcrumb extends Breadcrumb { const ContainerBreadcrumb({super.key, super.routes}); @@ -35,24 +34,32 @@ class ContainerBreadcrumb extends Breadcrumb { } Widget buildContainerPageRoute(List route) { - return Container( - height: 24.h, - margin: EdgeInsets.symmetric(horizontal: 8.w, vertical: 4.h), - decoration: BoxDecoration(color: Color(0xFFE3E3E3), borderRadius: BorderRadius.circular(2.r)), - padding: EdgeInsets.symmetric(horizontal: 6.w), - child: ListView.separated( - scrollDirection: Axis.horizontal, - physics: NeverScrollableScrollPhysics(), - shrinkWrap: true, - itemBuilder: (context, index) => Center( - child: Text(route[index], style: AppFonts.yekan14.copyWith(color: AppColor.labelTextColor)), + return Row( + children: [ + Container( + height: 24.h, + margin: EdgeInsets.symmetric(horizontal: 8.w, vertical: 4.h), + decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(2.r)), + padding: EdgeInsets.symmetric(horizontal: 6.w), + child: ListView.separated( + scrollDirection: Axis.horizontal, + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemBuilder: (context, index) => Center( + child: Text( + route[index], + style: AppFonts.yekan14.copyWith(color: AppColor.labelTextColor), + ), + ), + separatorBuilder: (context, index) => Assets.vec.arrowLeftSvg.svg( + height: 24.h, + fit: BoxFit.fitHeight, + colorFilter: ColorFilter.mode(Color(0xFFD6DEEE), BlendMode.srcIn), + ), + itemCount: route.length, + ), ), - separatorBuilder: (context, index) => - Assets.vec.arrowLeftSvg.svg(height: 24.h, fit: BoxFit.fitHeight), - itemCount: route.length, - ), + ], ); } } - - diff --git a/packages/core/lib/presentation/widget/base_page/widgets/r_app_bar.dart b/packages/core/lib/presentation/widget/base_page/widgets/r_app_bar.dart index 803700e..4065ad2 100644 --- a/packages/core/lib/presentation/widget/base_page/widgets/r_app_bar.dart +++ b/packages/core/lib/presentation/widget/base_page/widgets/r_app_bar.dart @@ -1,5 +1,3 @@ -import 'dart:developer'; - import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:rasadyar_core/core.dart'; @@ -32,6 +30,7 @@ class RAppBar extends StatelessWidget implements PreferredSizeWidget { /// Preferred size widget for the AppBar bottom. final PreferredSizeWidget? bottom; + const RAppBar({ super.key, this.children, @@ -72,16 +71,19 @@ class RAppBar extends StatelessWidget implements PreferredSizeWidget { if (hasNews) GestureDetector( onTap: onNewsTap, - child: Badge.count( - count: 5, - child: Icon(CupertinoIcons.news_solid, color: Colors.white), - ), + + child: Icon(CupertinoIcons.news_solid, color: Colors.white), ), if (hasNews) SizedBox(width: 8.w), if (hasNotification) - Badge.count(count: 2, child: Icon(CupertinoIcons.bell_fill, color: Colors.white)), + GestureDetector( + onTap: onNotificationTap, + child: Icon(CupertinoIcons.bell_fill, color: Colors.white), + ), + if (hasNotification) SizedBox(width: 8.w), + if (!isBase) ...{ if (hasFilter) GestureDetector( @@ -94,7 +96,14 @@ class RAppBar extends StatelessWidget implements PreferredSizeWidget { ), if (hasBack) SizedBox(width: 8.w), - if (hasSearch) SearchWidget(), + if (hasSearch) GestureDetector( + onTap: onSearchTap, + child: Assets.vec.searchSvg.svg( + width: 24.w, + height: 24.h, + colorFilter: ColorFilter.mode(Colors.white, BlendMode.srcIn), + ), + ), if (hasSearch) SizedBox(width: 8.w), }, if (hasBack) diff --git a/packages/core/lib/presentation/widget/base_page/widgets/search_widget.dart b/packages/core/lib/presentation/widget/base_page/widgets/search_widget.dart index d0d7ecb..edb9c2e 100644 --- a/packages/core/lib/presentation/widget/base_page/widgets/search_widget.dart +++ b/packages/core/lib/presentation/widget/base_page/widgets/search_widget.dart @@ -4,6 +4,7 @@ import 'package:rasadyar_core/core.dart'; class SearchWidget extends GetView { const SearchWidget({super.key}); + @override Widget build(BuildContext context) { return ObxValue((data) { diff --git a/packages/inspection/lib/presentation/widget/base_page/view.dart b/packages/inspection/lib/presentation/widget/base_page/view.dart index af89bf2..63bef54 100644 --- a/packages/inspection/lib/presentation/widget/base_page/view.dart +++ b/packages/inspection/lib/presentation/widget/base_page/view.dart @@ -132,7 +132,7 @@ class _BasePageState extends State { children: [ //widget.routesWidget != null ? widget.routesWidget! : buildPageRoute(widget.routes!), if (!widget.isBase && widget.hasSearch && widget.defaultSearch) ...{ - SearchWidget(onSearchChanged: widget.onSearchChanged), + SearchWidget2(onSearchChanged: widget.onSearchChanged), }, ...widget.widgets, ], diff --git a/packages/inspection/lib/presentation/widget/search.dart b/packages/inspection/lib/presentation/widget/search.dart index 3b9d6f9..3b18be6 100644 --- a/packages/inspection/lib/presentation/widget/search.dart +++ b/packages/inspection/lib/presentation/widget/search.dart @@ -3,16 +3,16 @@ import 'package:rasadyar_core/core.dart'; import 'package:rasadyar_inspection/presentation/widget/base_page/logic.dart' hide BaseLogic; -class SearchWidget extends StatefulWidget { - const SearchWidget({super.key, this.onSearchChanged}); +class SearchWidget2 extends StatefulWidget { + const SearchWidget2({super.key, this.onSearchChanged}); final void Function(String?)? onSearchChanged; @override - State createState() => _SearchWidgetState(); + State createState() => _SearchWidgetState(); } -class _SearchWidgetState extends State { +class _SearchWidgetState extends State { late final BaseLogic controller; final TextEditingController textEditingController = TextEditingController();