forked from firka/student-legacy
surprise grades
This commit is contained in:
parent
818060bbcb
commit
69a3090f16
BIN
filcnaplo/assets/animations/backpack-2.riv
Normal file
BIN
filcnaplo/assets/animations/backpack-2.riv
Normal file
Binary file not shown.
@ -63,7 +63,7 @@ Future<Database> initDB() async {
|
|||||||
"grades": "[]", "timetable": "[]", "exams": "[]", "homework": "[]", "messages": "[]", "notes": "[]", "events": "[]", "absences": "[]",
|
"grades": "[]", "timetable": "[]", "exams": "[]", "homework": "[]", "messages": "[]", "notes": "[]", "events": "[]", "absences": "[]",
|
||||||
"group_averages": "[]",
|
"group_averages": "[]",
|
||||||
// "subject_lesson_count": "{}", // non kreta data
|
// "subject_lesson_count": "{}", // non kreta data
|
||||||
"last_seen_grade": "0",
|
"last_seen_grade": 0,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
print("ERROR: migrateDB: $error");
|
print("ERROR: migrateDB: $error");
|
||||||
|
@ -27,7 +27,7 @@ import 'package:provider/provider.dart';
|
|||||||
|
|
||||||
const List<FilterType> homeFilters = [FilterType.all, FilterType.grades, FilterType.messages, FilterType.absences];
|
const List<FilterType> homeFilters = [FilterType.all, FilterType.grades, FilterType.messages, FilterType.absences];
|
||||||
|
|
||||||
enum FilterType { all, grades, messages, absences, homework, exams, notes, events, lessons, updates, certifications, missedExams }
|
enum FilterType { all, grades, newGrades, messages, absences, homework, exams, notes, events, lessons, updates, certifications, missedExams }
|
||||||
|
|
||||||
Future<List<DateWidget>> getFilterWidgets(FilterType activeData, {bool absencesNoExcused = false, required BuildContext context}) async {
|
Future<List<DateWidget>> getFilterWidgets(FilterType activeData, {bool absencesNoExcused = false, required BuildContext context}) async {
|
||||||
final gradeProvider = Provider.of<GradeProvider>(context);
|
final gradeProvider = Provider.of<GradeProvider>(context);
|
||||||
@ -62,7 +62,13 @@ Future<List<DateWidget>> getFilterWidgets(FilterType activeData, {bool absencesN
|
|||||||
|
|
||||||
// Grades
|
// Grades
|
||||||
case FilterType.grades:
|
case FilterType.grades:
|
||||||
items = grade_filter.getWidgets(gradeProvider.grades);
|
items = grade_filter.getWidgets(gradeProvider.grades, gradeProvider.lastSeenDate);
|
||||||
|
items.addAll(await getFilterWidgets(FilterType.newGrades, context: context));
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Grades
|
||||||
|
case FilterType.newGrades:
|
||||||
|
items = grade_filter.getNewWidgets(gradeProvider.grades, gradeProvider.lastSeenDate);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Certifications
|
// Certifications
|
||||||
|
@ -2,12 +2,13 @@ import 'package:filcnaplo/ui/date_widget.dart';
|
|||||||
import 'package:filcnaplo/utils/platform.dart';
|
import 'package:filcnaplo/utils/platform.dart';
|
||||||
import 'package:filcnaplo_kreta_api/models/grade.dart';
|
import 'package:filcnaplo_kreta_api/models/grade.dart';
|
||||||
import 'package:filcnaplo_mobile_ui/common/widgets/grade/grade_viewable.dart' as mobile;
|
import 'package:filcnaplo_mobile_ui/common/widgets/grade/grade_viewable.dart' as mobile;
|
||||||
|
import 'package:filcnaplo_mobile_ui/common/widgets/grade/new_grades.dart' as mobile;
|
||||||
import 'package:filcnaplo_desktop_ui/common/widgets/grade/grade_viewable.dart' as desktop;
|
import 'package:filcnaplo_desktop_ui/common/widgets/grade/grade_viewable.dart' as desktop;
|
||||||
|
|
||||||
List<DateWidget> getWidgets(List<Grade> providerGrades) {
|
List<DateWidget> getWidgets(List<Grade> providerGrades, DateTime? lastSeenDate) {
|
||||||
List<DateWidget> items = [];
|
List<DateWidget> items = [];
|
||||||
for (var grade in providerGrades) {
|
for (var grade in providerGrades) {
|
||||||
if (grade.type == GradeType.midYear) {
|
if (grade.type == GradeType.midYear && !(lastSeenDate != null && grade.date.isAfter(lastSeenDate))) {
|
||||||
items.add(DateWidget(
|
items.add(DateWidget(
|
||||||
key: grade.id,
|
key: grade.id,
|
||||||
date: grade.date,
|
date: grade.date,
|
||||||
@ -17,3 +18,22 @@ List<DateWidget> getWidgets(List<Grade> providerGrades) {
|
|||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<DateWidget> getNewWidgets(List<Grade> providerGrades, DateTime? lastSeenDate) {
|
||||||
|
List<DateWidget> items = [];
|
||||||
|
List<Grade> newGrades = [];
|
||||||
|
for (var grade in providerGrades) {
|
||||||
|
if (grade.type == GradeType.midYear && !(lastSeenDate != null && !grade.date.isAfter(lastSeenDate))) {
|
||||||
|
newGrades.add(grade);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newGrades.sort((a, b) => a.date.compareTo(b.date));
|
||||||
|
if (newGrades.isNotEmpty) {
|
||||||
|
items.add(DateWidget(
|
||||||
|
key: newGrades.last.id,
|
||||||
|
date: newGrades.last.date,
|
||||||
|
widget: mobile.NewGradesSurprise(newGrades),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
@ -120,11 +120,23 @@ class GradeTile extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class GradeValueWidget extends StatelessWidget {
|
class GradeValueWidget extends StatelessWidget {
|
||||||
const GradeValueWidget(this.value, {Key? key, this.size = 38.0, this.fill = false, this.complemented = false}) : super(key: key);
|
const GradeValueWidget(
|
||||||
|
this.value, {
|
||||||
|
Key? key,
|
||||||
|
this.size = 38.0,
|
||||||
|
this.fill = false,
|
||||||
|
this.contrast = false,
|
||||||
|
this.shadow = false,
|
||||||
|
this.outline = false,
|
||||||
|
this.complemented = false,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
final GradeValue value;
|
final GradeValue value;
|
||||||
final double size;
|
final double size;
|
||||||
final bool fill;
|
final bool fill;
|
||||||
|
final bool contrast;
|
||||||
|
final bool shadow;
|
||||||
|
final bool outline;
|
||||||
final bool complemented;
|
final bool complemented;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -164,11 +176,11 @@ class GradeValueWidget extends StatelessWidget {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: value.weight == 50 ? FontWeight.w600 : FontWeight.bold,
|
fontWeight: value.weight == 50 ? FontWeight.w600 : FontWeight.bold,
|
||||||
fontSize: size,
|
fontSize: size,
|
||||||
color: color,
|
color: contrast ? Colors.white : color,
|
||||||
shadows: [
|
shadows: [
|
||||||
if (value.weight >= 200)
|
if (value.weight >= 200)
|
||||||
Shadow(
|
Shadow(
|
||||||
color: color.withOpacity(.4),
|
color: (contrast ? Colors.white : color).withOpacity(.4),
|
||||||
offset: const Offset(-4, -3),
|
offset: const Offset(-4, -3),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@ -195,8 +207,15 @@ class GradeValueWidget extends StatelessWidget {
|
|||||||
width: size * 1.4,
|
width: size * 1.4,
|
||||||
height: size * 1.4,
|
height: size * 1.4,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: color.withOpacity(.25),
|
color: color.withOpacity(contrast ? 1.0 : .25),
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
|
boxShadow: [
|
||||||
|
if (shadow)
|
||||||
|
BoxShadow(
|
||||||
|
color: color,
|
||||||
|
blurRadius: 62.0,
|
||||||
|
)
|
||||||
|
],
|
||||||
),
|
),
|
||||||
child: Center(child: valueText),
|
child: Center(child: valueText),
|
||||||
)
|
)
|
||||||
|
@ -51,6 +51,8 @@ dependencies:
|
|||||||
live_activities: ^1.0.0
|
live_activities: ^1.0.0
|
||||||
animated_flip_counter: ^0.2.5
|
animated_flip_counter: ^0.2.5
|
||||||
lottie: ^1.4.3
|
lottie: ^1.4.3
|
||||||
|
rive: ^0.9.1
|
||||||
|
animated_background: ^2.0.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_lints: ^2.0.1
|
flutter_lints: ^2.0.1
|
||||||
@ -64,7 +66,7 @@ flutter:
|
|||||||
assets:
|
assets:
|
||||||
- assets/icons/ic_launcher.png
|
- assets/icons/ic_launcher.png
|
||||||
- assets/icons/ic_splash.png
|
- assets/icons/ic_splash.png
|
||||||
- assets/animations/bell-alert.json
|
- assets/animations/
|
||||||
|
|
||||||
fonts:
|
fonts:
|
||||||
- family: FilcIcons
|
- family: FilcIcons
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit a417359d1aa9405e6a6ae80a96c1c1451f390323
|
Subproject commit 99d8638344cbe14184fbe7c4edd9bbf9513a077f
|
Loading…
x
Reference in New Issue
Block a user