forked from firka/firka
firka: add GradeChartWithInteraction helper, use on grades and subject screens
This commit is contained in:
@@ -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<HomeGradesScreen> {
|
||||
),
|
||||
],
|
||||
),
|
||||
// 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 ?? [],
|
||||
|
||||
@@ -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<HomeGradesSubjectScreen> {
|
||||
),
|
||||
],
|
||||
),
|
||||
// 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<HomeGradesSubjectScreen> {
|
||||
SizedBox(height: 15),
|
||||
],
|
||||
),
|
||||
GradeChartWithInteraction(grades: grades?.toList() ?? []),
|
||||
SizedBox(height: 12),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 4),
|
||||
child: Column(
|
||||
|
||||
@@ -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<GradeChart> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 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<Grade> 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),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user