Merge branch 'main' into run/formats-wording
This commit is contained in:
@@ -254,10 +254,10 @@ class SegmentedBar extends StatelessWidget
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
background,
|
||||
background.withValues(alpha: background.a * 0.85),
|
||||
background.withValues(alpha: background.a * 0.95),
|
||||
background.withValues(alpha: 0),
|
||||
],
|
||||
stops: const [0, 0.45, 1],
|
||||
stops: const [0, 0.5, 1],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -120,7 +120,8 @@ class SegmentedTitlePill extends StatelessWidget {
|
||||
fontWeight: FontWeight.w600,
|
||||
color: foreground,
|
||||
);
|
||||
subtitleStyle = text.tabLabelTextStyle.copyWith(
|
||||
subtitleStyle = text.textStyle.copyWith(
|
||||
fontSize: 13,
|
||||
color:
|
||||
foreground ?? CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
);
|
||||
|
||||
@@ -111,7 +111,7 @@ class StickySectionTitle extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
final row = Padding(
|
||||
padding: const EdgeInsetsDirectional.only(start: 13, end: 8),
|
||||
padding: const EdgeInsetsDirectional.only(start: 16, end: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Colours for recorded outcome names, assigned per run by first appearance.
|
||||
///
|
||||
/// Outcome words are pipeline-defined ('approved', 'rejected', 'retry', …), so
|
||||
/// no name is hard-wired to a colour: the same name always gets the same
|
||||
/// colour within a run and two different names never share one. The first
|
||||
/// [_hues] names use well-separated hues; later ones continue around the
|
||||
/// colour wheel by the golden angle so they stay distinct.
|
||||
class OutcomePalette {
|
||||
OutcomePalette(Iterable<String> outcomes) {
|
||||
for (final outcome in outcomes) {
|
||||
final key = _key(outcome);
|
||||
if (key.isNotEmpty) _index.putIfAbsent(key, () => _index.length);
|
||||
}
|
||||
}
|
||||
|
||||
final Map<String, int> _index = {};
|
||||
|
||||
static String _key(String outcome) => outcome.trim().toLowerCase();
|
||||
|
||||
/// The position [outcome] was first seen at, or null for a blank or unseen
|
||||
/// name.
|
||||
int? indexOf(String outcome) => _index[_key(outcome)];
|
||||
|
||||
/// [outcome]'s colour for the host's brightness; an unseen or blank name
|
||||
/// uses the host's secondary text colour.
|
||||
Color colorFor(BuildContext context, String outcome) {
|
||||
final cupertino =
|
||||
context.findAncestorWidgetOfExactType<MaterialApp>() == null;
|
||||
final brightness = cupertino
|
||||
? CupertinoTheme.brightnessOf(context)
|
||||
: Theme.of(context).brightness;
|
||||
final index = indexOf(outcome);
|
||||
if (index == null) {
|
||||
return cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
}
|
||||
return outcomeColorAt(index, brightness);
|
||||
}
|
||||
}
|
||||
|
||||
const List<MaterialColor> _hues = [
|
||||
Colors.blue,
|
||||
Colors.green,
|
||||
Colors.deepOrange,
|
||||
Colors.purple,
|
||||
Colors.teal,
|
||||
Colors.pink,
|
||||
Colors.amber,
|
||||
Colors.indigo,
|
||||
Colors.brown,
|
||||
Colors.cyan,
|
||||
];
|
||||
|
||||
/// The colour for the [index]th distinct outcome, readable on the page in
|
||||
/// [brightness] (darker shades on light pages, lighter on dark).
|
||||
Color outcomeColorAt(int index, Brightness brightness) {
|
||||
final dark = brightness == Brightness.dark;
|
||||
if (index < _hues.length) {
|
||||
final hue = _hues[index];
|
||||
return dark ? hue.shade300 : hue.shade800;
|
||||
}
|
||||
final degrees = (index * 137.508) % 360;
|
||||
return HSLColor.fromAHSL(1, degrees, 0.6, dark ? 0.7 : 0.35).toColor();
|
||||
}
|
||||
Reference in New Issue
Block a user