forked from firka/student-legacy
added lessons/misses page and final summary page
This commit is contained in:
parent
1366984c15
commit
9314c613bc
@ -81,7 +81,7 @@ class _LiveCardWidgetState extends State<LiveCardWidget> {
|
|||||||
child: widget.isEvent
|
child: widget.isEvent
|
||||||
? Column(
|
? Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
widget.title ?? 'Esemény',
|
widget.title ?? 'Esemény',
|
||||||
@ -96,7 +96,7 @@ class _LiveCardWidgetState extends State<LiveCardWidget> {
|
|||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
widget.description ??
|
widget.description ??
|
||||||
Text(
|
Text(
|
||||||
|
171
filcnaplo_mobile_ui/lib/screens/summary/pages/allsum_page.dart
Normal file
171
filcnaplo_mobile_ui/lib/screens/summary/pages/allsum_page.dart
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
import 'package:filcnaplo/api/providers/user_provider.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/models/absence.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/models/grade.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/models/subject.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/providers/absence_provider.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/providers/grade_provider.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/providers/homework_provider.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class AllSumBody extends StatefulWidget {
|
||||||
|
const AllSumBody({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_AllSumBodyState createState() => _AllSumBodyState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AllSumBodyState extends State<AllSumBody> {
|
||||||
|
late UserProvider user;
|
||||||
|
late GradeProvider gradeProvider;
|
||||||
|
late HomeworkProvider homeworkProvider;
|
||||||
|
late AbsenceProvider absenceProvider;
|
||||||
|
//late TimetableProvider timetableProvider;
|
||||||
|
late Map<String, Map<String, dynamic>> things = {};
|
||||||
|
late List<Widget> firstSixTiles = [];
|
||||||
|
late List<Widget> lastSixTiles = [];
|
||||||
|
|
||||||
|
int avgDropValue = 0;
|
||||||
|
|
||||||
|
List<Grade> getSubjectGrades(Subject subject, {int days = 0}) => gradeProvider
|
||||||
|
.grades
|
||||||
|
.where((e) =>
|
||||||
|
e.subject == subject &&
|
||||||
|
e.type == GradeType.midYear &&
|
||||||
|
(days == 0 ||
|
||||||
|
e.date.isBefore(DateTime.now().subtract(Duration(days: days)))))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
gradeProvider = Provider.of<GradeProvider>(context, listen: false);
|
||||||
|
homeworkProvider = Provider.of<HomeworkProvider>(context, listen: false);
|
||||||
|
absenceProvider = Provider.of<AbsenceProvider>(context, listen: false);
|
||||||
|
//timetableProvider = Provider.of<TimetableProvider>(context, listen: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void getGrades() {
|
||||||
|
var allGrades = gradeProvider.grades;
|
||||||
|
var testsGrades = gradeProvider.grades.where((a) => a.value.weight == 100);
|
||||||
|
var closingTestsGrades =
|
||||||
|
gradeProvider.grades.where((a) => a.value.weight >= 200);
|
||||||
|
|
||||||
|
things.addAll({
|
||||||
|
'tests': {'name': 'dolgozat', 'value': testsGrades.length},
|
||||||
|
'closingTests': {'name': 'témazáró', 'value': closingTestsGrades.length},
|
||||||
|
'grades': {'name': 'jegy', 'value': allGrades.length}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void getHomework() {
|
||||||
|
var allHomework = homeworkProvider.homework;
|
||||||
|
|
||||||
|
things.addAll({
|
||||||
|
'homework': {'name': 'házi', 'value': allHomework.length}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void getSubjects() {
|
||||||
|
var allSubjects = gradeProvider.grades
|
||||||
|
.map((e) => e.subject)
|
||||||
|
.toSet()
|
||||||
|
.toList()
|
||||||
|
..sort((a, b) => a.name.compareTo(b.name));
|
||||||
|
//var totalLessons;
|
||||||
|
var totalLessons = 0;
|
||||||
|
|
||||||
|
things.addAll({
|
||||||
|
'subjects': {'name': 'tantárgy', 'value': allSubjects.length},
|
||||||
|
'lessons': {'name': 'óra', 'value': totalLessons}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void getAbsences() {
|
||||||
|
var allAbsences = absenceProvider.absences.where((a) => a.delay == 0);
|
||||||
|
var excusedAbsences = absenceProvider.absences
|
||||||
|
.where((a) => a.state == Justification.excused && a.delay == 0);
|
||||||
|
var unexcusedAbsences = absenceProvider.absences.where((a) =>
|
||||||
|
(a.state == Justification.unexcused ||
|
||||||
|
a.state == Justification.pending) &&
|
||||||
|
a.delay == 0);
|
||||||
|
|
||||||
|
things.addAll({
|
||||||
|
'absences': {'name': 'hiányzás', 'value': allAbsences.length},
|
||||||
|
'excusedAbsences': {'name': 'igazolt', 'value': excusedAbsences.length},
|
||||||
|
'unexcusedAbsences': {
|
||||||
|
'name': 'igazolatlan',
|
||||||
|
'value': unexcusedAbsences.length
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void getDelays() {
|
||||||
|
var allDelays = absenceProvider.absences.where((a) => a.delay > 0);
|
||||||
|
var totalDelayTime = (allDelays.map((a) {
|
||||||
|
return a.delay;
|
||||||
|
}).toList())
|
||||||
|
.reduce((a, b) => a + b);
|
||||||
|
var unexcusedDelays = absenceProvider.absences
|
||||||
|
.where((a) => a.state == Justification.unexcused && a.delay > 0);
|
||||||
|
|
||||||
|
things.addAll({
|
||||||
|
'delays': {'name': 'késés', 'value': allDelays.length},
|
||||||
|
'totalDelay': {'name': 'perc', 'value': totalDelayTime},
|
||||||
|
'unexcusedDelays': {
|
||||||
|
'name': 'igazolatlan',
|
||||||
|
'value': unexcusedDelays.length
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void generateTiles() {
|
||||||
|
for (var i in things.values) {
|
||||||
|
Widget w = Center(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Text(i.values.toList()[1]),
|
||||||
|
Text(i.values.toList()[0]),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (i.values.toList()[0] == 'óra') {
|
||||||
|
return; // amig nincs megoldva az osszes ora szamanak lekerese
|
||||||
|
}
|
||||||
|
if (firstSixTiles.length < 6) {
|
||||||
|
firstSixTiles.add(w);
|
||||||
|
} else {
|
||||||
|
lastSixTiles.add(w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
generateTiles();
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
GridView.count(
|
||||||
|
crossAxisCount: 3,
|
||||||
|
mainAxisSpacing: 10,
|
||||||
|
crossAxisSpacing: 10,
|
||||||
|
children: firstSixTiles,
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 40,
|
||||||
|
),
|
||||||
|
GridView.count(
|
||||||
|
crossAxisCount: 3,
|
||||||
|
mainAxisSpacing: 10,
|
||||||
|
crossAxisSpacing: 10,
|
||||||
|
children: lastSixTiles,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -8,10 +8,8 @@ import 'package:filcnaplo/utils/format.dart';
|
|||||||
import 'package:filcnaplo_kreta_api/models/grade.dart';
|
import 'package:filcnaplo_kreta_api/models/grade.dart';
|
||||||
import 'package:filcnaplo_kreta_api/models/subject.dart';
|
import 'package:filcnaplo_kreta_api/models/subject.dart';
|
||||||
import 'package:filcnaplo_kreta_api/providers/grade_provider.dart';
|
import 'package:filcnaplo_kreta_api/providers/grade_provider.dart';
|
||||||
import 'package:filcnaplo_mobile_ui/screens/summary/summary_screen.dart';
|
|
||||||
import 'package:filcnaplo_mobile_ui/screens/summary/summary_screen.i18n.dart';
|
import 'package:filcnaplo_mobile_ui/screens/summary/summary_screen.i18n.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:auto_size_text/auto_size_text.dart';
|
import 'package:auto_size_text/auto_size_text.dart';
|
||||||
|
|
||||||
@ -40,7 +38,6 @@ class _GradesBodyState extends State<GradesBody> {
|
|||||||
late GradeProvider gradeProvider;
|
late GradeProvider gradeProvider;
|
||||||
late SettingsProvider settings;
|
late SettingsProvider settings;
|
||||||
|
|
||||||
late String firstName;
|
|
||||||
late double subjectAvg;
|
late double subjectAvg;
|
||||||
|
|
||||||
List<Widget> subjectTiles5 = [];
|
List<Widget> subjectTiles5 = [];
|
||||||
@ -171,62 +168,11 @@ class _GradesBodyState extends State<GradesBody> {
|
|||||||
user = Provider.of<UserProvider>(context);
|
user = Provider.of<UserProvider>(context);
|
||||||
settings = Provider.of<SettingsProvider>(context);
|
settings = Provider.of<SettingsProvider>(context);
|
||||||
|
|
||||||
List<String> nameParts = user.displayName?.split(" ") ?? ["?"];
|
|
||||||
if (!settings.presentationMode) {
|
|
||||||
firstName = nameParts.length > 1 ? nameParts[1] : nameParts[0];
|
|
||||||
} else {
|
|
||||||
firstName = "János";
|
|
||||||
}
|
|
||||||
|
|
||||||
getGrades();
|
getGrades();
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'Jó éved volt, $firstName!',
|
|
||||||
textAlign: TextAlign.left,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontWeight: FontWeight.w900,
|
|
||||||
fontSize: 26.0,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Text(
|
|
||||||
'Nézzük a jegyeidet... 📖',
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 22.0,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pushReplacement(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) =>
|
|
||||||
const SummaryScreen(currentPage: 'lessons'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
icon: const Icon(
|
|
||||||
FeatherIcons.arrowRight,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 12.0),
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: ((100 * subjectTiles5.length) /
|
height: ((100 * subjectTiles5.length) /
|
||||||
(subjectTiles5[0].runtimeType == Row ? 1.95 : 1.2))
|
(subjectTiles5[0].runtimeType == Row ? 1.95 : 1.2))
|
||||||
|
@ -1,10 +1,262 @@
|
|||||||
|
import 'package:filcnaplo/api/providers/user_provider.dart';
|
||||||
|
import 'package:filcnaplo/helpers/subject.dart';
|
||||||
|
import 'package:filcnaplo/models/settings.dart';
|
||||||
|
import 'package:filcnaplo/utils/format.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/models/absence.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/models/lesson.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/models/subject.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/models/week.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/providers/absence_provider.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/providers/timetable_provider.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class LessonsBody extends StatelessWidget {
|
class SubjectAbsence {
|
||||||
|
Subject subject;
|
||||||
|
List<Absence> absences;
|
||||||
|
double percentage;
|
||||||
|
|
||||||
|
SubjectAbsence(
|
||||||
|
{required this.subject, this.absences = const [], this.percentage = 0.0});
|
||||||
|
}
|
||||||
|
|
||||||
|
class LessonsBody extends StatefulWidget {
|
||||||
const LessonsBody({Key? key}) : super(key: key);
|
const LessonsBody({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_LessonsBodyState createState() => _LessonsBodyState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LessonsBodyState extends State<LessonsBody> {
|
||||||
|
late UserProvider user;
|
||||||
|
late AbsenceProvider absenceProvider;
|
||||||
|
late SettingsProvider settingsProvider;
|
||||||
|
late TimetableProvider timetableProvider;
|
||||||
|
late List<SubjectAbsence> absences = [];
|
||||||
|
late List<Widget> lessons = [];
|
||||||
|
late List<Absence> delays = [];
|
||||||
|
|
||||||
|
final Map<Subject, Lesson> _lessonCount = {};
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
absenceProvider = Provider.of<AbsenceProvider>(context, listen: false);
|
||||||
|
settingsProvider = Provider.of<SettingsProvider>(context, listen: false);
|
||||||
|
timetableProvider = Provider.of<TimetableProvider>(context, listen: false);
|
||||||
|
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||||
|
for (final lesson in timetableProvider.getWeek(Week.current()) ?? []) {
|
||||||
|
if (!lesson.isEmpty &&
|
||||||
|
lesson.subject.id != '' &&
|
||||||
|
lesson.lessonYearIndex != null) {
|
||||||
|
_lessonCount.update(
|
||||||
|
lesson.subject,
|
||||||
|
(value) {
|
||||||
|
if (lesson.lessonYearIndex! > value.lessonYearIndex!) {
|
||||||
|
return lesson;
|
||||||
|
} else {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ifAbsent: () => lesson,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setState(() {});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void buildSubjectAbsences() {
|
||||||
|
Map<Subject, SubjectAbsence> _absences = {};
|
||||||
|
|
||||||
|
for (final absence in absenceProvider.absences) {
|
||||||
|
if (absence.delay != 0) continue;
|
||||||
|
|
||||||
|
if (!_absences.containsKey(absence.subject)) {
|
||||||
|
_absences[absence.subject] =
|
||||||
|
SubjectAbsence(subject: absence.subject, absences: [absence]);
|
||||||
|
} else {
|
||||||
|
_absences[absence.subject]?.absences.add(absence);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_absences.forEach((subject, absence) {
|
||||||
|
final absentLessonsOfSubject = absenceProvider.absences
|
||||||
|
.where((e) => e.subject == subject && e.delay == 0)
|
||||||
|
.length;
|
||||||
|
final totalLessonsOfSubject = _lessonCount[subject]?.lessonYearIndex ?? 0;
|
||||||
|
|
||||||
|
double absentLessonsOfSubjectPercentage;
|
||||||
|
|
||||||
|
if (absentLessonsOfSubject <= totalLessonsOfSubject) {
|
||||||
|
absentLessonsOfSubjectPercentage =
|
||||||
|
absentLessonsOfSubject / totalLessonsOfSubject * 100;
|
||||||
|
} else {
|
||||||
|
absentLessonsOfSubjectPercentage = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
_absences[subject]?.percentage =
|
||||||
|
absentLessonsOfSubjectPercentage.clamp(-1, 100.0);
|
||||||
|
});
|
||||||
|
|
||||||
|
absences = _absences.values.toList();
|
||||||
|
absences.sort((a, b) => -a.percentage.compareTo(b.percentage));
|
||||||
|
}
|
||||||
|
|
||||||
|
void getAndSortDelays() {
|
||||||
|
delays = absenceProvider.absences;
|
||||||
|
delays.sort((a, b) => -a.delay.compareTo(b.delay));
|
||||||
|
}
|
||||||
|
|
||||||
|
void generateTiles() {
|
||||||
|
Widget leastAbsent = Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
SubjectIcon.resolveVariant(
|
||||||
|
subject: absences.last.subject, context: context),
|
||||||
|
color: Colors.white,
|
||||||
|
size: 64,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
absences.last.subject.renamedTo ??
|
||||||
|
absences.last.subject.name.capital(),
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.w800,
|
||||||
|
fontSize: 36.0,
|
||||||
|
fontStyle: absences.last.subject.isRenamed &&
|
||||||
|
settingsProvider.renamedSubjectsItalics
|
||||||
|
? FontStyle.italic
|
||||||
|
: null,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'${absences.last.absences.length} hiányzás',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 18.0,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
Widget mostAbsent = Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
SubjectIcon.resolveVariant(
|
||||||
|
subject: absences.first.subject, context: context),
|
||||||
|
color: Colors.white,
|
||||||
|
size: 64,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
absences.first.subject.renamedTo ??
|
||||||
|
absences.first.subject.name.capital(),
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.w800,
|
||||||
|
fontSize: 36.0,
|
||||||
|
fontStyle: absences.first.subject.isRenamed &&
|
||||||
|
settingsProvider.renamedSubjectsItalics
|
||||||
|
? FontStyle.italic
|
||||||
|
: null,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'${absences.first.absences.length} hiányzás',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 18.0,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
Widget mostDelays = Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
SubjectIcon.resolveVariant(
|
||||||
|
subject: delays.first.subject, context: context),
|
||||||
|
color: Colors.white,
|
||||||
|
size: 64,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
delays.first.subject.renamedTo ??
|
||||||
|
delays.first.subject.name.capital(),
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.w800,
|
||||||
|
fontSize: 36.0,
|
||||||
|
fontStyle: delays.first.subject.isRenamed &&
|
||||||
|
settingsProvider.renamedSubjectsItalics
|
||||||
|
? FontStyle.italic
|
||||||
|
: null,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Összesen ${delays.first.delay} perc késés',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 18.0,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
lessons.addAll([leastAbsent, mostAbsent, mostDelays]);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return const Column();
|
buildSubjectAbsences();
|
||||||
|
getAndSortDelays();
|
||||||
|
generateTiles();
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
lessons[0],
|
||||||
|
const SizedBox(height: 18.0),
|
||||||
|
const Text(
|
||||||
|
'Nem volt kedved hozzá...',
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 22.0,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 18.0),
|
||||||
|
lessons[1],
|
||||||
|
const SizedBox(height: 18.0),
|
||||||
|
const Text(
|
||||||
|
'Késtél!',
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 22.0,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 18.0),
|
||||||
|
lessons[2],
|
||||||
|
],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:wtf_sliding_sheet/wtf_sliding_sheet.dart';
|
||||||
|
|
||||||
class StartBody extends StatefulWidget {
|
class StartBody extends StatefulWidget {
|
||||||
const StartBody({Key? key}) : super(key: key);
|
const StartBody({Key? key}) : super(key: key);
|
||||||
@ -31,98 +32,65 @@ class _StartBodyState extends State<StartBody> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
user = Provider.of<UserProvider>(context);
|
|
||||||
settings = Provider.of<SettingsProvider>(context);
|
|
||||||
|
|
||||||
List<String> nameParts = user.displayName?.split(" ") ?? ["?"];
|
|
||||||
if (!settings.presentationMode) {
|
|
||||||
firstName = nameParts.length > 1 ? nameParts[1] : nameParts[0];
|
|
||||||
} else {
|
|
||||||
firstName = "János";
|
|
||||||
}
|
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
const SizedBox(height: 40.0),
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
GestureDetector(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
onTap: () {
|
||||||
children: [
|
Navigator.of(context).pop();
|
||||||
Column(
|
showSlidingBottomSheet(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
context,
|
||||||
children: [
|
useRootNavigator: true,
|
||||||
Text(
|
builder: (context) => SlidingSheetDialog(
|
||||||
'Jó éved volt, $firstName!',
|
color: Colors.black.withOpacity(0.99),
|
||||||
textAlign: TextAlign.left,
|
duration: const Duration(milliseconds: 400),
|
||||||
style: const TextStyle(
|
scrollSpec: const ScrollSpec.bouncingScroll(),
|
||||||
fontWeight: FontWeight.w900,
|
snapSpec: const SnapSpec(
|
||||||
fontSize: 26.0,
|
snap: true,
|
||||||
color: Colors.white,
|
snappings: [1.0],
|
||||||
|
initialSnap: 1.0,
|
||||||
|
positioning: SnapPositioning.relativeToAvailableSpace,
|
||||||
|
),
|
||||||
|
minHeight: MediaQuery.of(context).size.height,
|
||||||
|
cornerRadius: 16,
|
||||||
|
cornerRadiusOnFullscreen: 0,
|
||||||
|
builder: (context, state) => const Material(
|
||||||
|
color: Colors.black,
|
||||||
|
child: SummaryScreen(
|
||||||
|
currentPage: 'grades',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Text(
|
),
|
||||||
'Összegezzünk hát...',
|
);
|
||||||
|
},
|
||||||
|
child: Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const Icon(
|
||||||
|
FeatherIcons.arrowRight,
|
||||||
|
size: 145,
|
||||||
|
color: Colors.white,
|
||||||
|
grade: 0.001,
|
||||||
|
weight: 0.001,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Kezdés',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.w500,
|
||||||
fontSize: 22.0,
|
fontSize: 16.0,
|
||||||
color: Colors.white,
|
color: Colors.white.withOpacity(0.7),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
// IconButton(
|
|
||||||
// onPressed: () {
|
|
||||||
// Navigator.of(context).maybePop();
|
|
||||||
// Navigator.of(context).push(
|
|
||||||
// MaterialPageRoute(
|
|
||||||
// builder: (context) =>
|
|
||||||
// const SummaryScreen(currentPage: 'lessons'),
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
// },
|
|
||||||
// icon: const Icon(
|
|
||||||
// FeatherIcons.arrowRight,
|
|
||||||
// color: Colors.white,
|
|
||||||
// ),
|
|
||||||
// )
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 40.0),
|
|
||||||
GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
Navigator.pushReplacement(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) =>
|
|
||||||
const SummaryScreen(currentPage: 'grades'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
const Icon(
|
|
||||||
FeatherIcons.arrowRight,
|
|
||||||
size: 145,
|
|
||||||
color: Colors.white,
|
|
||||||
grade: 0.001,
|
|
||||||
weight: 0.001,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'Kezdés',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
fontSize: 16.0,
|
|
||||||
color: Colors.white.withOpacity(0.7),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 50.69),
|
const SizedBox(height: 169.69),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
import 'package:confetti/confetti.dart';
|
import 'package:confetti/confetti.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:filcnaplo/api/providers/user_provider.dart';
|
||||||
|
import 'package:filcnaplo/models/settings.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:wtf_sliding_sheet/wtf_sliding_sheet.dart';
|
||||||
|
|
||||||
|
import 'pages/allsum_page.dart';
|
||||||
import 'pages/start_page.dart';
|
import 'pages/start_page.dart';
|
||||||
import 'pages/grades_page.dart';
|
import 'pages/grades_page.dart';
|
||||||
import 'pages/lessons_page.dart';
|
import 'pages/lessons_page.dart';
|
||||||
@ -18,9 +24,14 @@ class SummaryScreen extends StatefulWidget {
|
|||||||
|
|
||||||
class _SummaryScreenState extends State<SummaryScreen>
|
class _SummaryScreenState extends State<SummaryScreen>
|
||||||
with SingleTickerProviderStateMixin {
|
with SingleTickerProviderStateMixin {
|
||||||
|
late UserProvider user;
|
||||||
|
late SettingsProvider settings;
|
||||||
|
|
||||||
late AnimationController _hideContainersController;
|
late AnimationController _hideContainersController;
|
||||||
ConfettiController? _confettiController;
|
ConfettiController? _confettiController;
|
||||||
|
|
||||||
|
late String firstName;
|
||||||
|
|
||||||
final LinearGradient _backgroundGradient = const LinearGradient(
|
final LinearGradient _backgroundGradient = const LinearGradient(
|
||||||
colors: [
|
colors: [
|
||||||
Color(0xff1d56ac),
|
Color(0xff1d56ac),
|
||||||
@ -48,6 +59,16 @@ class _SummaryScreenState extends State<SummaryScreen>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
user = Provider.of<UserProvider>(context);
|
||||||
|
settings = Provider.of<SettingsProvider>(context);
|
||||||
|
|
||||||
|
List<String> nameParts = user.displayName?.split(" ") ?? ["?"];
|
||||||
|
if (!settings.presentationMode) {
|
||||||
|
firstName = nameParts.length > 1 ? nameParts[1] : nameParts[0];
|
||||||
|
} else {
|
||||||
|
firstName = "János";
|
||||||
|
}
|
||||||
|
|
||||||
return AnimatedBuilder(
|
return AnimatedBuilder(
|
||||||
animation: _hideContainersController,
|
animation: _hideContainersController,
|
||||||
builder: (context, child) => Opacity(
|
builder: (context, child) => Opacity(
|
||||||
@ -66,15 +87,82 @@ class _SummaryScreenState extends State<SummaryScreen>
|
|||||||
top: MediaQuery.of(context).padding.top,
|
top: MediaQuery.of(context).padding.top,
|
||||||
bottom: 52.0,
|
bottom: 52.0,
|
||||||
),
|
),
|
||||||
child: widget.currentPage == 'start'
|
child: Column(
|
||||||
? const StartBody()
|
crossAxisAlignment: widget.currentPage == 'start'
|
||||||
: widget.currentPage == 'grades'
|
? CrossAxisAlignment.center
|
||||||
? const GradesBody()
|
: CrossAxisAlignment.start,
|
||||||
: widget.currentPage == 'lessons'
|
mainAxisAlignment: widget.currentPage == 'start'
|
||||||
? const LessonsBody()
|
? MainAxisAlignment.spaceBetween
|
||||||
: widget.currentPage == 'allsum'
|
: MainAxisAlignment.start,
|
||||||
? const GradesBody()
|
children: [
|
||||||
: const PersonalityBody(),
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Jó éved volt, $firstName!',
|
||||||
|
textAlign: TextAlign.left,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.w900,
|
||||||
|
fontSize: 26.0,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
widget.currentPage == 'start'
|
||||||
|
? 'Összegezzünk hát...'
|
||||||
|
: widget.currentPage == 'grades'
|
||||||
|
? 'Nézzük a jegyeidet... 📖'
|
||||||
|
: widget.currentPage == 'lessons'
|
||||||
|
? 'A kedvenced órád 💓'
|
||||||
|
: '',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 22.0,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
widget.currentPage != 'start'
|
||||||
|
? IconButton(
|
||||||
|
onPressed: () async {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
if (widget.currentPage == 'grades') {
|
||||||
|
openNewPage(page: 'lessons');
|
||||||
|
} else if (widget.currentPage == 'lessons') {
|
||||||
|
openNewPage(page: 'allsum');
|
||||||
|
} else if (widget.currentPage == 'allsum') {
|
||||||
|
openNewPage(page: 'personality');
|
||||||
|
} else {
|
||||||
|
Navigator.of(context).maybePop();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
icon: Icon(
|
||||||
|
widget.currentPage == 'personality'
|
||||||
|
? FeatherIcons.x
|
||||||
|
: FeatherIcons.arrowRight,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Container()
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12.0),
|
||||||
|
widget.currentPage == 'start'
|
||||||
|
? const StartBody()
|
||||||
|
: widget.currentPage == 'grades'
|
||||||
|
? const GradesBody()
|
||||||
|
: widget.currentPage == 'lessons'
|
||||||
|
? const LessonsBody()
|
||||||
|
: widget.currentPage == 'allsum'
|
||||||
|
? const AllSumBody()
|
||||||
|
: const PersonalityBody(),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -82,4 +170,31 @@ class _SummaryScreenState extends State<SummaryScreen>
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void openNewPage({String page = 'personality'}) {
|
||||||
|
showSlidingBottomSheet(
|
||||||
|
context,
|
||||||
|
useRootNavigator: true,
|
||||||
|
builder: (context) => SlidingSheetDialog(
|
||||||
|
color: Colors.black.withOpacity(0.99),
|
||||||
|
duration: const Duration(milliseconds: 400),
|
||||||
|
scrollSpec: const ScrollSpec.bouncingScroll(),
|
||||||
|
snapSpec: const SnapSpec(
|
||||||
|
snap: true,
|
||||||
|
snappings: [1.0],
|
||||||
|
initialSnap: 1.0,
|
||||||
|
positioning: SnapPositioning.relativeToAvailableSpace,
|
||||||
|
),
|
||||||
|
minHeight: MediaQuery.of(context).size.height,
|
||||||
|
cornerRadius: 16,
|
||||||
|
cornerRadiusOnFullscreen: 0,
|
||||||
|
builder: (context, state) => Material(
|
||||||
|
color: Colors.black,
|
||||||
|
child: SummaryScreen(
|
||||||
|
currentPage: page,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user