fix : has more in list

This commit is contained in:
2025-07-08 12:17:39 +03:30
parent 8b656d4915
commit a9b012b016
5 changed files with 108 additions and 102 deletions

View File

@@ -18,6 +18,7 @@ class BuyInProvinceWaitingPage extends GetView<BuyInProvinceWaitingLogic> {
return RPaginatedListView(
listType: ListType.separated,
resource: data.value,
hasMore: data.value.data?.next!= null,
padding: EdgeInsets.fromLTRB(8, 8, 8, 80),
itemBuilder: (context, index) {
var item = data.value.data!.results![index];

View File

@@ -58,10 +58,8 @@ class BuyOutOfProvinceLogic extends GetxController {
super.onReady();
getStewardPurchaseOutOfProvince();
selectedProvince.listen((p0) => getCites());
outOfTheProvinceLogic.rolesProductsModel.listen((lists) {
selectedProduct.value = lists.first;
});
selectedProduct.value = outOfTheProvinceLogic.rolesProductsModel.first;
setupListeners();
debounce(
@@ -101,7 +99,7 @@ class BuyOutOfProvinceLogic extends GetxController {
call: () => rootLogic.chickenRepository.getStewardPurchasesOutSideOfTheProvince(
token: rootLogic.tokenService.accessToken.value!,
queryParameters: buildQueryParams(
pageSize: 10,
pageSize: 20,
page: currentPage.value,
search: 'filter',
role: 'Steward',

View File

@@ -30,6 +30,7 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
return RPaginatedListView(
listType: ListType.separated,
resource: data.value,
hasMore:data.value.data?.next!=null ,
padding: EdgeInsets.fromLTRB(8, 8, 8, 80),
itemBuilder: (context, index) {
var item = data.value.data!.results![index];
@@ -295,59 +296,84 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
child: Form(
key: controller.formKey,
child: Column(
spacing: 16,
spacing: 8,
children: [
Text(
isOnEdit ? 'ویرایش اطلاعات خرید' : 'ثبت اطلاعات خرید',
style: AppFonts.yekan16Bold.copyWith(color: AppColor.darkGreyDarkHover),
),
_productTypeWidget(),
RTextField(
controller: controller.sellerNameController,
label: 'نام فروشنده',
borderColor: AppColor.darkGreyLight,
filled: true,
filledColor: AppColor.bgLight,
),
RTextField(
controller: controller.sellerPhoneController,
label: 'تلفن فروشنده',
keyboardType: TextInputType.phone,
borderColor: AppColor.darkGreyLight,
maxLength: 11,
filled: true,
filledColor: AppColor.bgLight,
validator: (value) {
if (value == null || value.isEmpty) {
return 'لطفاً شماره موبایل را وارد کنید';
}
String cleaned = value.replaceAll(',', '');
if (cleaned.length != 11) {
return 'شماره موبایل باید ۱۱ رقم باشد';
}
if (!cleaned.startsWith('09')) {
return 'شماره موبایل باید با 09 شروع شود';
}
return null;
},
),
_provinceWidget(),
_cityWidget(),
RTextField(
controller: controller.carcassWeightController,
label: 'وزن',
filled: true,
suffixIcon: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Assets.vec.killogramSvg.svg(),
_productDropDown(),
Container(
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.darkGreyLight, width: 1),
),
child: Column(spacing: 12, children: [_provinceWidget(), _cityWidget()]),
),
Container(
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.darkGreyLight, width: 1),
),
child: Column(
spacing: 12,
children: [
RTextField(
controller: controller.sellerNameController,
label: 'نام فروشنده',
borderColor: AppColor.darkGreyLight,
filled: true,
filledColor: AppColor.bgLight,
),
RTextField(
controller: controller.sellerPhoneController,
label: 'تلفن فروشنده',
keyboardType: TextInputType.phone,
borderColor: AppColor.darkGreyLight,
maxLength: 11,
filled: true,
filledColor: AppColor.bgLight,
validator: (value) {
if (value == null || value.isEmpty) {
return 'لطفاً شماره موبایل را وارد کنید';
}
String cleaned = value.replaceAll(',', '');
if (cleaned.length != 11) {
return 'شماره موبایل باید ۱۱ رقم باشد';
}
if (!cleaned.startsWith('09')) {
return 'شماره موبایل باید با 09 شروع شود';
}
return null;
},
),
RTextField(
controller: controller.carcassWeightController,
label: 'وزن',
filled: true,
suffixIcon: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Assets.vec.killogramSvg.svg(),
),
filledColor: AppColor.bgLight,
keyboardType: TextInputType.number,
borderColor: AppColor.darkGreyLight,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
SeparatorInputFormatter(),
],
),
],
),
filledColor: AppColor.bgLight,
keyboardType: TextInputType.number,
borderColor: AppColor.darkGreyLight,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
SeparatorInputFormatter(),
],
),
_imageCarcasesWidget(isOnEdit),
submitButtonWidget(isOnEdit),
@@ -362,7 +388,7 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
Widget submitButtonWidget(bool isOnEdit) {
return ObxValue((data) {
return RElevated(
text: isOnEdit ? 'ویرایش' : 'ثبت خرید',
text: isOnEdit ? 'ویرایش' : 'ثبت',
width: Get.width,
backgroundColor: AppColor.greenNormal,
onPressed: data.value
@@ -378,25 +404,33 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
}, controller.isSubmitButtonEnabled);
}
Widget _productTypeWidget() {
Widget _productDropDown() {
return Obx(() {
return OverlayDropdownWidget<ProductModel>(
items: controller.outOfTheProvinceLogic.rolesProductsModel,
height: 56,
hasDropIcon: false,
background: Colors.white,
onChanged: (value) {
controller.selectedProduct.value = value;
},
selectedItem: controller.selectedProduct.value,
initialValue: controller.selectedProduct.value,
itemBuilder: (item) => Text(
item.name ?? 'بدون نام',
style: AppFonts.yekan14.copyWith(color: AppColor.lightGreyDarker),
itemBuilder: (item) => Text(item.name ?? 'بدون نام'),
labelBuilder: (item) => Row(
spacing: 8,
children: [
(item?.name?.contains('مرغ گرم') ?? false)
? Assets.images.chicken.image(width: 40, height: 40)
: Assets.vec.placeHolderSvg.svg(width: 40, height: 40),
Text(item?.name ?? 'انتخاب محصول'),
Spacer(),
Text(
'موجودی:${controller.rootLogic.inventoryModel.value?.totalRemainWeight.separatedByComma ?? 0}',
),
],
),
labelBuilder: (item) => item?.name != null
? Text(item!.name!, style: AppFonts.yekan14.copyWith(color: AppColor.textColor))
: Text(
'انتخاب محصول',
style: AppFonts.yekan14.copyWith(color: AppColor.textColorLight),
),
);
});
}
@@ -575,5 +609,4 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
}, controller.rootLogic.inventoryModel),
);
}
}

View File

@@ -20,6 +20,7 @@ class SalesOutOfProvinceBuyersPage extends GetView<SalesOutOfProvinceBuyersLogic
controller.currentPage.value = 1;
await controller.getOutProvinceCarcassesBuyer();
},
hasMore: data.value.data?.next!= null,
listType: ListType.separated,
resource: data.value,
padding: EdgeInsets.fromLTRB(8, 8, 8, 80),

View File

@@ -9,8 +9,7 @@ import 'package:rasadyar_core/core.dart';
import 'logic.dart';
class SalesOutOfProvinceSalesListPage
extends GetView<SalesOutOfProvinceSalesListLogic> {
class SalesOutOfProvinceSalesListPage extends GetView<SalesOutOfProvinceSalesListLogic> {
const SalesOutOfProvinceSalesListPage({super.key});
@override
@@ -23,6 +22,7 @@ class SalesOutOfProvinceSalesListPage
controller.currentPage.value = 1;
await controller.getOutProvinceSales();
},
hasMore: data.value.data?.next != null,
listType: ListType.separated,
resource: data.value,
padding: EdgeInsets.fromLTRB(8, 8, 8, 80),
@@ -123,10 +123,7 @@ class SalesOutOfProvinceSalesListPage
return Container(
padding: EdgeInsets.fromLTRB(8, 12, 14, 12),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
),
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
child: Column(
spacing: 8,
children: [
@@ -150,21 +147,12 @@ class SalesOutOfProvinceSalesListPage
borderRadius: BorderRadius.circular(8),
),
),
child: buildRow(
title: 'تاریخ',
value: item.date?.formattedJalaliDateYHMS ?? 'N/A',
),
),
buildRow(
title: 'مشخصات خریدار',
value: item.buyer?.fullname ?? 'N/A',
child: buildRow(title: 'تاریخ', value: item.date?.formattedJalaliDateYHMS ?? 'N/A'),
),
buildRow(title: 'مشخصات خریدار', value: item.buyer?.fullname ?? 'N/A'),
buildRow(title: 'تلفن خریدار', value: item.buyer?.mobile ?? 'N/A'),
buildRow(title: 'نام واحد', value: item.buyer?.unitName ?? 'N/A'),
buildRow(
title: 'وزن لاشه',
value: '${item.weightOfCarcasses?.separatedByComma}',
),
buildRow(title: 'وزن لاشه', value: '${item.weightOfCarcasses?.separatedByComma}'),
Row(
mainAxisAlignment: MainAxisAlignment.center,
@@ -220,13 +208,10 @@ class SalesOutOfProvinceSalesListPage
children: [
Text(
isOnEdit ? 'ویرایش فروش' : 'افزودن فروش',
style: AppFonts.yekan16Bold.copyWith(
color: AppColor.darkGreyDarkHover,
),
style: AppFonts.yekan16Bold.copyWith(color: AppColor.darkGreyDarkHover),
),
_productDropDown(),
Container(
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
@@ -301,9 +286,7 @@ class SalesOutOfProvinceSalesListPage
text: isOnEdit ? 'ویرایش' : 'ثبت',
onPressed: data.value
? () async {
var res = isOnEdit
? await controller.editSale()
: await controller.createSale();
var res = isOnEdit ? await controller.editSale() : await controller.createSale();
if (res) {
controller.getOutProvinceSales();
controller.clearSaleForm();
@@ -330,7 +313,6 @@ class SalesOutOfProvinceSalesListPage
});
}
Widget _productDropDown() {
return Obx(() {
return OverlayDropdownWidget<ProductModel>(
@@ -362,7 +344,6 @@ class SalesOutOfProvinceSalesListPage
});
}
GestureDetector timeFilterWidget({
isFrom = true,
required Rx<Jalali> date,
@@ -375,7 +356,7 @@ class SalesOutOfProvinceSalesListPage
child: Container(
height: 40,
decoration: BoxDecoration(
color:AppColor.bgLight,
color: AppColor.bgLight,
borderRadius: BorderRadius.circular(8),
border: Border.all(width: 1, color: AppColor.darkGreyLight),
),
@@ -386,23 +367,15 @@ class SalesOutOfProvinceSalesListPage
Assets.vec.calendarSvg.svg(
width: 24,
height: 24,
colorFilter: const ColorFilter.mode(
AppColor.bgDark,
BlendMode.srcIn,
),
),
Text(
'تاریخ',
style: AppFonts.yekan16.copyWith(color: AppColor.bgDark),
colorFilter: const ColorFilter.mode(AppColor.bgDark, BlendMode.srcIn),
),
Text('تاریخ', style: AppFonts.yekan16.copyWith(color: AppColor.bgDark)),
Expanded(
child: ObxValue((data) {
return Text(
date.value.formatCompactDate(),
textAlign: TextAlign.center,
style: AppFonts.yekan16.copyWith(
color: AppColor.darkGreyDark,
),
style: AppFonts.yekan16.copyWith(color: AppColor.darkGreyDark),
);
}, date),
),