feat : new ui and fix bug's
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:rasadyar_chicken/data/models/response/guild/guild_model.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/segmentation_model/segmentation_model.dart';
|
||||
@@ -22,7 +21,9 @@ class SegmentationLogic extends GetxController {
|
||||
Rx<Jalali> fromDateFilter = Jalali.now().obs;
|
||||
Rx<Jalali> toDateFilter = Jalali.now().obs;
|
||||
RxnString searchedValue = RxnString();
|
||||
RxInt segmentType = 1.obs;
|
||||
RxInt saleType = 1.obs;
|
||||
RxInt quotaType = 1.obs;
|
||||
GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
||||
TextEditingController weightController = TextEditingController(text: '0');
|
||||
RxBool isSubmitButtonEnabled = false.obs;
|
||||
@@ -82,6 +83,9 @@ class SegmentationLogic extends GetxController {
|
||||
weightController.text = '0';
|
||||
selectedSegment.value = null;
|
||||
selectedGuildModel.value = null;
|
||||
segmentType.value = 1;
|
||||
saleType.value = 1;
|
||||
quotaType.value = 1;
|
||||
}
|
||||
|
||||
void validateForm() {
|
||||
@@ -178,8 +182,10 @@ class SegmentationLogic extends GetxController {
|
||||
SegmentationModel segmentationModel = SegmentationModel(
|
||||
productKey: selectedProduct.value?.key,
|
||||
weight: int.tryParse(weightController.text.clearComma) ?? 0,
|
||||
saleType: saleType.value == 1 ? 'governmental' : 'free',
|
||||
quota: quotaType.value == 1 ? 'governmental' : 'free',
|
||||
);
|
||||
if (saleType.value == 2) {
|
||||
if (segmentType.value == 2) {
|
||||
segmentationModel = segmentationModel.copyWith(guildKey: selectedGuildModel.value?.key);
|
||||
}
|
||||
await safeCall(
|
||||
@@ -189,6 +195,8 @@ class SegmentationLogic extends GetxController {
|
||||
),
|
||||
onSuccess: (result) {
|
||||
res = true;
|
||||
isSubmitButtonEnabled.value = true;
|
||||
|
||||
},
|
||||
onError: (error, stacktrace) {
|
||||
res = false;
|
||||
|
||||
@@ -5,8 +5,6 @@ import 'package:rasadyar_chicken/data/models/response/roles_products/roles_produ
|
||||
import 'package:rasadyar_chicken/data/models/response/segmentation_model/segmentation_model.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/filter_bottom_sheet.dart';
|
||||
|
||||
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
@@ -23,53 +21,56 @@ class SegmentationPage extends GetView<SegmentationLogic> {
|
||||
hasBack: false,
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned.fill(child: ObxValue((data) {
|
||||
return RPaginatedListView(
|
||||
onLoadMore: () async => controller.getAllSegmentation(true),
|
||||
onRefresh: () async {
|
||||
controller.currentPage.value = 1;
|
||||
await controller.getAllSegmentation();
|
||||
},
|
||||
hasMore: data.value.data?.next != null,
|
||||
listType: ListType.separated,
|
||||
resource: data.value,
|
||||
padding: EdgeInsets.fromLTRB(8, 8, 8, 80),
|
||||
itemBuilder: (context, index) {
|
||||
var item = data.value.data!.results![index];
|
||||
return ObxValue((val) {
|
||||
return ExpandableListItem2(
|
||||
selected: val.contains(index),
|
||||
onTap: () => controller.isExpandedList.toggle(index),
|
||||
index: index,
|
||||
child: itemListWidget(item),
|
||||
secondChild: itemListExpandedWidget(item, index),
|
||||
labelColor: AppColor.blueLight,
|
||||
labelIconColor: AppColor.customGrey,
|
||||
labelIcon: Assets.vec.convertCubeSvg.path,
|
||||
);
|
||||
}, controller.isExpandedList);
|
||||
},
|
||||
itemCount: data.value.data?.results?.length ?? 0,
|
||||
separatorBuilder: (context, index) => SizedBox(height: 8.h),
|
||||
);
|
||||
}, controller.segmentationList)),
|
||||
Positioned.fill(
|
||||
child: ObxValue((data) {
|
||||
return RPaginatedListView(
|
||||
onLoadMore: () async => controller.getAllSegmentation(true),
|
||||
onRefresh: () async {
|
||||
controller.currentPage.value = 1;
|
||||
await controller.getAllSegmentation();
|
||||
},
|
||||
hasMore: data.value.data?.next != null,
|
||||
listType: ListType.separated,
|
||||
resource: data.value,
|
||||
padding: EdgeInsets.fromLTRB(8, 8, 8, 80),
|
||||
itemBuilder: (context, index) {
|
||||
var item = data.value.data!.results![index];
|
||||
return ObxValue((val) {
|
||||
return ExpandableListItem2(
|
||||
selected: val.contains(index),
|
||||
onTap: () => controller.isExpandedList.toggle(index),
|
||||
index: index,
|
||||
child: itemListWidget(item),
|
||||
secondChild: itemListExpandedWidget(item, index),
|
||||
labelColor: AppColor.blueLight,
|
||||
labelIconColor: AppColor.customGrey,
|
||||
labelIcon: Assets.vec.convertCubeSvg.path,
|
||||
);
|
||||
}, controller.isExpandedList);
|
||||
},
|
||||
itemCount: data.value.data?.results?.length ?? 0,
|
||||
separatorBuilder: (context, index) => SizedBox(height: 8.h),
|
||||
);
|
||||
}, controller.segmentationList),
|
||||
),
|
||||
Positioned(
|
||||
right: 10,
|
||||
bottom: 90.h,
|
||||
child: RFab.add(
|
||||
onPressed: () {
|
||||
Get.bottomSheet(
|
||||
addOrEditBottomSheet(),
|
||||
isScrollControlled: true,
|
||||
ignoreSafeArea: false,
|
||||
).whenComplete(() {
|
||||
controller.clearForm();
|
||||
});
|
||||
},
|
||||
))
|
||||
right: 10,
|
||||
bottom: 90.h,
|
||||
child: RFab.add(
|
||||
onPressed: () {
|
||||
Get.bottomSheet(
|
||||
addOrEditBottomSheet(),
|
||||
isScrollControlled: true,
|
||||
ignoreSafeArea: false,
|
||||
).whenComplete(() {
|
||||
controller.clearForm();
|
||||
//defaultShowSuccessMessage('با موفقیت ثبت شد');
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
@@ -257,7 +258,7 @@ class SegmentationPage extends GetView<SegmentationLogic> {
|
||||
|
||||
Widget addOrEditBottomSheet([bool isOnEdit = false]) {
|
||||
return BaseBottomSheet(
|
||||
height: 430.h,
|
||||
height: 480.h,
|
||||
child: SingleChildScrollView(
|
||||
child: Form(
|
||||
key: controller.formKey,
|
||||
@@ -284,25 +285,25 @@ class SegmentationPage extends GetView<SegmentationLogic> {
|
||||
height: 40,
|
||||
child: ObxValue((data) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Radio(
|
||||
value: 1,
|
||||
groupValue: controller.saleType.value,
|
||||
groupValue: controller.segmentType.value,
|
||||
onChanged: (value) {
|
||||
controller.saleType.value = value!;
|
||||
controller.segmentType.value = value!;
|
||||
|
||||
controller.selectedGuildModel.value = null;
|
||||
controller.selectedGuildModel.refresh();
|
||||
},
|
||||
),
|
||||
Text('قطعهبندی(مباشر)', style: AppFonts.yekan14),
|
||||
Text('قطعهبندی(کاربر)', style: AppFonts.yekan14),
|
||||
SizedBox(width: 12),
|
||||
Radio(
|
||||
value: 2,
|
||||
groupValue: controller.saleType.value,
|
||||
groupValue: controller.segmentType.value,
|
||||
onChanged: (value) {
|
||||
controller.saleType.value = value!;
|
||||
controller.segmentType.value = value!;
|
||||
},
|
||||
),
|
||||
Text('تخصیص به قطعهبند', style: AppFonts.yekan14),
|
||||
@@ -312,7 +313,68 @@ class SegmentationPage extends GetView<SegmentationLogic> {
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
guildsDropDown(),
|
||||
ObxValue((data) {
|
||||
return Visibility(visible: data.value == 2, child: guildsDropDown());
|
||||
}, controller.segmentType),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: AppColor.darkGreyLight, width: 1),
|
||||
),
|
||||
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(
|
||||
height: 40,
|
||||
child: ObxValue((data) {
|
||||
return RadioGroup(
|
||||
onChanged: (value) {
|
||||
controller.saleType.value = value ?? 0;
|
||||
controller.selectedGuildModel.value = null;
|
||||
controller.selectedGuildModel.refresh();
|
||||
},
|
||||
groupValue: controller.saleType.value,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Radio(value: 1),
|
||||
Text('فروش دولتی', style: AppFonts.yekan14),
|
||||
SizedBox(width: 12),
|
||||
Radio(value: 2),
|
||||
Text('فروش آزاد', style: AppFonts.yekan14),
|
||||
],
|
||||
),
|
||||
);
|
||||
}, controller.saleType),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
SizedBox(
|
||||
height: 40,
|
||||
child: ObxValue((data) {
|
||||
return RadioGroup(
|
||||
onChanged: (value) {
|
||||
controller.quotaType.value = value ?? 0;
|
||||
},
|
||||
groupValue: controller.quotaType.value,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Radio(value: 1),
|
||||
Text('انبار دولتی', style: AppFonts.yekan14),
|
||||
SizedBox(width: 12),
|
||||
Radio(value: 2),
|
||||
Text('انبار آزاد', style: AppFonts.yekan14),
|
||||
],
|
||||
),
|
||||
);
|
||||
}, controller.saleType),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user