From 27a5861a4a6e92a125d4371991dea3fb202fbe2d Mon Sep 17 00:00:00 2001 From: Martim Silva Date: Wed, 24 Jan 2024 16:59:02 +0000 Subject: [PATCH] Add IgnorePointer to live indicator to allow to press event Without IgnorePointer, because the live indicator is on top of the events it won't allow to press the events. --- CHANGELOG.md | 1 + README.md | 8 +++- lib/src/components/week_view_components.dart | 12 +++++ .../week_view/_internal_week_view_page.dart | 48 +++++++++++-------- lib/src/week_view/week_view.dart | 14 ++++-- 5 files changed, 60 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 630bfc14..43e05dd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ - # [1.1.1] (UnReleased) - Added showWeekTileBorder field whether to show border for header in month view. [#306](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/306) - Fixed an issue related to hiding day, which is not in the current month in MonthView. [#328](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/328) +- Added header title for full day events in week view. [#308](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/308) - Added support for double tapping gestures on any event in day, week, and month view. [#195](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/195) - Added support to set end time of day and week view. [#298](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/298) - Added support for horizontal scroll physics of week and month view page. [#314](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/314) diff --git a/README.md b/README.md index 7f76f072..52a0b364 100644 --- a/README.md +++ b/README.md @@ -220,7 +220,13 @@ WeekView( hourLinePainter: (lineColor, lineHeight, offset, minuteHeight, showVerticalLine, verticalLineOffset) { return //Your custom painter. }, - weekPageHeaderBuilder: WeekHeader.hidden // To hide week header + weekPageHeaderBuilder: WeekHeader.hidden, // To hide week header + fullDayHeaderTitle: 'All day', // To set full day events header title + fullDayHeaderTextConfig: FullDayHeaderTextConfig( + textAlign: TextAlign.center, + textOverflow: TextOverflow.ellipsis, + maxLines: 2, + ), // To set full day events header text config ); ``` diff --git a/lib/src/components/week_view_components.dart b/lib/src/components/week_view_components.dart index 69f88203..9807d8a9 100644 --- a/lib/src/components/week_view_components.dart +++ b/lib/src/components/week_view_components.dart @@ -43,3 +43,15 @@ class WeekPageHeader extends CalendarPageHeader { "${secondaryDate != null ? "${secondaryDate.day} / " "${secondaryDate.month} / ${secondaryDate.year}" : ""}"; } + +class FullDayHeaderTextConfig { + const FullDayHeaderTextConfig({ + this.textAlign = TextAlign.center, + this.maxLines = 2, + this.textOverflow = TextOverflow.ellipsis, + }); + + final TextAlign textAlign; + final int maxLines; + final TextOverflow textOverflow; +} diff --git a/lib/src/week_view/_internal_week_view_page.dart b/lib/src/week_view/_internal_week_view_page.dart index 55d4584e..c56362f1 100644 --- a/lib/src/week_view/_internal_week_view_page.dart +++ b/lib/src/week_view/_internal_week_view_page.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import '../components/_internal_components.dart'; +import '../components/week_view_components.dart'; import '../components/event_scroll_notifier.dart'; import '../enumerations.dart'; import '../event_arrangers/event_arrangers.dart'; @@ -12,7 +13,6 @@ import '../event_controller.dart'; import '../modals.dart'; import '../painters.dart'; import '../typedefs.dart'; -import '../constants.dart'; /// A single page for week view. class InternalWeekViewPage extends StatelessWidget { @@ -146,7 +146,10 @@ class InternalWeekViewPage extends StatelessWidget { final int endHour; /// Title of the full day events row - final String? fullDayHeaderTitle; + final String fullDayHeaderTitle; + + /// Defines full day events header text config + final FullDayHeaderTextConfig fullDayHeaderTextConfig; /// A single page for week view. const InternalWeekViewPage({ @@ -191,7 +194,8 @@ class InternalWeekViewPage extends StatelessWidget { required this.emulateVerticalOffsetBy, required this.onTileDoubleTap, required this.endHour, - this.fullDayHeaderTitle, + this.fullDayHeaderTitle = '', + required this.fullDayHeaderTextConfig, }) : super(key: key); @override @@ -237,36 +241,42 @@ class InternalWeekViewPage extends StatelessWidget { child: Container( decoration: BoxDecoration( border: Border( - bottom: BorderSide(color: hourIndicatorSettings.color, width: 2), + bottom: BorderSide( + color: hourIndicatorSettings.color, + width: 2, + ), ), ), child: Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, children: [ - Container( - width: timeLineWidth + hourIndicatorSettings.offset, - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 2.0, horizontal: 1), + if (fullDayHeaderTitle.isNotEmpty) + Container( + width: timeLineWidth + hourIndicatorSettings.offset, + padding: const EdgeInsets.symmetric( + vertical: 2, + horizontal: 1, + ), child: Text( - fullDayHeaderTitle ?? "", - textAlign: TextAlign.center, - maxLines: 2, - overflow: TextOverflow.ellipsis, + fullDayHeaderTitle, + textAlign: fullDayHeaderTextConfig.textAlign, + maxLines: fullDayHeaderTextConfig.maxLines, + overflow: fullDayHeaderTextConfig.textOverflow, ), ), - ), ...List.generate( filteredDates.length, - (index) { - final fullDayEventList = controller.getFullDayEvent(filteredDates[index]); + (index) { + final fullDayEventList = + controller.getFullDayEvent(filteredDates[index]); return Container( width: weekTitleWidth, child: fullDayEventList.isEmpty ? null : fullDayEventBuilder.call( - fullDayEventList, - dates[index], - ), + fullDayEventList, + dates[index], + ), ); }, ) diff --git a/lib/src/week_view/week_view.dart b/lib/src/week_view/week_view.dart index dcb29ae3..7f3de723 100644 --- a/lib/src/week_view/week_view.dart +++ b/lib/src/week_view/week_view.dart @@ -232,7 +232,10 @@ class WeekView extends StatefulWidget { final ScrollPhysics? pageViewPhysics; /// Title of the full day events row - final String? fullDayHeaderTitle; + final String fullDayHeaderTitle; + + /// Defines full day events header text config + final FullDayHeaderTextConfig? fullDayHeaderTextConfig; /// Main widget for week view. const WeekView({ @@ -289,7 +292,8 @@ class WeekView extends StatefulWidget { this.pageViewPhysics, this.onEventDoubleTap, this.endHour = Constants.hoursADay, - this.fullDayHeaderTitle, + this.fullDayHeaderTitle = '', + this.fullDayHeaderTextConfig, }) : assert(!(onHeaderTitleTap != null && weekPageHeaderBuilder != null), "can't use [onHeaderTitleTap] & [weekPageHeaderBuilder] simultaneously"), assert((timeLineOffset) >= 0, @@ -331,7 +335,7 @@ class WeekViewState extends State> { late DateTime _currentWeek; late int _totalWeeks; late int _currentIndex; - late String? _fullDayHeaderTitle; + late String _fullDayHeaderTitle; late EventArranger _eventArranger; @@ -351,6 +355,7 @@ class WeekViewState extends State> { late WeekNumberBuilder _weekNumberBuilder; late FullDayEventBuilder _fullDayEventBuilder; late DetectorBuilder _weekDetectorBuilder; + late FullDayHeaderTextConfig _fullDayHeaderTextConfig; late double _weekTitleWidth; late int _totalDaysInWeek; @@ -394,6 +399,8 @@ class WeekViewState extends State> { _assignBuilders(); _fullDayHeaderTitle = widget.fullDayHeaderTitle; + _fullDayHeaderTextConfig = + widget.fullDayHeaderTextConfig ?? FullDayHeaderTextConfig(); } @override @@ -540,6 +547,7 @@ class WeekViewState extends State> { showWeekDayAtBottom: widget.showWeekDayAtBottom, endHour: _endHour, fullDayHeaderTitle: _fullDayHeaderTitle, + fullDayHeaderTextConfig: _fullDayHeaderTextConfig, ), ); },