diff --git a/README.md b/README.md index 14a7de6a..5f478b95 100644 --- a/README.md +++ b/README.md @@ -188,6 +188,7 @@ DayView( }, dayTitleBuilder: DayHeader.hidden, // To Hide day header keepScrollOffset: true, // To maintain scroll offset when the page changes + currentHourVisibility : true // To display the current Hour, False by Default ); ``` @@ -396,4 +397,4 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -``` \ No newline at end of file +``` diff --git a/lib/src/components/_internal_components.dart b/lib/src/components/_internal_components.dart index 129e84c1..dee94ba4 100644 --- a/lib/src/components/_internal_components.dart +++ b/lib/src/components/_internal_components.dart @@ -167,6 +167,9 @@ class TimeLine extends StatefulWidget { /// This field will be used to set end hour for day and week view final int endHour; + /// This field will be optional if set true then the current timeline hour will be visible else default + final bool currentHourVisibility; + /// Time line to display time at left side of day or week view. const TimeLine({ Key? key, @@ -178,6 +181,7 @@ class TimeLine extends StatefulWidget { required this.startHour, this.showHalfHours = false, this.showQuarterHours = false, + this.currentHourVisibility = false, required this.liveTimeIndicatorSettings, this.endHour = Constants.hoursADay, }) : super(key: key); @@ -234,6 +238,7 @@ class _TimeLineState extends State { (widget.hourHeight * (i - widget.startHour + 1)) + widget.timeLineOffset, hour: i, + visibility: widget.currentHourVisibility ), if (widget.showHalfHours) for (int i = widget.startHour; i < widget.endHour; i++) @@ -246,6 +251,7 @@ class _TimeLineState extends State { widget.timeLineOffset, hour: i, minutes: 30, + visibility: widget.currentHourVisibility ), if (widget.showQuarterHours) for (int i = 0; i < widget.endHour; i++) ...[ @@ -259,6 +265,7 @@ class _TimeLineState extends State { widget.timeLineOffset, hour: i, minutes: 15, + visibility: widget.currentHourVisibility ), /// this is for 45 minutes @@ -271,6 +278,7 @@ class _TimeLineState extends State { widget.timeLineOffset, hour: i, minutes: 45, + visibility: widget.currentHourVisibility ), ], ], @@ -285,13 +293,14 @@ class _TimeLineState extends State { required double topPosition, required double bottomPosition, required int hour, + bool visibility = false, int minutes = 0, }) { return Visibility( - visible: !((_currentTime.minute >= 45 && _currentTime.hour == hour - 1) || + visible: visibility == false ? !((_currentTime.minute >= 45 && _currentTime.hour == hour - 1) || (_currentTime.minute <= 15 && _currentTime.hour == hour)) || !(widget.liveTimeIndicatorSettings.showTime || - widget.liveTimeIndicatorSettings.showTimeBackgroundView), + widget.liveTimeIndicatorSettings.showTimeBackgroundView) : true, child: Positioned( top: topPosition, left: 0, diff --git a/lib/src/day_view/_internal_day_view_page.dart b/lib/src/day_view/_internal_day_view_page.dart index d46be383..2f3c3632 100644 --- a/lib/src/day_view/_internal_day_view_page.dart +++ b/lib/src/day_view/_internal_day_view_page.dart @@ -133,6 +133,9 @@ class InternalDayViewPage extends StatefulWidget { /// Flag to keep scrollOffset of pages on page change final bool keepScrollOffset; + /// Flag to keep the visibility of the current hour to be optional + final bool currentHourVisibility; + /// Defines a single day page. const InternalDayViewPage({ Key? key, @@ -173,6 +176,7 @@ class InternalDayViewPage extends StatefulWidget { required this.emulateVerticalOffsetBy, required this.onTileDoubleTap, this.keepScrollOffset = false, + this.currentHourVisibility = false }) : super(key: key); @override @@ -326,6 +330,7 @@ class _InternalDayViewPageState key: ValueKey(widget.heightPerMinute), liveTimeIndicatorSettings: widget.liveTimeIndicatorSettings, + currentHourVisibility: widget.currentHourVisibility, ), if (widget.showLiveLine && widget.liveTimeIndicatorSettings.height > 0) diff --git a/lib/src/day_view/day_view.dart b/lib/src/day_view/day_view.dart index 163b8937..25e2feb4 100644 --- a/lib/src/day_view/day_view.dart +++ b/lib/src/day_view/day_view.dart @@ -229,6 +229,9 @@ class DayView extends StatefulWidget { /// Flag to keep scrollOffset of pages on page change final bool keepScrollOffset; + /// Flag to keep the visibility of the current hour to be optional + final bool currentHourVisibility; + /// Main widget for day view. const DayView({ Key? key, @@ -279,6 +282,7 @@ class DayView extends StatefulWidget { this.onEventDoubleTap, this.endHour = Constants.hoursADay, this.keepScrollOffset = false, + this.currentHourVisibility = false }) : assert(!(onHeaderTitleTap != null && dayTitleBuilder != null), "can't use [onHeaderTitleTap] & [dayTitleBuilder] simultaneously"), assert(timeLineOffset >= 0, @@ -505,6 +509,7 @@ class DayViewState extends State> { dayViewScrollController: _scrollController, scrollListener: _scrollPageListener, keepScrollOffset: widget.keepScrollOffset, + currentHourVisibility: widget.currentHourVisibility, ), ); },