feat :
1 - AllocatedMadeModel 2 - RSegment widget 3 - buy in province
This commit is contained in:
@@ -1,6 +1,31 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/buy/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<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;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
routesName.value = [...buyLogic.routesName, 'داخل استان'].toList();
|
||||
routesName.add(selectedSegmentIndex.value ==0 ? 'در انتظار':'همه');
|
||||
ever(selectedSegmentIndex, (callback) {
|
||||
routesName.removeLast();
|
||||
routesName.add(callback ==0 ? 'در انتظار':'همه');
|
||||
},);
|
||||
|
||||
}
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
@@ -12,4 +37,9 @@ class BuyInProvinceLogic extends GetxController {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
void setSearchValue(String? data) {
|
||||
searchedValue.value = data?.trim();
|
||||
//TODO
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/buy_in_province_all/view.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/buy_in_province_waiting/view.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/page_route.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
@@ -8,9 +12,40 @@ class BuyInProvincePage extends GetView<BuyInProvinceLogic> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BasePage(
|
||||
routesWidget: ObxValue((route) => buildPageRoute(route), controller.routesName),
|
||||
onBackPressed: () => Get.back(id: 0),
|
||||
onSearchChanged: (data) => controller.setSearchValue(data),
|
||||
filteringWidget: Container(color: Colors.redAccent),
|
||||
widgets: [
|
||||
segmentWidget(),
|
||||
ObxValue((index) {
|
||||
return Expanded(
|
||||
child: index.value == 0 ? BuyInProvinceWaitingPage() : BuyInProvinceAllPage(),
|
||||
);
|
||||
}, controller.selectedSegmentIndex),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return Container(
|
||||
color: Colors.amberAccent,
|
||||
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,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class BuyInProvinceAllLogic extends GetxController {
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
class BuyInProvinceAllPage extends GetView<BuyInProvinceAllLogic> {
|
||||
const BuyInProvinceAllPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(color: Colors.blue);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import 'package:rasadyar_auth/data/utils/safe_call.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/waiting_arrival/waiting_arrival.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/root/logic.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class BuyInProvinceWaitingLogic extends GetxController {
|
||||
RxList<int> isExpandedList = <int>[].obs;
|
||||
Rx<Jalali> fromDateFilter = Jalali.now().obs;
|
||||
Rx<Jalali> toDateFilter = Jalali.now().obs;
|
||||
RxnString searchedValue = RxnString();
|
||||
|
||||
RootLogic rootLogic = Get.find<RootLogic>();
|
||||
Rx<Resource<List<WaitingArrivalModel>>> waitingProduct =
|
||||
Resource<List<WaitingArrivalModel>>.loading().obs;
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
getWaitingArrivals();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
Future<void> getWaitingArrivals() async {
|
||||
safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.getWaitingArrivals(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(
|
||||
queryParams: {
|
||||
'type':'not_entered'
|
||||
},
|
||||
pageSize: 10,
|
||||
page: 1,
|
||||
search: 'filter',
|
||||
role: 'Steward',
|
||||
value: searchedValue.value,
|
||||
fromDate: fromDateFilter.value.toDateTime(),
|
||||
toDate: toDateFilter.value.toDateTime(),
|
||||
),
|
||||
),
|
||||
onSuccess: (res) async {
|
||||
await Future.delayed(Duration(milliseconds: 500));
|
||||
if ((res?.count ?? 0) == 0) {
|
||||
waitingProduct.value = Resource<List<WaitingArrivalModel>>.empty();
|
||||
} else {
|
||||
waitingProduct.value = Resource<List<WaitingArrivalModel>>.success(res!.results!);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void setSearchValue(String? data) {
|
||||
searchedValue.value = data?.trim();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/waiting_arrival/waiting_arrival.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/list_item/list_item.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/list_row_item.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
class BuyInProvinceWaitingPage extends GetView<BuyInProvinceWaitingLogic> {
|
||||
const BuyInProvinceWaitingPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: ObxValue((data) {
|
||||
return RPaginatedListView(
|
||||
listType: ListType.separated,
|
||||
resource: data.value,
|
||||
padding: EdgeInsets.fromLTRB(8, 8, 8, 80),
|
||||
itemBuilder: (context, index) {
|
||||
var item = data.value.data![index];
|
||||
return ObxValue((val) {
|
||||
return ListItem2(
|
||||
selected: val.contains(index),
|
||||
onTap: () => controller.isExpandedList.toggle(index),
|
||||
index: index,
|
||||
child: itemListWidget(item),
|
||||
secondChild: itemListExpandedWidget(item),
|
||||
labelColor: AppColor.blueLight,
|
||||
labelIcon: Assets.vec.truckFastOutlinedSvg.path,
|
||||
);
|
||||
}, controller.isExpandedList);
|
||||
},
|
||||
itemCount: data.value.data?.length ?? 0,
|
||||
separatorBuilder: (context, index) => SizedBox(height: 8.h),
|
||||
onLoadMore: () async {},
|
||||
);
|
||||
}, controller.waitingProduct),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Row itemListWidget(WaitingArrivalModel item) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
SizedBox(width: 20),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 3,
|
||||
children: [
|
||||
Text(
|
||||
item.toSteward?.user?.fullname ?? 'N/A',
|
||||
textAlign: TextAlign.start,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
Text(
|
||||
item.date?.formattedJalaliDate ?? 'N/A',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.bgDark),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
spacing: 3,
|
||||
children: [
|
||||
Visibility(
|
||||
visible: item.product?.name?.contains('مرغ گرم') ?? false,
|
||||
child: Assets.vec.hotChickenSvg.svg(
|
||||
width: 24,
|
||||
height: 24,
|
||||
colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${item.weightOfCarcasses?.separatedByComma}kg',
|
||||
textAlign: TextAlign.left,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
SizedBox(height: 2),
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Assets.vec.scanSvg.svg(
|
||||
width: 32.w,
|
||||
height: 32.h,
|
||||
colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Container itemListExpandedWidget(WaitingArrivalModel item) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
|
||||
child: Column(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.steward?.user?.fullname ?? 'N/A',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan16.copyWith(color: AppColor.greenDark),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
height: 32,
|
||||
padding: EdgeInsets.symmetric(horizontal: 4),
|
||||
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(
|
||||
item.date?.toJalali.formatter.wN ?? 'N/A',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
|
||||
Text(
|
||||
'${item.date?.toJalali.formatter.d} ${item.date?.toJalali.formatter.mN ?? 'N/A'}',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Text(
|
||||
'${item.date?.toJalali.formatter.y}',
|
||||
style: AppFonts.yekan20.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
|
||||
Text(
|
||||
'${item.date?.toJalali.formatter.tHH}:${item.date?.toJalali.formatter.tMM ?? 'N/A'}',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// buildRow(title: 'مشخصات فروشنده', value: item.killHouseName ?? 'N/A'),
|
||||
|
||||
buildRow(
|
||||
title: 'تلفن فروشنده',
|
||||
value: item.steward?.user?.mobile ?? 'N/A',
|
||||
valueStyle: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
buildRow(title: 'محصول', value: item.product?.name ?? 'N/A'),
|
||||
buildRow(
|
||||
title: 'وزن خریداری شده',
|
||||
value: '${item.weightOfCarcasses?.separatedByComma} کیلوگرم',
|
||||
),
|
||||
buildRowOnTapped(
|
||||
title: 'مشاهده بارنامه',
|
||||
titleStyle: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
|
||||
valueWidget: Assets.vec.clipboardEyeSvg.svg(
|
||||
width: 20,
|
||||
height: 24,
|
||||
colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn),
|
||||
),
|
||||
onTap: () {
|
||||
Get.bottomSheet(
|
||||
BaseBottomSheet(
|
||||
height: 400,
|
||||
child: Column(
|
||||
spacing: 16,
|
||||
children: [
|
||||
Text(
|
||||
'بارنامه',
|
||||
style: AppFonts.yekan16Bold.copyWith(color: AppColor.darkGreyDarkHover),
|
||||
),
|
||||
|
||||
/* Image.network(
|
||||
item.barImage ?? '',
|
||||
fit: BoxFit.cover,
|
||||
height: 300,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
eLog(error.toString());
|
||||
return Center(child: Text('خطایی پیش آمده!'));
|
||||
},
|
||||
loadingBuilder: (context, child, loadingProgress) {
|
||||
if (loadingProgress == null) return child;
|
||||
return CupertinoActivityIndicator();
|
||||
},
|
||||
),*/
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
/* Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 16.w,
|
||||
children: [
|
||||
RElevated(
|
||||
text: 'ویرایش',
|
||||
width: 150.w,
|
||||
height: 40.h,
|
||||
onPressed: () {
|
||||
controller.setEditData(item);
|
||||
Get.bottomSheet(
|
||||
addPurchasedInformationBottomSheet(true),
|
||||
isScrollControlled: true,
|
||||
).whenComplete(() {
|
||||
controller.resetSubmitForm();
|
||||
});
|
||||
},
|
||||
textStyle: AppFonts.yekan20.copyWith(color: Colors.white),
|
||||
backgroundColor: AppColor.greenNormal,
|
||||
),
|
||||
ROutlinedElevated(
|
||||
text: 'حذف',
|
||||
textStyle: AppFonts.yekan20.copyWith(color: AppColor.redNormal),
|
||||
width: 150.w,
|
||||
height: 40.h,
|
||||
onPressed: () {
|
||||
buildDeleteDialog(
|
||||
onConfirm: () => controller.deleteStewardPurchaseOutOfProvince(item.key!),
|
||||
onRefresh: () => controller.getStewardPurchaseOutOfProvince(),
|
||||
);
|
||||
},
|
||||
borderColor: AppColor.redNormal,
|
||||
),
|
||||
],
|
||||
),*/
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,7 +31,6 @@ class BuyOutOfProvinceLogic extends GetxController {
|
||||
RxnString editImageUrl = RxnString();
|
||||
|
||||
RootLogic get rootLogic => Get.find<RootLogic>();
|
||||
|
||||
BuyLogic get buyLogic => Get.find<BuyLogic>();
|
||||
|
||||
SaleLogic get outOfTheProvinceLogic => Get.find<SaleLogic>();
|
||||
|
||||
@@ -33,9 +33,9 @@ class EnteringTheWarehouseLogic extends GetxController {
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
//rootLogic.getInventory();
|
||||
|
||||
getBarGeneralInformation();
|
||||
getWaitingArrivals();
|
||||
|
||||
getImportedEntried();
|
||||
|
||||
scrollControllerImportedLoad.addListener(() {
|
||||
@@ -50,7 +50,7 @@ class EnteringTheWarehouseLogic extends GetxController {
|
||||
if (scrollControllerWaitingForArrival.position.pixels >=
|
||||
scrollControllerWaitingForArrival.position.maxScrollExtent - 100) {
|
||||
addPageWaitingForArrival.value = true;
|
||||
getWaitingArrivals();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -72,38 +72,7 @@ class EnteringTheWarehouseLogic extends GetxController {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getWaitingArrivals() async {
|
||||
if (isLoadingMoreWaitingForArrival.value ||
|
||||
!hasMoreDataWaitingForArrival.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (addPageWaitingForArrival.value) {
|
||||
currentPageWaitingForArrival.value++;
|
||||
}
|
||||
|
||||
safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.getWaitingArrivals(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
page: currentPageWaitingForArrival.value,
|
||||
),
|
||||
onError: (error, stackTrace) {
|
||||
isLoadingMoreImportedLoad.value = false;
|
||||
},
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
waitingForArrival.value = result;
|
||||
if (isLoadingMoreWaitingForArrival.value) {
|
||||
waitingForArrival.value?.results.addAll(result.results);
|
||||
} else {
|
||||
waitingForArrival.value = result;
|
||||
}
|
||||
}
|
||||
|
||||
isLoadingMoreImportedLoad.value = false;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> acceptEntried(String key) async {
|
||||
var request = StewardAllocationRequest(
|
||||
@@ -139,7 +108,7 @@ class EnteringTheWarehouseLogic extends GetxController {
|
||||
},
|
||||
onSuccess: (result) {
|
||||
clearControllers();
|
||||
getWaitingArrivals();
|
||||
|
||||
getBarGeneralInformation();
|
||||
},
|
||||
);
|
||||
@@ -162,7 +131,7 @@ class EnteringTheWarehouseLogic extends GetxController {
|
||||
eLog(error);
|
||||
},
|
||||
onSuccess: (result) {
|
||||
getWaitingArrivals();
|
||||
|
||||
getBarGeneralInformation();
|
||||
},
|
||||
);
|
||||
|
||||
@@ -21,7 +21,7 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
|
||||
ObxValue((data) {
|
||||
return generalBarInformation(data.value);
|
||||
}, controller.barInformation),
|
||||
waitingForArrival(),
|
||||
|
||||
importedLoads(),
|
||||
],
|
||||
),
|
||||
@@ -251,7 +251,7 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget waitingForArrival() {
|
||||
/* Widget waitingForArrival() {
|
||||
return Column(
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
@@ -398,7 +398,7 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
|
||||
}, controller.waitingForArrival),
|
||||
],
|
||||
);
|
||||
}
|
||||
}*/
|
||||
|
||||
Widget importedLoads() {
|
||||
return Column(
|
||||
@@ -546,7 +546,7 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget acceptBottomSheet(ResultModel resultModel) {
|
||||
/* Widget acceptBottomSheet(ResultModel resultModel) {
|
||||
return BaseBottomSheet(
|
||||
height: 500,
|
||||
child: Column(
|
||||
@@ -625,5 +625,5 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user