feat :
1 - date_picker_bottom_sheet 2 - delete_dialog 3 - use in view
This commit is contained in:
@@ -198,6 +198,7 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
|
||||
onPressed: () {
|
||||
buildDeleteDialog(
|
||||
onConfirm: () => controller.deleteStewardPurchaseOutOfProvince(item.key!),
|
||||
onRefresh: () => controller.getStewardPurchaseOutOfProvince(),
|
||||
);
|
||||
},
|
||||
borderColor: AppColor.redNormal,
|
||||
@@ -315,7 +316,6 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'لطفاً شماره موبایل را وارد کنید';
|
||||
}
|
||||
// حذف کاماها برای اعتبارسنجی
|
||||
String cleaned = value.replaceAll(',', '');
|
||||
if (cleaned.length != 11) {
|
||||
return 'شماره موبایل باید ۱۱ رقم باشد';
|
||||
@@ -402,7 +402,6 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
|
||||
items: controller.rootLogic.provinces,
|
||||
onChanged: (value) {
|
||||
controller.selectedProvince.value = value;
|
||||
print('Selected Product: ${value.name}');
|
||||
},
|
||||
selectedItem: controller.selectedProvince.value,
|
||||
itemBuilder: (item) => Text(
|
||||
@@ -516,30 +515,6 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> buildDeleteDialog({required Future<void> Function() onConfirm}) async {
|
||||
await Get.defaultDialog(
|
||||
title: 'حذف خرید',
|
||||
middleText: 'آیا از حذف این خرید مطمئن هستید؟',
|
||||
confirm: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColor.error,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
onPressed: () async {
|
||||
await onConfirm();
|
||||
Get.back();
|
||||
},
|
||||
child: Text('بله'),
|
||||
),
|
||||
cancel: ElevatedButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
child: Text('خیر'),
|
||||
),
|
||||
).whenComplete(() => controller.getStewardPurchaseOutOfProvince());
|
||||
}
|
||||
|
||||
Widget filterBottomSheet() {
|
||||
return BaseBottomSheet(
|
||||
height: 250,
|
||||
@@ -551,13 +526,13 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
|
||||
spacing: 8,
|
||||
children: [
|
||||
Expanded(
|
||||
child: timeFilterWidget(
|
||||
child: dateFilterWidget(
|
||||
date: controller.fromDateFilter,
|
||||
onChanged: (jalali) => controller.fromDateFilter.value = jalali,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: timeFilterWidget(
|
||||
child: dateFilterWidget(
|
||||
isFrom: false,
|
||||
date: controller.toDateFilter,
|
||||
onChanged: (jalali) => controller.toDateFilter.value = jalali,
|
||||
@@ -579,102 +554,4 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
GestureDetector timeFilterWidget({
|
||||
isFrom = true,
|
||||
required Rx<Jalali> date,
|
||||
required Function(Jalali jalali) onChanged,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
Get.bottomSheet(modalDatePicker((value) => onChanged(value)));
|
||||
},
|
||||
child: Container(
|
||||
height: 35,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(width: 1, color: AppColor.blueNormal),
|
||||
),
|
||||
padding: EdgeInsets.symmetric(horizontal: 11, vertical: 4),
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Assets.vec.calendarSvg.svg(
|
||||
width: 24,
|
||||
height: 24,
|
||||
colorFilter: const ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn),
|
||||
),
|
||||
Text(
|
||||
isFrom ? 'از' : 'تا',
|
||||
style: AppFonts.yekan16.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
Expanded(
|
||||
child: ObxValue((data) {
|
||||
return Text(
|
||||
date.value.formatCompactDate(),
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan16.copyWith(color: AppColor.lightGreyNormalActive),
|
||||
);
|
||||
}, date),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Container modalDatePicker(ValueChanged<Jalali> onDateSelected) {
|
||||
Jalali? tempPickedDate;
|
||||
return Container(
|
||||
height: 250,
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 20),
|
||||
RElevated(
|
||||
height: 35,
|
||||
width: 70,
|
||||
textStyle: AppFonts.yekan14.copyWith(color: Colors.white),
|
||||
onPressed: () {
|
||||
onDateSelected(tempPickedDate ?? Jalali.now());
|
||||
Get.back();
|
||||
},
|
||||
text: 'تایید',
|
||||
),
|
||||
Spacer(),
|
||||
RElevated(
|
||||
height: 35,
|
||||
width: 70,
|
||||
backgroundColor: AppColor.error,
|
||||
textStyle: AppFonts.yekan14.copyWith(color: Colors.white),
|
||||
onPressed: () {
|
||||
onDateSelected(tempPickedDate ?? Jalali.now());
|
||||
Get.back();
|
||||
},
|
||||
text: 'لغو',
|
||||
),
|
||||
SizedBox(width: 20),
|
||||
],
|
||||
),
|
||||
),
|
||||
Divider(height: 0, thickness: 1),
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: PersianCupertinoDatePicker(
|
||||
initialDateTime: Jalali.now(),
|
||||
mode: PersianCupertinoDatePickerMode.date,
|
||||
onDateTimeChanged: (dateTime) {
|
||||
tempPickedDate = dateTime;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core.dart';
|
||||
|
||||
GestureDetector dateFilterWidget({
|
||||
isFrom = true,
|
||||
required Rx<Jalali> date,
|
||||
required Function(Jalali jalali) onChanged,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
Get.bottomSheet(modalDatePicker((value) => onChanged(value)));
|
||||
},
|
||||
child: Container(
|
||||
height: 35,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(width: 1, color: AppColor.blueNormal),
|
||||
),
|
||||
padding: EdgeInsets.symmetric(horizontal: 11, vertical: 4),
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Assets.vec.calendarSvg.svg(
|
||||
width: 24,
|
||||
height: 24,
|
||||
colorFilter: const ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn),
|
||||
),
|
||||
Text(isFrom ? 'از' : 'تا', style: AppFonts.yekan16.copyWith(color: AppColor.blueNormal)),
|
||||
Expanded(
|
||||
child: ObxValue((data) {
|
||||
return Text(
|
||||
date.value.formatCompactDate(),
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan16.copyWith(color: AppColor.lightGreyNormalActive),
|
||||
);
|
||||
}, date),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Container modalDatePicker(ValueChanged<Jalali> onDateSelected) {
|
||||
Jalali? tempPickedDate;
|
||||
return Container(
|
||||
height: 250,
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(width: 20),
|
||||
RElevated(
|
||||
height: 35,
|
||||
width: 70,
|
||||
textStyle: AppFonts.yekan14.copyWith(color: Colors.white),
|
||||
onPressed: () {
|
||||
onDateSelected(tempPickedDate ?? Jalali.now());
|
||||
Get.back();
|
||||
},
|
||||
text: 'تایید',
|
||||
),
|
||||
Spacer(),
|
||||
RElevated(
|
||||
height: 35,
|
||||
width: 70,
|
||||
backgroundColor: AppColor.error,
|
||||
textStyle: AppFonts.yekan14.copyWith(color: Colors.white),
|
||||
onPressed: () {
|
||||
onDateSelected(tempPickedDate ?? Jalali.now());
|
||||
Get.back();
|
||||
},
|
||||
text: 'لغو',
|
||||
),
|
||||
SizedBox(width: 20),
|
||||
],
|
||||
),
|
||||
Divider(height: 0, thickness: 1),
|
||||
Expanded(
|
||||
child: PersianCupertinoDatePicker(
|
||||
initialDateTime: Jalali.now(),
|
||||
mode: PersianCupertinoDatePickerMode.date,
|
||||
onDateTimeChanged: (dateTime) {
|
||||
tempPickedDate = dateTime;
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core.dart';
|
||||
|
||||
|
||||
|
||||
Future<void> buildDeleteDialog({
|
||||
required Future<void> Function() onConfirm,
|
||||
required Future<void> Function() onRefresh,
|
||||
}) async {
|
||||
await Get.defaultDialog(
|
||||
title: 'حذف',
|
||||
middleText: 'آیا از حذف این مورد مطمئن هستید؟',
|
||||
confirm: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColor.error,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
onPressed: () async {
|
||||
await onConfirm();
|
||||
onRefresh();
|
||||
Get.back();
|
||||
},
|
||||
child: Text('بله'),
|
||||
),
|
||||
cancel: ElevatedButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
child: Text('خیر'),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ export 'app_bar/r_app_bar.dart';
|
||||
export 'bottom_navigation/r_bottom_navigation.dart';
|
||||
export 'bottom_navigation/wave_bottom_navigation.dart';
|
||||
export 'bottom_sheet/base_bottom_sheet.dart';
|
||||
export 'bottom_sheet/date_picker_bottom_sheet.dart';
|
||||
export 'buttons/elevated.dart';
|
||||
export 'buttons/fab.dart';
|
||||
export 'buttons/outline_elevated.dart';
|
||||
@@ -9,19 +10,19 @@ export 'buttons/outline_elevated_icon.dart';
|
||||
export 'buttons/text_button.dart';
|
||||
export 'card/card_with_icon_with_border.dart';
|
||||
export 'chips/r_chips.dart';
|
||||
export 'dialog/delete_dialog.dart';
|
||||
export 'draggable_bottom_sheet/bottom_sheet_manger.dart';
|
||||
export 'draggable_bottom_sheet/draggable_bottom_sheet.dart';
|
||||
export 'draggable_bottom_sheet/draggable_bottom_sheet2.dart';
|
||||
export 'draggable_bottom_sheet/draggable_bottom_sheet_controller.dart';
|
||||
export 'empty_widget.dart';
|
||||
export 'inputs/input_fixed_hint.dart';
|
||||
export 'inputs/r_input.dart';
|
||||
export 'list_view/list_view.dart';
|
||||
export 'loading_widget.dart';
|
||||
export 'overlay_dropdown_widget/view.dart';
|
||||
export 'pagination/pagination_from_until.dart';
|
||||
export 'pagination/show_more.dart';
|
||||
export 'tabs/new_tab.dart';
|
||||
export 'tabs/tab.dart';
|
||||
export 'vec_widget.dart';
|
||||
export 'empty_widget.dart';
|
||||
export 'loading_widget.dart';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user