Skip to content

Commit

Permalink
fork_rabelo_corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
MarceloRab committed Jan 12, 2025
1 parent 05c3a8d commit 8abcc90
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 71 deletions.
10 changes: 5 additions & 5 deletions example/lib/widgets/month_view_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class MonthViewWidget extends StatelessWidget {
showWeekends: true,
startDay: WeekDays.friday,
useAvailableVerticalSpace: true,
/* callBackStartEndPage: true,
callBackStartEndPage: true,
onHasReachedStart: (date, page) => debugPrint(
'🚀 month_calendar_view.dart - date - ${date.toString()} - date - ${page.toString()}'),
'🚀 MonthViewWidget - date - ${date.toString()} - date - ${page.toString()}'),
onHasReachedEnd: (date, page) => debugPrint(
'🚀 month_calendar_view.dart - date - ${date.toString()} - date - ${page.toString()}'), */
onPageChange: (date, pageIndex) => debugPrint(
'🚀 month_calendar_view.dart - date - ${date.toString()} - date - ${pageIndex.toString()}'),
'🚀 MonthViewWidget - date - ${date.toString()} - date - ${page.toString()}'),
//onPageChange: (date, pageIndex) => debugPrint(
// '🚀 MonthViewWidget - date - ${date.toString()} - date - ${pageIndex.toString()}'),
onEventTap: (event, date) {
Navigator.of(context).push(
MaterialPageRoute(
Expand Down
138 changes: 72 additions & 66 deletions lib/src/month_view/month_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -375,74 +375,80 @@ class MonthViewState<T extends Object?> extends State<MonthView<T>> {
start: widget.startDay,
showWeekEnds: widget.showWeekends,
);

final bool isFirstPage = index == 0;
final bool isLastPage = index == _totalMonths - 1;
if (isFirstPage || isLastPage) {
return GestureDetector(
onHorizontalDragEnd: (details) => onHorizontalDragStartEnd(details,
isFirstPage: isFirstPage, isLastPage: isLastPage),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: _width,
child: Row(
children: List.generate(
widget.showWeekends ? 7 : 5,
(index) => Expanded(
child: SizedBox(
width: _cellWidth,
child: _weekBuilder(weekDays[index].weekday - 1),
if (widget.callBackStartEndPage) {
// build callBack Drags Pagination
//
final bool isFirstPage = index == 0;
final bool isLastPage = index == _totalMonths - 1;
if (isFirstPage || isLastPage) {
return GestureDetector(
onHorizontalDragEnd: (details) => onHorizontalDragStartEnd(
details,
isFirstPage: isFirstPage,
isLastPage: isLastPage),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: _width,
child: Row(
children: List.generate(
widget.showWeekends ? 7 : 5,
(index) => Expanded(
child: SizedBox(
width: _cellWidth,
child: _weekBuilder(weekDays[index].weekday - 1),
),
),
),
),
),
),
Expanded(
child: LayoutBuilder(
builder: (context, constraints) {
final dates = date.datesOfMonths(
startDay: widget.startDay,
hideDaysNotInMonth: widget.hideDaysNotInMonth,
showWeekends: widget.showWeekends,
);
final _cellAspectRatio = widget.useAvailableVerticalSpace
? calculateCellAspectRatio(
height: constraints.maxHeight,
daysInMonth: dates.length,
)
: widget.cellAspectRatio;

return SizedBox(
height: _height,
width: _width,
child: _MonthPageBuilder<T>(
key: ValueKey(date.toIso8601String()),
onCellTap: widget.onCellTap,
onDateLongPress: widget.onDateLongPress,
width: _width,
height: _height,
controller: controller,
borderColor: widget.borderColor,
borderSize: widget.borderSize,
cellBuilder: _cellBuilder,
cellRatio: _cellAspectRatio,
date: date,
showBorder: widget.showBorder,
Expanded(
child: LayoutBuilder(
builder: (context, constraints) {
final dates = date.datesOfMonths(
startDay: widget.startDay,
physics: widget.pagePhysics,
hideDaysNotInMonth: widget.hideDaysNotInMonth,
weekDays: widget.showWeekends ? 7 : 5,
),
);
},
showWeekends: widget.showWeekends,
);
final _cellAspectRatio =
widget.useAvailableVerticalSpace
? calculateCellAspectRatio(
height: constraints.maxHeight,
daysInMonth: dates.length,
)
: widget.cellAspectRatio;

return SizedBox(
height: _height,
width: _width,
child: _MonthPageBuilder<T>(
key: ValueKey(date.toIso8601String()),
onCellTap: widget.onCellTap,
onDateLongPress: widget.onDateLongPress,
width: _width,
height: _height,
controller: controller,
borderColor: widget.borderColor,
borderSize: widget.borderSize,
cellBuilder: _cellBuilder,
cellRatio: _cellAspectRatio,
date: date,
showBorder: widget.showBorder,
startDay: widget.startDay,
physics: widget.pagePhysics,
hideDaysNotInMonth: widget.hideDaysNotInMonth,
weekDays: widget.showWeekends ? 7 : 5,
),
);
},
),
),
),
],
),
);
],
),
);
}
}

return Column(
Expand Down Expand Up @@ -602,13 +608,13 @@ class MonthViewState<T extends Object?> extends State<MonthView<T>> {
/// Sets the minimum and maximum dates for current view.
void _setDateRange() {
// Initialize minimum date.
//_minDate = (widget.minMonth ?? CalendarConstants.epochDate).withoutTime;
final now = DateTime.now();
_minDate = DateTime(now.year, now.month - 1);
_minDate = (widget.minMonth ?? CalendarConstants.epochDate).withoutTime;
//final now = DateTime.now();
//_minDate = DateTime(now.year, now.month - 1);

// Initialize maximum date.
//_maxDate = (widget.maxMonth ?? CalendarConstants.maxDate).withoutTime;
_maxDate = DateTime(now.year, now.month + 1);
_maxDate = (widget.maxMonth ?? CalendarConstants.maxDate).withoutTime;
//_maxDate = DateTime(now.year, now.month + 1);

assert(
_minDate.isBefore(_maxDate),
Expand Down

0 comments on commit 8abcc90

Please sign in to comment.