From 3e470981a8d9580e147e6f4db00992877e80cd21 Mon Sep 17 00:00:00 2001 From: Kima Date: Mon, 28 Aug 2023 00:36:24 +0200 Subject: [PATCH] made goal planner even better --- .../ui/mobile/goal_planner/route_option.dart | 6 +- .../lib/ui/mobile/goal_planner/test.dart | 152 ++++++++++++------ 2 files changed, 105 insertions(+), 53 deletions(-) diff --git a/filcnaplo_premium/lib/ui/mobile/goal_planner/route_option.dart b/filcnaplo_premium/lib/ui/mobile/goal_planner/route_option.dart index 8c7f9ca..3d02d26 100644 --- a/filcnaplo_premium/lib/ui/mobile/goal_planner/route_option.dart +++ b/filcnaplo_premium/lib/ui/mobile/goal_planner/route_option.dart @@ -1,3 +1,4 @@ +import 'package:filcnaplo/theme/colors/colors.dart'; import 'package:filcnaplo_premium/ui/mobile/goal_planner/goal_planner.dart'; import 'package:filcnaplo_premium/ui/mobile/goal_planner/goal_planner_screen.i18n.dart'; import 'package:filcnaplo_premium/ui/mobile/goal_planner/grade_display.dart'; @@ -57,7 +58,7 @@ class RouteOption extends StatelessWidget { style: TextStyle( fontSize: 22.0, fontWeight: FontWeight.w500, - color: Colors.black.withOpacity(.7), + color: AppColors.of(context).text.withOpacity(.7), ), ), const SizedBox(width: 4.0), @@ -74,7 +75,8 @@ class RouteOption extends StatelessWidget { height: 36.0, width: 32.0, child: Center( - child: Icon(Icons.add, color: Colors.black.withOpacity(.5))), + child: Icon(Icons.add, + color: AppColors.of(context).text.withOpacity(.5))), )); } } diff --git a/filcnaplo_premium/lib/ui/mobile/goal_planner/test.dart b/filcnaplo_premium/lib/ui/mobile/goal_planner/test.dart index 7327b9e..401f6a5 100644 --- a/filcnaplo_premium/lib/ui/mobile/goal_planner/test.dart +++ b/filcnaplo_premium/lib/ui/mobile/goal_planner/test.dart @@ -1,8 +1,12 @@ +import 'package:filcnaplo/helpers/average_helper.dart'; import 'package:filcnaplo/helpers/subject.dart'; import 'package:filcnaplo/models/settings.dart'; import 'package:filcnaplo_kreta_api/models/grade.dart'; +import 'package:filcnaplo_kreta_api/models/group_average.dart'; import 'package:filcnaplo_kreta_api/models/subject.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/round_border_icon.dart'; import 'package:filcnaplo_mobile_ui/pages/grades/calculator/grade_calculator_provider.dart'; import 'package:filcnaplo_premium/ui/mobile/goal_planner/goal_input.dart'; import 'package:filcnaplo_premium/ui/mobile/goal_planner/goal_planner.dart'; @@ -10,7 +14,6 @@ import 'package:filcnaplo_premium/ui/mobile/goal_planner/goal_planner_screen.i18 import 'package:filcnaplo_premium/ui/mobile/goal_planner/route_option.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:filcnaplo_mobile_ui/common/beta_chip.dart'; enum PlanResult { available, // There are possible solutions @@ -117,31 +120,78 @@ class _GoalPlannerTestState extends State { final result = getResult(); + List subjectGrades = getSubjectGrades(widget.subject); + + double avg = AverageHelper.averageEvals(subjectGrades); + + var nullavg = GroupAverage(average: 0.0, subject: widget.subject, uid: "0"); + double groupAverage = gradeProvider.groupAverages + .firstWhere((e) => e.subject == widget.subject, orElse: () => nullavg) + .average; + return Scaffold( body: SafeArea( child: ListView( padding: const EdgeInsets.only( left: 22.0, right: 22.0, top: 5.0, bottom: 220.0), children: [ + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // const BackButton(), + // Padding( + // padding: const EdgeInsets.only(right: 15.0), + // child: Row( + // children: [ + // Text( + // 'goal_planner_title'.i18n, + // style: const TextStyle( + // fontWeight: FontWeight.w500, fontSize: 18.0), + // ), + // const SizedBox( + // width: 5, + // ), + // const BetaChip(), + // ], + // ), + // ), + // ], + // ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, children: [ - const BackButton(), - Padding( - padding: const EdgeInsets.only(right: 15.0), - child: Row( - children: [ - Text( - 'goal_planner_title'.i18n, - style: const TextStyle( - fontWeight: FontWeight.w500, fontSize: 18.0), + Row( + children: [ + const BackButton(), + RoundBorderIcon( + icon: Icon( + SubjectIcon.resolveVariant( + context: context, + subject: widget.subject, + ), + size: 10, ), - const SizedBox( - width: 5, + ), + Text( + (widget.subject.isRenamed + ? widget.subject.renamedTo + : widget.subject.name) ?? + 'goal_planner_title'.i18n, + style: const TextStyle( + fontSize: 17.0, + fontWeight: FontWeight.w500, ), - const BetaChip(), - ], - ), + ), + ], + ), + Row( + children: [ + if (groupAverage != 0) + AverageDisplay(average: groupAverage, border: true), + const SizedBox(width: 6.0), + AverageDisplay(average: avg) + ], ), ], ), @@ -151,7 +201,7 @@ class _GoalPlannerTestState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Column( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.start, children: [ Text( "set_a_goal".i18n, @@ -171,40 +221,40 @@ class _GoalPlannerTestState extends State { ), ], ), - Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "select_subject".i18n, - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20.0, - ), - ), - const SizedBox(height: 4.0), - Column( - children: [ - Icon( - SubjectIcon.resolveVariant( - context: context, - subject: widget.subject, - ), - size: 48.0, - ), - Text( - (widget.subject.isRenamed - ? widget.subject.renamedTo - : widget.subject.name) ?? - '', - style: const TextStyle( - fontSize: 17.0, - fontWeight: FontWeight.w500, - ), - ) - ], - ) - ], - ) + // Column( + // mainAxisAlignment: MainAxisAlignment.center, + // children: [ + // Text( + // "select_subject".i18n, + // style: const TextStyle( + // fontWeight: FontWeight.bold, + // fontSize: 20.0, + // ), + // ), + // const SizedBox(height: 4.0), + // Column( + // children: [ + // Icon( + // SubjectIcon.resolveVariant( + // context: context, + // subject: widget.subject, + // ), + // size: 48.0, + // ), + // Text( + // (widget.subject.isRenamed + // ? widget.subject.renamedTo + // : widget.subject.name) ?? + // '', + // style: const TextStyle( + // fontSize: 17.0, + // fontWeight: FontWeight.w500, + // ), + // ) + // ], + // ) + // ], + // ) ], ), const SizedBox(height: 24.0), @@ -254,7 +304,7 @@ class _GoalPlannerTestState extends State { child: Container( padding: const EdgeInsets.only(top: 24.0), decoration: BoxDecoration( - color: Colors.white, + color: Theme.of(context).colorScheme.background, borderRadius: const BorderRadius.vertical(top: Radius.circular(24.0)), boxShadow: [