diff --git a/firka/lib/ui/phone/pages/home/home_grades.dart b/firka/lib/ui/phone/pages/home/home_grades.dart index 32dae70..7b9abd3 100644 --- a/firka/lib/ui/phone/pages/home/home_grades.dart +++ b/firka/lib/ui/phone/pages/home/home_grades.dart @@ -1,6 +1,5 @@ import 'package:kreta_api/kreta_api.dart'; import 'package:firka/core/average_helper.dart'; -import 'package:firka/routing/chart_interaction_scope.dart'; import 'package:firka/ui/components/firka_card.dart'; import 'package:firka/ui/components/grade_helpers.dart'; import 'package:firka/ui/phone/widgets/grade_chart.dart'; @@ -227,17 +226,7 @@ class _HomeGradesScreen extends FirkaState { ), ], ), - // SizedBox(height: 16), // TODO: Add graphs here - Listener( - behavior: HitTestBehavior.opaque, - onPointerDown: (_) => - ChartInteractionScope.of(context).value = true, - onPointerUp: (_) => - ChartInteractionScope.of(context).value = false, - onPointerCancel: (_) => - ChartInteractionScope.of(context).value = false, - child: GradeChart(grades: grades?.response ?? []), - ), + GradeChartWithInteraction(grades: grades?.response ?? []), SizedBox(height: 2), GradeSummaryBar( grades: grades?.response ?? [], diff --git a/firka/lib/ui/phone/pages/home/home_grades_subject.dart b/firka/lib/ui/phone/pages/home/home_grades_subject.dart index 7d92b19..341536f 100644 --- a/firka/lib/ui/phone/pages/home/home_grades_subject.dart +++ b/firka/lib/ui/phone/pages/home/home_grades_subject.dart @@ -4,6 +4,7 @@ import 'package:firka/ui/components/common_bottom_sheets.dart'; import 'package:firka/ui/components/firka_card.dart'; import 'package:firka/ui/components/grade.dart'; import 'package:firka/ui/phone/pages/home/home_grades.dart'; +import 'package:firka/ui/phone/widgets/grade_chart.dart'; import 'package:firka/ui/shared/class_icon.dart'; import 'package:firka/ui/shared/firka_icon.dart'; import 'package:flutter/material.dart'; @@ -196,13 +197,8 @@ class _HomeGradesSubjectScreen extends FirkaState { ), ], ), - // SizedBox(height: 16), - // GradeChart(grades: grades?.toList() ?? []), - SizedBox( - height: - MediaQuery.of(context).size.height - - MediaQuery.of(context).padding.top - - 230, + SizedBox(height: 16), + Expanded( child: ListView( children: [ Column( @@ -241,6 +237,8 @@ class _HomeGradesSubjectScreen extends FirkaState { SizedBox(height: 15), ], ), + GradeChartWithInteraction(grades: grades?.toList() ?? []), + SizedBox(height: 12), Padding( padding: EdgeInsets.only(left: 4), child: Column( diff --git a/firka/lib/ui/phone/widgets/grade_chart.dart b/firka/lib/ui/phone/widgets/grade_chart.dart index 3933a2a..e45a498 100644 --- a/firka/lib/ui/phone/widgets/grade_chart.dart +++ b/firka/lib/ui/phone/widgets/grade_chart.dart @@ -1,4 +1,5 @@ import 'package:kreta_api/kreta_api.dart'; +import 'package:firka/routing/chart_interaction_scope.dart'; import 'package:firka/ui/components/grade_helpers.dart'; import 'package:firka/ui/theme/style.dart'; import 'package:fl_chart/fl_chart.dart'; @@ -370,3 +371,22 @@ class _GradeChartState extends State { ); } } + +/// Wraps [GradeChart] with a [Listener] that updates [ChartInteractionScope] +/// so the navigator does not intercept touch/drag (e.g. for swipe back). +class GradeChartWithInteraction extends StatelessWidget { + final List grades; + + const GradeChartWithInteraction({super.key, required this.grades}); + + @override + Widget build(BuildContext context) { + return Listener( + behavior: HitTestBehavior.opaque, + onPointerDown: (_) => ChartInteractionScope.of(context).value = true, + onPointerUp: (_) => ChartInteractionScope.of(context).value = false, + onPointerCancel: (_) => ChartInteractionScope.of(context).value = false, + child: GradeChart(grades: grades), + ); + } +}