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

InitialTimeRange settings #45

Closed
CripyIce opened this issue Jul 23, 2020 · 1 comment
Closed

InitialTimeRange settings #45

CripyIce opened this issue Jul 23, 2020 · 1 comment
Assignees
Labels
C: Timetable Component: The actual timetable package T: Fix Type: :bug: Bug Fixes

Comments

@CripyIce
Copy link

Is there a way to start the Timetable at the current hour?
I've tried the following code:

initialTimeRange: InitialTimeRange.range(
    startTime: LocalTime.currentClockTime().subtract(Period(hours: 1)),
    endTime: LocalTime.currentClockTime().add(Period(hours: 6)),
)

And it works but if i'm testing this code at 9pm it will throw an exception 'startTime < endTime': is not true.
So, for testing purposes i've tried using this code for getting a small range to start the Timetable with:

initialTimeRange: InitialTimeRange.range(
    startTime: LocalTime.currentClockTime(),
    endTime: LocalTime.currentClockTime().add(Period(hours: 3)),
)

This code just throwed another error 'VerticalZoom.zoomMin <= 1 / (endFraction - startFraction) && 1 / (endFraction - startFraction) <= VerticalZoom.zoomMax': is not true.

This is what I basically want to achieve:
image

Thanks!

@JonasWanke JonasWanke self-assigned this Sep 2, 2020
@JonasWanke JonasWanke added C: Timetable Component: The actual timetable package T: Fix Type: :bug: Bug Fixes labels Sep 2, 2020
@JonasWanke
Copy link
Owner

I'm really sorry for the late reply.

The first exception occurs because adding to a LocalTime beyond the 24 h of a day wraps the result — so 9 PM + 6 hours = 3 AM, and hence your startTime of 8 PM is bigger than your endTime.

The second exception is thrown because the internally used VerticalZoom widget (for zooming in/out the hours) had fixed limits for minimum and maximum zoom values and the initial zoom level had to be within those constraints. I've now (as of v0.2.7) moved these fixed limits to TimetableThemeData as minimumHourZoom and maximumHourZoom, and values outside of these constraints are now coerced to fulfill them — so if the initialTimeRange is set to 11 PM – 12 PM, but showing only this range would exceed the maximum zoom level, the range is extended to e.g. 7 PM – 12 PM. By setting TimetableThemeData.maximumHourHeight to double.infinity (the default for maximumHourZoom is double.infinity already), no coercion is performed and only 11 PM – 12 PM will be shown.

Feel free to reopen this issue if this doesn't solve your problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Timetable Component: The actual timetable package T: Fix Type: :bug: Bug Fixes
Projects
None yet
Development

No branches or pull requests

2 participants