refactor : inspection

This commit is contained in:
2025-09-27 09:35:00 +03:30
parent a7c7442b49
commit d9a18c968b
14 changed files with 85 additions and 51 deletions

View File

@@ -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,

View File

@@ -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 extends Object?>(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 extends Object?>(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 extends Object?>(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 extends Object?>(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 extends Object?>(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 extends Object?>(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

View File

@@ -158,7 +158,7 @@ _Poultry _$PoultryFromJson(Map<String, dynamic> 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(),

View File

@@ -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<BaseLogic>();
Rx<Resource<PaginationModel<HatchingModel>>> hatchingList =
Resource<PaginationModel<HatchingModel>>.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 {
}
}
}

View File

@@ -18,12 +18,12 @@ class InspectionPoultrySciencePage extends GetView<InspectionPoultryScienceLogic
hasBack: true,
hasFilter: true,
hasSearch: true,
filteringWidget: filterBottomSheet(),
onFilterTap: () {
Get.bottomSheet(filterBottomSheet());
},
onSearchChanged: (data) => controller.setSearchValue(data),
backId: poultryFirstKey,
routes: controller.routesName,
//routesWidget: ObxValue((route) => buildContainerPageRoute(route), controller.routesName),
widgets: [
SizedBox(height: 50, child: segmentWidget()),
ObxValue((data) {

View File

@@ -24,6 +24,7 @@ RAppBar chickenAppBar({
isBase: isBase,
backId: backId,
hasFilter: hasFilter,
onFilterTap: onFilterTap,
onSearchTap: onSearchTap,
onBackTap: onBackTap,
onNotificationTap: onNotificationTap,

View File

@@ -84,6 +84,7 @@ class ChickenBasePage extends GetView<BaseLogic> {
widgets: widgets,
child: child,
scrollable: scrollable,
onSearchChanged: onSearchChanged,
floatingActionButtonLocation: floatingActionButtonLocation,
floatingActionButton: floatingActionButton,
backGroundWidget: backGroundWidget ?? chickenBackground(),
@@ -100,8 +101,8 @@ class ChickenBasePage extends GetView<BaseLogic> {
onBackTap: onBackTap,
hasNotification: hasNotification,
onNotificationTap: onNotificationTap,
onFilterTap: hasFilter ? _onFilterTap : null,
//onSearchTap: widget.hasSearch ? controller.toggleSearch : null,
onFilterTap: onFilterTap ?? _onFilterTap,
onSearchTap: hasSearch ? controller.toggleSearch : null,
),
);
}

View File

@@ -8,6 +8,7 @@ class BaseLogic extends GetxController {
final TextEditingController textEditingController = TextEditingController();
void setSearchCallback(void Function(String?)? onSearchChanged) {
fLog("sssssssssssssssssssssssssssssssss");
debounce<String?>(searchValue, (val) {
if (val != null && val.trim().isNotEmpty) {
onSearchChanged?.call(val);

View File

@@ -15,6 +15,7 @@ class BasePage extends GetView<BaseLogic> {
this.backGroundWidget,
this.onPopScopTaped,
this.backId,
this.onSearchChanged,
});
final List<String>? routes;
@@ -28,13 +29,18 @@ class BasePage extends GetView<BaseLogic> {
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(),
],
);
}

View File

@@ -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<String> 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,
),
],
);
}
}

View File

@@ -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)

View File

@@ -4,6 +4,7 @@ import 'package:rasadyar_core/core.dart';
class SearchWidget extends GetView<BaseLogic> {
const SearchWidget({super.key});
@override
Widget build(BuildContext context) {
return ObxValue((data) {

View File

@@ -132,7 +132,7 @@ class _BasePageState extends State<BasePage> {
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,
],

View File

@@ -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<SearchWidget> createState() => _SearchWidgetState();
State<SearchWidget2> createState() => _SearchWidgetState();
}
class _SearchWidgetState extends State<SearchWidget> {
class _SearchWidgetState extends State<SearchWidget2> {
late final BaseLogic controller;
final TextEditingController textEditingController = TextEditingController();