Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
DGoiana authored and thePeras committed Jul 9, 2024
1 parent c3e8dfc commit b0a8403
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 44 deletions.
26 changes: 16 additions & 10 deletions uni/lib/controller/parsers/parser_course_unit_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,21 @@ Future<List<CourseUnitFileDirectory>> parseFiles(

Future<Sheet> parseSheet(http.Response response) async {
final json = jsonDecode(response.body) as Map<String, dynamic>;
final professors =
getCourseUnitProfessors(json['ds'] as Iterable<Map<String, dynamic>>);
final regents =
(json['responsabilidades'] as List<Map<String, dynamic>>).map((element) {
return Professor.fromJson(element);

final professors = getCourseUnitProfessors(
(json['ds'] as List)
.map((element) => element as Map<String, dynamic>)
.toList(),
);

final regents = (json['responsabilidades'] as List).map((element) {
return Professor.fromJson(element as Map<String, dynamic>);
}).toList();

final books =
(json['bibliografia'] as List<Map<String, dynamic>>).map<Book>((element) {
final books = (json['bibliografia'] as List)
.map((element) => element as Map<String, dynamic>)
.toList()
.map<Book>((element) {
return Book(
title: element['titulo'].toString(),
isbn: element['isbn'].toString(),
Expand All @@ -71,12 +77,12 @@ Future<Sheet> parseSheet(http.Response response) async {
);
}

List<Professor> getCourseUnitProfessors(Iterable<Map<String, dynamic>> ds) {
List<Professor> getCourseUnitProfessors(List<Map<String, dynamic>> ds) {
final professors = <Professor>[];
for (final map in ds) {
for (final docente in map['docentes'] as Iterable<Map<String, dynamic>>) {
for (final docente in map['docentes'] as List<dynamic>) {
final professor = Professor(
code: docente['doc_codigo'].toString(),
code: (docente as Map<String, dynamic>)['doc_codigo'].toString(),
name: shortName(docente['nome'].toString()),
classes: [map['tipo'].toString()],
);
Expand Down
52 changes: 18 additions & 34 deletions uni/lib/view/course_unit_info/widgets/course_unit_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,10 @@ Widget buildRegentsRow(BuildContext context, List<Professor> regents) {
left: 10,
right: 10,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
regent.value.name,
style: const TextStyle(fontSize: 17),
),
],
child: Text(
regent.value.name,
style: const TextStyle(fontSize: 17),
textAlign: TextAlign.center,
),
),
],
Expand All @@ -113,19 +108,15 @@ Widget buildProfessorsRow(BuildContext context, List<Professor> professors) {
children: [
...professors.asMap().entries.map((professor) {
final idx = professor.key;
return Row(
children: [
FutureBuilder<File?>(
builder: (context, snapshot) => Transform.translate(
offset: Offset(-10.0 * idx, 0),
child: _buildAvatar(snapshot, 20),
),
future: ProfileProvider.fetchOrGetCachedProfilePicture(
session,
studentNumber: int.parse(professor.value.code),
),
),
],
return FutureBuilder<File?>(
builder: (context, snapshot) => Transform.translate(
offset: Offset(-10.0 * idx, 0),
child: _buildAvatar(snapshot, 20),
),
future: ProfileProvider.fetchOrGetCachedProfilePicture(
session,
studentNumber: int.parse(professor.value.code),
),
);
}),
],
Expand Down Expand Up @@ -153,9 +144,7 @@ Widget buildExpandedProfessors(
child: Row(
children: [
FutureBuilder<File?>(
builder:
(context, snapshot) =>
_buildAvatar(snapshot, 20),
builder: (context, snapshot) => _buildAvatar(snapshot, 20),
future: ProfileProvider.fetchOrGetCachedProfilePicture(
session,
studentNumber: int.parse(professor.value.code),
Expand All @@ -165,15 +154,10 @@ Widget buildExpandedProfessors(
padding: const EdgeInsets.only(
left: 10,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
professor.value.name,
style: const TextStyle(fontSize: 14),
),
],
child: Text(
professor.value.name,
style: const TextStyle(fontSize: 14),
textAlign: TextAlign.center,
),
),
],
Expand Down

0 comments on commit b0a8403

Please sign in to comment.