Basic Webuntis error handling
This commit is contained in:
@ -1,7 +1,10 @@
|
||||
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:marianum_mobile/data/timetable/timetableProps.dart';
|
||||
import 'package:marianum_mobile/screen/pages/timetable/weekView.dart';
|
||||
import 'package:marianum_mobile/widget/errorView.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
|
||||
@ -26,83 +29,30 @@ class _TimetableState extends State<Timetable> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
TimetableProps timetable = Provider.of<TimetableProps>(context, listen: false);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text("Vertretungsplan"),
|
||||
actions: [
|
||||
IconButton(onPressed: () => timetable.switchWeek(previous: true), icon: const Icon(Icons.chevron_left)),
|
||||
IconButton(onPressed: () => timetable.nearest(), icon: const Icon(Icons.home)),
|
||||
IconButton(onPressed: () => timetable.switchWeek(), icon: const Icon(Icons.chevron_right))
|
||||
],
|
||||
),
|
||||
body: Consumer<TimetableProps>(
|
||||
builder: (context, value, child) {
|
||||
|
||||
if(value.hasError) {
|
||||
return ErrorView(icon: Icons.error, text: value.error?.message ?? "Unbekannt?");
|
||||
}
|
||||
|
||||
if(value.primaryLoading()) {
|
||||
log("LOADING");
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
TimetableProps timetable = Provider.of<TimetableProps>(context, listen: false);
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
child: WeekView(value),
|
||||
onHorizontalDragUpdate: (details) {
|
||||
if(!draggable) return;
|
||||
if(details.delta.dx > 5) {
|
||||
draggable = false;
|
||||
timetable.switchWeek(previous: true);
|
||||
} else if(details.delta.dx < 5) {
|
||||
draggable = false;
|
||||
timetable.switchWeek();
|
||||
}
|
||||
},
|
||||
onHorizontalDragEnd: (details) {
|
||||
draggable = true;
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
// Flexible(
|
||||
// child:
|
||||
// ),
|
||||
|
||||
Visibility(
|
||||
visible: false,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only(top: 5, bottom: 5),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
top: BorderSide(width: 2, color: Theme.of(context).disabledColor)
|
||||
)
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () => timetable.switchWeek(previous: true),
|
||||
icon: const Icon(Icons.navigate_before_sharp),
|
||||
color: Theme.of(context).primaryColor,
|
||||
iconSize: 30,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () => timetable.nearest(),
|
||||
icon: const Icon(Icons.home),
|
||||
color: Theme.of(context).primaryColor,
|
||||
iconSize: 30,
|
||||
),
|
||||
],
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () => timetable.switchWeek(),
|
||||
icon: const Icon(Icons.navigate_next_sharp),
|
||||
color: Theme.of(context).primaryColor,
|
||||
iconSize: 30,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
return WeekView(value);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
@ -109,6 +109,8 @@ class _WeekViewState extends State<WeekView> {
|
||||
List<LaneEvents> _buildLaneEvents(TimetableProps data) {
|
||||
List<LaneEvents> laneEvents = List<LaneEvents>.empty(growable: true);
|
||||
|
||||
if(data.primaryLoading()) throw UnimplementedError();
|
||||
|
||||
GetTimetableResponse timetable = data.getTimetableResponse;
|
||||
GetRoomsResponse rooms = data.getRoomsResponse;
|
||||
GetSubjectsResponse subjects = data.getSubjectsResponse;
|
||||
|
Reference in New Issue
Block a user