new UI + new targets.

This commit is contained in:
Jan Pleterski
2026-11-27 14:37:44 +01:00
parent 5f9e2a3b86
commit 2fc741a9f6
113 changed files with 6861 additions and 7381 deletions
+120
View File
@@ -0,0 +1,120 @@
import 'package:flutter/material.dart';
import '../theme/app_theme.dart';
class BarEntry {
final String label;
final double value;
final String valueText;
final bool highlight; // drawn in gold (best target, the 10s)
final bool goldLabel;
const BarEntry(this.label, this.value, this.valueText, {this.highlight = false, this.goldLabel = false});
}
/// Horizontal bars, one per row: label, bar on a track, value. Ticks along the
/// bottom. The rows share the height they get.
class BarList extends StatelessWidget {
final List<BarEntry> entries;
final double max;
final List<double> ticks;
final double labelWidth;
final double valueWidth;
final double scale; // text size factor (share image)
final Palette? palette;
const BarList({
super.key,
required this.entries,
required this.max,
this.ticks = const [],
this.labelWidth = 32,
this.valueWidth = 40,
this.scale = 1,
this.palette,
});
@override
Widget build(BuildContext context) {
final c = palette ?? Palette.current;
String tick(double v) => v == v.roundToDouble() ? '${v.round()}' : v.toStringAsFixed(1);
return LayoutBuilder(builder: (context, box) {
final barWidth = box.maxWidth - labelWidth - valueWidth;
return Column(
children: [
Expanded(
child: Column(
children: [
for (final e in entries)
Expanded(
child: Row(
children: [
SizedBox(
width: labelWidth,
child: Text(e.label,
style: TextStyle(
fontSize: 12 * scale,
fontWeight: FontWeight.w600,
color: e.goldLabel ? c.gold : c.muted)),
),
SizedBox(
width: barWidth,
child: Stack(
alignment: Alignment.centerLeft,
children: [
Container(
height: 26 * scale,
decoration: BoxDecoration(color: c.tile, borderRadius: BorderRadius.circular(7 * scale)),
),
FractionallySizedBox(
widthFactor: max <= 0 ? 0 : (e.value / max).clamp(0.0, 1.0),
child: Container(
height: 26 * scale,
decoration: BoxDecoration(
color: e.highlight ? c.gold : c.accent,
borderRadius: BorderRadius.circular(7 * scale),
),
),
),
],
),
),
SizedBox(
width: valueWidth,
child: Padding(
padding: EdgeInsets.only(left: 10 * scale),
child: Text(e.valueText,
maxLines: 1,
style: TextStyle(
fontSize: 15 * scale,
fontWeight: FontWeight.w700,
color: e.highlight ? c.gold : (e.value == 0 ? c.faint : c.ink),
fontFeatures: AppTheme.tnum)),
),
),
],
),
),
],
),
),
if (ticks.isNotEmpty)
Padding(
padding: EdgeInsets.only(left: labelWidth, right: valueWidth, top: 6 * scale),
child: SizedBox(
height: 14 * scale,
child: Stack(
children: [
for (final t in ticks)
Align(
alignment: Alignment(max <= 0 ? -1 : (t / max) * 2 - 1, 0),
child: Text(tick(t), style: TextStyle(fontSize: 10 * scale, color: c.faint, fontFeatures: AppTheme.tnum)),
),
],
),
),
),
],
);
});
}
}