added german translation and store stuff for app

This commit is contained in:
Jan Pleterski
2026-11-13 10:56:11 +01:00
parent d4bc01f202
commit 30708c73b1
47 changed files with 530 additions and 160 deletions
+30 -4
View File
@@ -1,4 +1,5 @@
import 'dart:math';
import 'package:flutter/foundation.dart' show listEquals;
import 'package:flutter/material.dart';
enum ChartAxis { left, right, none }
@@ -42,12 +43,37 @@ class ProgressChart extends StatefulWidget {
class _ProgressChartState extends State<ProgressChart> {
int? _selected;
void _select(Offset position, Size size) {
// Other data (another month/year, filter): the old selection means nothing there
@override
void didUpdateWidget(ProgressChart old) {
super.didUpdateWidget(old);
final same = listEquals(old.labels, widget.labels) &&
old.series.length == widget.series.length &&
[
for (var i = 0; i < widget.series.length; i++)
listEquals(old.series[i].values, widget.series[i].values)
].every((e) => e);
if (!same) _selected = null;
}
int? _indexAt(Offset position, Size size) {
final n = widget.labels.length;
if (n == 0) return;
if (n == 0) return null;
final plot = _ChartPainter.plotRect(size);
final x = (position.dx - plot.left) / plot.width;
setState(() => _selected = (x * (n - 1)).round().clamp(0, n - 1));
return (x * (n - 1)).round().clamp(0, n - 1);
}
void _select(Offset position, Size size) {
final i = _indexAt(position, size);
if (i != null && i != _selected) setState(() => _selected = i);
}
// Tapping the selected point again hides the tooltip
void _toggle(Offset position, Size size) {
final i = _indexAt(position, size);
if (i == null) return;
setState(() => _selected = i == _selected ? null : i);
}
@override
@@ -60,7 +86,7 @@ class _ProgressChartState extends State<ProgressChart> {
final size = Size(constraints.maxWidth, 190);
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTapDown: (d) => _select(d.localPosition, size),
onTapDown: (d) => _toggle(d.localPosition, size),
onHorizontalDragUpdate: (d) => _select(d.localPosition, size),
child: CustomPaint(
size: size,