Skip to content

Commit

Permalink
Format exam files
Browse files Browse the repository at this point in the history
  • Loading branch information
rubuy-74 committed Aug 13, 2023
1 parent 59d27c2 commit 949f65a
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 82 deletions.
25 changes: 16 additions & 9 deletions uni/lib/view/exams/exams.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,24 @@ class ExamsPageViewState extends GeneralPageViewState<ExamsPageView> {
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),
),
),
)
],
),
);
}

Expand Down
16 changes: 8 additions & 8 deletions uni/lib/view/exams/widgets/exam_filter_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ class ExamFilterFormState extends State<ExamFilterForm> {
)
],
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<String, bool> filteredExamsTypes;

const FilteredExamList(this.filteredExamsTypes, {super.key});
final Map<String, bool> filteredExamsTypes;

@override
FilteredExamListState createState() => FilteredExamListState();
Expand All @@ -58,10 +58,10 @@ class FilteredExamListState extends State<FilteredExamList> {
.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,
Expand Down
137 changes: 72 additions & 65 deletions uni/lib/view/exams/widgets/exam_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,67 +33,74 @@ class _ExamRowState extends State<ExamRow> {
'${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: <Widget>[
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: <Widget>[
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<ExamProvider>(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

Check warning on line 40 in uni/lib/view/exams/widgets/exam_row.dart

View check run for this annotation

Codecov / codecov/patch

uni/lib/view/exams/widgets/exam_row.dart#L40

Added line #L40 was not covered by tests
: Theme.of(context).scaffoldBackgroundColor,
child: Column(
children: [
Container(
margin: const EdgeInsets.only(top: 8, bottom: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ExamTime(
begin: widget.exam.beginTime,
)
],
),
ExamTitle(
subject: widget.exam.subject,
type: widget.exam.type,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
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<ExamProvider>(
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() {
Expand All @@ -107,15 +114,15 @@ class _ExamRowState extends State<ExamRow> {
}

class ListExamRooms extends StatelessWidget {
final List<String> examRooms;
const ListExamRooms(this.examRooms, {super.key});
final List<String> examRooms;

@override
Widget build(BuildContext context) {
return Wrap(
alignment: WrapAlignment.start,
spacing: 13,
children: roomsList(context, examRooms));
spacing: 13,
children: roomsList(context, examRooms),
);
}

List<Text> roomsList(BuildContext context, List<String> rooms) {
Expand Down

0 comments on commit 949f65a

Please sign in to comment.