Skip to content

Commit 7d8fd5a

Browse files
authored
Merge pull request #416 from SimformSolutionsPvtLtd/feature/event_tile_width
feat: Fixes issue #413: Set max width of event slot in week & day view
2 parents 3924c93 + 8aa85b1 commit 7d8fd5a

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Fixes issue calendar scroll physics for day & week view. [#417](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/417)
1212
- Adds `onTimestampTap` callback in `WeekView`
1313
and `DayView`. [#383](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/383)
14+
- Use `maxWidth` to set max width of event slot in day & week view. [#413](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/413)
1415
- `Deprecations`:
1516
- deprecated `backgroundColor` and `iconColor` from `CalendarPageHeader`, `DayPageHeader`, `MonthPageHeader` and `WeekPageHeader`.
1617
- **Solution:** use `headerStyle` instead.

example/lib/widgets/day_view_widget.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class DayViewWidget extends StatelessWidget {
2323
heightPerMinute: 3,
2424
timeLineBuilder: _timeLineBuilder,
2525
scrollPhysics: const BouncingScrollPhysics(),
26+
eventArranger: SideEventArranger(maxWidth: 30),
2627
hourIndicatorSettings: HourIndicatorSettings(
2728
color: Theme.of(context).dividerColor,
2829
),

example/lib/widgets/week_view_widget.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class WeekViewWidget extends StatelessWidget {
1515
key: state,
1616
width: width,
1717
showLiveTimeLineInAllDays: true,
18+
eventArranger: SideEventArranger(maxWidth: 30),
1819
timeLineWidth: 65,
1920
scrollPhysics: const BouncingScrollPhysics(),
2021
liveTimeIndicatorSettings: LiveTimeIndicatorSettings(

lib/src/event_arrangers/side_event_arranger.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class SideEventArranger<T extends Object?> extends EventArranger<T> {
88
/// This class will provide method that will arrange
99
/// all the events side by side.
1010
const SideEventArranger({
11+
this.maxWidth,
1112
this.includeEdges = false,
1213
});
1314

@@ -19,6 +20,12 @@ class SideEventArranger<T extends Object?> extends EventArranger<T> {
1920
///
2021
final bool includeEdges;
2122

23+
/// If enough space is available, the event slot will
24+
/// use the specified max width.
25+
/// Otherwise, it will reduce to fit all events in the cell.
26+
/// If max width is not specified, slots will expand to fill the cell.
27+
final double? maxWidth;
28+
2229
/// {@macro event_arranger_arrange_method_doc}
2330
///
2431
/// Make sure that all the events that are passed in [events], must be in
@@ -100,7 +107,8 @@ class SideEventArranger<T extends Object?> extends EventArranger<T> {
100107
final arranged = <OrganizedCalendarEventData<T>>[];
101108

102109
for (final event in events) {
103-
final slotWidth = width / event.columns;
110+
final slotWidth =
111+
math.min(width / event.columns, maxWidth ?? double.maxFinite);
104112

105113
if (event.event.isNotEmpty) {
106114
// TODO(parth): Arrange events and add it in arranged.

0 commit comments

Comments
 (0)