Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Intermittent Gap in Timeline Display Causing Missing Hour (#381) #384

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
```

Expand Down Expand Up @@ -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.

```
```
13 changes: 11 additions & 2 deletions lib/src/components/_internal_components.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand Down Expand Up @@ -234,6 +238,7 @@ class _TimeLineState extends State<TimeLine> {
(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++)
Expand All @@ -246,6 +251,7 @@ class _TimeLineState extends State<TimeLine> {
widget.timeLineOffset,
hour: i,
minutes: 30,
visibility: widget.currentHourVisibility
),
if (widget.showQuarterHours)
for (int i = 0; i < widget.endHour; i++) ...[
Expand All @@ -259,6 +265,7 @@ class _TimeLineState extends State<TimeLine> {
widget.timeLineOffset,
hour: i,
minutes: 15,
visibility: widget.currentHourVisibility
),

/// this is for 45 minutes
Expand All @@ -271,6 +278,7 @@ class _TimeLineState extends State<TimeLine> {
widget.timeLineOffset,
hour: i,
minutes: 45,
visibility: widget.currentHourVisibility
),
],
],
Expand All @@ -285,13 +293,14 @@ class _TimeLineState extends State<TimeLine> {
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,
Expand Down
5 changes: 5 additions & 0 deletions lib/src/day_view/_internal_day_view_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ class InternalDayViewPage<T extends Object?> 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,
Expand Down Expand Up @@ -173,6 +176,7 @@ class InternalDayViewPage<T extends Object?> extends StatefulWidget {
required this.emulateVerticalOffsetBy,
required this.onTileDoubleTap,
this.keepScrollOffset = false,
this.currentHourVisibility = false
}) : super(key: key);

@override
Expand Down Expand Up @@ -326,6 +330,7 @@ class _InternalDayViewPageState<T extends Object?>
key: ValueKey(widget.heightPerMinute),
liveTimeIndicatorSettings:
widget.liveTimeIndicatorSettings,
currentHourVisibility: widget.currentHourVisibility,
),
if (widget.showLiveLine &&
widget.liveTimeIndicatorSettings.height > 0)
Expand Down
5 changes: 5 additions & 0 deletions lib/src/day_view/day_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ class DayView<T extends Object?> 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,
Expand Down Expand Up @@ -279,6 +282,7 @@ class DayView<T extends Object?> 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,
Expand Down Expand Up @@ -505,6 +509,7 @@ class DayViewState<T extends Object?> extends State<DayView<T>> {
dayViewScrollController: _scrollController,
scrollListener: _scrollPageListener,
keepScrollOffset: widget.keepScrollOffset,
currentHourVisibility: widget.currentHourVisibility,
),
);
},
Expand Down
Loading