Skip to content

✨ Add timeSlotColorBuilder in MultiDayView#536

Open
lavigarg-simform wants to merge 1 commit into
masterfrom
fix/I535
Open

✨ Add timeSlotColorBuilder in MultiDayView#536
lavigarg-simform wants to merge 1 commit into
masterfrom
fix/I535

Conversation

@lavigarg-simform

@lavigarg-simform lavigarg-simform commented May 22, 2026

Copy link
Copy Markdown
Contributor

Description

Extends the existing timeSlotColorBuilder feature (previously available only in DayView and WeekView) to MultiDayView, and extracts the duplicated slot-background building logic into a single shared TimeSlotBackgrounds widget used by all three calendar views.

Changes

Feature — timeSlotColorBuilder in MultiDayView

  • MultiDayView (multi_day_view.dart): Added timeSlotColorBuilder parameter (TimeSlotColorBuilder?), threaded it through to InternalMultiDayViewPage.
  • InternalMultiDayViewPage (_internal_multi_day_view_page.dart): Renders the slot-background layer inside the scrollable Stack when timeSlotColorBuilder is non-null, producing one coloured column per visible day.
  • Example (multi_day_view_widget.dart): Added a timeSlotColorBuilder usage example to the demo app (highlights business hours, lunch breaks, and weekends).

Refactor — Shared TimeSlotBackgrounds widget

The inline implementations of _buildTimeSlotBackground (DayView), _buildWeekTimeSlotBackgrounds (WeekView), and _buildMultiDayTimeSlotBackgrounds (MultiDayView) were all functionally equivalent column-painting logic. They have been replaced with a single shared widget:

  • TimeSlotBackgrounds added to common_components.dart:
    • Accepts a List<DateTime> dates (one column per date), so it works for single-day and multi-column layouts.
    • Computes slot heights, total slot count, and per-slot colors internally.
    • Wraps each column in ClipRect + RepaintBoundary to isolate repaints.
    • Respects RTL (Directionality) layout.
  • _internal_day_view_page.dart: _buildTimeSlotBackground() now delegates to TimeSlotBackgrounds(dates: [widget.date], ...). Pre-existing unused extensions.dart import removed.
  • _internal_week_view_page.dart: _buildWeekTimeSlotBackgrounds() now delegates to TimeSlotBackgrounds.
  • _internal_multi_day_view_page.dart: _buildMultiDayTimeSlotBackgrounds() now delegates to TimeSlotBackgrounds.

Tests

  • time_slot_color_builder_test.dart: Added a MultiDayView test case that verifies:
    • The timeSlotColorBuilder is invoked for every slot on every visible day column (12 unique date-time slot starts for 3 days × 4 half-hour slots in a 9–11 window).
    • Each day produces its own TimeSlotBackgroundPainter (findsNWidgets(3)).
    • Assertions are date-independent since MultiDayView aligns page boundaries relative to DateTime.now().

Checklist

  • The title of my PR starts with a [Conventional Commit] prefix (fix:, feat:, docs: etc).
  • I have followed the [Contributor Guide] when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

Closes #535

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds timeSlotColorBuilder support to MultiDayView to match the existing DayView/WeekView API, enabling per-slot background coloring for business hours, blocked time, etc.

Changes:

  • Exposes timeSlotColorBuilder on MultiDayView and wires it through to the internal page implementation.
  • Renders painted slot background layers in InternalMultiDayViewPage when the builder is provided.
  • Updates the example and changelog to reflect the new capability.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
lib/src/multi_day_view/multi_day_view.dart Adds the public timeSlotColorBuilder parameter and passes it into the internal page.
lib/src/multi_day_view/_internal_multi_day_view_page.dart Implements slot background painting for MultiDayView using TimeSlotBackgroundPainter.
example/lib/widgets/multi_day_view_widget.dart Demonstrates usage of timeSlotColorBuilder in MultiDayView.
CHANGELOG.md Notes MultiDayView support for timeSlotColorBuilder.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/src/multi_day_view/_internal_multi_day_view_page.dart Outdated
Comment thread lib/src/multi_day_view/_internal_multi_day_view_page.dart Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for timeSlotColorBuilder in MultiDayView

2 participants