diff --git a/packages/chicken/lib/presentation/pages/buy_out_of_province/view.dart b/packages/chicken/lib/presentation/pages/buy_out_of_province/view.dart index 27e8a94..776360a 100644 --- a/packages/chicken/lib/presentation/pages/buy_out_of_province/view.dart +++ b/packages/chicken/lib/presentation/pages/buy_out_of_province/view.dart @@ -198,6 +198,7 @@ class BuyOutOfProvincePage extends GetView { onPressed: () { buildDeleteDialog( onConfirm: () => controller.deleteStewardPurchaseOutOfProvince(item.key!), + onRefresh: () => controller.getStewardPurchaseOutOfProvince(), ); }, borderColor: AppColor.redNormal, @@ -315,7 +316,6 @@ class BuyOutOfProvincePage extends GetView { if (value == null || value.isEmpty) { return 'لطفاً شماره موبایل را وارد کنید'; } - // حذف کاماها برای اعتبارسنجی String cleaned = value.replaceAll(',', ''); if (cleaned.length != 11) { return 'شماره موبایل باید ۱۱ رقم باشد'; @@ -402,7 +402,6 @@ class BuyOutOfProvincePage extends GetView { 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 { ); } - Future buildDeleteDialog({required Future 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 { 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 { ), ); } - - GestureDetector timeFilterWidget({ - isFrom = true, - required Rx 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 onDateSelected) { - Jalali? tempPickedDate; - return Container( - height: 250, - color: Colors.white, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - 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; - }, - ), - ), - ), - ], - ), - ); - } } diff --git a/packages/core/lib/presentation/widget/bottom_sheet/date_picker_bottom_sheet.dart b/packages/core/lib/presentation/widget/bottom_sheet/date_picker_bottom_sheet.dart new file mode 100644 index 0000000..7d3195a --- /dev/null +++ b/packages/core/lib/presentation/widget/bottom_sheet/date_picker_bottom_sheet.dart @@ -0,0 +1,94 @@ +import 'package:flutter/material.dart'; + +import '../../../core.dart'; + +GestureDetector dateFilterWidget({ + isFrom = true, + required Rx 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 onDateSelected) { + Jalali? tempPickedDate; + return Container( + height: 250, + color: Colors.white, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + 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; + }, + ), + ), + ], + ), + ); +} diff --git a/packages/core/lib/presentation/widget/dialog/delete_dialog.dart b/packages/core/lib/presentation/widget/dialog/delete_dialog.dart new file mode 100644 index 0000000..5ec7dd2 --- /dev/null +++ b/packages/core/lib/presentation/widget/dialog/delete_dialog.dart @@ -0,0 +1,33 @@ +import 'package:flutter/material.dart'; + +import '../../../core.dart'; + + + +Future buildDeleteDialog({ + required Future Function() onConfirm, + required Future 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('خیر'), + ), + ); +} diff --git a/packages/core/lib/presentation/widget/widget.dart b/packages/core/lib/presentation/widget/widget.dart index 46c10d5..1ea7bfa 100644 --- a/packages/core/lib/presentation/widget/widget.dart +++ b/packages/core/lib/presentation/widget/widget.dart @@ -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'; -