-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/aggregate academic path page (#1102)
Feature/aggregate academic path page
- Loading branch information
Showing
8 changed files
with
139 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:uni/generated/l10n.dart'; | ||
import 'package:uni/utils/drawer_items.dart'; | ||
import 'package:uni/view/academic_path/widgets/course_units_card.dart'; | ||
import 'package:uni/view/common_widgets/generic_card.dart'; | ||
import 'package:uni/view/common_widgets/page_title.dart'; | ||
import 'package:uni/view/common_widgets/pages_layouts/general/general.dart'; | ||
import 'package:uni/view/home/widgets/exam_card.dart'; | ||
import 'package:uni/view/home/widgets/schedule_card.dart'; | ||
|
||
class AcademicPathPageView extends StatefulWidget { | ||
const AcademicPathPageView({super.key}); | ||
|
||
@override | ||
State<StatefulWidget> createState() => AcademicPathPageViewState(); | ||
} | ||
|
||
class AcademicPathPageViewState extends GeneralPageViewState { | ||
List<GenericCard> academicPathCards = [ | ||
ScheduleCard(), | ||
ExamCard(), | ||
CourseUnitsCard(), | ||
// Add more cards if needed | ||
]; | ||
|
||
@override | ||
Widget getBody(BuildContext context) { | ||
return ListView( | ||
children: [ | ||
PageTitle( | ||
name: S.of(context).nav_title(DrawerItem.navAcademicPath.title), | ||
), | ||
Column( | ||
children: academicPathCards, | ||
), | ||
], | ||
); | ||
} | ||
|
||
@override | ||
Future<void> onRefresh(BuildContext context) async { | ||
for (final card in academicPathCards) { | ||
card.onRefresh(context); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:provider/provider.dart'; | ||
import 'package:uni/generated/l10n.dart'; | ||
import 'package:uni/model/entities/course_units/course_unit.dart'; | ||
import 'package:uni/model/entities/profile.dart'; | ||
import 'package:uni/model/providers/startup/profile_provider.dart'; | ||
import 'package:uni/utils/drawer_items.dart'; | ||
import 'package:uni/view/common_widgets/generic_card.dart'; | ||
import 'package:uni/view/course_units/widgets/course_unit_card.dart'; | ||
import 'package:uni/view/lazy_consumer.dart'; | ||
|
||
class CourseUnitsCard extends GenericCard { | ||
CourseUnitsCard({super.key}); | ||
|
||
@override | ||
void onRefresh(BuildContext context) { | ||
Provider.of<ProfileProvider>(context, listen: false).forceRefresh(context); | ||
} | ||
|
||
@override | ||
Widget buildCardContent(BuildContext context) { | ||
return LazyConsumer<ProfileProvider, Profile>( | ||
builder: (context, profile) { | ||
final courseUnits = profile.courseUnits | ||
.where( | ||
(courseUnit) => | ||
courseUnit.enrollmentIsValid() && courseUnit.grade == '', | ||
) | ||
.take(5) | ||
.toList(); | ||
return _generateCourseUnitsCards(courseUnits, context); | ||
}, | ||
hasContent: (Profile profile) => profile.courseUnits.isNotEmpty, | ||
onNullContent: Center( | ||
heightFactor: 10, | ||
child: Text( | ||
S.of(context).no_course_units, | ||
style: Theme.of(context).textTheme.titleLarge, | ||
), | ||
), | ||
); | ||
} | ||
|
||
Widget _generateCourseUnitsCards( | ||
List<CourseUnit> courseUnits, | ||
BuildContext context, | ||
) { | ||
if (courseUnits.isEmpty) { | ||
return Center( | ||
heightFactor: 3, | ||
child: Text( | ||
S.of(context).no_course_units, | ||
style: Theme.of(context).textTheme.titleLarge, | ||
), | ||
); | ||
} | ||
|
||
return Column( | ||
children: courseUnits | ||
.map( | ||
(courseUnit) => Column( | ||
children: [ | ||
Padding( | ||
padding: const EdgeInsets.all(5), | ||
child: CourseUnitCard(courseUnit), | ||
), | ||
], | ||
), | ||
) | ||
.toList(), | ||
); | ||
} | ||
|
||
@override | ||
String getTitle(BuildContext context) => | ||
S.of(context).nav_title(DrawerItem.navCourseUnits.title); | ||
|
||
@override | ||
Future<Object?> onClick(BuildContext context) => | ||
Navigator.pushNamed(context, '/${DrawerItem.navCourseUnits.title}'); | ||
} |