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/material.dart';
|
||||||
|
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||||
import 'package:refilc_kreta_api/models/grade.dart';
|
import 'package:refilc_kreta_api/models/grade.dart';
|
||||||
import 'package:refilc_mobile_ui/pages/grades/grades_count_item.dart';
|
import 'package:refilc_mobile_ui/pages/grades/grades_count_item.dart';
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
|
import 'package:rounded_expansion_tile/rounded_expansion_tile.dart';
|
||||||
|
import 'grades_page.i18n.dart';
|
||||||
|
|
||||||
class GradesCount extends StatelessWidget {
|
class GradesCount extends StatelessWidget {
|
||||||
const GradesCount({super.key, required this.grades});
|
const GradesCount({super.key, required this.grades});
|
||||||
@ -14,57 +19,41 @@ class GradesCount extends StatelessWidget {
|
|||||||
(int index) => grades.where((e) => e.value.value == index + 1).length);
|
(int index) => grades.where((e) => e.value.value == index + 1).length);
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(6.0),
|
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||||
child: IntrinsicHeight(
|
child: RoundedExpansionTile(
|
||||||
child: Row(
|
tileColor: Colors.transparent,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
childrenPadding: const EdgeInsets.only(bottom: 8.0, top: 10.0),
|
||||||
children: [
|
contentPadding: EdgeInsets.zero,
|
||||||
// TODO: make a new widget here, cuz this will not fit
|
visualDensity: const VisualDensity(vertical: -4),
|
||||||
// Text.rich(
|
duration: const Duration(milliseconds: 250),
|
||||||
// TextSpan(children: [
|
trailingDuration: 0.5,
|
||||||
// TextSpan(
|
trailing: const Icon(FeatherIcons.chevronDown),
|
||||||
// text: gradesCount.reduce((a, b) => a + b).toString(),
|
title: Text(
|
||||||
// style: const TextStyle(fontWeight: FontWeight.w600),
|
'grades_cnt'.i18n.fill([
|
||||||
// ),
|
gradesCount.reduce((a, b) => a + b).toString(),
|
||||||
// const TextSpan(
|
]),
|
||||||
// text: "x",
|
style: const TextStyle(
|
||||||
// style: TextStyle(
|
height: 1.0,
|
||||||
// fontSize: 13.0,
|
fontSize: 16.0,
|
||||||
// ),
|
fontWeight: FontWeight.w600,
|
||||||
// ),
|
),
|
||||||
// ]),
|
),
|
||||||
// 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
|
children: gradesCount
|
||||||
.mapIndexed((index, e) => Padding(
|
.mapIndexed(
|
||||||
padding: const EdgeInsets.only(left: 9.69),
|
(index, e) => Padding(
|
||||||
child: GradesCountItem(count: e, value: index + 1)))
|
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(),
|
.toList(),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
|
||||||
width: 8.0,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,33 +1,76 @@
|
|||||||
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:refilc/ui/widgets/grade/grade_tile.dart';
|
import 'package:refilc/ui/widgets/grade/grade_tile.dart';
|
||||||
import 'package:refilc_kreta_api/models/grade.dart';
|
import 'package:refilc_kreta_api/models/grade.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:refilc_mobile_ui/common/progress_bar.dart';
|
||||||
|
|
||||||
class GradesCountItem extends StatelessWidget {
|
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 count;
|
||||||
final int value;
|
final int value;
|
||||||
|
final double total;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
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(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
Text.rich(
|
GradeValueWidget(
|
||||||
TextSpan(children: [
|
GradeValue(value, "Value", "Value", 100),
|
||||||
TextSpan(
|
size: 18.0,
|
||||||
text: count.toString(),
|
fill: true,
|
||||||
style: const TextStyle(fontWeight: FontWeight.w600),
|
shadow: false,
|
||||||
),
|
),
|
||||||
const TextSpan(
|
const SizedBox(
|
||||||
text: "x",
|
width: 12.0,
|
||||||
style: TextStyle(fontSize: 13.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,
|
||||||
),
|
),
|
||||||
]),
|
|
||||||
style: const TextStyle(fontSize: 15.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",
|
"subjectavg": "Subject Average",
|
||||||
"classavg": "Class Average",
|
"classavg": "Class Average",
|
||||||
"fail_warning": "Failure warning",
|
"fail_warning": "Failure warning",
|
||||||
"fail_warning_description": "You are failing %d subjects!"
|
"fail_warning_description":
|
||||||
.one("You are failing a subject!"),
|
"You are failing %d subjects!".one("You are failing a subject!"),
|
||||||
"data": "Data",
|
"data": "Data",
|
||||||
"you_have_hw": "You have %s homework(s) to do",
|
"you_have_hw": "You have %s homework(s) to do",
|
||||||
|
"grades_cnt": "Grade count: %s",
|
||||||
},
|
},
|
||||||
"hu_hu": {
|
"hu_hu": {
|
||||||
"Grades": "Tantárgyak",
|
"Grades": "Tantárgyak",
|
||||||
@ -39,6 +40,7 @@ extension Localization on String {
|
|||||||
"fail_warning_description": "Bukásra állsz %d tantárgyból",
|
"fail_warning_description": "Bukásra állsz %d tantárgyból",
|
||||||
"data": "Adatok",
|
"data": "Adatok",
|
||||||
"you_have_hw": "%s házi feladat vár rád",
|
"you_have_hw": "%s házi feladat vár rád",
|
||||||
|
"grades_cnt": "Jegyek száma: %s",
|
||||||
},
|
},
|
||||||
"de_de": {
|
"de_de": {
|
||||||
"Grades": "Fächer",
|
"Grades": "Fächer",
|
||||||
@ -57,6 +59,7 @@ extension Localization on String {
|
|||||||
"fail_warning_description": "Sie werden in %d des Fachs durchfallen",
|
"fail_warning_description": "Sie werden in %d des Fachs durchfallen",
|
||||||
"data": "Daten",
|
"data": "Daten",
|
||||||
"you_have_hw": "Du hast %s Hausaufgaben",
|
"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())!
|
.transform(average - average.floor())!
|
||||||
: Theme.of(context).colorScheme.secondary;
|
: Theme.of(context).colorScheme.secondary;
|
||||||
|
|
||||||
|
// color magic happens here
|
||||||
List<Color> averageColors = getColors(data);
|
List<Color> averageColors = getColors(data);
|
||||||
|
|
||||||
subjectSpots = getSpots(data);
|
subjectSpots = getSpots(data);
|
||||||
|
|
||||||
// naplo/#73
|
// naplo/#73
|
||||||
|
Loading…
x
Reference in New Issue
Block a user