1 - date_picker_bottom_sheet
2 - delete_dialog
3 - use in view
This commit is contained in:
2025-07-02 09:09:36 +03:30
parent 2cfb158d96
commit e0ac676f0a
4 changed files with 134 additions and 129 deletions

View File

@@ -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;
},
),
),
],
),
);
}

View File

@@ -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('خیر'),
),
);
}

View File

@@ -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';