Skip to content

Commit

Permalink
Merge pull request #416 from SimformSolutionsPvtLtd/feature/event_til…
Browse files Browse the repository at this point in the history
…e_width

feat: Fixes issue #413: Set max width of event slot in week & day view
  • Loading branch information
PRBaraiya authored Nov 11, 2024
2 parents 3924c93 + 8aa85b1 commit 7d8fd5a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Fixes issue calendar scroll physics for day & week view. [#417](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/417)
- Adds `onTimestampTap` callback in `WeekView`
and `DayView`. [#383](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/383)
- Use `maxWidth` to set max width of event slot in day & week view. [#413](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/413)
- `Deprecations`:
- deprecated `backgroundColor` and `iconColor` from `CalendarPageHeader`, `DayPageHeader`, `MonthPageHeader` and `WeekPageHeader`.
- **Solution:** use `headerStyle` instead.
Expand Down
1 change: 1 addition & 0 deletions example/lib/widgets/day_view_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class DayViewWidget extends StatelessWidget {
heightPerMinute: 3,
timeLineBuilder: _timeLineBuilder,
scrollPhysics: const BouncingScrollPhysics(),
eventArranger: SideEventArranger(maxWidth: 30),
hourIndicatorSettings: HourIndicatorSettings(
color: Theme.of(context).dividerColor,
),
Expand Down
1 change: 1 addition & 0 deletions example/lib/widgets/week_view_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class WeekViewWidget extends StatelessWidget {
key: state,
width: width,
showLiveTimeLineInAllDays: true,
eventArranger: SideEventArranger(maxWidth: 30),
timeLineWidth: 65,
scrollPhysics: const BouncingScrollPhysics(),
liveTimeIndicatorSettings: LiveTimeIndicatorSettings(
Expand Down
10 changes: 9 additions & 1 deletion lib/src/event_arrangers/side_event_arranger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class SideEventArranger<T extends Object?> extends EventArranger<T> {
/// This class will provide method that will arrange
/// all the events side by side.
const SideEventArranger({
this.maxWidth,
this.includeEdges = false,
});

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

/// If enough space is available, the event slot will
/// use the specified max width.
/// Otherwise, it will reduce to fit all events in the cell.
/// If max width is not specified, slots will expand to fill the cell.
final double? maxWidth;

/// {@macro event_arranger_arrange_method_doc}
///
/// Make sure that all the events that are passed in [events], must be in
Expand Down Expand Up @@ -100,7 +107,8 @@ class SideEventArranger<T extends Object?> extends EventArranger<T> {
final arranged = <OrganizedCalendarEventData<T>>[];

for (final event in events) {
final slotWidth = width / event.columns;
final slotWidth =
math.min(width / event.columns, maxWidth ?? double.maxFinite);

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

0 comments on commit 7d8fd5a

Please sign in to comment.