feat : new ui
This commit is contained in:
@@ -100,4 +100,33 @@ class GenocideLogic extends GetxController {
|
||||
void toggleExpanded(int index) {
|
||||
expandedIndex.value = expandedIndex.value == index ? -1 : index;
|
||||
}
|
||||
|
||||
|
||||
String getRequestType(PoultryOrder item) {
|
||||
if (item.market ?? false) {
|
||||
return 'پنل معاملات';
|
||||
} else if (item.union ?? false) {
|
||||
return 'اتحادیه';
|
||||
} else {
|
||||
return 'خرید مستقیم';
|
||||
}
|
||||
}
|
||||
|
||||
String getKillType(PoultryOrder item) {
|
||||
if (item.export ?? false) {
|
||||
return 'صادرات';
|
||||
} else if (item.freezing ?? false) {
|
||||
return 'انجماد';
|
||||
} else {
|
||||
return 'عادی';
|
||||
}
|
||||
}
|
||||
|
||||
String getState(PoultryOrder item) {
|
||||
if (item.stateProcess == 'pending') {
|
||||
return 'در انتظار تایید';
|
||||
} else {
|
||||
return 'تایید شده';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/poultry_order/poultry_order.dart';
|
||||
import 'package:rasadyar_chicken/presentation/routes/routes.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/poultry_science/killing_registration/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/filter_bottom_sheet.dart';
|
||||
@@ -23,48 +23,59 @@ class GenocidePage extends GetView<GenocideLogic> {
|
||||
},
|
||||
filteringWidget: filterBottomSheet(),
|
||||
onBackPressed: () => Get.back(id: poultryFirstKey),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.startFloat,
|
||||
floatingActionButton: RFab.add(
|
||||
onPressed: () {
|
||||
Get.toNamed(ChickenRoutes.killingRegistrationPoultryScience, id: poultryFirstKey);
|
||||
},
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
Positioned.fill(child: poultryOrderListWidget()),
|
||||
Positioned(
|
||||
bottom: 130,
|
||||
right: 16,
|
||||
child: RFab.add(
|
||||
onPressed: () {
|
||||
Get.bottomSheet(
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
killRegistrationBottomSheet(),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
widgets: [poultryOrderListWidget()],
|
||||
);
|
||||
}
|
||||
|
||||
//region List and Items
|
||||
Widget poultryOrderListWidget() {
|
||||
return Expanded(
|
||||
child: ObxValue((data) {
|
||||
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];
|
||||
return ObxValue((val) {
|
||||
return ExpandableListItem2(
|
||||
selected: val.value.isEqual(index),
|
||||
onTap: () => controller.toggleExpanded(index),
|
||||
index: index,
|
||||
child: itemListWidget(item),
|
||||
secondChild: itemListExpandedWidget(item),
|
||||
labelColor: AppColor.blueLight,
|
||||
labelIcon: Assets.vec.cubeScanSvg.path,
|
||||
);
|
||||
}, controller.expandedIndex);
|
||||
},
|
||||
itemCount: data.value.data?.results?.length ?? 0,
|
||||
separatorBuilder: (context, index) => SizedBox(height: 8.h),
|
||||
onLoadMore: () async => controller.getPoultryOrderList(true),
|
||||
onRefresh: () async {
|
||||
controller.currentPage.value = 1;
|
||||
await controller.getPoultryOrderList();
|
||||
},
|
||||
);
|
||||
}, controller.poultryOrderList),
|
||||
);
|
||||
return ObxValue((data) {
|
||||
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];
|
||||
return ObxValue((val) {
|
||||
return ExpandableListItem2(
|
||||
selected: val.value.isEqual(index),
|
||||
onTap: () => controller.toggleExpanded(index),
|
||||
index: index,
|
||||
child: itemListWidget(item),
|
||||
secondChild: itemListExpandedWidget(item),
|
||||
labelColor: AppColor.blueLight,
|
||||
labelIcon: Assets.vec.cubeScanSvg.path,
|
||||
);
|
||||
}, controller.expandedIndex);
|
||||
},
|
||||
itemCount: data.value.data?.results?.length ?? 0,
|
||||
separatorBuilder: (context, index) => SizedBox(height: 8.h),
|
||||
onLoadMore: () async => controller.getPoultryOrderList(true),
|
||||
onRefresh: () async {
|
||||
controller.currentPage.value = 1;
|
||||
await controller.getPoultryOrderList();
|
||||
},
|
||||
);
|
||||
}, controller.poultryOrderList);
|
||||
}
|
||||
|
||||
Container itemListExpandedWidget(PoultryOrder item) {
|
||||
@@ -129,8 +140,8 @@ class GenocidePage extends GetView<GenocideLogic> {
|
||||
title: 'نوع فروش',
|
||||
value: (item.freeSaleInProvince ?? false) ? 'آزاد' : 'دولتی ',
|
||||
),
|
||||
buildRow(title: 'نوع کشتار ', value: getKillType(item)),
|
||||
buildRow(title: 'درخواست', value: getRequestType(item) ?? 'N/A'),
|
||||
buildRow(title: 'نوع کشتار ', value: controller.getKillType(item)),
|
||||
buildRow(title: 'درخواست', value: controller.getRequestType(item) ?? 'N/A'),
|
||||
|
||||
buildRow(title: 'میانگین وزنی', value: '${(item.indexWeight)} (کیلوگرم)'),
|
||||
buildRow(title: 'قیمت مرغدار', value: '${item.amount.separatedByComma} (ریال)'),
|
||||
@@ -138,7 +149,7 @@ class GenocidePage extends GetView<GenocideLogic> {
|
||||
title: 'مانده در سالن ',
|
||||
value: '${item.hatching?.leftOver.separatedByComma ?? 0} (قطعه)',
|
||||
),
|
||||
buildRow(title: ' وضعیت', value: getState(item)),
|
||||
buildRow(title: ' وضعیت', value: controller.getState(item)),
|
||||
|
||||
Visibility(
|
||||
visible: item.stateProcess == 'pending',
|
||||
@@ -159,13 +170,12 @@ class GenocidePage extends GetView<GenocideLogic> {
|
||||
onPressed: data.value
|
||||
? null
|
||||
: () => _buildDeleteDialog(
|
||||
onConfirm: () async {
|
||||
Get.back();
|
||||
await controller.deletePoultryOrder(item.id!);
|
||||
controller.getPoultryOrderList();
|
||||
|
||||
},
|
||||
),
|
||||
onConfirm: () async {
|
||||
Get.back();
|
||||
await controller.deletePoultryOrder(item.id!);
|
||||
controller.getPoultryOrderList();
|
||||
},
|
||||
),
|
||||
);
|
||||
}, controller.isLoadingDelete),
|
||||
),
|
||||
@@ -231,34 +241,9 @@ class GenocidePage extends GetView<GenocideLogic> {
|
||||
);
|
||||
}
|
||||
|
||||
String getRequestType(PoultryOrder item) {
|
||||
if (item.market ?? false) {
|
||||
return 'پنل معاملات';
|
||||
} else if (item.union ?? false) {
|
||||
return 'اتحادیه';
|
||||
} else {
|
||||
return 'خرید مستقیم';
|
||||
}
|
||||
}
|
||||
|
||||
String getKillType(PoultryOrder item) {
|
||||
if (item.export ?? false) {
|
||||
return 'صادرات';
|
||||
} else if (item.freezing ?? false) {
|
||||
return 'انجماد';
|
||||
} else {
|
||||
return 'عادی';
|
||||
}
|
||||
}
|
||||
|
||||
String getState(PoultryOrder item) {
|
||||
if (item.stateProcess == 'pending') {
|
||||
return 'در انتظار تایید';
|
||||
} else {
|
||||
return 'تایید شده';
|
||||
}
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region other widgets
|
||||
void _buildDeleteDialog({required VoidCallback onConfirm}) {
|
||||
Get.defaultDialog(
|
||||
title: 'حذف درخواست کشتار',
|
||||
@@ -280,7 +265,6 @@ class GenocidePage extends GetView<GenocideLogic> {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Widget filterBottomSheet() => filterBottomSheetWidget(
|
||||
fromDate: controller.fromDateFilter,
|
||||
onChangedFromDate: (jalali) => controller.fromDateFilter.value = jalali,
|
||||
@@ -289,4 +273,16 @@ class GenocidePage extends GetView<GenocideLogic> {
|
||||
onSubmit: () => controller.getPoultryOrderList(),
|
||||
);
|
||||
|
||||
//endregion
|
||||
|
||||
//region kill registration bottom sheet
|
||||
Widget killRegistrationBottomSheet() {
|
||||
return BaseBottomSheet(
|
||||
height: Get.height * 0.9,
|
||||
bgColor: Color(0x66E4E4E4),
|
||||
child: KillingRegistrationPage(),
|
||||
);
|
||||
}
|
||||
|
||||
//endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user