-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix classes card app freeze in #1511
- Loading branch information
Showing
4 changed files
with
150 additions
and
91 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import 'package:campus_mobile_experimental/ui/classes/upcoming_classes.dart'; | |
import 'package:campus_mobile_experimental/ui/common/card_container.dart'; | ||
import 'package:campus_mobile_experimental/ui/common/last_updated_widget.dart'; | ||
import 'package:campus_mobile_experimental/ui/common/time_range_widget.dart'; | ||
import 'package:firebase_crashlytics/firebase_crashlytics.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
|
@@ -59,48 +60,66 @@ class ClassScheduleCard extends StatelessWidget { | |
|
||
Widget buildClassScheduleCard(List<SectionData> courseData, | ||
int selectedCourse, DateTime? lastUpdated, String nextDayWithClasses) { | ||
return Padding( | ||
padding: const EdgeInsets.only(left: 4.0, top: 4.0), | ||
child: Row( | ||
children: <Widget>[ | ||
Flexible( | ||
flex: 5, | ||
child: Padding( | ||
padding: const EdgeInsets.only(left: 8.0), | ||
child: IntrinsicHeight( | ||
child: Column( | ||
children: [ | ||
buildWeekdayText(nextDayWithClasses), | ||
buildClassTitle(courseData[selectedCourse].subjectCode! + | ||
' ' + | ||
courseData[selectedCourse].courseCode!), | ||
buildClassType(courseData[selectedCourse].meetingType!), | ||
buildTimeRow(courseData[selectedCourse].time), | ||
buildLocationRow(courseData[selectedCourse].building! + | ||
' ' + | ||
courseData[selectedCourse].room!), | ||
buildGradeEvaluationRow( | ||
courseData[selectedCourse].gradeOption), | ||
Flexible( | ||
flex: 2, | ||
child: Padding( | ||
padding: const EdgeInsets.only(left: 4.0, top: 24.0), | ||
child: LastUpdatedWidget(time: lastUpdated), | ||
try { | ||
return Padding( | ||
padding: const EdgeInsets.only(left: 4.0, top: 4.0), | ||
child: Row( | ||
children: <Widget>[ | ||
Flexible( | ||
flex: 5, | ||
child: Padding( | ||
padding: const EdgeInsets.only(left: 8.0), | ||
child: IntrinsicHeight( | ||
child: Column( | ||
children: [ | ||
buildWeekdayText(nextDayWithClasses), | ||
buildClassTitle(courseData[selectedCourse].subjectCode! + | ||
' ' + | ||
courseData[selectedCourse].courseCode!), | ||
buildClassType(courseData[selectedCourse].meetingType!), | ||
buildTimeRow(courseData[selectedCourse].time), | ||
buildLocationRow(courseData[selectedCourse].building! + | ||
' ' + | ||
courseData[selectedCourse].room!), | ||
buildGradeEvaluationRow( | ||
courseData[selectedCourse].gradeOption), | ||
Flexible( | ||
flex: 2, | ||
child: Padding( | ||
padding: const EdgeInsets.only(left: 4.0, top: 24.0), | ||
child: LastUpdatedWidget(time: lastUpdated), | ||
), | ||
), | ||
), | ||
], | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
], | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
), | ||
), | ||
), | ||
), | ||
Flexible( | ||
flex: 2, | ||
child: UpcomingCoursesList(), | ||
), | ||
], | ||
), | ||
); | ||
} catch (e) { | ||
FirebaseCrashlytics.instance.recordError( | ||
e, StackTrace.fromString(e.toString()), | ||
reason: "Classes Card: Failed to build card content.", fatal: false); | ||
return Container( | ||
width: double.infinity, | ||
child: Center( | ||
child: Padding( | ||
padding: EdgeInsets.only(top: 32, bottom: 48), | ||
child: Container( | ||
child: Text( | ||
"Your classes could not be displayed.\n\nIf the problem persists contact [email protected]"), | ||
), | ||
), | ||
Flexible( | ||
flex: 2, | ||
child: UpcomingCoursesList(), | ||
), | ||
], | ||
), | ||
); | ||
), | ||
); | ||
} | ||
} | ||
|
||
Widget buildWeekdayText(String nextDayWithClasses) { | ||
|
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 |
---|---|---|
|
@@ -83,13 +83,26 @@ class CardContainer extends StatelessWidget { | |
child: Text('An error occurred, please try again.'), | ||
); | ||
} else if (titleText == 'Finals') { | ||
// TODO: Resolve alignment issues on cards without action buttons | ||
var customErrorText = ''; | ||
if (errorText!.contains('Exception')) { | ||
customErrorText = | ||
'Your finals could not be displayed.\n\nIf the problem persists contact [email protected]'; | ||
} else { | ||
customErrorText = 'No finals found.'; | ||
} | ||
return Padding( | ||
padding: const EdgeInsets.only(bottom: 42.0), | ||
child: Text('No finals found.'), | ||
child: Text(customErrorText), | ||
); | ||
} else if (titleText == 'Classes') { | ||
return Text('No classes found.'); | ||
var customErrorText = ''; | ||
if (errorText!.contains('Exception')) { | ||
customErrorText = | ||
'Your classes could not be displayed.\n\nIf the problem persists contact [email protected]'; | ||
} else { | ||
customErrorText = 'No finals found.'; | ||
} | ||
return Text(customErrorText); | ||
} else { | ||
return Text('An error occurred, please try again.'); | ||
} | ||
|
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ import 'package:campus_mobile_experimental/core/providers/classes.dart'; | |
import 'package:campus_mobile_experimental/ui/common/card_container.dart'; | ||
import 'package:campus_mobile_experimental/ui/common/last_updated_widget.dart'; | ||
import 'package:campus_mobile_experimental/ui/common/time_range_widget.dart'; | ||
import 'package:firebase_crashlytics/firebase_crashlytics.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
|
@@ -62,36 +63,54 @@ class FinalsCard extends StatelessWidget { | |
|
||
Widget buildFinalsCard(Map<String, List<SectionData>> finalsData, | ||
DateTime? lastUpdated, String? nextDayWithClasses, BuildContext context) { | ||
List<Widget> listToReturn = []; | ||
finalsData.forEach((key, value) { | ||
for (SectionData data in value) { | ||
listToReturn.add(ListTile( | ||
title: buildWeekdayText(abbrevToFullWeekday(data.days)), | ||
subtitle: Column( | ||
children: [ | ||
buildClassTitle(data.subjectCode! + ' ' + data.courseCode!), | ||
buildTimeRow(data.time), | ||
buildClassTitle(data.courseTitle!), | ||
buildLocationRow(data.building! + ' ' + data.room!), | ||
], | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
try { | ||
List<Widget> listToReturn = []; | ||
finalsData.forEach((key, value) { | ||
for (SectionData data in value) { | ||
listToReturn.add(ListTile( | ||
title: buildWeekdayText(abbrevToFullWeekday(data.days)), | ||
subtitle: Column( | ||
children: [ | ||
buildClassTitle(data.subjectCode! + ' ' + data.courseCode!), | ||
buildTimeRow(data.time), | ||
buildClassTitle(data.courseTitle!), | ||
buildLocationRow(data.building! + ' ' + data.room!), | ||
], | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
), | ||
)); | ||
} | ||
}); | ||
listToReturn = | ||
ListTile.divideTiles(tiles: listToReturn, context: context).toList(); | ||
listToReturn.add( | ||
Padding( | ||
padding: const EdgeInsets.only(left: 16.0, bottom: 8.0), | ||
child: LastUpdatedWidget(time: lastUpdated), | ||
), | ||
); | ||
return ListView( | ||
physics: NeverScrollableScrollPhysics(), | ||
children: listToReturn, | ||
shrinkWrap: true, | ||
); | ||
} catch (e) { | ||
FirebaseCrashlytics.instance.recordError( | ||
e, StackTrace.fromString(e.toString()), | ||
reason: "Finals Card: Failed to build card content.", fatal: false); | ||
return Container( | ||
width: double.infinity, | ||
child: Center( | ||
child: Padding( | ||
padding: EdgeInsets.only(top: 32, bottom: 48), | ||
child: Container( | ||
child: Text( | ||
"Your finals could not be displayed.\n\nIf the problem persists contact [email protected]"), | ||
), | ||
), | ||
)); | ||
} | ||
}); | ||
listToReturn = | ||
ListTile.divideTiles(tiles: listToReturn, context: context).toList(); | ||
listToReturn.add( | ||
Padding( | ||
padding: const EdgeInsets.only(left: 16.0, bottom: 8.0), | ||
child: LastUpdatedWidget(time: lastUpdated), | ||
), | ||
); | ||
return ListView( | ||
physics: NeverScrollableScrollPhysics(), | ||
children: listToReturn, | ||
shrinkWrap: true, | ||
); | ||
), | ||
); | ||
} | ||
} | ||
|
||
Widget buildClassTitle(String title) { | ||
|