From 949f65a6aff1375d765d31b939f9e9d7b4bcdf6d Mon Sep 17 00:00:00 2001 From: rubuy-74 Date: Sun, 13 Aug 2023 15:18:17 +0100 Subject: [PATCH] Format exam files --- uni/lib/view/exams/exams.dart | 25 ++-- .../view/exams/widgets/exam_filter_form.dart | 16 +- uni/lib/view/exams/widgets/exam_row.dart | 137 +++++++++--------- 3 files changed, 96 insertions(+), 82 deletions(-) diff --git a/uni/lib/view/exams/exams.dart b/uni/lib/view/exams/exams.dart index d04be5786..e494a6771 100644 --- a/uni/lib/view/exams/exams.dart +++ b/uni/lib/view/exams/exams.dart @@ -102,17 +102,24 @@ class ExamsPageViewState extends GeneralPageViewState { key: Key(keyValue), margin: const EdgeInsets.only(bottom: 8), padding: const EdgeInsets.all(8), - child: Column(children: [ - DayTitle( + child: Column( + children: [ + DayTitle( day: exams[0].begin.day.toString(), weekDay: exams[0].weekDay, - month: exams[0].month), - ...exams.map((exam) => Container( - key: Key('$exam-exam'), - margin: const EdgeInsets.fromLTRB(12, 4, 12, 0), - child: RowContainer( - child: ExamRow(exam: exam, teacher: '', mainPage: false)))) - ]), + month: exams[0].month, + ), + ...exams.map( + (exam) => Container( + key: Key('$exam-exam'), + margin: const EdgeInsets.fromLTRB(12, 4, 12, 0), + child: RowContainer( + child: ExamRow(exam: exam, teacher: '', mainPage: false), + ), + ), + ) + ], + ), ); } diff --git a/uni/lib/view/exams/widgets/exam_filter_form.dart b/uni/lib/view/exams/widgets/exam_filter_form.dart index 2eb4e0485..22f136875 100644 --- a/uni/lib/view/exams/widgets/exam_filter_form.dart +++ b/uni/lib/view/exams/widgets/exam_filter_form.dart @@ -35,17 +35,17 @@ class ExamFilterFormState extends State { ) ], content: SizedBox( - height: 230.0, - width: 200.0, - child: FilteredExamList(widget.filteredExamsTypes)), + height: 230, + width: 200, + child: FilteredExamList(widget.filteredExamsTypes), + ), ); } } class FilteredExamList extends StatefulWidget { - final Map filteredExamsTypes; - const FilteredExamList(this.filteredExamsTypes, {super.key}); + final Map filteredExamsTypes; @override FilteredExamListState createState() => FilteredExamListState(); @@ -58,10 +58,10 @@ class FilteredExamListState extends State { .removeWhere((key, value) => !Exam.types.containsKey(key)); return ListView( children: List.generate(widget.filteredExamsTypes.length, (i) { - final String key = widget.filteredExamsTypes.keys.elementAt(i); - if (!Exam.types.containsKey(key)) return const Text(""); + final key = widget.filteredExamsTypes.keys.elementAt(i); + if (!Exam.types.containsKey(key)) return const Text(''); return CheckboxListTile( - contentPadding: const EdgeInsets.all(0), + contentPadding: EdgeInsets.zero, title: Text( key, overflow: TextOverflow.ellipsis, diff --git a/uni/lib/view/exams/widgets/exam_row.dart b/uni/lib/view/exams/widgets/exam_row.dart index 85d61a860..32dc3e2c8 100644 --- a/uni/lib/view/exams/widgets/exam_row.dart +++ b/uni/lib/view/exams/widgets/exam_row.dart @@ -33,67 +33,74 @@ class _ExamRowState extends State { '${widget.exam.subject}-${widget.exam.rooms}-${widget.exam.beginTime}-' '${widget.exam.endTime}'; return Center( - child: Container( - padding: const EdgeInsets.only(left: 12.0, bottom: 8.0, right: 12), - margin: const EdgeInsets.only(top: 8.0), - color: isHidden - ? Theme.of(context).hintColor - : Theme.of(context).scaffoldBackgroundColor, - child: Column( - children: [ - Container( - margin: const EdgeInsets.only(top: 8, bottom: 8), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Column( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - ExamTime( - begin: widget.exam.beginTime, - ) - ]), - ExamTitle( - subject: widget.exam.subject, - type: widget.exam.type), - Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - if (!widget.mainPage) - IconButton( - icon: !isHidden - ? const Icon(Icons.visibility, size: 30) - : const Icon(Icons.visibility_off, - size: 30), - tooltip: isHidden - ? "Mostrar na Área Pessoal" - : "Ocultar da Área Pessoal", - onPressed: () => setState(() { - Provider.of(context, - listen: false) - .toggleHiddenExam(widget.exam.id); - })), - IconButton( - icon: Icon(MdiIcons.calendarPlus, size: 30), - onPressed: () => Add2Calendar.addEvent2Cal( - createExamEvent())), - ]), - ], - )), - Container( - key: Key(roomsKey), - alignment: Alignment.topLeft, - child: widget.exam.rooms[0] == '' - ? null - : ListExamRooms(widget.exam.rooms)) - ], - ))); + child: Container( + padding: const EdgeInsets.only(left: 12, bottom: 8, right: 12), + margin: const EdgeInsets.only(top: 8), + color: isHidden + ? Theme.of(context).hintColor + : Theme.of(context).scaffoldBackgroundColor, + child: Column( + children: [ + Container( + margin: const EdgeInsets.only(top: 8, bottom: 8), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ExamTime( + begin: widget.exam.beginTime, + ) + ], + ), + ExamTitle( + subject: widget.exam.subject, + type: widget.exam.type, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + if (!widget.mainPage) + IconButton( + icon: !isHidden + ? const Icon(Icons.visibility, size: 30) + : const Icon( + Icons.visibility_off, + size: 30, + ), + tooltip: isHidden + ? 'Mostrar na Área Pessoal' + : 'Ocultar da Área Pessoal', + onPressed: () => setState(() { + Provider.of( + context, + listen: false, + ).toggleHiddenExam(widget.exam.id); + }), + ), + IconButton( + icon: Icon(MdiIcons.calendarPlus, size: 30), + onPressed: () => Add2Calendar.addEvent2Cal( + createExamEvent(), + ), + ), + ], + ), + ], + ), + ), + Container( + key: Key(roomsKey), + alignment: Alignment.topLeft, + child: widget.exam.rooms[0] == '' + ? null + : ListExamRooms(widget.exam.rooms), + ) + ], + ), + ), + ); } Event createExamEvent() { @@ -107,15 +114,15 @@ class _ExamRowState extends State { } class ListExamRooms extends StatelessWidget { - final List examRooms; const ListExamRooms(this.examRooms, {super.key}); + final List examRooms; @override Widget build(BuildContext context) { return Wrap( - alignment: WrapAlignment.start, - spacing: 13, - children: roomsList(context, examRooms)); + spacing: 13, + children: roomsList(context, examRooms), + ); } List roomsList(BuildContext context, List rooms) {