diff --git a/lib/home.dart b/lib/home.dart index 15689b6..148d4ae 100644 --- a/lib/home.dart +++ b/lib/home.dart @@ -282,8 +282,11 @@ class HomePageState extends State { ), ); apidataTT = response.data; - _lessonStatus = - getLessonStatus(apidataTT["Days"].values.first, TimeOfDay.now()); + _lessonStatus = getLessonStatus( + apidataTT["Days"].values.length == 0 + ? [] + : apidataTT["Days"].values.first, + TimeOfDay.now()); if (_lessonStatus.hasLessonsToday) { _startTimer(); } @@ -681,7 +684,7 @@ class HomePageState extends State { splashColor: Colors.transparent, child: Badge( label: Text(local.homePreview), - alignment: AlignmentDirectional.topEnd, + alignment: Alignment.topLeft, child: ListTile( leading: const Icon(Icons.bolt_rounded), title: Text(local.homeQuickstart), diff --git a/lib/messages.dart b/lib/messages.dart index e82dcba..c5d25cc 100644 --- a/lib/messages.dart +++ b/lib/messages.dart @@ -125,7 +125,7 @@ class TimeTablePageState extends State { } ]; List msgs = - apidataMsg.where((msg) => msg["type"] == "sprava").toList(); + apidataMsg.where((msg) => msg["typ"] == "sprava").toList(); List msgsWOR = List.from(msgs); List> bump = []; for (Map msg in msgs) { @@ -141,13 +141,8 @@ class TimeTablePageState extends State { } } for (Map msg in msgsWOR) { - String attText = msg["attachments"].length < 5 - ? msg["attachments"].length > 1 - ? "y" - : "a" - : ""; rows.add(Card( - color: msg["isSeen"] ? null : const Color.fromARGB(255, 124, 95, 0), + //color: msg["isSeen"] ? null : const Color.fromARGB(255, 124, 95, 0), child: InkWell( onTap: () { Navigator.push( @@ -165,8 +160,7 @@ class TimeTablePageState extends State { Row( children: [ Text( - '${msg["owner"]["firstname"]?.trim()} ${msg["owner"]["lastname"]?.trim()}' - .replaceAll(RegExp(r'\s+'), ' '), + msg["vlastnik_meno"].replaceAll(RegExp(r'\s+'), ' '), style: const TextStyle(fontSize: 18), ), const Icon( @@ -175,7 +169,7 @@ class TimeTablePageState extends State { ), Expanded( child: Text( - unescape.convert(msg["title"]), + unescape.convert(msg["user_meno"]), overflow: TextOverflow.fade, maxLines: 5, softWrap: false, @@ -197,6 +191,7 @@ class TimeTablePageState extends State { ) ], ), + /* for (Map r in msg["replies"]) Row( children: [ @@ -217,7 +212,8 @@ class TimeTablePageState extends State { ), ], ), - if (msg["attachments"].length > 0) + */ + if (msg["data"]["Value"]["attachements"].length > 0) Padding( padding: const EdgeInsets.only(top: 5), child: Row( @@ -227,8 +223,11 @@ class TimeTablePageState extends State { Icons.attach_file_rounded, size: 18, ), - Text(msg["attachments"].length.toString()), - Text(" Přípon$attText"), + Text(msg["data"]["Value"]["attachements"] + .length + .toString()), + const Text( + ""), //TODO Setup localization for attachments ], ), ), diff --git a/lib/timetable.dart b/lib/timetable.dart index 08a5042..7537240 100644 --- a/lib/timetable.dart +++ b/lib/timetable.dart @@ -151,7 +151,7 @@ class TimeTablePageState extends State { String token = sharedPreferences.getString("token")!; Response response = await dio.get( - "$baseUrl/api/timetable?to=${DateFormat('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'', 'en_US').format(DateTime(date.year, date.month, date.day))}&from=${DateFormat('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'', 'en_US').format(DateTime.now())}", + "$baseUrl/api/timetable?to=${DateFormat('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'', 'en_US').format(DateTime(date.year, date.month, date.day))}&from=${DateFormat('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'', 'en_US').format(DateTime(date.year, date.month, date.day))}", options: buildCacheOptions( const Duration(days: 4), forceRefresh: true, @@ -166,7 +166,8 @@ class TimeTablePageState extends State { List ttClasses = []; Map lessons = response.data["Days"]; - for (Map ttLesson in lessons.values.first) { + for (Map ttLesson + in lessons.values.isEmpty ? [] : lessons.values.first) { ttClasses.add( TimeTableClass( ttLesson["uniperiod"], @@ -185,7 +186,10 @@ class TimeTablePageState extends State { ); } TimeTableData t = TimeTableData( - DateTime.parse(response.data["Days"].keys.first), ttClasses); + DateTime.parse(response.data["Days"].keys.isEmpty + ? date.toString() + : response.data["Days"].keys.first), + ttClasses); timetables.add(t); return t; } @@ -280,6 +284,24 @@ Widget getTimeTable(TimeTableData tt, int daydiff, Function(int) modifyDayDiff, } for (TimeTableClass ttclass in tt.classes) { List extrasRow = []; + if (ttclass.data["teachers"] != null) { + List teachers = ttclass.data["teachers"]; + String names = teachers.length == 1 ? "Teacher: " : "Teachers: "; + names += teachers[0]["firstname"] + " " + teachers[0]["lastname"]; + for (Map teacher in teachers.skip(1)) { + names += ", ${teacher["firstname"]} ${teacher["lastname"]}"; + } + extrasRow.add( + Expanded( + child: Text( + names, + overflow: TextOverflow.fade, + maxLines: 5, + softWrap: false, + ), + ), + ); + } if (ttclass.data['curriculum'] != null) { extrasRow.add( Expanded(