feat: new date picker and new logic

This commit is contained in:
2025-11-02 15:45:31 +03:30
parent 627497a840
commit 858fb48f68
13 changed files with 1090 additions and 247 deletions

View File

@@ -10,6 +10,10 @@ import 'package:rasadyar_core/core.dart';
import 'logic.dart';
class SegmentationPage extends GetView<SegmentationLogic> {
final today = Jalali.now();
final oneDayAgo = Jalali.now().addDays(-1);
final twoDaysAgo = Jalali.now().addDays(-2);
@override
Widget build(BuildContext context) {
return ChickenBasePage(
@@ -342,24 +346,6 @@ class SegmentationPage extends GetView<SegmentationLogic> {
],
),
),
ObxValue((data) {
return RTextField(
controller: TextEditingController(),
filledColor: AppColor.bgLight,
filled: true,
label: 'تاریخ تولید گوشت',
onTap: () {
Get.bottomSheet(
modalDatePicker((value) {
controller.productionData.value = value;
controller.productionData.refresh();
}),
);
},
borderColor: AppColor.darkGreyLight,
initText: data.value?.formatCompactDate(),
);
}, controller.productionData),
Container(
height: 50.h,
@@ -458,13 +444,46 @@ class SegmentationPage extends GetView<SegmentationLogic> {
children: [
Expanded(
child: GestureDetector(
onTap: () {
controller.quotaType.value = 1;
},
onTap:
(controller
.rootLogic
.stewardSalesInfoDashboard
.value
?.totalGovernmentalRemainWeight ??
-1) >
0
? () {
controller.quotaType.value = 1;
}
: null,
child: Row(
children: [
Radio(value: 1),
Text('انبار دولتی', style: AppFonts.yekan14),
Radio(
value: 1,
enabled:
(controller
.rootLogic
.stewardSalesInfoDashboard
.value
?.totalGovernmentalRemainWeight ??
-1) >
0,
),
Text(
'انبار دولتی',
style: AppFonts.yekan14.copyWith(
color:
((controller
.rootLogic
.stewardSalesInfoDashboard
.value
?.totalGovernmentalRemainWeight ??
-1) >
0)
? AppColor.textColor
: AppColor.labelTextColor,
),
),
],
),
),
@@ -472,13 +491,46 @@ class SegmentationPage extends GetView<SegmentationLogic> {
Expanded(
child: GestureDetector(
onTap: () {
controller.quotaType.value = 2;
},
onTap:
(controller
.rootLogic
.stewardSalesInfoDashboard
.value
?.totalFreeRemainWeight ??
-1) >
0
? () {
controller.quotaType.value = 2;
}
: null,
child: Row(
children: [
Radio(value: 2),
Text('انبار آزاد', style: AppFonts.yekan14),
Radio(
value: 2,
enabled:
(controller
.rootLogic
.stewardSalesInfoDashboard
.value
?.totalFreeRemainWeight ??
-1) >
0,
),
Text(
'انبار آزاد',
style: AppFonts.yekan14.copyWith(
color:
((controller
.rootLogic
.stewardSalesInfoDashboard
.value
?.totalFreeRemainWeight ??
-1) >
0)
? AppColor.textColor
: AppColor.labelTextColor,
),
),
],
),
),
@@ -490,6 +542,17 @@ class SegmentationPage extends GetView<SegmentationLogic> {
],
),
),
Obx(() {
return MonthlyDataCalendar(
label: 'تاریخ تولید گوشت',
selectedDate: controller.productionDate.value?.formatCompactDate(),
onDateSelect: (value) => controller.productionDate..value = value.date,
dayData: controller.quotaType.value == 1
? controller.governmentalProductionDateData
: controller.freeProductionDateData,
);
}),
],
),
),
@@ -609,6 +672,7 @@ class SegmentationPage extends GetView<SegmentationLogic> {
}
Container modalDatePicker(ValueChanged<Jalali> onDateSelected) {
Jalali currentDate = Jalali.now();
Jalali? tempPickedDate;
return Container(
height: 250,
@@ -652,6 +716,14 @@ class SegmentationPage extends GetView<SegmentationLogic> {
child: PersianCupertinoDatePicker(
initialDateTime: controller.saleDate.value,
mode: PersianCupertinoDatePickerMode.date,
maximumDate: currentDate.addDays(3),
minimumDate: currentDate
.toDateTime()
.subtract(Duration(days: 1))
.toString()
.toJalali,
maximumYear: currentDate.year,
minimumYear: currentDate.year,
onDateTimeChanged: (dateTime) {
tempPickedDate = dateTime;
},