Limit timetable scrolling so no errors occur
This commit is contained in:
parent
f51e3cd216
commit
7dde66b89c
@ -105,4 +105,17 @@ class TimetableProps extends DataHolder {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
void resetWeek() {
|
||||
error = null;
|
||||
notifyListeners();
|
||||
|
||||
DateTime queryWeek = DateTime.now().add(const Duration(days: 2));
|
||||
|
||||
startDate = getDate(queryWeek.subtract(Duration(days: queryWeek.weekday - 1)));
|
||||
endDate = getDate(queryWeek.add(Duration(days: DateTime.daysPerWeek - queryWeek.weekday)));
|
||||
|
||||
run();
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
@ -72,6 +72,12 @@ class _TimetableState extends State<Timetable> {
|
||||
return PlaceholderView(
|
||||
icon: Icons.calendar_month,
|
||||
text: "Webuntis error: ${value.error.toString()}",
|
||||
button: TextButton(
|
||||
child: const Text("Neu laden"),
|
||||
onPressed: () {
|
||||
Provider.of<TimetableProps>(context, listen: false).resetWeek();
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -90,6 +96,9 @@ class _TimetableState extends State<Timetable> {
|
||||
view: CalendarView.workWeek,
|
||||
dataSource: _buildTableEvents(value),
|
||||
|
||||
maxDate: DateTime.now().add(const Duration(days: 7)),
|
||||
minDate: DateTime.now().subtract(const Duration (days: 14)),
|
||||
|
||||
controller: controller,
|
||||
|
||||
onViewChanged: (ViewChangedDetails details) {
|
||||
|
@ -3,7 +3,8 @@ import 'package:flutter/material.dart';
|
||||
class PlaceholderView extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String text;
|
||||
const PlaceholderView({Key? key, required this.icon, required this.text}) : super(key: key);
|
||||
final Widget? button;
|
||||
const PlaceholderView({Key? key, required this.icon, required this.text, this.button}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -25,6 +26,8 @@ class PlaceholderView extends StatelessWidget {
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
if(button != null) button!,
|
||||
],
|
||||
),
|
||||
),
|
||||
|
Loading…
x
Reference in New Issue
Block a user