Skip to content

Commit

Permalink
i2 - Add autoClose after invoke action
Browse files Browse the repository at this point in the history
  • Loading branch information
dab246 committed Mar 21, 2023
1 parent a0aa143 commit 04972c5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
4 changes: 4 additions & 0 deletions lib/material_date_range_picker_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class MaterialDateRangePickerDialog {
String? last30daysTitle,
String? last6monthsTitle,
String? lastYearTitle,
bool autoClose = true,
SelectDateRangeActionCallback? selectDateRangeActionCallback
}
) {
Expand Down Expand Up @@ -56,6 +57,7 @@ class MaterialDateRangePickerDialog {
startDate: initStartDate,
endDate: initEndDate,
radius: radius,
autoClose: autoClose,
selectDateRangeActionCallback: selectDateRangeActionCallback
),
));
Expand All @@ -69,6 +71,7 @@ class MaterialDateRangePickerDialog {
String? title,
DateTime? currentDate,
double? radius,
bool autoClose = true,
SelectDateActionCallback? selectDateActionCallback
}
) {
Expand All @@ -95,6 +98,7 @@ class MaterialDateRangePickerDialog {
child: SingleViewDatePicker(
title: title,
radius: radius,
autoClose: autoClose,
currentDate: currentDate,
selectDateActionCallback: selectDateActionCallback
),
Expand Down
12 changes: 9 additions & 3 deletions lib/multiple_view_date_range_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class MultipleViewDateRangePicker extends StatefulWidget {
final DateTime? endDate;
final List<Widget>? customDateRangeButtons;
final double? radius;
final bool autoClose;

const MultipleViewDateRangePicker({
Key? key,
Expand All @@ -53,7 +54,8 @@ class MultipleViewDateRangePicker extends StatefulWidget {
this.startDateInputController,
this.endDateInputController,
this.customDateRangeButtons,
this.radius
this.radius,
this.autoClose = true
}) : super(key: key);

@override
Expand Down Expand Up @@ -395,7 +397,9 @@ class _MultipleViewDateRangePickerState extends State<MultipleViewDateRangePicke
widget.confirmText,
onTap: () {
widget.selectDateRangeActionCallback?.call(_startDate, _endDate);
Navigator.maybeOf(context)?.maybePop();
if (widget.autoClose) {
Navigator.maybeOf(context)?.maybePop();
}
},
),
),
Expand Down Expand Up @@ -457,7 +461,9 @@ class _MultipleViewDateRangePickerState extends State<MultipleViewDateRangePicke
padding: const EdgeInsets.symmetric(horizontal: 20),
onTap: () {
widget.selectDateRangeActionCallback?.call(_startDate, _endDate);
Navigator.maybeOf(context)?.maybePop();
if (widget.autoClose) {
Navigator.maybeOf(context)?.maybePop();
}
},
)
]),
Expand Down
8 changes: 6 additions & 2 deletions lib/single_view_date_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ class SingleViewDatePicker extends StatelessWidget {
final DateRangePickerController? datePickerController;
final DateTime? currentDate;
final double? radius;
final bool autoClose;

const SingleViewDatePicker({
Key? key,
this.title,
this.currentDate,
this.selectDateActionCallback,
this.datePickerController,
this.radius
this.radius,
this.autoClose = true
}) : super(key: key);

@override
Expand Down Expand Up @@ -165,6 +167,8 @@ class SingleViewDatePicker extends StatelessWidget {
final startDate = pickerDateRange.startDate;
selectDateActionCallback?.call(startDate);
}
Navigator.maybeOf(context)?.maybePop();
if (autoClose) {
Navigator.maybeOf(context)?.maybePop();
}
}
}

0 comments on commit 04972c5

Please sign in to comment.