Skip to content

Commit

Permalink
Merge pull request #249 from SimformSolutionsPvtLtd/fix/issue_237_day…
Browse files Browse the repository at this point in the history
…_and_week_view_layout_issue

fix: 🐛Fixed week-view & day-view layout issue in landscape mode #237.
  • Loading branch information
PRBaraiya authored Aug 8, 2023
2 parents 25d950f + f9546e7 commit 1eb148f
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 139 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
Issue [#219 - There is an issue with the daily view layout display](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/219)
- Fixed
Issue [#205 - SafeArea can't be deactivated on MonthView](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/205)
- Fixed
Issue [#237 - DayView & MonthView layout issue in landscape mode](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/237)

# [1.0.3 - 3 Apr 2023](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/tree/1.0.3)

Expand Down
11 changes: 7 additions & 4 deletions example/lib/pages/create_event_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@ class _CreateEventPageState extends State<CreateEventPage> {
),
),
),
body: Padding(
padding: EdgeInsets.all(20.0),
child: AddEventWidget(
onEventAdd: context.pop,
body: SingleChildScrollView(
physics: ClampingScrollPhysics(),
child: Padding(
padding: EdgeInsets.all(20.0),
child: AddEventWidget(
onEventAdd: context.pop,
),
),
),
);
Expand Down
130 changes: 65 additions & 65 deletions lib/src/day_view/day_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,6 @@ class DayViewState<T extends Object?> extends State<DayView<T>> {
// user adds new events.
..addListener(_reloadCallback);
}

_updateViewDimensions();
}

@override
Expand Down Expand Up @@ -349,8 +347,6 @@ class DayViewState<T extends Object?> extends State<DayView<T>> {
// Update heights.
_calculateHeights();

_updateViewDimensions();

// Update builders and callbacks
_assignBuilders();
}
Expand All @@ -366,68 +362,74 @@ class DayViewState<T extends Object?> extends State<DayView<T>> {
Widget build(BuildContext context) {
return SafeAreaWrapper(
option: widget.safeAreaOption,
child: SizedBox(
width: _width,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
_dayTitleBuilder(_currentDate),
Expanded(
child: DecoratedBox(
decoration: BoxDecoration(color: widget.backgroundColor),
child: SizedBox(
height: _height,
child: PageView.builder(
physics: widget.pageViewPhysics,
itemCount: _totalDays,
controller: _pageController,
onPageChanged: _onPageChange,
itemBuilder: (_, index) {
final date = DateTime(
_minDate.year, _minDate.month, _minDate.day + index);
return ValueListenableBuilder(
valueListenable: _scrollConfiguration,
builder: (_, __, ___) => InternalDayViewPage<T>(
key: ValueKey(
_hourHeight.toString() + date.toString()),
width: _width,
liveTimeIndicatorSettings: _liveTimeIndicatorSettings,
timeLineBuilder: _timeLineBuilder,
dayDetectorBuilder: _dayDetectorBuilder,
eventTileBuilder: _eventTileBuilder,
heightPerMinute: widget.heightPerMinute,
hourIndicatorSettings: _hourIndicatorSettings,
date: date,
onTileTap: widget.onEventTap,
onDateLongPress: widget.onDateLongPress,
onDateTap: widget.onDateTap,
showLiveLine: widget.showLiveTimeLineInAllDays ||
date.compareWithoutTime(DateTime.now()),
timeLineOffset: widget.timeLineOffset,
timeLineWidth: _timeLineWidth,
verticalLineOffset: widget.verticalLineOffset,
showVerticalLine: widget.showVerticalLine,
height: _height,
controller: controller,
hourHeight: _hourHeight,
eventArranger: _eventArranger,
minuteSlotSize: widget.minuteSlotSize,
scrollNotifier: _scrollConfiguration,
fullDayEventBuilder: _fullDayEventBuilder,
scrollController: _scrollController,
showHalfHours: widget.showHalfHours,
halfHourIndicatorSettings: _halfHourIndicatorSettings,
),
);
},
child: LayoutBuilder(builder: (context, constraint) {
_width = widget.width ?? constraint.maxWidth;
_updateViewDimensions();
return SizedBox(
width: _width,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
_dayTitleBuilder(_currentDate),
Expanded(
child: DecoratedBox(
decoration: BoxDecoration(color: widget.backgroundColor),
child: SizedBox(
height: _height,
child: PageView.builder(
physics: widget.pageViewPhysics,
itemCount: _totalDays,
controller: _pageController,
onPageChanged: _onPageChange,
itemBuilder: (_, index) {
final date = DateTime(_minDate.year, _minDate.month,
_minDate.day + index);
return ValueListenableBuilder(
valueListenable: _scrollConfiguration,
builder: (_, __, ___) => InternalDayViewPage<T>(
key: ValueKey(
_hourHeight.toString() + date.toString()),
width: _width,
liveTimeIndicatorSettings:
_liveTimeIndicatorSettings,
timeLineBuilder: _timeLineBuilder,
dayDetectorBuilder: _dayDetectorBuilder,
eventTileBuilder: _eventTileBuilder,
heightPerMinute: widget.heightPerMinute,
hourIndicatorSettings: _hourIndicatorSettings,
date: date,
onTileTap: widget.onEventTap,
onDateLongPress: widget.onDateLongPress,
onDateTap: widget.onDateTap,
showLiveLine: widget.showLiveTimeLineInAllDays ||
date.compareWithoutTime(DateTime.now()),
timeLineOffset: widget.timeLineOffset,
timeLineWidth: _timeLineWidth,
verticalLineOffset: widget.verticalLineOffset,
showVerticalLine: widget.showVerticalLine,
height: _height,
controller: controller,
hourHeight: _hourHeight,
eventArranger: _eventArranger,
minuteSlotSize: widget.minuteSlotSize,
scrollNotifier: _scrollConfiguration,
fullDayEventBuilder: _fullDayEventBuilder,
scrollController: _scrollController,
showHalfHours: widget.showHalfHours,
halfHourIndicatorSettings:
_halfHourIndicatorSettings,
),
);
},
),
),
),
),
),
],
),
),
],
),
);
}),
);
}

Expand All @@ -453,8 +455,6 @@ class DayViewState<T extends Object?> extends State<DayView<T>> {

/// Updates data related to size of this view.
void _updateViewDimensions() {
_width = widget.width ?? MediaQuery.of(context).size.width;

_timeLineWidth = widget.timeLineWidth ?? _width * 0.13;

_liveTimeIndicatorSettings = widget.liveTimeIndicatorSettings ??
Expand Down
139 changes: 69 additions & 70 deletions lib/src/week_view/week_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,6 @@ class WeekViewState<T extends Object?> extends State<WeekView<T>> {
// user adds new events.
..addListener(_reloadCallback);
}

_updateViewDimensions();
}

@override
Expand Down Expand Up @@ -359,8 +357,6 @@ class WeekViewState<T extends Object?> extends State<WeekView<T>> {
// Update heights.
_calculateHeights();

_updateViewDimensions();

// Update builders and callbacks
_assignBuilders();
}
Expand All @@ -376,73 +372,78 @@ class WeekViewState<T extends Object?> extends State<WeekView<T>> {
Widget build(BuildContext context) {
return SafeAreaWrapper(
option: widget.safeAreaOption,
child: SizedBox(
width: _width,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
_weekHeaderBuilder(_currentStartDate, _currentEndDate),
Expanded(
child: DecoratedBox(
decoration: BoxDecoration(color: widget.backgroundColor),
child: SizedBox(
height: _height,
width: _width,
child: PageView.builder(
itemCount: _totalWeeks,
controller: _pageController,
onPageChanged: _onPageChange,
itemBuilder: (_, index) {
final dates = DateTime(_minDate.year, _minDate.month,
_minDate.day + (index * DateTime.daysPerWeek))
.datesOfWeek(start: widget.startDay);

return ValueListenableBuilder(
valueListenable: _scrollConfiguration,
builder: (_, __, ___) => InternalWeekViewPage<T>(
key: ValueKey(
_hourHeight.toString() + dates[0].toString()),
height: _height,
width: _width,
weekTitleWidth: _weekTitleWidth,
weekTitleHeight: widget.weekTitleHeight,
weekDayBuilder: _weekDayBuilder,
weekNumberBuilder: _weekNumberBuilder,
weekDetectorBuilder: _weekDetectorBuilder,
liveTimeIndicatorSettings: _liveTimeIndicatorSettings,
timeLineBuilder: _timeLineBuilder,
onTileTap: widget.onEventTap,
onDateLongPress: widget.onDateLongPress,
onDateTap: widget.onDateTap,
eventTileBuilder: _eventTileBuilder,
heightPerMinute: widget.heightPerMinute,
hourIndicatorSettings: _hourIndicatorSettings,
dates: dates,
showLiveLine: widget.showLiveTimeLineInAllDays ||
_showLiveTimeIndicator(dates),
timeLineOffset: widget.timeLineOffset,
timeLineWidth: _timeLineWidth,
verticalLineOffset: 0,
showVerticalLine: true,
controller: controller,
hourHeight: _hourHeight,
scrollController: _scrollController,
eventArranger: _eventArranger,
weekDays: _weekDays,
minuteSlotSize: widget.minuteSlotSize,
scrollConfiguration: _scrollConfiguration,
fullDayEventBuilder: _fullDayEventBuilder,
),
);
},
child: LayoutBuilder(builder: (context, constraint) {
_width = widget.width ?? constraint.maxWidth;
_updateViewDimensions();
return SizedBox(
width: _width,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
_weekHeaderBuilder(_currentStartDate, _currentEndDate),
Expanded(
child: DecoratedBox(
decoration: BoxDecoration(color: widget.backgroundColor),
child: SizedBox(
height: _height,
width: _width,
child: PageView.builder(
itemCount: _totalWeeks,
controller: _pageController,
onPageChanged: _onPageChange,
itemBuilder: (_, index) {
final dates = DateTime(_minDate.year, _minDate.month,
_minDate.day + (index * DateTime.daysPerWeek))
.datesOfWeek(start: widget.startDay);

return ValueListenableBuilder(
valueListenable: _scrollConfiguration,
builder: (_, __, ___) => InternalWeekViewPage<T>(
key: ValueKey(
_hourHeight.toString() + dates[0].toString()),
height: _height,
width: _width,
weekTitleWidth: _weekTitleWidth,
weekTitleHeight: widget.weekTitleHeight,
weekDayBuilder: _weekDayBuilder,
weekNumberBuilder: _weekNumberBuilder,
weekDetectorBuilder: _weekDetectorBuilder,
liveTimeIndicatorSettings:
_liveTimeIndicatorSettings,
timeLineBuilder: _timeLineBuilder,
onTileTap: widget.onEventTap,
onDateLongPress: widget.onDateLongPress,
onDateTap: widget.onDateTap,
eventTileBuilder: _eventTileBuilder,
heightPerMinute: widget.heightPerMinute,
hourIndicatorSettings: _hourIndicatorSettings,
dates: dates,
showLiveLine: widget.showLiveTimeLineInAllDays ||
_showLiveTimeIndicator(dates),
timeLineOffset: widget.timeLineOffset,
timeLineWidth: _timeLineWidth,
verticalLineOffset: 0,
showVerticalLine: true,
controller: controller,
hourHeight: _hourHeight,
scrollController: _scrollController,
eventArranger: _eventArranger,
weekDays: _weekDays,
minuteSlotSize: widget.minuteSlotSize,
scrollConfiguration: _scrollConfiguration,
fullDayEventBuilder: _fullDayEventBuilder,
),
);
},
),
),
),
),
),
],
),
),
],
),
);
}),
);
}

Expand Down Expand Up @@ -484,8 +485,6 @@ class WeekViewState<T extends Object?> extends State<WeekView<T>> {
}

void _updateViewDimensions() {
_width = widget.width ?? MediaQuery.of(context).size.width;

_timeLineWidth = widget.timeLineWidth ?? _width * 0.13;

_liveTimeIndicatorSettings = widget.liveTimeIndicatorSettings ??
Expand Down

0 comments on commit 1eb148f

Please sign in to comment.