feat(ui): scope, freshness and jurist-review badges + live empty-state
Adds three dark-first chip badges in the TierBadge pattern: - Jurisdiction (Berlin/DE/EU/International) — derived from the ELI, surfaced on the norms list, detail header and heatmap chips/hover. - Freshness (aktuell/geaendert/ungeprueft) — flags norms amended upstream (standDate + sourceSha256); renders only when stale. - Jurist review — marks evaluations a trusted jurist has confirmed (optional; the figure stands on its own). Models gain Jurisdiction/Freshness enums, Norm.freshness/supersededNote and Evaluation.reviewedBy/reviewedAt; HubRepository parses them from the flow bag (ELI fallback). HeatmapPage shows a real empty-state (hub-down vs no-evaluations) instead of a blank plot, and connect() no longer throws on a failed probe. Signed-off-by: flemming-it <sf@flemming.it>
This commit is contained in:
parent
9dfa418e92
commit
aabff2b140
11 changed files with 604 additions and 26 deletions
74
app/lib/widgets/freshness_badge.dart
Normal file
74
app/lib/widgets/freshness_badge.dart
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../data/models.dart';
|
||||
import '../theme/reclaim_tokens.dart';
|
||||
|
||||
/// Freshness badge — flags when a norm version is stale relative to
|
||||
/// the published source (amended upstream) or hasn't been reconciled.
|
||||
/// By design it renders NOTHING for [Freshness.current] (the common
|
||||
/// case shouldn't add noise) unless [alwaysShow] is set. Same chip
|
||||
/// shape as the scope/tier badges.
|
||||
class FreshnessBadge extends StatelessWidget {
|
||||
const FreshnessBadge({
|
||||
super.key,
|
||||
required this.freshness,
|
||||
this.note,
|
||||
this.compact = false,
|
||||
this.alwaysShow = false,
|
||||
});
|
||||
|
||||
final Freshness freshness;
|
||||
|
||||
/// Optional plain-text hint of what changed (from Norm.supersededNote).
|
||||
final String? note;
|
||||
final bool compact;
|
||||
final bool alwaysShow;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!freshness.needsBadge && !alwaysShow) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
final t = Theme.of(context).textTheme;
|
||||
final color = switch (freshness) {
|
||||
Freshness.current => ReclaimColors.signal,
|
||||
Freshness.superseded => ReclaimColors.freshSuperseded,
|
||||
Freshness.unknown => ReclaimColors.freshUnknown,
|
||||
};
|
||||
final icon = switch (freshness) {
|
||||
Freshness.current => Icons.check_circle_outline,
|
||||
Freshness.superseded => Icons.history_toggle_off,
|
||||
Freshness.unknown => Icons.help_outline,
|
||||
};
|
||||
final label = compact ? freshness.label : 'Stand: ${freshness.label}';
|
||||
return Tooltip(
|
||||
message: '${freshness.description}'
|
||||
'${note != null && note!.isNotEmpty ? '\n$note' : ''}',
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: compact ? 6 : ReclaimSpace.sm,
|
||||
vertical: compact ? 2 : 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withValues(alpha: 0.18),
|
||||
border: Border.all(color: color.withValues(alpha: 0.55)),
|
||||
borderRadius: const BorderRadius.all(ReclaimRadius.sm),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(icon, size: compact ? 12 : 14, color: color),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
label,
|
||||
style: (compact ? t.labelSmall : t.labelLarge)?.copyWith(
|
||||
color: color,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -267,7 +267,8 @@ class _HeatmapPainter extends CustomPainter {
|
|||
);
|
||||
_drawText(
|
||||
canvas,
|
||||
'Tier: ${e.tierLowest.short} Klick → Detail',
|
||||
'Bereich: ${e.norm.jurisdiction.short} '
|
||||
'Tier: ${e.tierLowest.short} Klick → Detail',
|
||||
box.topLeft + const Offset(10, 44),
|
||||
const TextStyle(
|
||||
color: mute,
|
||||
|
|
|
|||
69
app/lib/widgets/jurisdiction_badge.dart
Normal file
69
app/lib/widgets/jurisdiction_badge.dart
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../data/models.dart';
|
||||
import '../theme/reclaim_tokens.dart';
|
||||
|
||||
/// Scope badge — surfaces a norm's Geltungsbereich (Berlin /
|
||||
/// Deutschland / EU / International) wherever the norm appears, so
|
||||
/// the reader sees at a glance which reform lever a figure speaks
|
||||
/// to. Visually mirrors [TierBadge]: a scope glyph + code in a
|
||||
/// tinted chip, here with a Material icon instead of a dot.
|
||||
class JurisdictionBadge extends StatelessWidget {
|
||||
const JurisdictionBadge({
|
||||
super.key,
|
||||
required this.jurisdiction,
|
||||
this.compact = false,
|
||||
});
|
||||
|
||||
final Jurisdiction jurisdiction;
|
||||
final bool compact;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final t = Theme.of(context).textTheme;
|
||||
final color = switch (jurisdiction) {
|
||||
Jurisdiction.berlin => ReclaimColors.scopeBerlin,
|
||||
Jurisdiction.deutschland => ReclaimColors.scopeDeutschland,
|
||||
Jurisdiction.eu => ReclaimColors.scopeEu,
|
||||
Jurisdiction.international => ReclaimColors.scopeInternational,
|
||||
};
|
||||
final icon = switch (jurisdiction) {
|
||||
Jurisdiction.berlin => Icons.location_city_outlined,
|
||||
Jurisdiction.deutschland => Icons.flag_outlined,
|
||||
Jurisdiction.eu => Icons.star_outline_rounded,
|
||||
Jurisdiction.international => Icons.public,
|
||||
};
|
||||
final label = compact
|
||||
? jurisdiction.short
|
||||
: '${jurisdiction.short} · ${jurisdiction.label}';
|
||||
return Tooltip(
|
||||
message: 'Geltungsbereich: ${jurisdiction.label} '
|
||||
'(${jurisdiction.level}).\n${jurisdiction.reformLever}.',
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: compact ? 6 : ReclaimSpace.sm,
|
||||
vertical: compact ? 2 : 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withValues(alpha: 0.18),
|
||||
border: Border.all(color: color.withValues(alpha: 0.55)),
|
||||
borderRadius: const BorderRadius.all(ReclaimRadius.sm),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(icon, size: compact ? 12 : 14, color: color),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
label,
|
||||
style: (compact ? t.labelSmall : t.labelLarge)?.copyWith(
|
||||
color: color,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
77
app/lib/widgets/review_badge.dart
Normal file
77
app/lib/widgets/review_badge.dart
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../data/models.dart';
|
||||
import '../theme/reclaim_tokens.dart';
|
||||
|
||||
/// Review badge — marks an evaluation a trusted jurist has confirmed
|
||||
/// (signed off via the hub approval). Jurist review is OPTIONAL: an
|
||||
/// evaluation stands on its own; this only adds the "bestätigt" mark.
|
||||
/// Renders a confirm-green check when reviewed; renders the muted
|
||||
/// "ungeprüft" state only when [showUnreviewed] is set (otherwise
|
||||
/// nothing, to keep unreviewed rows clean).
|
||||
class ReviewBadge extends StatelessWidget {
|
||||
const ReviewBadge({
|
||||
super.key,
|
||||
required this.evaluation,
|
||||
this.compact = false,
|
||||
this.showUnreviewed = false,
|
||||
});
|
||||
|
||||
final Evaluation evaluation;
|
||||
final bool compact;
|
||||
final bool showUnreviewed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final reviewed = evaluation.isReviewed;
|
||||
if (!reviewed && !showUnreviewed) return const SizedBox.shrink();
|
||||
|
||||
final t = Theme.of(context).textTheme;
|
||||
final color =
|
||||
reviewed ? ReclaimColors.reviewConfirmed : ReclaimColors.mute;
|
||||
final icon = reviewed
|
||||
? Icons.verified_outlined
|
||||
: Icons.radio_button_unchecked;
|
||||
final label = reviewed
|
||||
? (compact ? 'geprüft' : 'Jurist-geprüft')
|
||||
: (compact ? 'offen' : 'ungeprüft');
|
||||
final tip = reviewed
|
||||
? 'Bestätigt von ${evaluation.reviewedBy}'
|
||||
'${evaluation.reviewedAt != null ? ' am ${_d(evaluation.reviewedAt!)}' : ''}.\n'
|
||||
'Jurist-Review ist optional — es bestätigt die Auswertung, '
|
||||
'ist aber keine Voraussetzung.'
|
||||
: 'Noch von keinem Juristen bestätigt. Die Auswertung gilt '
|
||||
'trotzdem (Review ist optional).';
|
||||
return Tooltip(
|
||||
message: tip,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: compact ? 6 : ReclaimSpace.sm,
|
||||
vertical: compact ? 2 : 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withValues(alpha: 0.18),
|
||||
border: Border.all(color: color.withValues(alpha: 0.55)),
|
||||
borderRadius: const BorderRadius.all(ReclaimRadius.sm),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(icon, size: compact ? 12 : 14, color: color),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
label,
|
||||
style: (compact ? t.labelSmall : t.labelLarge)?.copyWith(
|
||||
color: color,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static String _d(DateTime d) =>
|
||||
'${d.day.toString().padLeft(2, '0')}.${d.month.toString().padLeft(2, '0')}.${d.year}';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue