feat : buy in province

This commit is contained in:
2025-07-07 11:38:37 +03:30
parent 21d3490d0c
commit 80dabe991d
23 changed files with 568 additions and 605 deletions

View File

@@ -1,31 +1,39 @@
import 'package:flutter/material.dart';
import 'package:rasadyar_chicken/presentation/pages/buy/logic.dart';
import 'package:rasadyar_chicken/presentation/pages/buy_in_province_all/logic.dart';
import 'package:rasadyar_chicken/presentation/pages/buy_in_province_waiting/logic.dart';
import 'package:rasadyar_chicken/presentation/pages/root/logic.dart';
import 'package:rasadyar_core/core.dart';
class BuyInProvinceLogic extends GetxController {
RxList<String> routesName = RxList();
RxList<String> routesName = RxList();
RxList<int> isExpandedList = <int>[].obs;
RxnString searchedValue = RxnString();
Rx<Jalali> fromDateFilter = Jalali.now().obs;
Rx<Jalali> toDateFilter = Jalali.now().obs;
RootLogic get rootLogic => Get.find<RootLogic>();
BuyLogic get buyLogic => Get.find<BuyLogic>();
RxInt selectedSegmentIndex = 0.obs;
BuyInProvinceAllLogic buyAllLogic = Get.find<BuyInProvinceAllLogic>();
BuyInProvinceWaitingLogic buyWaitingLogic = Get.find<BuyInProvinceWaitingLogic>();
@override
void onInit() {
super.onInit();
routesName.value = [...buyLogic.routesName, 'داخل استان'].toList();
routesName.add(selectedSegmentIndex.value ==0 ? 'در انتظار':'همه');
routesName.add(selectedSegmentIndex.value == 0 ? 'در انتظار' : 'همه');
ever(selectedSegmentIndex, (callback) {
routesName.removeLast();
routesName.add(callback ==0 ? 'در انتظار':'همه');
},);
routesName.add(callback == 0 ? 'در انتظار' : 'همه');
});
ever(fromDateFilter, (callback) => _setFromDateFilter(callback));
ever(toDateFilter, (callback) => _setToDateFilter(callback));
}
@override
void onReady() {
// TODO: implement onReady
@@ -38,8 +46,40 @@ class BuyInProvinceLogic extends GetxController {
super.onClose();
}
void _setFromDateFilter(Jalali jalali) {
final isWaiting = selectedSegmentIndex.value == 0;
if (isWaiting) {
buyWaitingLogic.fromDateFilter.value = fromDateFilter.value;
} else {
buyAllLogic.fromDateFilter.value = fromDateFilter.value;
}
}
void _setToDateFilter(Jalali jalali) {
final isWaiting = selectedSegmentIndex.value == 0;
if (isWaiting) {
buyWaitingLogic.toDateFilter.value = fromDateFilter.value;
} else {
buyAllLogic.toDateFilter.value = fromDateFilter.value;
}
}
Future<void> submitFilter() async {
final isWaiting = selectedSegmentIndex.value == 0;
if (isWaiting) {
buyWaitingLogic.getWaitingArrivals();
} else {
buyAllLogic.getImportedEntries();
}
}
void setSearchValue(String? data) {
searchedValue.value = data?.trim();
//TODO
final isWaiting = selectedSegmentIndex.value == 0;
if (isWaiting) {
buyWaitingLogic.searchedValue.value = searchedValue.value;
} else {
buyAllLogic.searchedValue.value = searchedValue.value;
}
}
}

View File

@@ -16,7 +16,7 @@ class BuyInProvincePage extends GetView<BuyInProvinceLogic> {
routesWidget: ObxValue((route) => buildPageRoute(route), controller.routesName),
onBackPressed: () => Get.back(id: 0),
onSearchChanged: (data) => controller.setSearchValue(data),
filteringWidget: Container(color: Colors.redAccent),
filteringWidget: filterBottomSheet(),
widgets: [
segmentWidget(),
ObxValue((index) {
@@ -48,4 +48,44 @@ class BuyInProvincePage extends GetView<BuyInProvinceLogic> {
),
);
}
Widget filterBottomSheet() {
return BaseBottomSheet(
height: 250,
child: Column(
spacing: 16,
children: [
Text('فیلترها', style: AppFonts.yekan16Bold.copyWith(color: AppColor.darkGreyDarkHover)),
Row(
spacing: 8,
children: [
Expanded(
child: dateFilterWidget(
date: controller.fromDateFilter,
onChanged: (jalali) => controller.fromDateFilter.value = jalali,
),
),
Expanded(
child: dateFilterWidget(
isFrom: false,
date: controller.toDateFilter,
onChanged: (jalali) => controller.toDateFilter.value = jalali,
),
),
],
),
SizedBox(height: 2),
RElevated(
text: 'اعمال فیلتر',
onPressed: () {
controller.submitFilter();
Get.back();
},
height: 40,
),
SizedBox(height: 16),
],
),
);
}
}