Dash: DIN 1451 opt-in per widget (hudFont), GNSS compass, rei by default; widget catalogue
From smart-serow: the DIN 1451 face (Alte DIN 1451 Mittelschrift, via gps-speedo) and GpsCompass. A cosmetic font is opt-in: widgets name hudFont in their own TextStyle, the rest keeps the basic font (CJK). Boxes and telltales shrink long labels instead of wrapping. Telltale and Reading get their own files; lib/README.md catalogues folders and widgets like smart-serow's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DDwfd6Ki8UfG4hK6W5YpJz
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
// An on/off lamp in the boxed pattern (lib/widgets/stat_box.dart): the label is the
|
||||
// lamp. Takes a [Reading] (lib/reading.dart) so missing and stale draw as they do elsewhere.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../reading.dart';
|
||||
import '../theme/palette.dart';
|
||||
|
||||
/// An on/off lamp in the boxed pattern: the label is the lamp. Lit in foreground
|
||||
/// (highlight when [warn]), dark in subdued; missing shows as a dash.
|
||||
class Telltale extends StatelessWidget {
|
||||
const Telltale({
|
||||
super.key,
|
||||
required this.label,
|
||||
required this.reading,
|
||||
this.icon,
|
||||
this.warn = false,
|
||||
this.flex = 1,
|
||||
});
|
||||
|
||||
final String label;
|
||||
|
||||
/// Drawn instead of the label when set. Glyphs like ◀ ▶ come out as emoji on Android.
|
||||
final IconData? icon;
|
||||
final Reading reading;
|
||||
final bool warn;
|
||||
final int flex;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final p = AppTheme.of(context);
|
||||
final missing = reading.value == null;
|
||||
final lit = reading.on && !reading.dim;
|
||||
final color = lit
|
||||
? (warn ? p.highlight : p.foreground)
|
||||
: p.subdued.withValues(alpha: missing ? 0.35 : 0.6);
|
||||
return Expanded(
|
||||
flex: flex,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, c) {
|
||||
final size = c.maxHeight * 0.3;
|
||||
if (icon != null && !missing) {
|
||||
return Center(
|
||||
child: Icon(
|
||||
icon,
|
||||
size: c.maxHeight * 0.7,
|
||||
color: color,
|
||||
semanticLabel: label,
|
||||
),
|
||||
);
|
||||
}
|
||||
return Center(
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Text(
|
||||
missing ? '—' : label,
|
||||
maxLines: 1,
|
||||
style: TextStyle(
|
||||
fontFamily: hudFont,
|
||||
fontSize: size,
|
||||
fontWeight: lit ? FontWeight.w700 : FontWeight.w400,
|
||||
color: color,
|
||||
letterSpacing: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user