refactor: update data source and repository structure by removing unused files, enhancing model integration, and adjusting import paths for better organization

This commit is contained in:
2025-12-07 12:33:39 +03:30
parent c28a4a3177
commit 02686115cb
129 changed files with 5269 additions and 545 deletions

View File

@@ -0,0 +1,89 @@
import 'package:rasadyar_chicken/features/steward/buy/logic.dart';
import 'package:rasadyar_chicken/features/steward/buy_in_province_all/logic.dart';
import 'package:rasadyar_chicken/features/steward/buy_in_province_waiting/logic.dart';
import 'package:rasadyar_chicken/features/steward/root/logic.dart';
import 'package:rasadyar_core/core.dart';
class BuyInProvinceLogic extends GetxController {
RxList<String> routesName = RxList();
RxList<int> isExpandedList = <int>[].obs;
RxnString searchedValue = RxnString();
Rx<Jalali> fromDateFilter = Jalali.now().obs;
Rx<Jalali> toDateFilter = Jalali.now().obs;
StewardRootLogic rootLogic = Get.find<StewardRootLogic>();
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 ? 'در انتظار' : 'کل خریدها');
ever(selectedSegmentIndex, (callback) {
routesName.removeLast();
routesName.add(callback == 0 ? 'در انتظار' : 'کل خریدها');
});
ever(fromDateFilter, (callback) => _setFromDateFilter(callback));
ever(toDateFilter, (callback) => _setToDateFilter(callback));
}
@override
void onReady() {
fLog('BuyInProvinceLogic onReady');
super.onReady();
}
@override
void onClose() {
// TODO: implement onClose
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.getAllArrivals();
}
}
void setSearchValue(String? data) {
searchedValue.value = data?.trim();
final isWaiting = selectedSegmentIndex.value == 0;
if (isWaiting) {
buyWaitingLogic.searchedValue.value = searchedValue.value;
} else {
buyAllLogic.searchedValue.value = searchedValue.value;
}
}
Future<void> onRefresh() async {
await rootLogic.onRefresh();
await Future.wait([buyWaitingLogic.getWaitingArrivals(), buyAllLogic.getAllArrivals()]);
}
}

View File

@@ -0,0 +1,148 @@
import 'package:flutter/material.dart';
import 'package:rasadyar_chicken/features/steward/buy_in_province_all/view.dart';
import 'package:rasadyar_chicken/features/steward/buy_in_province_waiting/view.dart';
import 'package:rasadyar_chicken/presentation/utils/nested_keys_utils.dart';
import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart';
import 'package:rasadyar_chicken/presentation/widget/inventory/inventory_widget.dart';
import 'package:rasadyar_core/core.dart';
import 'logic.dart';
class BuyInProvincePage extends GetView<BuyInProvinceLogic> {
const BuyInProvincePage({super.key});
@override
Widget build(BuildContext context) {
return ChickenBasePage(
routesWidget: ContainerBreadcrumb(rxRoutes: controller.routesName),
onSearchChanged: (data) => controller.setSearchValue(data),
hasBack: true,
backId: stewardFirstKey,
onFilterTap: () {
Get.bottomSheet(filterBottomSheet());
},
onRefresh: controller.onRefresh,
child: Column(
children: [
Obx(() {
var list = [
InventoryItemData(
title: 'موجودی انبار',
value: controller
.rootLogic
.inventoryModel
.value
?.totalRemainWeight
?.separatedByCommaFa,
color: const Color(0xFFEAFBFC),
),
InventoryItemData(
title: 'مانده دولتی',
value: controller
.rootLogic
.inventoryModel
.value
?.totalGovernmentalRemainWeight
?.separatedByCommaFa,
color: const Color(0xFFF5ECEE),
),
InventoryItemData(
title: 'مانده آزاد',
value: controller
.rootLogic
.inventoryModel
.value
?.totalFreeRemainWeight
?.separatedByCommaFa,
color: const Color(0xFFF1E7FF),
),
];
return InventoryWidget(inventoryModel: list);
}),
segmentWidget(),
ObxValue((index) {
return Expanded(
child: index.value == 0
? BuyInProvinceWaitingPage()
: BuyInProvinceAllPage(),
);
}, controller.selectedSegmentIndex),
],
),
);
}
Padding segmentWidget() {
return Padding(
padding: const EdgeInsets.fromLTRB(8, 0, 8, 8),
child: Row(
children: [
Expanded(
child: RSegment(
children: ['در انتظار', 'کل خریدها'],
selectedIndex: 0,
borderColor: const Color(0xFFB4B4B4),
selectedBorderColor: AppColor.blueNormal,
selectedBackgroundColor: AppColor.blueLight,
onSegmentSelected: (index) =>
controller.selectedSegmentIndex.value = index,
backgroundColor: AppColor.whiteGreyNormal,
),
),
],
),
);
}
Widget filterBottomSheet() {
return BaseBottomSheet(
height: 200,
child: Column(
spacing: 16,
children: [
Text(
'فیلترها',
style: AppFonts.yekan16Bold.copyWith(color: AppColor.blueNormal),
),
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,
),
),
],
),
RElevated(
text: 'اعمال فیلتر',
isFullWidth: true,
backgroundColor: AppColor.greenNormal,
onPressed: () {
controller.submitFilter();
Get.back();
},
height: 40,
),
SizedBox(height: 16),
],
),
);
}
}