CONVERT KEY TO SUPER PARAMETER KYS
This commit is contained in:
@@ -39,8 +39,7 @@ import 'grades_page.i18n.dart';
|
||||
// import 'package:filcnaplo_premium/ui/mobile/goal_planner/new_goal.dart';
|
||||
|
||||
class GradeSubjectView extends StatefulWidget {
|
||||
const GradeSubjectView(this.subject, {Key? key, this.groupAverage = 0.0})
|
||||
: super(key: key);
|
||||
const GradeSubjectView(this.subject, {super.key, this.groupAverage = 0.0});
|
||||
|
||||
final GradeSubject subject;
|
||||
final double groupAverage;
|
||||
@@ -110,21 +109,21 @@ class _GradeSubjectViewState extends State<GradeSubjectView> {
|
||||
),
|
||||
));
|
||||
|
||||
List<Widget> _gradeTiles = [];
|
||||
List<Widget> gradeTiles = [];
|
||||
|
||||
if (!gradeCalcMode) {
|
||||
subjectGrades.sort((a, b) => -a.date.compareTo(b.date));
|
||||
for (var grade in subjectGrades) {
|
||||
if (grade.type == GradeType.midYear) {
|
||||
_gradeTiles.add(GradeViewable(grade));
|
||||
gradeTiles.add(GradeViewable(grade));
|
||||
} else {
|
||||
_gradeTiles.add(CertificationTile(grade, padding: EdgeInsets.zero));
|
||||
gradeTiles.add(CertificationTile(grade, padding: EdgeInsets.zero));
|
||||
}
|
||||
}
|
||||
} else if (subjectGrades.isNotEmpty) {
|
||||
subjectGrades.sort((a, b) => -a.date.compareTo(b.date));
|
||||
for (var grade in subjectGrades) {
|
||||
_gradeTiles.add(GradeTile(grade));
|
||||
gradeTiles.add(GradeTile(grade));
|
||||
}
|
||||
}
|
||||
tiles.add(
|
||||
@@ -138,18 +137,18 @@ class _GradeSubjectViewState extends State<GradeSubjectView> {
|
||||
animation: primaryAnimation,
|
||||
secondaryAnimation: secondaryAnimation,
|
||||
transitionType: SharedAxisTransitionType.vertical,
|
||||
child: child,
|
||||
fillColor: Colors.transparent,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: _gradeTiles.isNotEmpty
|
||||
child: gradeTiles.isNotEmpty
|
||||
? Panel(
|
||||
key: ValueKey(gradeCalcMode),
|
||||
title: Text(
|
||||
gradeCalcMode ? "Ghost Grades".i18n : "Grades".i18n,
|
||||
),
|
||||
child: Column(
|
||||
children: _gradeTiles,
|
||||
children: gradeTiles,
|
||||
))
|
||||
: const SizedBox(),
|
||||
),
|
||||
@@ -230,24 +229,22 @@ class _GradeSubjectViewState extends State<GradeSubjectView> {
|
||||
.where((e) => e.type == GradeType.midYear)
|
||||
.isNotEmpty,
|
||||
child: ExpandableFab(
|
||||
backgroundColor: Theme.of(context).colorScheme.secondary,
|
||||
overlayStyle: ExpandableFabOverlayStyle(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
type: ExpandableFabType.up,
|
||||
distance: 50,
|
||||
closeButtonStyle: ExpandableFabCloseButtonStyle(
|
||||
backgroundColor: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
children: [
|
||||
FloatingActionButton.small(
|
||||
heroTag: "btn_ghost_grades",
|
||||
child: const Icon(FeatherIcons.plus),
|
||||
backgroundColor: Theme.of(context).colorScheme.secondary,
|
||||
onPressed: () {
|
||||
gradeCalc(context);
|
||||
},
|
||||
child: const Icon(FeatherIcons.plus),
|
||||
),
|
||||
FloatingActionButton.small(
|
||||
heroTag: "btn_goal_planner",
|
||||
child: const Icon(FeatherIcons.flag, size: 20.0),
|
||||
backgroundColor: Theme.of(context).colorScheme.secondary,
|
||||
onPressed: () {
|
||||
if (!Provider.of<PremiumProvider>(context, listen: false)
|
||||
@@ -264,6 +261,7 @@ class _GradeSubjectViewState extends State<GradeSubjectView> {
|
||||
builder: (context) =>
|
||||
GoalPlannerScreen(subject: widget.subject)));
|
||||
},
|
||||
child: const Icon(FeatherIcons.flag, size: 20.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -348,7 +346,7 @@ class _GradeSubjectViewState extends State<GradeSubjectView> {
|
||||
|
||||
_sheetController = _scaffoldKey.currentState?.showBottomSheet(
|
||||
(context) => RoundedBottomSheet(
|
||||
child: GradeCalculator(widget.subject), borderRadius: 14.0),
|
||||
borderRadius: 14.0, child: GradeCalculator(widget.subject)),
|
||||
backgroundColor: const Color(0x00000000),
|
||||
elevation: 12.0,
|
||||
);
|
||||
|
||||
@@ -12,17 +12,18 @@ import 'package:provider/provider.dart';
|
||||
import 'graph.i18n.dart';
|
||||
|
||||
class GradeGraph extends StatefulWidget {
|
||||
const GradeGraph(this.data, {Key? key, this.dayThreshold = 7, this.classAvg}) : super(key: key);
|
||||
const GradeGraph(this.data,
|
||||
{super.key, this.dayThreshold = 7, this.classAvg});
|
||||
|
||||
final List<Grade> data;
|
||||
final int dayThreshold;
|
||||
final double? classAvg;
|
||||
|
||||
@override
|
||||
_GradeGraphState createState() => _GradeGraphState();
|
||||
GradeGraphState createState() => GradeGraphState();
|
||||
}
|
||||
|
||||
class _GradeGraphState extends State<GradeGraph> {
|
||||
class GradeGraphState extends State<GradeGraph> {
|
||||
late SettingsProvider settings;
|
||||
|
||||
List<FlSpot> getSpots(List<Grade> data) {
|
||||
@@ -34,7 +35,9 @@ class _GradeGraphState extends State<GradeGraph> {
|
||||
|
||||
// Sort data to points by treshold
|
||||
for (var element in data) {
|
||||
if (sortedData.last.isNotEmpty && sortedData.last.last.writeDate.difference(element.writeDate).inDays > widget.dayThreshold) {
|
||||
if (sortedData.last.isNotEmpty &&
|
||||
sortedData.last.last.writeDate.difference(element.writeDate).inDays >
|
||||
widget.dayThreshold) {
|
||||
sortedData.add([]);
|
||||
}
|
||||
for (var dataList in sortedData) {
|
||||
@@ -48,7 +51,9 @@ class _GradeGraphState extends State<GradeGraph> {
|
||||
|
||||
if (dataList.isNotEmpty) {
|
||||
subjectData.add(FlSpot(
|
||||
dataList[0].writeDate.month + (dataList[0].writeDate.day / 31) + ((dataList[0].writeDate.year - data.last.writeDate.year) * 12),
|
||||
dataList[0].writeDate.month +
|
||||
(dataList[0].writeDate.day / 31) +
|
||||
((dataList[0].writeDate.year - data.last.writeDate.year) * 12),
|
||||
double.parse(average.toStringAsFixed(2)),
|
||||
));
|
||||
}
|
||||
@@ -74,14 +79,19 @@ class _GradeGraphState extends State<GradeGraph> {
|
||||
.toList();
|
||||
|
||||
// Filter ghost data
|
||||
List<Grade> ghostData = widget.data.where((e) => e.value.weight != 0).where((e) => e.type == GradeType.ghost).toList();
|
||||
List<Grade> ghostData = widget.data
|
||||
.where((e) => e.value.weight != 0)
|
||||
.where((e) => e.type == GradeType.ghost)
|
||||
.toList();
|
||||
|
||||
// Calculate average
|
||||
double average = AverageHelper.averageEvals(data);
|
||||
|
||||
// Calculate graph color
|
||||
Color averageColor = average >= 1 && average <= 5
|
||||
? ColorTween(begin: settings.gradeColors[average.floor() - 1], end: settings.gradeColors[average.ceil() - 1])
|
||||
? ColorTween(
|
||||
begin: settings.gradeColors[average.floor() - 1],
|
||||
end: settings.gradeColors[average.ceil() - 1])
|
||||
.transform(average - average.floor())!
|
||||
: Theme.of(context).colorScheme.secondary;
|
||||
|
||||
@@ -92,17 +102,26 @@ class _GradeGraphState extends State<GradeGraph> {
|
||||
ghostSpots = getSpots(data + ghostData);
|
||||
|
||||
// hax
|
||||
ghostSpots = ghostSpots.where((e) => e.x >= subjectSpots.map((f) => f.x).reduce(max)).toList();
|
||||
ghostSpots = ghostSpots
|
||||
.where((e) => e.x >= subjectSpots.map((f) => f.x).reduce(max))
|
||||
.toList();
|
||||
ghostSpots = ghostSpots.map((e) => FlSpot(e.x + 0.1, e.y)).toList();
|
||||
ghostSpots.add(subjectSpots.firstWhere((e) => e.x >= subjectSpots.map((f) => f.x).reduce(max), orElse: () => const FlSpot(-1, -1)));
|
||||
ghostSpots.removeWhere((element) => element.x == -1 && element.y == -1); // naplo/#74
|
||||
ghostSpots.add(subjectSpots.firstWhere(
|
||||
(e) => e.x >= subjectSpots.map((f) => f.x).reduce(max),
|
||||
orElse: () => const FlSpot(-1, -1)));
|
||||
ghostSpots.removeWhere(
|
||||
(element) => element.x == -1 && element.y == -1); // naplo/#74
|
||||
}
|
||||
|
||||
Grade halfYearGrade = widget.data.lastWhere((e) => e.type == GradeType.halfYear, orElse: () => Grade.fromJson({}));
|
||||
Grade halfYearGrade = widget.data.lastWhere(
|
||||
(e) => e.type == GradeType.halfYear,
|
||||
orElse: () => Grade.fromJson({}));
|
||||
|
||||
if (halfYearGrade.date.year != 0 && data.isNotEmpty) {
|
||||
final maxX = ghostSpots.isNotEmpty ? ghostSpots.first.x : 0;
|
||||
final x = halfYearGrade.writeDate.month + (halfYearGrade.writeDate.day / 31) + ((halfYearGrade.writeDate.year - data.last.writeDate.year) * 12);
|
||||
final x = halfYearGrade.writeDate.month +
|
||||
(halfYearGrade.writeDate.day / 31) +
|
||||
((halfYearGrade.writeDate.year - data.last.writeDate.year) * 12);
|
||||
if (x <= maxX) {
|
||||
extraLinesV.add(
|
||||
VerticalLine(
|
||||
@@ -110,7 +129,7 @@ class _GradeGraphState extends State<GradeGraph> {
|
||||
strokeWidth: 3.0,
|
||||
color: AppColors.of(context).red.withOpacity(.75),
|
||||
label: VerticalLineLabel(
|
||||
labelResolver: (_) => " " + "mid".i18n + " ", // <- zwsp for padding
|
||||
labelResolver: (_) => " ${"mid".i18n} ", // <- zwsp for padding
|
||||
show: true,
|
||||
alignment: Alignment.topLeft,
|
||||
style: TextStyle(
|
||||
@@ -126,7 +145,9 @@ class _GradeGraphState extends State<GradeGraph> {
|
||||
}
|
||||
|
||||
// Horizontal line displaying the class average
|
||||
if (widget.classAvg != null && widget.classAvg! > 0.0 && settings.graphClassAvg) {
|
||||
if (widget.classAvg != null &&
|
||||
widget.classAvg! > 0.0 &&
|
||||
settings.graphClassAvg) {
|
||||
extraLinesH.add(HorizontalLine(
|
||||
y: widget.classAvg!,
|
||||
color: AppColors.of(context).text.withOpacity(.75),
|
||||
@@ -147,12 +168,15 @@ class _GradeGraphState extends State<GradeGraph> {
|
||||
)
|
||||
: ClipRect(
|
||||
child: SizedBox(
|
||||
height: 158,
|
||||
child: subjectSpots.length > 1
|
||||
? Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0, right: 8.0),
|
||||
child: LineChart(
|
||||
LineChartData(
|
||||
extraLinesData: ExtraLinesData(verticalLines: extraLinesV, horizontalLines: extraLinesH),
|
||||
extraLinesData: ExtraLinesData(
|
||||
verticalLines: extraLinesV,
|
||||
horizontalLines: extraLinesH),
|
||||
lineBarsData: [
|
||||
LineChartBarData(
|
||||
preventCurveOverShooting: true,
|
||||
@@ -230,7 +254,8 @@ class _GradeGraphState extends State<GradeGraph> {
|
||||
strokeWidth: 3.5,
|
||||
),
|
||||
FlDotData(
|
||||
getDotPainter: (a, b, c, d) => FlDotCirclePainter(
|
||||
getDotPainter: (a, b, c, d) =>
|
||||
FlDotCirclePainter(
|
||||
strokeWidth: 0,
|
||||
color: Colors.grey.shade900,
|
||||
radius: 10.0,
|
||||
@@ -252,25 +277,45 @@ class _GradeGraphState extends State<GradeGraph> {
|
||||
showTitles: true,
|
||||
reservedSize: 24,
|
||||
getTextStyles: (context, value) => TextStyle(
|
||||
color: AppColors.of(context).text.withOpacity(.75),
|
||||
color:
|
||||
AppColors.of(context).text.withOpacity(.75),
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14.0,
|
||||
),
|
||||
margin: 12.0,
|
||||
getTitles: (value) {
|
||||
var format = DateFormat("MMM", I18n.of(context).locale.toString());
|
||||
var format = DateFormat(
|
||||
"MMM", I18n.of(context).locale.toString());
|
||||
|
||||
String title = format.format(DateTime(0, value.floor() % 12)).replaceAll(".", "");
|
||||
title = title.substring(0, min(title.length, 4));
|
||||
String title = format
|
||||
.format(DateTime(0, value.floor() % 12))
|
||||
.replaceAll(".", "");
|
||||
title =
|
||||
title.substring(0, min(title.length, 4));
|
||||
|
||||
return title.toUpperCase();
|
||||
},
|
||||
interval: () {
|
||||
List<Grade> tData = ghostData.isNotEmpty ? ghostData : data;
|
||||
tData.sort((a, b) => a.writeDate.compareTo(b.writeDate));
|
||||
return tData.first.writeDate.add(const Duration(days: 120)).isBefore(tData.last.writeDate) ? 2.0 : 1.0;
|
||||
List<Grade> tData =
|
||||
ghostData.isNotEmpty ? ghostData : data;
|
||||
tData.sort((a, b) =>
|
||||
a.writeDate.compareTo(b.writeDate));
|
||||
return tData.first.writeDate
|
||||
.add(const Duration(days: 120))
|
||||
.isBefore(tData.last.writeDate)
|
||||
? 2.0
|
||||
: 1.0;
|
||||
}(),
|
||||
checkToShowTitle: (double minValue, double maxValue, SideTitles sideTitles, double appliedInterval, double value) { if (value == maxValue || value == minValue) return false; return true; },
|
||||
checkToShowTitle: (double minValue,
|
||||
double maxValue,
|
||||
SideTitles sideTitles,
|
||||
double appliedInterval,
|
||||
double value) {
|
||||
if (value == maxValue || value == minValue) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
),
|
||||
leftTitles: SideTitles(
|
||||
showTitles: true,
|
||||
@@ -289,7 +334,6 @@ class _GradeGraphState extends State<GradeGraph> {
|
||||
),
|
||||
)
|
||||
: null,
|
||||
height: 158,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user