Open GaoMax opened 3 years ago
Would it be possible to get a code snippet ?
Sure! Thanks for the help, really like your project.
return DayView(
controller: dayViewController,
date: DateTime(
DateTime.now().add(Duration(days: i)).year,
DateTime.now().add(Duration(days: i)).month,
DateTime.now().add(Duration(days: i)).day),
events: getEvents(i),
initialTime: getInitialTime(i),
userZoomable: false,
dayBarStyle: DayBarStyle(
color: _darkMode ? Colors.grey[850] : Colors.grey[50],
textAlignment: Alignment.centerLeft,
textStyle: Style.smallTextStyle,
dateFormatter: formatDate,
),
style: DayViewStyle(
backgroundColor: _darkMode ? Colors.grey[850] : Colors.grey[50],
backgroundRulesColor:
_darkMode ? Colors.grey[50] : Colors.grey[400],
hourRowHeight: 100,
currentTimeCircleColor: Style.primaryColor,
currentTimeRuleColor: Style.primaryColor,
headerSize: 0,
),
hoursColumnStyle: HoursColumnStyle(
color: _darkMode ? Colors.grey[850] : Colors.grey[50],
textStyle: TextStyle(
color: _darkMode
? Style.darkModeTextColor
: Style.brightModeTextColor,
),
),
);
HourMinute getInitialTime(i) {
DateTime date = DateTime(
DateTime.now().add(Duration(days: i)).year,
DateTime.now().add(Duration(days: i)).month,
DateTime.now().add(Duration(days: i)).day);
DateTime chosen = date.add(Duration(hours: 23, minutes: 59));
bool b = false;
for (Termin t in widget.userData.termine.getAll()) {
//if (t.status != Termin.RED) {
if (t.startTime.year == date.year &&
t.startTime.month == date.month &&
t.startTime.day == date.day) {
if (t.startTime.isBefore(chosen)) {
chosen = t.startTime;
b = true;
}
}
//}
}
if (!b) {
chosen = date.add(Duration(minutes: 45));
} else {
chosen = chosen.subtract(Duration(minutes: 15));
}
print(HourMinute.fromDateTime(dateTime: chosen));
return HourMinute.fromDateTime(dateTime: chosen);
}
Thanks ! Would it be possible to also know how you're setting the initialTime
value (Provider, setState
, ...) ?
I'm using it inside a PageView, but I believe I've found the bug. It's due to daylight saving time (tonight). But I can't seem to figure out how to prevent it, I'm using UTC for all my calculations and they are right. I believe that the dayView somehow accounts for daylight saving time, resulting in {"hour":6,"minute":45}, being shown as 7:45.
I believe that the dayView somehow accounts for daylight saving time, resulting in {"hour":6,"minute":45}, being shown as 7:45.
You're right. I have to figure out what I can do to fix this bug.
Describe the bug I use a function to determine the initialTime for the DayView, but in some cases the DayView just ignores the initialTime. For example: the function returns HourMinute {"hour":6,"minute":45}, but the DayView initializes with 7:45. The same function worked flawlessly with the previous initalHour build.
Testen on Android & iOS, using devices and simulators.