Skip to content

Commit

Permalink
Fix background color of single view date picker
Browse files Browse the repository at this point in the history
  • Loading branch information
tddang-linagora committed Mar 27, 2024
1 parent 12c773c commit 1f42870
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 27 deletions.
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
66 changes: 40 additions & 26 deletions lib/material_date_range_picker_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,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);
},
);
},
);
}
}

0 comments on commit 1f42870

Please sign in to comment.