Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix background color not consistent #14

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,23 @@ class _SampleDatePickerState extends State<SampleDatePicker> {
fontWeight: FontWeight.w500,
color: Colors.black,
fontSize: 16),
)
),
const SizedBox(height: 16),
WrapTextButton('Show date picker single view',
height: 50,
backgroundColor: Colors.blue,
padding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
textStyle: const TextStyle(
fontWeight: FontWeight.w500,
color: Colors.white,
fontSize: 16),
onTap: () {
MaterialDateRangePickerDialog.showDatePicker(
context,
selectDateActionCallback: (date) {}
);
}),
]),
),
);
Expand Down
136 changes: 76 additions & 60 deletions lib/material_date_range_picker_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,45 @@ class MaterialDateRangePickerDialog {
SelectDateRangeActionCallback? selectDateRangeActionCallback
}
) {
showModalBottomSheet(
showGeneralDialog(
context: context,
isScrollControlled: true,
barrierColor: Colors.black26,
backgroundColor: Colors.transparent,
enableDrag: false,
constraints: ResponsiveUtils.isLandscapeMobile(context)
? const BoxConstraints(maxWidth: 450)
: null,
shape: RoundedRectangleBorder(
borderRadius: ResponsiveUtils.isMobile(context)
? BorderRadius.only(
topLeft: Radius.circular(radius ?? 16.0),
topRight: Radius.circular(radius ?? 16.0)
)
: BorderRadius.all(Radius.circular(radius ?? 16.0))
),
builder: (context) {
return PointerInterceptor(child: Padding(
padding: MediaQuery.of(context).viewInsets,
child: MultipleViewDateRangePicker(
confirmText: confirmText,
cancelText: cancelText,
startDateTitle: startDateTitle,
endDateTitle: endDateTitle,
last7daysTitle: last7daysTitle,
last30daysTitle: last30daysTitle,
last6monthsTitle: last6monthsTitle,
lastYearTitle: lastYearTitle,
startDate: initStartDate,
endDate: initEndDate,
radius: radius,
autoClose: autoClose,
selectDateRangeActionCallback: selectDateRangeActionCallback
useRootNavigator: false,
pageBuilder: (context, _, __) {
return Container(
alignment: ResponsiveUtils.isMobile(context)
? Alignment.bottomCenter
: Alignment.center,
constraints: ResponsiveUtils.isLandscapeMobile(context)
? const BoxConstraints(maxWidth: 450)
: const BoxConstraints(),
child: Material(
borderRadius: ResponsiveUtils.isMobile(context)
? BorderRadius.only(
topLeft: Radius.circular(radius ?? 16.0),
topRight: Radius.circular(radius ?? 16.0))
: BorderRadius.all(Radius.circular(radius ?? 16.0)),
child: PointerInterceptor(child: Padding(
padding: MediaQuery.of(context).viewInsets,
child: MultipleViewDateRangePicker(
confirmText: confirmText,
cancelText: cancelText,
startDateTitle: startDateTitle,
endDateTitle: endDateTitle,
last7daysTitle: last7daysTitle,
last30daysTitle: last30daysTitle,
last6monthsTitle: last6monthsTitle,
lastYearTitle: lastYearTitle,
startDate: initStartDate,
endDate: initEndDate,
radius: radius,
autoClose: autoClose,
selectDateRangeActionCallback: selectDateRangeActionCallback
),
)),
),
));
}
);
},
);
}

Expand All @@ -75,35 +77,49 @@ class MaterialDateRangePickerDialog {
SelectDateActionCallback? selectDateActionCallback
}
) {
showModalBottomSheet(
showGeneralDialog(
context: context,
isScrollControlled: true,
barrierColor: Colors.black26,
backgroundColor: Colors.transparent,
enableDrag: false,
constraints: ResponsiveUtils.isLandscapeMobile(context)
? const BoxConstraints(maxWidth: 450)
: null,
shape: RoundedRectangleBorder(
borderRadius: ResponsiveUtils.isMobile(context)
? BorderRadius.only(
topLeft: Radius.circular(radius ?? 16.0),
topRight: Radius.circular(radius ?? 16.0)
)
: BorderRadius.all(Radius.circular(radius ?? 16.0))
),
builder: (context) {
return PointerInterceptor(child: Padding(
padding: MediaQuery.of(context).viewInsets,
child: SingleViewDatePicker(
title: title,
radius: radius,
autoClose: autoClose,
currentDate: currentDate,
selectDateActionCallback: selectDateActionCallback
useRootNavigator: false,
pageBuilder: (context, animation, _) {
return AnimatedBuilder(
animation: animation,
child: Container(
alignment: ResponsiveUtils.isMobile(context)
? Alignment.bottomCenter
: Alignment.center,
constraints: ResponsiveUtils.isLandscapeMobile(context)
? const BoxConstraints(maxWidth: 450)
: null,
child: Material(
borderRadius: ResponsiveUtils.isMobile(context)
? BorderRadius.only(
topLeft: Radius.circular(radius ?? 16.0),
topRight: Radius.circular(radius ?? 16.0))
: BorderRadius.all(Radius.circular(radius ?? 16.0)),
type: MaterialType.transparency,
child: PointerInterceptor(child: Padding(
padding: MediaQuery.viewInsetsOf(context),
child: SingleViewDatePicker(
title: title,
radius: radius,
autoClose: autoClose,
currentDate: currentDate,
selectDateActionCallback: selectDateActionCallback
),
)),
),
),
));
}
builder: (BuildContext context, Widget? child) {
return SlideTransition(
position: Tween<Offset>(
begin: const Offset(0, 1),
end: Offset.zero)
.animate(animation),
child: child);
},
);
},
);
}
}
Loading