forked from firka/student-legacy
finished new grade counter
This commit is contained in:
parent
fdd4a9700c
commit
3ab43d84fe
@ -1,7 +1,12 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||
import 'package:refilc_kreta_api/models/grade.dart';
|
||||
import 'package:refilc_mobile_ui/pages/grades/grades_count_item.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:rounded_expansion_tile/rounded_expansion_tile.dart';
|
||||
import 'grades_page.i18n.dart';
|
||||
|
||||
class GradesCount extends StatelessWidget {
|
||||
const GradesCount({super.key, required this.grades});
|
||||
@ -14,56 +19,40 @@ class GradesCount extends StatelessWidget {
|
||||
(int index) => grades.where((e) => e.value.value == index + 1).length);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(6.0),
|
||||
child: IntrinsicHeight(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// TODO: make a new widget here, cuz this will not fit
|
||||
// Text.rich(
|
||||
// TextSpan(children: [
|
||||
// TextSpan(
|
||||
// text: gradesCount.reduce((a, b) => a + b).toString(),
|
||||
// style: const TextStyle(fontWeight: FontWeight.w600),
|
||||
// ),
|
||||
// const TextSpan(
|
||||
// text: "x",
|
||||
// style: TextStyle(
|
||||
// fontSize: 13.0,
|
||||
// ),
|
||||
// ),
|
||||
// ]),
|
||||
// style: const TextStyle(fontSize: 15.0),
|
||||
// ),
|
||||
// const SizedBox(
|
||||
// width: 10.0,
|
||||
// ),
|
||||
// ClipRRect(
|
||||
// borderRadius: BorderRadius.circular(10.0),
|
||||
// child: VerticalDivider(
|
||||
// width: 2,
|
||||
// thickness: 2,
|
||||
// indent: 2,
|
||||
// endIndent: 2,
|
||||
// color: MediaQuery.of(context).platformBrightness ==
|
||||
// Brightness.light
|
||||
// ? Colors.grey.shade300
|
||||
// : Colors.grey.shade700,
|
||||
// ),
|
||||
// ),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: gradesCount
|
||||
.mapIndexed((index, e) => Padding(
|
||||
padding: const EdgeInsets.only(left: 9.69),
|
||||
child: GradesCountItem(count: e, value: index + 1)))
|
||||
.toList(),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8.0,
|
||||
),
|
||||
],
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: RoundedExpansionTile(
|
||||
tileColor: Colors.transparent,
|
||||
childrenPadding: const EdgeInsets.only(bottom: 8.0, top: 10.0),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
visualDensity: const VisualDensity(vertical: -4),
|
||||
duration: const Duration(milliseconds: 250),
|
||||
trailingDuration: 0.5,
|
||||
trailing: const Icon(FeatherIcons.chevronDown),
|
||||
title: Text(
|
||||
'grades_cnt'.i18n.fill([
|
||||
gradesCount.reduce((a, b) => a + b).toString(),
|
||||
]),
|
||||
style: const TextStyle(
|
||||
height: 1.0,
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
children: gradesCount
|
||||
.mapIndexed(
|
||||
(index, e) => Padding(
|
||||
padding: const EdgeInsets.only(bottom: 7.0, left: 4.0),
|
||||
child: GradesCountItem(
|
||||
count: e,
|
||||
value: index + 1,
|
||||
total:
|
||||
gradesCount.reduce(max) + (gradesCount.reduce(max) / 5),
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList()
|
||||
.reversed
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -1,33 +1,76 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:refilc/ui/widgets/grade/grade_tile.dart';
|
||||
import 'package:refilc_kreta_api/models/grade.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:refilc_mobile_ui/common/progress_bar.dart';
|
||||
|
||||
class GradesCountItem extends StatelessWidget {
|
||||
const GradesCountItem({super.key, required this.count, required this.value});
|
||||
const GradesCountItem({
|
||||
super.key,
|
||||
required this.count,
|
||||
required this.value,
|
||||
required this.total,
|
||||
});
|
||||
|
||||
final int count;
|
||||
final int value;
|
||||
final double total;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// return Row(
|
||||
// children: [
|
||||
// Text.rich(
|
||||
// TextSpan(children: [
|
||||
// TextSpan(
|
||||
// text: count.toString(),
|
||||
// style: const TextStyle(fontWeight: FontWeight.w600),
|
||||
// ),
|
||||
// const TextSpan(
|
||||
// text: "x",
|
||||
// style: TextStyle(fontSize: 13.0),
|
||||
// ),
|
||||
// ]),
|
||||
// style: const TextStyle(fontSize: 15.0),
|
||||
// ),
|
||||
// const SizedBox(width: 3.0),
|
||||
// GradeValueWidget(GradeValue(value, "Value", "Value", 100),
|
||||
// size: 18.0, fill: true, shadow: false),
|
||||
// ],
|
||||
// );
|
||||
return Row(
|
||||
children: [
|
||||
Text.rich(
|
||||
TextSpan(children: [
|
||||
TextSpan(
|
||||
text: count.toString(),
|
||||
style: const TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
const TextSpan(
|
||||
text: "x",
|
||||
style: TextStyle(fontSize: 13.0),
|
||||
),
|
||||
]),
|
||||
style: const TextStyle(fontSize: 15.0),
|
||||
GradeValueWidget(
|
||||
GradeValue(value, "Value", "Value", 100),
|
||||
size: 18.0,
|
||||
fill: true,
|
||||
shadow: false,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 12.0,
|
||||
),
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width / 1.7,
|
||||
child: ProgressBar(
|
||||
value: (count / total),
|
||||
backgroundColor: gradeColor(
|
||||
context: context,
|
||||
value: value,
|
||||
nocolor: false,
|
||||
),
|
||||
height: 10.0,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 12.0,
|
||||
),
|
||||
Text(
|
||||
count.toString(),
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 14.0,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 3.0),
|
||||
GradeValueWidget(GradeValue(value, "Value", "Value", 100),
|
||||
size: 18.0, fill: true, shadow: false),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -17,10 +17,11 @@ extension Localization on String {
|
||||
"subjectavg": "Subject Average",
|
||||
"classavg": "Class Average",
|
||||
"fail_warning": "Failure warning",
|
||||
"fail_warning_description": "You are failing %d subjects!"
|
||||
.one("You are failing a subject!"),
|
||||
"fail_warning_description":
|
||||
"You are failing %d subjects!".one("You are failing a subject!"),
|
||||
"data": "Data",
|
||||
"you_have_hw": "You have %s homework(s) to do",
|
||||
"grades_cnt": "Grade count: %s",
|
||||
},
|
||||
"hu_hu": {
|
||||
"Grades": "Tantárgyak",
|
||||
@ -39,6 +40,7 @@ extension Localization on String {
|
||||
"fail_warning_description": "Bukásra állsz %d tantárgyból",
|
||||
"data": "Adatok",
|
||||
"you_have_hw": "%s házi feladat vár rád",
|
||||
"grades_cnt": "Jegyek száma: %s",
|
||||
},
|
||||
"de_de": {
|
||||
"Grades": "Fächer",
|
||||
@ -57,6 +59,7 @@ extension Localization on String {
|
||||
"fail_warning_description": "Sie werden in %d des Fachs durchfallen",
|
||||
"data": "Daten",
|
||||
"you_have_hw": "Du hast %s Hausaufgaben",
|
||||
"grades_cnt": "Anzahl der Noten: %s",
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -131,7 +131,9 @@ class GradeGraphState extends State<GradeGraph> {
|
||||
.transform(average - average.floor())!
|
||||
: Theme.of(context).colorScheme.secondary;
|
||||
|
||||
// color magic happens here
|
||||
List<Color> averageColors = getColors(data);
|
||||
|
||||
subjectSpots = getSpots(data);
|
||||
|
||||
// naplo/#73
|
||||
|
Loading…
x
Reference in New Issue
Block a user