forked from firka/student-legacy
setted goal plans can be saved now
This commit is contained in:
parent
3e470981a8
commit
0ac0586fba
@ -46,6 +46,8 @@ const userDataDB = DatabaseStruct("user_data", {
|
|||||||
"renamed_teachers": String,
|
"renamed_teachers": String,
|
||||||
// "subject_lesson_count": String, // non kreta data
|
// "subject_lesson_count": String, // non kreta data
|
||||||
"last_seen_grade": int,
|
"last_seen_grade": int,
|
||||||
|
// goal plans // non kreta data
|
||||||
|
"goal_plans": String,
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<void> createTable(Database db, DatabaseStruct struct) =>
|
Future<void> createTable(Database db, DatabaseStruct struct) =>
|
||||||
@ -97,6 +99,8 @@ Future<Database> initDB(DatabaseProvider database) async {
|
|||||||
"renamed_teachers": "{}",
|
"renamed_teachers": "{}",
|
||||||
// "subject_lesson_count": "{}", // non kreta data
|
// "subject_lesson_count": "{}", // non kreta data
|
||||||
"last_seen_grade": 0,
|
"last_seen_grade": 0,
|
||||||
|
// goal plans // non kreta data
|
||||||
|
"goal_plans": "{}",
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
print("ERROR: migrateDB: $error");
|
print("ERROR: migrateDB: $error");
|
||||||
|
@ -213,4 +213,15 @@ class UserDatabaseQuery {
|
|||||||
return (jsonDecode(renamedTeachersJson) as Map)
|
return (jsonDecode(renamedTeachersJson) as Map)
|
||||||
.map((key, value) => MapEntry(key.toString(), value.toString()));
|
.map((key, value) => MapEntry(key.toString(), value.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Map<String, String>> subjectGoalPlans({required String userId}) async {
|
||||||
|
List<Map> userData =
|
||||||
|
await db.query("user_data", where: "id = ?", whereArgs: [userId]);
|
||||||
|
if (userData.isEmpty) return {};
|
||||||
|
String? goalPlansJson =
|
||||||
|
userData.elementAt(0)["goal_plans"] as String?;
|
||||||
|
if (goalPlansJson == null) return {};
|
||||||
|
return (jsonDecode(goalPlansJson) as Map)
|
||||||
|
.map((key, value) => MapEntry(key.toString(), value.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,4 +140,11 @@ class UserDatabaseStore {
|
|||||||
await db.update("user_data", {"renamed_teachers": renamedTeachersJson},
|
await db.update("user_data", {"renamed_teachers": renamedTeachersJson},
|
||||||
where: "id = ?", whereArgs: [userId]);
|
where: "id = ?", whereArgs: [userId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> storeSubjectGoalPlans(Map<String, String> plans,
|
||||||
|
{required String userId}) async {
|
||||||
|
String goalPlansJson = jsonEncode(plans);
|
||||||
|
await db.update("user_data", {"goal_plans": goalPlansJson},
|
||||||
|
where: "id = ?", whereArgs: [userId]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ class RoundBorderIcon extends StatelessWidget {
|
|||||||
const RoundBorderIcon(
|
const RoundBorderIcon(
|
||||||
{Key? key,
|
{Key? key,
|
||||||
this.color = Colors.black,
|
this.color = Colors.black,
|
||||||
this.width = 16.0,
|
this.width = 1.5,
|
||||||
required this.icon})
|
required this.icon})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ class RoundBorderIcon extends StatelessWidget {
|
|||||||
borderRadius: BorderRadius.circular(50.0),
|
borderRadius: BorderRadius.circular(50.0),
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.zero,
|
padding: const EdgeInsets.all(5.0),
|
||||||
child: icon,
|
child: icon,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:animations/animations.dart';
|
import 'package:animations/animations.dart';
|
||||||
|
import 'package:filcnaplo/api/providers/database_provider.dart';
|
||||||
|
import 'package:filcnaplo/api/providers/user_provider.dart';
|
||||||
import 'package:filcnaplo/models/settings.dart';
|
import 'package:filcnaplo/models/settings.dart';
|
||||||
import 'package:filcnaplo/utils/format.dart';
|
import 'package:filcnaplo/utils/format.dart';
|
||||||
import 'package:filcnaplo_kreta_api/providers/grade_provider.dart';
|
import 'package:filcnaplo_kreta_api/providers/grade_provider.dart';
|
||||||
@ -21,7 +23,7 @@ import 'package:filcnaplo_mobile_ui/pages/grades/calculator/grade_calculator_pro
|
|||||||
import 'package:filcnaplo_mobile_ui/pages/grades/grades_count.dart';
|
import 'package:filcnaplo_mobile_ui/pages/grades/grades_count.dart';
|
||||||
import 'package:filcnaplo_mobile_ui/pages/grades/graph.dart';
|
import 'package:filcnaplo_mobile_ui/pages/grades/graph.dart';
|
||||||
import 'package:filcnaplo_mobile_ui/pages/grades/subject_grades_container.dart';
|
import 'package:filcnaplo_mobile_ui/pages/grades/subject_grades_container.dart';
|
||||||
import 'package:filcnaplo_premium/ui/mobile/goal_planner/test.dart';
|
import 'package:filcnaplo_premium/ui/mobile/goal_planner/goal_planner_screen.dart';
|
||||||
import 'package:filcnaplo_premium/models/premium_scopes.dart';
|
import 'package:filcnaplo_premium/models/premium_scopes.dart';
|
||||||
import 'package:filcnaplo_premium/providers/premium_provider.dart';
|
import 'package:filcnaplo_premium/providers/premium_provider.dart';
|
||||||
import 'package:filcnaplo_premium/ui/mobile/premium/upsell.dart';
|
import 'package:filcnaplo_premium/ui/mobile/premium/upsell.dart';
|
||||||
@ -62,12 +64,16 @@ class _GradeSubjectViewState extends State<GradeSubjectView> {
|
|||||||
late GradeProvider gradeProvider;
|
late GradeProvider gradeProvider;
|
||||||
late GradeCalculatorProvider calculatorProvider;
|
late GradeCalculatorProvider calculatorProvider;
|
||||||
late SettingsProvider settingsProvider;
|
late SettingsProvider settingsProvider;
|
||||||
|
late DatabaseProvider dbProvider;
|
||||||
|
late UserProvider user;
|
||||||
|
|
||||||
late double average;
|
late double average;
|
||||||
late Widget gradeGraph;
|
late Widget gradeGraph;
|
||||||
|
|
||||||
bool gradeCalcMode = false;
|
bool gradeCalcMode = false;
|
||||||
|
|
||||||
|
String plan = '';
|
||||||
|
|
||||||
List<Grade> getSubjectGrades(Subject subject) => !gradeCalcMode
|
List<Grade> getSubjectGrades(Subject subject) => !gradeCalcMode
|
||||||
? gradeProvider.grades.where((e) => e.subject == subject).toList()
|
? gradeProvider.grades.where((e) => e.subject == subject).toList()
|
||||||
: calculatorProvider.grades.where((e) => e.subject == subject).toList();
|
: calculatorProvider.grades.where((e) => e.subject == subject).toList();
|
||||||
@ -151,6 +157,20 @@ class _GradeSubjectViewState extends State<GradeSubjectView> {
|
|||||||
gradeTiles = List.castFrom(tiles);
|
gradeTiles = List.castFrom(tiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
user = Provider.of<UserProvider>(context, listen: false);
|
||||||
|
dbProvider = Provider.of<DatabaseProvider>(context, listen: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fetchGoalPlans() async {
|
||||||
|
plan = (await dbProvider.userQuery
|
||||||
|
.subjectGoalPlans(userId: user.id!))[widget.subject.id] ??
|
||||||
|
'';
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
gradeProvider = Provider.of<GradeProvider>(context);
|
gradeProvider = Provider.of<GradeProvider>(context);
|
||||||
@ -196,6 +216,8 @@ class _GradeSubjectViewState extends State<GradeSubjectView> {
|
|||||||
buildTiles(ghostGrades);
|
buildTiles(ghostGrades);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fetchGoalPlans();
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
key: _scaffoldKey,
|
key: _scaffoldKey,
|
||||||
floatingActionButtonLocation: ExpandableFab.location,
|
floatingActionButtonLocation: ExpandableFab.location,
|
||||||
@ -213,6 +235,7 @@ class _GradeSubjectViewState extends State<GradeSubjectView> {
|
|||||||
),
|
),
|
||||||
children: [
|
children: [
|
||||||
FloatingActionButton.small(
|
FloatingActionButton.small(
|
||||||
|
heroTag: "btn_ghost_grades",
|
||||||
child: const Icon(FeatherIcons.plus),
|
child: const Icon(FeatherIcons.plus),
|
||||||
backgroundColor: Theme.of(context).colorScheme.secondary,
|
backgroundColor: Theme.of(context).colorScheme.secondary,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@ -220,6 +243,7 @@ class _GradeSubjectViewState extends State<GradeSubjectView> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
FloatingActionButton.small(
|
FloatingActionButton.small(
|
||||||
|
heroTag: "btn_goal_planner",
|
||||||
child: const Icon(FeatherIcons.flag, size: 20.0),
|
child: const Icon(FeatherIcons.flag, size: 20.0),
|
||||||
backgroundColor: Theme.of(context).colorScheme.secondary,
|
backgroundColor: Theme.of(context).colorScheme.secondary,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@ -235,7 +259,7 @@ class _GradeSubjectViewState extends State<GradeSubjectView> {
|
|||||||
|
|
||||||
Navigator.of(context).push(CupertinoPageRoute(
|
Navigator.of(context).push(CupertinoPageRoute(
|
||||||
builder: (context) =>
|
builder: (context) =>
|
||||||
GoalPlannerTest(subject: widget.subject)));
|
GoalPlannerScreen(subject: widget.subject)));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -261,6 +285,35 @@ class _GradeSubjectViewState extends State<GradeSubjectView> {
|
|||||||
const SizedBox(width: 6.0),
|
const SizedBox(width: 6.0),
|
||||||
if (average != 0)
|
if (average != 0)
|
||||||
Center(child: AverageDisplay(average: average)),
|
Center(child: AverageDisplay(average: average)),
|
||||||
|
const SizedBox(width: 6.0),
|
||||||
|
if (plan != '')
|
||||||
|
Center(
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).push(CupertinoPageRoute(
|
||||||
|
builder: (context) =>
|
||||||
|
GoalPlannerScreen(subject: widget.subject)));
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
width: 54.0,
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 5.0, vertical: 8.0),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(45.0),
|
||||||
|
color: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.primary
|
||||||
|
.withOpacity(.15),
|
||||||
|
),
|
||||||
|
child: Icon(
|
||||||
|
FeatherIcons.flag,
|
||||||
|
size: 17.0,
|
||||||
|
weight: 2.5,
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
const SizedBox(width: 12.0),
|
const SizedBox(width: 12.0),
|
||||||
],
|
],
|
||||||
icon: SubjectIcon.resolveVariant(
|
icon: SubjectIcon.resolveVariant(
|
||||||
|
@ -138,6 +138,14 @@ class Plan {
|
|||||||
|
|
||||||
Plan(this.plan);
|
Plan(this.plan);
|
||||||
|
|
||||||
|
String get dbString {
|
||||||
|
var finalString = '';
|
||||||
|
for (var i in plan) {
|
||||||
|
finalString += "$i,";
|
||||||
|
}
|
||||||
|
return finalString;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(other) => other is Plan && listEquals(plan, other.plan);
|
bool operator ==(other) => other is Plan && listEquals(plan, other.plan);
|
||||||
|
|
||||||
|
@ -1,360 +1,380 @@
|
|||||||
import 'package:filcnaplo/helpers/average_helper.dart';
|
import 'package:filcnaplo/api/providers/database_provider.dart';
|
||||||
import 'package:filcnaplo/helpers/subject.dart';
|
import 'package:filcnaplo/api/providers/user_provider.dart';
|
||||||
import 'package:filcnaplo/models/settings.dart';
|
import 'package:filcnaplo/helpers/average_helper.dart';
|
||||||
import 'package:filcnaplo_kreta_api/models/grade.dart';
|
import 'package:filcnaplo/helpers/subject.dart';
|
||||||
import 'package:filcnaplo_kreta_api/models/group_average.dart';
|
import 'package:filcnaplo/models/settings.dart';
|
||||||
import 'package:filcnaplo_kreta_api/models/subject.dart';
|
import 'package:filcnaplo_kreta_api/models/grade.dart';
|
||||||
import 'package:filcnaplo_kreta_api/providers/grade_provider.dart';
|
import 'package:filcnaplo_kreta_api/models/group_average.dart';
|
||||||
import 'package:filcnaplo_mobile_ui/common/average_display.dart';
|
import 'package:filcnaplo_kreta_api/models/subject.dart';
|
||||||
import 'package:filcnaplo_mobile_ui/common/round_border_icon.dart';
|
import 'package:filcnaplo_kreta_api/providers/grade_provider.dart';
|
||||||
import 'package:filcnaplo_mobile_ui/pages/grades/calculator/grade_calculator_provider.dart';
|
import 'package:filcnaplo_mobile_ui/common/average_display.dart';
|
||||||
import 'package:filcnaplo_premium/ui/mobile/goal_planner/goal_input.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_mobile_ui/pages/grades/calculator/grade_calculator_provider.dart';
|
||||||
import 'package:filcnaplo_premium/ui/mobile/goal_planner/goal_planner_screen.i18n.dart';
|
import 'package:filcnaplo_premium/ui/mobile/goal_planner/goal_input.dart';
|
||||||
import 'package:filcnaplo_premium/ui/mobile/goal_planner/route_option.dart';
|
import 'package:filcnaplo_premium/ui/mobile/goal_planner/goal_planner.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:filcnaplo_premium/ui/mobile/goal_planner/goal_planner_screen.i18n.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:filcnaplo_premium/ui/mobile/goal_planner/route_option.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
enum PlanResult {
|
import 'package:provider/provider.dart';
|
||||||
available, // There are possible solutions
|
|
||||||
unreachable, // The solutions are too hard don't even try
|
enum PlanResult {
|
||||||
unsolvable, // There are no solutions
|
available, // There are possible solutions
|
||||||
reached, // Goal already reached
|
unreachable, // The solutions are too hard don't even try
|
||||||
}
|
unsolvable, // There are no solutions
|
||||||
|
reached, // Goal already reached
|
||||||
class GoalPlannerTest extends StatefulWidget {
|
}
|
||||||
final Subject subject;
|
|
||||||
|
class GoalPlannerScreen extends StatefulWidget {
|
||||||
const GoalPlannerTest({Key? key, required this.subject}) : super(key: key);
|
final Subject subject;
|
||||||
|
|
||||||
@override
|
const GoalPlannerScreen({Key? key, required this.subject}) : super(key: key);
|
||||||
State<GoalPlannerTest> createState() => _GoalPlannerTestState();
|
|
||||||
}
|
@override
|
||||||
|
State<GoalPlannerScreen> createState() => _GoalPlannerScreenState();
|
||||||
class _GoalPlannerTestState extends State<GoalPlannerTest> {
|
}
|
||||||
late GradeProvider gradeProvider;
|
|
||||||
late GradeCalculatorProvider calculatorProvider;
|
class _GoalPlannerScreenState extends State<GoalPlannerScreen> {
|
||||||
late SettingsProvider settingsProvider;
|
late GradeProvider gradeProvider;
|
||||||
|
late GradeCalculatorProvider calculatorProvider;
|
||||||
bool gradeCalcMode = false;
|
late SettingsProvider settingsProvider;
|
||||||
|
late DatabaseProvider dbProvider;
|
||||||
List<Grade> getSubjectGrades(Subject subject) => !gradeCalcMode
|
late UserProvider user;
|
||||||
? gradeProvider.grades.where((e) => e.subject == subject).toList()
|
|
||||||
: calculatorProvider.grades.where((e) => e.subject == subject).toList();
|
bool gradeCalcMode = false;
|
||||||
|
|
||||||
double goalValue = 4.0;
|
List<Grade> getSubjectGrades(Subject subject) => !gradeCalcMode
|
||||||
List<Grade> grades = [];
|
? gradeProvider.grades.where((e) => e.subject == subject).toList()
|
||||||
|
: calculatorProvider.grades.where((e) => e.subject == subject).toList();
|
||||||
Plan? recommended;
|
|
||||||
Plan? fastest;
|
double goalValue = 4.0;
|
||||||
Plan? selectedRoute;
|
List<Grade> grades = [];
|
||||||
List<Plan> otherPlans = [];
|
|
||||||
|
Plan? recommended;
|
||||||
PlanResult getResult() {
|
Plan? fastest;
|
||||||
final currentAvg = GoalPlannerHelper.averageEvals(grades);
|
Plan? selectedRoute;
|
||||||
|
List<Plan> otherPlans = [];
|
||||||
recommended = null;
|
|
||||||
fastest = null;
|
@override
|
||||||
otherPlans = [];
|
void initState() {
|
||||||
|
super.initState();
|
||||||
if (currentAvg >= goalValue) return PlanResult.reached;
|
user = Provider.of<UserProvider>(context, listen: false);
|
||||||
|
dbProvider = Provider.of<DatabaseProvider>(context, listen: false);
|
||||||
final planner = GoalPlanner(goalValue, grades);
|
}
|
||||||
final plans = planner.solve();
|
|
||||||
|
Future<Map<String, String>> fetchGoalPlans() async {
|
||||||
plans.sort((a, b) => (a.avg - (2 * goalValue + 5) / 3)
|
return await dbProvider.userQuery.subjectGoalPlans(userId: user.id!);
|
||||||
.abs()
|
}
|
||||||
.compareTo(b.avg - (2 * goalValue + 5) / 3));
|
|
||||||
|
PlanResult getResult() {
|
||||||
try {
|
final currentAvg = GoalPlannerHelper.averageEvals(grades);
|
||||||
final singleSolution = plans.every((e) => e.sigma == 0);
|
|
||||||
recommended =
|
recommended = null;
|
||||||
plans.where((e) => singleSolution ? true : e.sigma > 0).first;
|
fastest = null;
|
||||||
plans.removeWhere((e) => e == recommended);
|
otherPlans = [];
|
||||||
} catch (_) {}
|
|
||||||
|
if (currentAvg >= goalValue) return PlanResult.reached;
|
||||||
plans.sort((a, b) => a.plan.length.compareTo(b.plan.length));
|
|
||||||
|
final planner = GoalPlanner(goalValue, grades);
|
||||||
try {
|
final plans = planner.solve();
|
||||||
fastest = plans.removeAt(0);
|
|
||||||
} catch (_) {}
|
plans.sort((a, b) => (a.avg - (2 * goalValue + 5) / 3)
|
||||||
|
.abs()
|
||||||
if ((recommended?.plan.length ?? 0) - (fastest?.plan.length ?? 0) >= 3) {
|
.compareTo(b.avg - (2 * goalValue + 5) / 3));
|
||||||
recommended = fastest;
|
|
||||||
}
|
try {
|
||||||
|
final singleSolution = plans.every((e) => e.sigma == 0);
|
||||||
if (recommended == null) {
|
recommended =
|
||||||
recommended = null;
|
plans.where((e) => singleSolution ? true : e.sigma > 0).first;
|
||||||
fastest = null;
|
plans.removeWhere((e) => e == recommended);
|
||||||
otherPlans = [];
|
} catch (_) {}
|
||||||
selectedRoute = null;
|
|
||||||
return PlanResult.unsolvable;
|
plans.sort((a, b) => a.plan.length.compareTo(b.plan.length));
|
||||||
}
|
|
||||||
|
try {
|
||||||
if (recommended!.plan.length > 10) {
|
fastest = plans.removeAt(0);
|
||||||
recommended = null;
|
} catch (_) {}
|
||||||
fastest = null;
|
|
||||||
otherPlans = [];
|
if ((recommended?.plan.length ?? 0) - (fastest?.plan.length ?? 0) >= 3) {
|
||||||
selectedRoute = null;
|
recommended = fastest;
|
||||||
return PlanResult.unreachable;
|
}
|
||||||
}
|
|
||||||
|
if (recommended == null) {
|
||||||
otherPlans = List.from(plans);
|
recommended = null;
|
||||||
|
fastest = null;
|
||||||
return PlanResult.available;
|
otherPlans = [];
|
||||||
}
|
selectedRoute = null;
|
||||||
|
return PlanResult.unsolvable;
|
||||||
void getGrades() {
|
}
|
||||||
grades = getSubjectGrades(widget.subject).toList();
|
|
||||||
}
|
if (recommended!.plan.length > 10) {
|
||||||
|
recommended = null;
|
||||||
@override
|
fastest = null;
|
||||||
Widget build(BuildContext context) {
|
otherPlans = [];
|
||||||
gradeProvider = Provider.of<GradeProvider>(context);
|
selectedRoute = null;
|
||||||
calculatorProvider = Provider.of<GradeCalculatorProvider>(context);
|
return PlanResult.unreachable;
|
||||||
settingsProvider = Provider.of<SettingsProvider>(context);
|
}
|
||||||
|
|
||||||
getGrades();
|
otherPlans = List.from(plans);
|
||||||
|
|
||||||
final currentAvg = GoalPlannerHelper.averageEvals(grades);
|
return PlanResult.available;
|
||||||
|
}
|
||||||
final result = getResult();
|
|
||||||
|
void getGrades() {
|
||||||
List<Grade> subjectGrades = getSubjectGrades(widget.subject);
|
grades = getSubjectGrades(widget.subject).toList();
|
||||||
|
}
|
||||||
double avg = AverageHelper.averageEvals(subjectGrades);
|
|
||||||
|
@override
|
||||||
var nullavg = GroupAverage(average: 0.0, subject: widget.subject, uid: "0");
|
Widget build(BuildContext context) {
|
||||||
double groupAverage = gradeProvider.groupAverages
|
gradeProvider = Provider.of<GradeProvider>(context);
|
||||||
.firstWhere((e) => e.subject == widget.subject, orElse: () => nullavg)
|
calculatorProvider = Provider.of<GradeCalculatorProvider>(context);
|
||||||
.average;
|
settingsProvider = Provider.of<SettingsProvider>(context);
|
||||||
|
|
||||||
return Scaffold(
|
getGrades();
|
||||||
body: SafeArea(
|
|
||||||
child: ListView(
|
final currentAvg = GoalPlannerHelper.averageEvals(grades);
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
left: 22.0, right: 22.0, top: 5.0, bottom: 220.0),
|
final result = getResult();
|
||||||
children: [
|
|
||||||
// Row(
|
List<Grade> subjectGrades = getSubjectGrades(widget.subject);
|
||||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
// children: [
|
double avg = AverageHelper.averageEvals(subjectGrades);
|
||||||
// const BackButton(),
|
|
||||||
// Padding(
|
var nullavg = GroupAverage(average: 0.0, subject: widget.subject, uid: "0");
|
||||||
// padding: const EdgeInsets.only(right: 15.0),
|
double groupAverage = gradeProvider.groupAverages
|
||||||
// child: Row(
|
.firstWhere((e) => e.subject == widget.subject, orElse: () => nullavg)
|
||||||
// children: [
|
.average;
|
||||||
// Text(
|
|
||||||
// 'goal_planner_title'.i18n,
|
return Scaffold(
|
||||||
// style: const TextStyle(
|
body: SafeArea(
|
||||||
// fontWeight: FontWeight.w500, fontSize: 18.0),
|
child: ListView(
|
||||||
// ),
|
padding: const EdgeInsets.only(
|
||||||
// const SizedBox(
|
left: 22.0, right: 22.0, top: 5.0, bottom: 220.0),
|
||||||
// width: 5,
|
children: [
|
||||||
// ),
|
// Row(
|
||||||
// const BetaChip(),
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
// ],
|
// children: [
|
||||||
// ),
|
// const BackButton(),
|
||||||
// ),
|
// Padding(
|
||||||
// ],
|
// padding: const EdgeInsets.only(right: 15.0),
|
||||||
// ),
|
// child: Row(
|
||||||
Row(
|
// children: [
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
// Text(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
// 'goal_planner_title'.i18n,
|
||||||
children: [
|
// style: const TextStyle(
|
||||||
Row(
|
// fontWeight: FontWeight.w500, fontSize: 18.0),
|
||||||
children: [
|
// ),
|
||||||
const BackButton(),
|
// const SizedBox(
|
||||||
RoundBorderIcon(
|
// width: 5,
|
||||||
icon: Icon(
|
// ),
|
||||||
SubjectIcon.resolveVariant(
|
// const BetaChip(),
|
||||||
context: context,
|
// ],
|
||||||
subject: widget.subject,
|
// ),
|
||||||
),
|
// ),
|
||||||
size: 10,
|
// ],
|
||||||
),
|
// ),
|
||||||
),
|
Row(
|
||||||
Text(
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
(widget.subject.isRenamed
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
? widget.subject.renamedTo
|
children: [
|
||||||
: widget.subject.name) ??
|
Row(
|
||||||
'goal_planner_title'.i18n,
|
children: [
|
||||||
style: const TextStyle(
|
const BackButton(),
|
||||||
fontSize: 17.0,
|
RoundBorderIcon(
|
||||||
fontWeight: FontWeight.w500,
|
icon: Icon(
|
||||||
),
|
SubjectIcon.resolveVariant(
|
||||||
),
|
context: context,
|
||||||
],
|
subject: widget.subject,
|
||||||
),
|
),
|
||||||
Row(
|
size: 18,
|
||||||
children: [
|
weight: 1.5,
|
||||||
if (groupAverage != 0)
|
),
|
||||||
AverageDisplay(average: groupAverage, border: true),
|
),
|
||||||
const SizedBox(width: 6.0),
|
const SizedBox(
|
||||||
AverageDisplay(average: avg)
|
width: 5.0,
|
||||||
],
|
),
|
||||||
),
|
Text(
|
||||||
],
|
(widget.subject.isRenamed
|
||||||
),
|
? widget.subject.renamedTo
|
||||||
const SizedBox(height: 12.0),
|
: widget.subject.name) ??
|
||||||
Row(
|
'goal_planner_title'.i18n,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
style: const TextStyle(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
fontSize: 20.0,
|
||||||
children: [
|
fontWeight: FontWeight.w700,
|
||||||
Column(
|
),
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
),
|
||||||
children: [
|
],
|
||||||
Text(
|
),
|
||||||
"set_a_goal".i18n,
|
Row(
|
||||||
style: const TextStyle(
|
children: [
|
||||||
fontWeight: FontWeight.bold,
|
if (groupAverage != 0)
|
||||||
fontSize: 20.0,
|
AverageDisplay(average: groupAverage, border: true),
|
||||||
),
|
const SizedBox(width: 6.0),
|
||||||
),
|
AverageDisplay(average: avg)
|
||||||
const SizedBox(height: 4.0),
|
],
|
||||||
Text(
|
),
|
||||||
goalValue.toString(),
|
],
|
||||||
style: TextStyle(
|
),
|
||||||
fontWeight: FontWeight.w900,
|
const SizedBox(height: 12.0),
|
||||||
fontSize: 42.0,
|
Text(
|
||||||
color: gradeColor(goalValue.round(), settingsProvider),
|
"set_a_goal".i18n,
|
||||||
),
|
style: const TextStyle(
|
||||||
),
|
fontWeight: FontWeight.bold,
|
||||||
],
|
fontSize: 20.0,
|
||||||
),
|
),
|
||||||
// Column(
|
),
|
||||||
// mainAxisAlignment: MainAxisAlignment.center,
|
const SizedBox(height: 4.0),
|
||||||
// children: [
|
Text(
|
||||||
// Text(
|
goalValue.toString(),
|
||||||
// "select_subject".i18n,
|
style: TextStyle(
|
||||||
// style: const TextStyle(
|
fontWeight: FontWeight.w900,
|
||||||
// fontWeight: FontWeight.bold,
|
fontSize: 48.0,
|
||||||
// fontSize: 20.0,
|
color: gradeColor(goalValue.round(), settingsProvider),
|
||||||
// ),
|
),
|
||||||
// ),
|
),
|
||||||
// const SizedBox(height: 4.0),
|
// Column(
|
||||||
// Column(
|
// mainAxisAlignment: MainAxisAlignment.center,
|
||||||
// children: [
|
// children: [
|
||||||
// Icon(
|
// Text(
|
||||||
// SubjectIcon.resolveVariant(
|
// "select_subject".i18n,
|
||||||
// context: context,
|
// style: const TextStyle(
|
||||||
// subject: widget.subject,
|
// fontWeight: FontWeight.bold,
|
||||||
// ),
|
// fontSize: 20.0,
|
||||||
// size: 48.0,
|
// ),
|
||||||
// ),
|
// ),
|
||||||
// Text(
|
// const SizedBox(height: 4.0),
|
||||||
// (widget.subject.isRenamed
|
// Column(
|
||||||
// ? widget.subject.renamedTo
|
// children: [
|
||||||
// : widget.subject.name) ??
|
// Icon(
|
||||||
// '',
|
// SubjectIcon.resolveVariant(
|
||||||
// style: const TextStyle(
|
// context: context,
|
||||||
// fontSize: 17.0,
|
// subject: widget.subject,
|
||||||
// fontWeight: FontWeight.w500,
|
// ),
|
||||||
// ),
|
// size: 48.0,
|
||||||
// )
|
// ),
|
||||||
// ],
|
// Text(
|
||||||
// )
|
// (widget.subject.isRenamed
|
||||||
// ],
|
// ? widget.subject.renamedTo
|
||||||
// )
|
// : widget.subject.name) ??
|
||||||
],
|
// '',
|
||||||
),
|
// style: const TextStyle(
|
||||||
const SizedBox(height: 24.0),
|
// fontSize: 17.0,
|
||||||
Text(
|
// fontWeight: FontWeight.w500,
|
||||||
"pick_route".i18n,
|
// ),
|
||||||
style: const TextStyle(
|
// )
|
||||||
fontWeight: FontWeight.bold,
|
// ],
|
||||||
fontSize: 20.0,
|
// )
|
||||||
),
|
// ],
|
||||||
),
|
// )
|
||||||
const SizedBox(height: 12.0),
|
const SizedBox(height: 24.0),
|
||||||
if (recommended != null)
|
Text(
|
||||||
RouteOption(
|
"pick_route".i18n,
|
||||||
plan: recommended!,
|
style: const TextStyle(
|
||||||
mark: RouteMark.recommended,
|
fontWeight: FontWeight.bold,
|
||||||
selected: selectedRoute == recommended!,
|
fontSize: 20.0,
|
||||||
onSelected: () => setState(() {
|
),
|
||||||
selectedRoute = recommended;
|
),
|
||||||
}),
|
const SizedBox(height: 12.0),
|
||||||
),
|
if (recommended != null)
|
||||||
if (fastest != null && fastest != recommended)
|
RouteOption(
|
||||||
RouteOption(
|
plan: recommended!,
|
||||||
plan: fastest!,
|
mark: RouteMark.recommended,
|
||||||
mark: RouteMark.fastest,
|
selected: selectedRoute == recommended!,
|
||||||
selected: selectedRoute == fastest!,
|
onSelected: () => setState(() {
|
||||||
onSelected: () => setState(() {
|
selectedRoute = recommended;
|
||||||
selectedRoute = fastest;
|
}),
|
||||||
}),
|
),
|
||||||
),
|
if (fastest != null && fastest != recommended)
|
||||||
...otherPlans.map((e) => RouteOption(
|
RouteOption(
|
||||||
plan: e,
|
plan: fastest!,
|
||||||
selected: selectedRoute == e,
|
mark: RouteMark.fastest,
|
||||||
onSelected: () => setState(() {
|
selected: selectedRoute == fastest!,
|
||||||
selectedRoute = e;
|
onSelected: () => setState(() {
|
||||||
}),
|
selectedRoute = fastest;
|
||||||
)),
|
}),
|
||||||
if (result != PlanResult.available) Text(result.name),
|
),
|
||||||
],
|
...otherPlans.map((e) => RouteOption(
|
||||||
),
|
plan: e,
|
||||||
),
|
selected: selectedRoute == e,
|
||||||
bottomSheet: MediaQuery.removePadding(
|
onSelected: () => setState(() {
|
||||||
context: context,
|
selectedRoute = e;
|
||||||
removeBottom: false,
|
}),
|
||||||
removeTop: true,
|
)),
|
||||||
child: Container(
|
if (result != PlanResult.available) Text(result.name),
|
||||||
color: Theme.of(context).scaffoldBackgroundColor,
|
],
|
||||||
child: Container(
|
),
|
||||||
padding: const EdgeInsets.only(top: 24.0),
|
),
|
||||||
decoration: BoxDecoration(
|
bottomSheet: MediaQuery.removePadding(
|
||||||
color: Theme.of(context).colorScheme.background,
|
context: context,
|
||||||
borderRadius:
|
removeBottom: false,
|
||||||
const BorderRadius.vertical(top: Radius.circular(24.0)),
|
removeTop: true,
|
||||||
boxShadow: [
|
child: Container(
|
||||||
BoxShadow(
|
color: Theme.of(context).scaffoldBackgroundColor,
|
||||||
color: Colors.black.withOpacity(.1),
|
child: Container(
|
||||||
blurRadius: 8.0,
|
padding: const EdgeInsets.only(top: 24.0),
|
||||||
)
|
decoration: BoxDecoration(
|
||||||
]),
|
color: Theme.of(context).colorScheme.background,
|
||||||
child: SafeArea(
|
borderRadius:
|
||||||
child: Padding(
|
const BorderRadius.vertical(top: Radius.circular(24.0)),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
boxShadow: [
|
||||||
child: Column(
|
BoxShadow(
|
||||||
mainAxisSize: MainAxisSize.min,
|
color: Colors.black.withOpacity(.1),
|
||||||
children: [
|
blurRadius: 8.0,
|
||||||
GoalInput(
|
)
|
||||||
value: goalValue,
|
]),
|
||||||
currentAverage: currentAvg,
|
child: SafeArea(
|
||||||
onChanged: (v) => setState(() {
|
child: Padding(
|
||||||
selectedRoute = null;
|
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||||
goalValue = v;
|
child: Column(
|
||||||
}),
|
mainAxisSize: MainAxisSize.min,
|
||||||
),
|
children: [
|
||||||
const SizedBox(height: 24.0),
|
GoalInput(
|
||||||
SizedBox(
|
value: goalValue,
|
||||||
width: double.infinity,
|
currentAverage: currentAvg,
|
||||||
child: RawMaterialButton(
|
onChanged: (v) => setState(() {
|
||||||
onPressed: () {
|
selectedRoute = null;
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
goalValue = v;
|
||||||
const SnackBar(content: Text("Hamarosan...")));
|
}),
|
||||||
},
|
),
|
||||||
fillColor: Theme.of(context).colorScheme.primary,
|
const SizedBox(height: 24.0),
|
||||||
shape: const StadiumBorder(),
|
SizedBox(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
width: double.infinity,
|
||||||
child: Text(
|
child: RawMaterialButton(
|
||||||
"track_it".i18n,
|
onPressed: () async {
|
||||||
style: const TextStyle(
|
if (selectedRoute == null) {
|
||||||
color: Colors.white,
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
fontSize: 20.0,
|
content: Text('${"pick_route".i18n}...')));
|
||||||
fontWeight: FontWeight.w600,
|
}
|
||||||
),
|
|
||||||
),
|
final goalPlans = await fetchGoalPlans();
|
||||||
),
|
goalPlans[widget.subject.id] =
|
||||||
)
|
selectedRoute!.dbString;
|
||||||
],
|
|
||||||
),
|
await dbProvider.userStore.storeSubjectGoalPlans(
|
||||||
),
|
goalPlans,
|
||||||
),
|
userId: user.id!);
|
||||||
),
|
|
||||||
),
|
Navigator.of(context).pop();
|
||||||
),
|
},
|
||||||
);
|
fillColor: Theme.of(context).colorScheme.primary,
|
||||||
}
|
shape: const StadiumBorder(),
|
||||||
}
|
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||||
|
child: Text(
|
||||||
|
"track_it".i18n,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 20.0,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user