feat: enhance kill house - submit request module with submit request functionality, including new models, repository updates, and UI integration
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
import 'package:rasadyar_chicken/presentation/routes/routes.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class KillHouseActionLogic extends GetxController {
|
||||
List<GlassMorphismCardItem> items = [
|
||||
GlassMorphismCardItem(title: "ثبت درخواست", icon: Assets.vec.submitRequestSvg.path, route: ''),
|
||||
GlassMorphismCardItem(
|
||||
title: "ثبت درخواست",
|
||||
icon: Assets.vec.submitRequestSvg.path,
|
||||
route: ChickenRoutes.submitRequestKillHouse,
|
||||
),
|
||||
GlassMorphismCardItem(
|
||||
title: "انبار و توزیع",
|
||||
icon: Assets.vec.warehouseDistributionSvg.path,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/presentation/utils/nested_keys_utils.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
@@ -13,8 +14,8 @@ class KillHouseActionPage extends GetView<KillHouseActionLogic> {
|
||||
isBase: true,
|
||||
child: GlassMorphismGrid(
|
||||
items: controller.items,
|
||||
onTap: () {
|
||||
iLog("Hoooooura 😍😍😍😍😍");
|
||||
onTap: (item) {
|
||||
Get.toNamed(item.route, id: killHouseActionKey);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/data/di/chicken_di.dart';
|
||||
import 'package:rasadyar_chicken/data/repositories/kill_house/kill_house_repository.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/common/profile/view.dart';
|
||||
import 'package:rasadyar_chicken/presentation/routes/pages.dart';
|
||||
import 'package:rasadyar_chicken/presentation/routes/routes.dart';
|
||||
@@ -6,11 +8,21 @@ import 'package:rasadyar_chicken/presentation/utils/nested_keys_utils.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class KillHouseRootLogic extends GetxController {
|
||||
RxInt currentPage = 2.obs;
|
||||
RxInt currentPage = 1.obs;
|
||||
|
||||
var tokenService = Get.find<TokenStorageService>();
|
||||
|
||||
late KillHouseRepository killHouseRepository;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
killHouseRepository = diChicken.get<KillHouseRepository>();
|
||||
}
|
||||
|
||||
final pages = [
|
||||
Navigator(
|
||||
key: Get.nestedKey(killHouseFirstKey),
|
||||
key: Get.nestedKey(killHouseActionKey),
|
||||
onGenerateRoute: (settings) {
|
||||
final page = ChickenPages.pages.firstWhere(
|
||||
(e) => e.name == settings.name,
|
||||
|
||||
@@ -0,0 +1,378 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
Widget addKillRequestBottomSheet(SubmitRequestKillHouseLogic controller) {
|
||||
return ObxValue(
|
||||
(data) => AnimatedContainer(
|
||||
duration: Duration(milliseconds: 300),
|
||||
height: data.value ? 680.h : 580.h,
|
||||
child: BaseBottomSheet(
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(width: 12),
|
||||
Text(
|
||||
"ثبت درخواست کشتار",
|
||||
style: AppFonts.yekan18Bold.copyWith(color: AppColor.iconColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
Divider(),
|
||||
SizedBox(height: 8),
|
||||
|
||||
InformationTag(
|
||||
data: InformationTagData(
|
||||
labelTitle: 'قیمت روز مرغ (${Jalali.now().formatCompactDate()})',
|
||||
labelTitleStyle: AppFonts.yekan14,
|
||||
isLoading: false,
|
||||
height: 40.h,
|
||||
value: controller.commissionPrices.chickenAveragePrice.separatedByComma.addReal,
|
||||
valueStyle: AppFonts.yekan14,
|
||||
borderColor: AppColor.greenNormal,
|
||||
radiusWidth: 1,
|
||||
valueBgColor: Colors.white,
|
||||
labelGradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [AppColor.greenLightActive, Colors.white],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 12),
|
||||
ResourceOverlayDropdown(
|
||||
height: 40.h,
|
||||
items: controller.killHouseList,
|
||||
itemBuilder: (item) => Text(item.name ?? 'بدون نام'),
|
||||
labelBuilder: (selected) => Text(selected?.name ?? 'محل کشتار'),
|
||||
onChanged: controller.setKillHouse,
|
||||
),
|
||||
|
||||
SizedBox(height: 8),
|
||||
|
||||
UnitTextField(
|
||||
controller: controller.breedCountController,
|
||||
keyboardType: TextInputType.number,
|
||||
maxLines: 1,
|
||||
minLines: 1,
|
||||
inputFormatters: [FilteringTextInputFormatter.digitsOnly, SeparatorInputFormatter()],
|
||||
unit: 'قطعه',
|
||||
hint: 'حجم کشتار',
|
||||
initialValue: 0.separatedByComma,
|
||||
),
|
||||
|
||||
SizedBox(height: 8),
|
||||
ResourceOverlayDropdown(
|
||||
items: controller.timeFrameOfKilling,
|
||||
itemBuilder: (item) => Text(item),
|
||||
labelBuilder: (selected) => Text(selected ?? 'زمان دریافت'),
|
||||
onChanged: (selected) => controller.setTimeFrameOfKilling(selected),
|
||||
),
|
||||
|
||||
SizedBox(height: 8),
|
||||
RTextField(
|
||||
controller: controller.dateOfSlaughterTextEditor,
|
||||
hintText: 'تاریخ کشتار',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
prefixIcon: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Assets.vec.calendarSvg.svg(
|
||||
width: 16.w,
|
||||
height: 16.h,
|
||||
colorFilter: ColorFilter.mode(AppColor.bgIcon, BlendMode.srcIn),
|
||||
),
|
||||
),
|
||||
readonly: true,
|
||||
onTap: () {
|
||||
Get.bottomSheet(
|
||||
modalDatePicker(
|
||||
onDateSelected: (value) {
|
||||
controller.dateOfSlaughterTextEditor.text = value.formatCompactDate();
|
||||
controller.dateOfSlaughter = value;
|
||||
},
|
||||
),
|
||||
isScrollControlled: true,
|
||||
isDismissible: true,
|
||||
ignoreSafeArea: false,
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
buildAnimatedLabelContainer(controller),
|
||||
SizedBox(height: 8),
|
||||
Container(
|
||||
height: 40.h,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: AppColor.blueDark, width: 0.5),
|
||||
),
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
if (controller.isAgreedUndertaking.value == false) {
|
||||
undertakingDialog(controller);
|
||||
}
|
||||
else{
|
||||
controller.toggleAgreeUndertaking(false);
|
||||
}
|
||||
},
|
||||
child: Row(
|
||||
spacing: 2,
|
||||
children: [
|
||||
ObxValue((data) {
|
||||
return Checkbox(
|
||||
value: data.value,
|
||||
onChanged: (value) {
|
||||
if (controller.isAgreedUndertaking.value == false) {
|
||||
undertakingDialog(controller);
|
||||
}
|
||||
else {
|
||||
controller.toggleAgreeUndertaking(false);
|
||||
}
|
||||
},
|
||||
);
|
||||
}, controller.isAgreedUndertaking),
|
||||
|
||||
Text(
|
||||
"با تعهدنامه موافق هستم !",
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.blueDark),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
Container(
|
||||
height: 40.h,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: AppColor.mediumGrey, width: 1),
|
||||
),
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () => controller.toggleAgreeSmsNotification(),
|
||||
child: Row(
|
||||
spacing: 2,
|
||||
children: [
|
||||
ObxValue((selected) {
|
||||
return Checkbox(
|
||||
value: selected.value,
|
||||
onChanged: (value) => controller.toggleAgreeSmsNotification(),
|
||||
);
|
||||
}, controller.isAgreedSmsNotification),
|
||||
Text(
|
||||
"دریافت پیامک اطلاع رسانی",
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor2),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Row(
|
||||
spacing: 16,
|
||||
mainAxisAlignment: .center,
|
||||
children: [
|
||||
RElevated(
|
||||
width: 160.w,
|
||||
height: 40.h,
|
||||
backgroundColor: AppColor.greenNormal,
|
||||
text: 'ثبت',
|
||||
onPressed: () async {
|
||||
await controller.submitKillRequest();
|
||||
},
|
||||
),
|
||||
|
||||
ROutlinedElevated(
|
||||
height: 40,
|
||||
text: 'انصراف',
|
||||
borderColor: AppColor.redNormal,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
controller.isBreedWeightSelected,
|
||||
);
|
||||
}
|
||||
|
||||
void undertakingDialog(SubmitRequestKillHouseLogic controller) {
|
||||
Get.dialog(
|
||||
AlertDialog(
|
||||
title: Text("تعهد نامه", textAlign: TextAlign.center),
|
||||
titleTextStyle: AppFonts.yekan20.copyWith(color: AppColor.textColor3),
|
||||
content: Column(
|
||||
mainAxisSize: .min,
|
||||
spacing: 10,
|
||||
children: [
|
||||
Text(
|
||||
"اینجانب ${controller.baseLogic.userProfile.value.data?.fullname} موافقت خود را نسبت به موارد ذکر شده اعلام می نمایم.",
|
||||
style: AppFonts.yekan13.copyWith(color: AppColor.textColor3),
|
||||
),
|
||||
Text(
|
||||
"✅ بر اساس این توافق نامه در صورت لغو کشتار جریمه خواهم شد.",
|
||||
style: AppFonts.yekan13.copyWith(color: AppColor.textColor3),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
Row(
|
||||
spacing: 10,
|
||||
children: [
|
||||
Expanded(
|
||||
child: RElevated(
|
||||
text: 'موافقم',
|
||||
height: 32.h,
|
||||
onPressed: () {
|
||||
controller.toggleAgreeUndertaking(true);
|
||||
Get.back();
|
||||
},
|
||||
textStyle: AppFonts.yekan20Bold.copyWith(color: Colors.white),
|
||||
backgroundColor: AppColor.greenNormal,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ROutlinedElevated(
|
||||
text: 'رد',
|
||||
textStyle: AppFonts.yekan20.copyWith(color: AppColor.redNormal),
|
||||
height: 32.h,
|
||||
onPressed: () {
|
||||
controller.toggleAgreeUndertaking(false);
|
||||
Get.back();
|
||||
},
|
||||
borderColor: AppColor.redNormal,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildAnimatedLabelContainer(SubmitRequestKillHouseLogic controller) {
|
||||
return ObxValue((data) {
|
||||
return AnimatedCrossFade(
|
||||
firstChild: GestureDetector(
|
||||
onTap: () {
|
||||
controller.toggleBreedWeightSelection();
|
||||
},
|
||||
child: Container(
|
||||
height: 40.h,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: AppColor.mediumGrey, width: 0.5),
|
||||
),
|
||||
child: Row(
|
||||
spacing: 7,
|
||||
children: [
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Switch(
|
||||
value: data.value,
|
||||
onChanged: (data) => controller.toggleBreedWeightSelection(),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"تعیین نژاد / وزن مرغ",
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor2),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
secondChild: SizedBox(
|
||||
height: 140.h,
|
||||
child: Stack(
|
||||
fit: StackFit.passthrough,
|
||||
children: [
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Container(
|
||||
height: 121.h,
|
||||
padding: EdgeInsets.fromLTRB(8.r, 18.r, 8.r, 8.r),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: AppColor.mediumGrey, width: (0.5).w),
|
||||
),
|
||||
child: Column(
|
||||
spacing: 8,
|
||||
children: [
|
||||
ResourceOverlayDropdown(
|
||||
items: controller.chickenBreedList,
|
||||
itemBuilder: (item) => Text(item),
|
||||
labelBuilder: (selected) => Text(selected ?? 'نژاد مرغ'),
|
||||
onChanged: (selected) => controller.setChickenBreed(selected),
|
||||
),
|
||||
|
||||
RTextField(
|
||||
controller: controller.chickenWeight,
|
||||
label: ' وزن مرغ (کیلوگرم) ',
|
||||
filled: true,
|
||||
filledColor: AppColor.bgLight,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
SeparatorInputFormatter(),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 0,
|
||||
right: 7,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
controller.toggleBreedWeightSelection();
|
||||
},
|
||||
child: Container(
|
||||
height: 30.h,
|
||||
padding: EdgeInsets.symmetric(horizontal: 4.w, vertical: 4.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: AppColor.mediumGrey, width: 0.5),
|
||||
),
|
||||
child: Row(
|
||||
spacing: 7,
|
||||
children: [
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Switch(
|
||||
value: data.value,
|
||||
onChanged: (_) => controller.toggleBreedWeightSelection(),
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"تعیین نژاد / وزن مرغ",
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.textColor2),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
crossFadeState: data.value ? CrossFadeState.showSecond : CrossFadeState.showFirst,
|
||||
duration: Duration(milliseconds: 500),
|
||||
);
|
||||
}, controller.isBreedWeightSelected);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,225 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/data/models/kill_house_module/register_request/request/kill_request_response.dart';
|
||||
import 'package:rasadyar_chicken/data/models/kill_house_module/register_request/response/chicken_commission_prices/chicken_commission_prices.dart';
|
||||
import 'package:rasadyar_chicken/data/models/kill_house_module/register_request/response/kill_house/kill_house_response.dart';
|
||||
import 'package:rasadyar_chicken/data/models/kill_house_module/register_request/response/kill_request_list/kill_request_list.dart'
|
||||
as listModel;
|
||||
import 'package:rasadyar_chicken/presentation/pages/kill_house/root/logic.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/base_page/logic.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class SubmitRequestKillHouseLogic extends GetxController {
|
||||
ChickenBaseLogic baseLogic = Get.find<ChickenBaseLogic>();
|
||||
RxList<String> routesName = ["عملیات", "ثبت درخواست کشتار"].obs;
|
||||
late KillHouseRootLogic rootLogic;
|
||||
|
||||
RxInt expandedItemIndex = RxInt(-1);
|
||||
Rx<Jalali> fromDateFilter = Jalali.now().obs;
|
||||
Rx<Jalali> toDateFilter = Jalali.now().obs;
|
||||
RxnString searchedValue = RxnString();
|
||||
|
||||
RxBool isBreedWeightSelected = false.obs;
|
||||
|
||||
TextEditingController breedCountController = TextEditingController();
|
||||
TextEditingController dateOfSlaughterTextEditor = TextEditingController();
|
||||
Jalali dateOfSlaughter = Jalali.now();
|
||||
TextEditingController chickenWeight = TextEditingController();
|
||||
|
||||
Resource<List<String>> timeFrameOfKilling = Resource.success([
|
||||
'12 - 14',
|
||||
'14 - 16',
|
||||
'16 - 18',
|
||||
'18 - 20',
|
||||
'20 - 22',
|
||||
'22 - 24',
|
||||
]);
|
||||
|
||||
RxString timeFrameOfKillingSelected = ''.obs;
|
||||
|
||||
Resource<List<String>> chickenBreedList = Resource.success([
|
||||
'آرین',
|
||||
'راس',
|
||||
'آربراکوز (آیلاس)',
|
||||
'کاب',
|
||||
'هوبارد',
|
||||
'ترکیبی',
|
||||
'وارداتی',
|
||||
]);
|
||||
|
||||
RxString chickenBreedSelected = ''.obs;
|
||||
RxBool isAgreedUndertaking = false.obs;
|
||||
RxBool isAgreedSmsNotification = false.obs;
|
||||
|
||||
KillHouseResponse? selectedKillHouse;
|
||||
late Resource<List<KillHouseResponse>> killHouseList;
|
||||
late ChickenCommissionPrices commissionPrices;
|
||||
|
||||
Rx<Resource<List<listModel.KillRequestList>>> killRequestList = Rx(
|
||||
Resource.initial(),
|
||||
);
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
rootLogic = Get.find<KillHouseRootLogic>();
|
||||
|
||||
getCommissionPrice();
|
||||
getKillHouseList();
|
||||
getListOfKillRequests();
|
||||
dateOfSlaughterTextEditor.text = Jalali.now().formatCompactDate();
|
||||
dateOfSlaughter = Jalali.now();
|
||||
chickenWeight.text = '2.7';
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
void onRefresh() {
|
||||
getCommissionPrice();
|
||||
getKillHouseList();
|
||||
getListOfKillRequests();
|
||||
}
|
||||
|
||||
void toggleExpandedItem(int index) {
|
||||
if (expandedItemIndex.value == index) {
|
||||
expandedItemIndex.value = -1;
|
||||
} else {
|
||||
expandedItemIndex.value = index;
|
||||
}
|
||||
}
|
||||
|
||||
void toggleBreedWeightSelection() {
|
||||
isBreedWeightSelected.value = !isBreedWeightSelected.value;
|
||||
}
|
||||
|
||||
void clearPage() {
|
||||
expandedItemIndex.value = -1;
|
||||
isBreedWeightSelected.value = false;
|
||||
isAgreedUndertaking.value = false;
|
||||
isAgreedSmsNotification.value = false;
|
||||
breedCountController.clear();
|
||||
dateOfSlaughter = Jalali.now();
|
||||
dateOfSlaughterTextEditor.text = Jalali.now().formatCompactDate();
|
||||
chickenWeight.text = '2.7';
|
||||
timeFrameOfKillingSelected.value = '';
|
||||
chickenBreedSelected.value = '';
|
||||
}
|
||||
|
||||
void setKillHouse(KillHouseResponse killHouse) {
|
||||
selectedKillHouse = killHouse;
|
||||
iLog(selectedKillHouse?.key);
|
||||
}
|
||||
|
||||
void setTimeFrameOfKilling(String timeFrame) {
|
||||
timeFrameOfKillingSelected.value = timeFrame;
|
||||
}
|
||||
|
||||
void setChickenBreed(String breed) {
|
||||
chickenBreedSelected.value = breed;
|
||||
}
|
||||
|
||||
void toggleAgreeUndertaking(bool item) {
|
||||
isAgreedUndertaking.value = item;
|
||||
}
|
||||
|
||||
void toggleAgreeSmsNotification() {
|
||||
isAgreedSmsNotification.value = !isAgreedSmsNotification.value;
|
||||
}
|
||||
|
||||
Future<void> getKillHouseList() async {
|
||||
await safeCall(
|
||||
call: () => rootLogic.killHouseRepository.getKillHouseList(
|
||||
token: rootLogic.tokenService.accessToken.value ?? '',
|
||||
),
|
||||
onSuccess: (result) => killHouseList = Resource.success(result ?? []),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getCommissionPrice() async {
|
||||
await safeCall(
|
||||
call: () => rootLogic.killHouseRepository.getCommissionPrice(
|
||||
token: rootLogic.tokenService.accessToken.value ?? '',
|
||||
),
|
||||
onSuccess: (result) => commissionPrices =
|
||||
result ?? ChickenCommissionPrices(chickenAveragePrice: 0),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> submitKillRequest() async {
|
||||
KillRequestResponse request = KillRequestResponse(
|
||||
killCapacity: int.parse(breedCountController.text),
|
||||
reciveTime: timeFrameOfKillingSelected.value,
|
||||
reciveDate: dateOfSlaughter
|
||||
.toDateTime()
|
||||
.formattedGregorianDateWithoutMillisecond,
|
||||
lowWeight: false,
|
||||
highWeight: false,
|
||||
indexWeight: double.parse(chickenWeight.text),
|
||||
chickenBreed: chickenBreedSelected.value,
|
||||
cash: true,
|
||||
credit: false,
|
||||
smsPayment: isAgreedSmsNotification.value,
|
||||
killHouseKey: selectedKillHouse?.key,
|
||||
killerKillHouseKey: null,
|
||||
role: 'KillHouse',
|
||||
);
|
||||
await safeCall(
|
||||
showError: true,
|
||||
|
||||
call: () => rootLogic.killHouseRepository.submitKillHouseRequest(
|
||||
token: rootLogic.tokenService.accessToken.value ?? '',
|
||||
data: request,
|
||||
),
|
||||
onSuccess: (result) {
|
||||
onRefresh();
|
||||
Get.back();
|
||||
Future.delayed(
|
||||
Duration(seconds: 3),
|
||||
() => defaultShowSuccessMessage("عملیات با موفقیت انجام شد"),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getListOfKillRequests() async {
|
||||
await safeCall(
|
||||
showError: true,
|
||||
call: () => rootLogic.killHouseRepository.getListKillRequest(
|
||||
token: rootLogic.tokenService.accessToken.value ?? '',
|
||||
queryParameters: buildRawQueryParams(
|
||||
role: 'KillHouse',
|
||||
fromDate: fromDateFilter.value.toDateTime(),
|
||||
toDate: toDateFilter.value.toDateTime(),
|
||||
),
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result == null || result.isEmpty) {
|
||||
killRequestList.value = Resource.empty();
|
||||
return;
|
||||
}
|
||||
killRequestList.value = Resource.success(result);
|
||||
},
|
||||
onError: (error, stackTrace) {
|
||||
killRequestList.value = Resource.error(error);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> deleteRequest(int id) async {
|
||||
await safeCall(
|
||||
showError: true,
|
||||
|
||||
call: () => rootLogic.killHouseRepository.deleteKillRequest(
|
||||
token: rootLogic.tokenService.accessToken.value ?? '',
|
||||
requestId: id,
|
||||
),
|
||||
onSuccess: (result) {
|
||||
onRefresh();
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/data/models/kill_house_module/register_request/response/kill_request_list/kill_request_list.dart'
|
||||
as listModel
|
||||
show KillRequestList;
|
||||
import 'package:rasadyar_chicken/presentation/utils/nested_keys_utils.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import 'add_request_bottom_sheet.dart';
|
||||
import 'logic.dart';
|
||||
|
||||
class SubmitRequestKillHousePage extends GetView<SubmitRequestKillHouseLogic> {
|
||||
const SubmitRequestKillHousePage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ChickenBasePage(
|
||||
hasBack: true,
|
||||
hasFilter: true,
|
||||
hasSearch: true,
|
||||
onBackTap: () => Get.back(id: killHouseActionKey),
|
||||
onSearchChanged: (data) {
|
||||
//Todo
|
||||
},
|
||||
onRefresh: () async => controller.onRefresh(),
|
||||
routesWidget: ContainerBreadcrumb(rxRoutes: controller.routesName),
|
||||
child: Stack(
|
||||
fit: .expand,
|
||||
children: [
|
||||
Positioned.fill(
|
||||
right: 13,
|
||||
left: 14,
|
||||
child: Obx(() {
|
||||
return RListView.separated(
|
||||
itemCount: controller.killRequestList.value.data?.length ?? 0,
|
||||
itemBuilder: (context, index) {
|
||||
var item = controller.killRequestList.value.data![index];
|
||||
return ObxValue((data) {
|
||||
return ExpandableListItem2(
|
||||
index: index,
|
||||
child: itemListWidget(item),
|
||||
secondChild: itemListExpandedWidget(item),
|
||||
onTap: () => controller.toggleExpandedItem(index),
|
||||
selected: data.value == index,
|
||||
labelColor: AppColor.blueLight,
|
||||
labelIcon: Assets.vec.virtualSvg.path,
|
||||
);
|
||||
}, controller.expandedItemIndex);
|
||||
},
|
||||
separatorBuilder: (context, index) => SizedBox(height: 8),
|
||||
resource: controller.killRequestList.value,
|
||||
);
|
||||
}),
|
||||
),
|
||||
|
||||
Positioned(
|
||||
right: 8,
|
||||
bottom: 92,
|
||||
child: RFab.add(
|
||||
onPressed: () {
|
||||
Get.bottomSheet(
|
||||
isScrollControlled: true,
|
||||
addKillRequestBottomSheet(controller),
|
||||
).then((value) {
|
||||
controller.clearPage();
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Row itemListWidget(listModel.KillRequestList item) {
|
||||
return Row(
|
||||
children: [
|
||||
SizedBox(width: 30),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
item.killHouse?.name ?? 'بدون نام',
|
||||
style: AppFonts.yekan14Bold.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
SizedBox(height: 4),
|
||||
Text(
|
||||
item.createDate?.toJalali.formatCompactDate() ?? "-",
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.bgDark),
|
||||
),
|
||||
],
|
||||
),
|
||||
Spacer(),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'درخواست ${item.killCapacity}'.addCountEXT,
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
SizedBox(height: 4),
|
||||
Text(
|
||||
'تعداد مورد تایید 150 قطعه',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.bgDark),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Spacer(),
|
||||
Assets.vec.scanSvg.svg(
|
||||
width: 32.w,
|
||||
height: 32.h,
|
||||
colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn),
|
||||
),
|
||||
SizedBox(width: 12),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Container itemListExpandedWidget(listModel.KillRequestList item) {
|
||||
Jalali date = item.createDate.toJalali;
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.killHouse?.name ?? 'بدون نام',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan16.copyWith(color: AppColor.greenDark),
|
||||
),
|
||||
Spacer(),
|
||||
//todo
|
||||
Text(
|
||||
'در انتظار تایید استان',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan10.copyWith(color: AppColor.darkGreyDark),
|
||||
),
|
||||
SizedBox(width: 7),
|
||||
Assets.vec.clockSvg.svg(width: 16.w, height: 16.h),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
height: 32,
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
decoration: ShapeDecoration(
|
||||
color: AppColor.blueLight,
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(width: 1, color: AppColor.blueLightHover),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
spacing: 3,
|
||||
children: [
|
||||
Text(
|
||||
date.formatter.wN,
|
||||
style: AppFonts.yekan14.copyWith(
|
||||
color: AppColor.textColor,
|
||||
),
|
||||
),
|
||||
|
||||
Text(
|
||||
'${date.formatter.d} ${date.formatter.mN ?? 'N/A'}',
|
||||
style: AppFonts.yekan14.copyWith(
|
||||
color: AppColor.blueNormal,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Text(
|
||||
date.formatter.y,
|
||||
style: AppFonts.yekan20.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
|
||||
Text(
|
||||
'${date.formatter.tHH}:${date.formatter.tMM ?? 'N/A'}',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
buildRow(
|
||||
title: 'تعداد درخواست اولیه',
|
||||
value: item.killCapacity.separatedByComma.addCountEXT,
|
||||
),
|
||||
//todo
|
||||
buildRow(
|
||||
title: 'تعداد مورد تایید',
|
||||
value: item.numberOfAllocated.separatedByComma.addCountEXT,
|
||||
),
|
||||
buildRow(title: 'زمان دریافت', value: item.reciveTime ?? '-'),
|
||||
buildRow(
|
||||
title: 'تاریخ درخواستی کشتار',
|
||||
value: item.reciveDate.toJalali.formatCompactDate(),
|
||||
),
|
||||
ROutlinedElevated(
|
||||
text: 'حذف',
|
||||
height: 40.h,
|
||||
textStyle: AppFonts.yekan20.copyWith(color: AppColor.redNormal),
|
||||
isFullWidth: true,
|
||||
onPressed: () {
|
||||
buildWarningDialog(
|
||||
title: 'اخطار',
|
||||
middleText: 'آیا از حذف شدن این مورد اطمینان دارید؟',
|
||||
onConfirm: () async {
|
||||
controller.deleteRequest(item.id!);
|
||||
},
|
||||
onRefresh: () async {
|
||||
controller.onRefresh();
|
||||
},
|
||||
);
|
||||
},
|
||||
borderColor: AppColor.redNormal,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user