Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix courses page when no courses appear #1468

Open
wants to merge 10 commits into
base: ui/redesign
Choose a base branch
from
Open
4 changes: 4 additions & 0 deletions packages/uni_app/lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ class MessageLookup extends MessageLookupByLibrary {
"no_college": MessageLookupByLibrary.simpleMessage("no college"),
"no_course_units": MessageLookupByLibrary.simpleMessage(
"No course units in the selected period"),
"no_courses":
MessageLookupByLibrary.simpleMessage("No courses we\'re found"),
Process-ing marked this conversation as resolved.
Show resolved Hide resolved
"no_courses_description":
MessageLookupByLibrary.simpleMessage("Try to refresh the page"),
"no_data": MessageLookupByLibrary.simpleMessage(
"There is no data to show at this time"),
"no_date": MessageLookupByLibrary.simpleMessage("No date"),
Expand Down
4 changes: 4 additions & 0 deletions packages/uni_app/lib/generated/intl/messages_pt_PT.dart
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ class MessageLookup extends MessageLookupByLibrary {
"no_college": MessageLookupByLibrary.simpleMessage("sem faculdade"),
"no_course_units": MessageLookupByLibrary.simpleMessage(
"Sem cadeiras no período selecionado"),
"no_courses": MessageLookupByLibrary.simpleMessage(
"Não foram encontrados cursos"),
"no_courses_description":
MessageLookupByLibrary.simpleMessage("Tenta refrescar a página"),
"no_data": MessageLookupByLibrary.simpleMessage(
"Não há dados a mostrar neste momento"),
"no_date": MessageLookupByLibrary.simpleMessage("Sem data"),
Expand Down
20 changes: 20 additions & 0 deletions packages/uni_app/lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion packages/uni_app/lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -375,5 +375,9 @@
"favorite_filter": "Favorites",
"@favorite_filter": {},
"restaurant_period": "{period, select, lunch{Lunch} dinner{Dinner} other{Other}}",
"@restaurant_period": {}
"@restaurant_period": {},
"no_courses": "No courses we're found",
Adriano-7 marked this conversation as resolved.
Show resolved Hide resolved
"@no_courses": {},
"no_courses_description": "Try to refresh the page",
"@no_courses_description": {}
}
6 changes: 5 additions & 1 deletion packages/uni_app/lib/l10n/intl_pt_PT.arb
Original file line number Diff line number Diff line change
Expand Up @@ -376,5 +376,9 @@
"favorite_filter": "Favoritos",
"@favorite_filter": {},
"restaurant_period": "{period, select, lunch{Almoço} dinner{Jantar} other{Other}}",
"@restaurant_period": {}
"@restaurant_period": {},
"no_courses": "Não foram encontrados cursos",
"@no_courses": {},
"no_courses_description": "Tenta refrescar a página",
"@no_courses_description": {}
}
37 changes: 26 additions & 11 deletions packages/uni_app/lib/view/academic_path/courses_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:uni/model/entities/course.dart';
import 'package:uni/model/entities/profile.dart';
import 'package:uni/model/providers/startup/profile_provider.dart';
import 'package:uni/view/academic_path/widgets/course_units_view.dart';
import 'package:uni/view/academic_path/widgets/no_courses_widget.dart';
import 'package:uni/view/lazy_consumer.dart';
import 'package:uni_ui/courses/average_bar.dart';
import 'package:uni_ui/courses/course_info.dart';
Expand Down Expand Up @@ -63,14 +64,16 @@ class CoursesPageState extends State<CoursesPage> {

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(16),
child: LazyConsumer<ProfileProvider, Profile>(
builder: (context, profile) {
final courses = profile.courses;
final course = courses[courseUnitIndex];
const bottomNavbarHeight = 120.0;

return ListView(
return LazyConsumer<ProfileProvider, Profile>(
builder: (context, profile) {
final courses = profile.courses;
final course = courses[courseUnitIndex];

return Padding(
padding: const EdgeInsets.all(16),
child: ListView(
children: [
Center(
child: CourseSelection(
Expand Down Expand Up @@ -106,10 +109,22 @@ class CoursesPageState extends State<CoursesPage> {
course: course,
),
],
);
},
hasContent: (profile) => profile.courses.isNotEmpty,
onNullContent: Container(),
),
);
},
hasContent: (profile) => profile.courses.isNotEmpty,
onNullContent: LayoutBuilder(
// Band-aid for allowing refresh on null content
builder: (context, constraints) => SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: Container(
height: constraints.maxHeight, // Height of bottom navbar
padding: const EdgeInsets.only(bottom: bottomNavbarHeight),
child: const Center(
child: NoCoursesWidget(),
),
),
),
),
);
}
Expand Down
34 changes: 23 additions & 11 deletions packages/uni_app/lib/view/academic_path/exam_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class _ExamsPageState extends State<ExamsPage> {

@override
Widget build(BuildContext context) {
const bottomNavbarHeight = 120.0;

/*
If we want to filters exams again
filteredExamTypes[Exam.getExamTypeLong(exam.examType)] ??
Expand Down Expand Up @@ -110,18 +112,28 @@ class _ExamsPageState extends State<ExamsPage> {
.toList(),
),
hasContent: (exams) => exams.isNotEmpty,
onNullContent: Center(
heightFactor: 1.2,
child: ImageLabel(
imagePath: 'assets/images/vacation.png',
label: S.of(context).no_exams_label,
labelTextStyle: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
color: Theme.of(context).colorScheme.primary,
onNullContent: LayoutBuilder(
// Band-aid for allowing refresh on null content
builder: (context, constraints) => SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: Container(
height: constraints.maxHeight, // Height of bottom navbar
padding: const EdgeInsets.only(bottom: bottomNavbarHeight),
child: Center(
heightFactor: 1.2,
child: ImageLabel(
imagePath: 'assets/images/vacation.png',
label: S.of(context).no_exams_label,
labelTextStyle: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
color: Theme.of(context).colorScheme.primary,
),
sublabel: S.of(context).no_exams,
sublabelTextStyle: const TextStyle(fontSize: 15),
),
),
),
sublabel: S.of(context).no_exams,
sublabelTextStyle: const TextStyle(fontSize: 15),
),
),
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'package:flutter/material.dart';
import 'package:uni/generated/l10n.dart';
import 'package:uni/view/common_widgets/expanded_image_label.dart';

class NoCoursesWidget extends StatelessWidget {
const NoCoursesWidget({super.key});

@override
Widget build(BuildContext context) {
return ImageLabel(
imagePath: 'assets/images/school.png',
label: S.of(context).no_courses,
labelTextStyle: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
color: Theme.of(context).colorScheme.primary,
),
sublabel: S.of(context).no_courses_description,
sublabelTextStyle: Theme.of(context).textTheme.bodyLarge,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ImageLabel extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Image.asset(
imagePath,
Expand Down
2 changes: 1 addition & 1 deletion packages/uni_app/lib/view/schedule/schedule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class SchedulePageViewState extends State<SchedulePageView>

return Center(
child: ImageLabel(
imagePath: 'assets/images/schedule.png',
imagePath: 'assets/images/school.png',
label: '$noClassesText $weekday.',
labelTextStyle: const TextStyle(fontSize: 15),
),
Expand Down