forked from firka/student-legacy
basically finished goal planner
This commit is contained in:
parent
1d6b9dd5d8
commit
8f85116353
@ -226,7 +226,7 @@ class _GoalPlannerScreenState extends State<GoalPlannerScreen> {
|
|||||||
if (groupAverage != 0)
|
if (groupAverage != 0)
|
||||||
AverageDisplay(average: groupAverage, border: true),
|
AverageDisplay(average: groupAverage, border: true),
|
||||||
const SizedBox(width: 6.0),
|
const SizedBox(width: 6.0),
|
||||||
AverageDisplay(average: avg)
|
AverageDisplay(average: avg),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -6,16 +6,19 @@ import 'package:filcnaplo/models/settings.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/common/average_display.dart';
|
||||||
import 'package:filcnaplo_mobile_ui/common/panel/panel.dart';
|
import 'package:filcnaplo_mobile_ui/common/panel/panel.dart';
|
||||||
import 'package:filcnaplo_mobile_ui/common/progress_bar.dart';
|
import 'package:filcnaplo_mobile_ui/common/progress_bar.dart';
|
||||||
import 'package:filcnaplo_mobile_ui/common/round_border_icon.dart';
|
import 'package:filcnaplo_mobile_ui/common/round_border_icon.dart';
|
||||||
import 'package:filcnaplo_premium/ui/mobile/goal_planner/goal_planner.dart';
|
import 'package:filcnaplo_premium/ui/mobile/goal_planner/goal_planner.dart';
|
||||||
import 'package:filcnaplo_premium/ui/mobile/goal_planner/goal_state_screen.i18n.dart';
|
import 'package:filcnaplo_premium/ui/mobile/goal_planner/goal_state_screen.i18n.dart';
|
||||||
import 'package:filcnaplo_premium/ui/mobile/goal_planner/route_option.dart';
|
import 'package:filcnaplo_premium/ui/mobile/goal_planner/route_option.dart';
|
||||||
|
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 'goal_planner_screen.dart';
|
||||||
import 'graph.dart';
|
import 'graph.dart';
|
||||||
|
|
||||||
class GoalStateScreen extends StatefulWidget {
|
class GoalStateScreen extends StatefulWidget {
|
||||||
@ -36,6 +39,7 @@ class _GoalStateScreenState extends State<GoalStateScreen> {
|
|||||||
double currAvg = 0.0;
|
double currAvg = 0.0;
|
||||||
double goalAvg = 0.0;
|
double goalAvg = 0.0;
|
||||||
double beforeAvg = 0.0;
|
double beforeAvg = 0.0;
|
||||||
|
double afterAvg = 0.0;
|
||||||
double avgDifference = 0;
|
double avgDifference = 0;
|
||||||
|
|
||||||
Plan? plan;
|
Plan? plan;
|
||||||
@ -73,7 +77,10 @@ class _GoalStateScreenState extends State<GoalStateScreen> {
|
|||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Grade> getSubjectGrades(Subject subject) => gradeProvider.grades
|
List<Grade> getSubjectGrades(Subject subject) =>
|
||||||
|
gradeProvider.grades.where((e) => (e.subject == subject)).toList();
|
||||||
|
|
||||||
|
List<Grade> getAfterGoalGrades(Subject subject) => gradeProvider.grades
|
||||||
.where((e) => (e.subject == subject && e.date.isAfter(goalPinDate)))
|
.where((e) => (e.subject == subject && e.date.isAfter(goalPinDate)))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
@ -94,9 +101,12 @@ class _GoalStateScreenState extends State<GoalStateScreen> {
|
|||||||
gradeProvider = Provider.of<GradeProvider>(context);
|
gradeProvider = Provider.of<GradeProvider>(context);
|
||||||
settingsProvider = Provider.of<SettingsProvider>(context);
|
settingsProvider = Provider.of<SettingsProvider>(context);
|
||||||
|
|
||||||
List<Grade> subjectGrades = getSubjectGrades(widget.subject).toList();
|
var subjectGrades = getSubjectGrades(widget.subject).toList();
|
||||||
currAvg = AverageHelper.averageEvals(subjectGrades);
|
currAvg = AverageHelper.averageEvals(subjectGrades);
|
||||||
|
|
||||||
|
var afterGoalGrades = getAfterGoalGrades(widget.subject).toList();
|
||||||
|
afterAvg = AverageHelper.averageEvals(afterGoalGrades);
|
||||||
|
|
||||||
Color averageColor = currAvg >= 1 && currAvg <= 5
|
Color averageColor = currAvg >= 1 && currAvg <= 5
|
||||||
? ColorTween(
|
? ColorTween(
|
||||||
begin: settingsProvider.gradeColors[currAvg.floor() - 1],
|
begin: settingsProvider.gradeColors[currAvg.floor() - 1],
|
||||||
@ -115,8 +125,8 @@ class _GoalStateScreenState extends State<GoalStateScreen> {
|
|||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.only(top: 16.0, right: 12.0),
|
padding: const EdgeInsets.only(top: 16.0, right: 12.0),
|
||||||
child:
|
child: GoalGraph(afterGoalGrades,
|
||||||
GoalGraph(subjectGrades, dayThreshold: 5, classAvg: goalAvg),
|
dayThreshold: 5, classAvg: goalAvg),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 5.0),
|
const SizedBox(height: 5.0),
|
||||||
Padding(
|
Padding(
|
||||||
@ -249,6 +259,8 @@ class _GoalStateScreenState extends State<GoalStateScreen> {
|
|||||||
fontSize: 20.0,
|
fontSize: 20.0,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(width: 5.0),
|
||||||
|
AverageDisplay(average: beforeAvg),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
@ -260,6 +272,10 @@ class _GoalStateScreenState extends State<GoalStateScreen> {
|
|||||||
fontSize: 20.0,
|
fontSize: 20.0,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(width: 5.0),
|
||||||
|
AverageDisplay(average: currAvg),
|
||||||
|
const SizedBox(width: 5.0),
|
||||||
|
// ide majd kell average difference
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -284,7 +300,13 @@ class _GoalStateScreenState extends State<GoalStateScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
RawMaterialButton(
|
RawMaterialButton(
|
||||||
onPressed: () async {},
|
onPressed: () async {
|
||||||
|
Navigator.of(context).push(
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (context) =>
|
||||||
|
GoalPlannerScreen(
|
||||||
|
subject: widget.subject)));
|
||||||
|
},
|
||||||
fillColor: Colors.black,
|
fillColor: Colors.black,
|
||||||
shape: const StadiumBorder(),
|
shape: const StadiumBorder(),
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
@ -321,7 +343,10 @@ class _GoalStateScreenState extends State<GoalStateScreen> {
|
|||||||
),
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(45.0),
|
borderRadius: BorderRadius.circular(45.0),
|
||||||
color: Colors.greenAccent.shade700
|
color: avgDifference.isNegative
|
||||||
|
? Colors.redAccent.shade400
|
||||||
|
.withOpacity(.15)
|
||||||
|
: Colors.greenAccent.shade700
|
||||||
.withOpacity(.15),
|
.withOpacity(.15),
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
@ -329,8 +354,12 @@ class _GoalStateScreenState extends State<GoalStateScreen> {
|
|||||||
CrossAxisAlignment.center,
|
CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
FeatherIcons.chevronUp,
|
avgDifference.isNegative
|
||||||
color: Colors.greenAccent.shade700,
|
? FeatherIcons.chevronDown
|
||||||
|
: FeatherIcons.chevronUp,
|
||||||
|
color: avgDifference.isNegative
|
||||||
|
? Colors.redAccent.shade400
|
||||||
|
: Colors.greenAccent.shade700,
|
||||||
size: 18.0,
|
size: 18.0,
|
||||||
),
|
),
|
||||||
const SizedBox(width: 5.0),
|
const SizedBox(width: 5.0),
|
||||||
@ -339,7 +368,9 @@ class _GoalStateScreenState extends State<GoalStateScreen> {
|
|||||||
'%',
|
'%',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.greenAccent.shade700,
|
color: avgDifference.isNegative
|
||||||
|
? Colors.redAccent.shade400
|
||||||
|
: Colors.greenAccent.shade700,
|
||||||
fontSize: 22.0,
|
fontSize: 22.0,
|
||||||
height: 0.8,
|
height: 0.8,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user