Files
pipelines/app/lib/ui/adaptive/floating_tab_button.dart
T
alan a6db4ba20e App: run tabs under the header on wide layouts, stable Artifacts tab, spelled-out pipeline status, shared list selection, code block header and edge fades
- Run detail: on a wide window (>= 840, pane >= 600) the tabs are Material
  segments under the run header; phones keep the floating bottom bar.
  Artifacts is always a tab, badged with its count and disabled with 0 (its
  tooltip says why), so Changes never moves.
- Pipelines list: 'Failed · last run 19 Oct' beside the status dot; facts on
  the next line; compact rows keep 'Failed · 19 Oct'.
- Settings: Disconnect is outlined beside a tonal Reconnect.
- Lists: one selection style (tonal fill plus one leading accent bar) for
  runs, pipelines and chats; chat's border, fill and pointer removed.
- Transcript: overflowing blocks fade at the edge with a chevron instead of
  a 'Scroll horizontally' line (semantics hint kept); code blocks get a
  header strip with language and Copy; lighter light-mode code fill.
- Runs list: rows under a day heading show only the time of day.
- Artifact search reveal re-centres once the lazy list's extent settles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 00:55:50 +00:00

159 lines
4.8 KiB
Dart

import 'dart:ui' show SemanticsRole;
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/material.dart';
import '../motion/motion.dart';
import 'floating_tab_motion.dart';
import 'glass_pill.dart';
import 'segmented_bar_motion.dart';
/// One tab of a floating tab bar: a round [GlassPill] of [size] with the
/// tab's icon in the middle.
///
/// The selected tab fills its circle with Material `secondaryContainer`
/// and draws its icon in the selected colour; the
/// tint and colour cross-fade when the selection moves. A press sinks the
/// button ([SegmentedPress]), the Material one with its circular ink.
///
/// It is announced like the host navigation controls' tabs: a tab (and a
/// button) named by [label], with its selected state and "tab n of m"
/// in its accessible label. Material shows [label]
/// as a tooltip. The icon is painted above the glass, unclipped, so a badge
/// on its corner can reach past the circle.
class FloatingTabButton extends StatelessWidget {
const FloatingTabButton({
super.key,
required this.motion,
required this.index,
required this.count,
required this.selected,
required this.size,
required this.iconSize,
required this.label,
required this.icon,
required this.onTap,
this.enabled = true,
this.tooltip,
});
/// Shown (and given as the accessibility hint) instead of [label].
final String? tooltip;
/// False greys the tab out and ignores taps; it keeps its place.
final bool enabled;
final FloatingTabMotion motion;
final int index;
final int count;
final bool selected;
final double size;
final double iconSize;
final String label;
/// The icon for the current state (the item's selected icon when selected).
final Widget icon;
final VoidCallback onTap;
/// The selection [Ink] inside each button, for tests.
static const Key fillKey = ValueKey('floating-tab-button.fill');
@override
Widget build(BuildContext context) {
final colors = _colors(context);
final duration = Motion.of(context, Motion.tabSelectDuration);
final button = TweenAnimationBuilder<double>(
tween: Tween(end: selected ? 1 : 0),
duration: duration,
curve: Motion.curve,
builder: (context, t, _) => _button(context, colors, t),
);
return MergeSemantics(
child: Semantics(
role: SemanticsRole.tab,
selected: selected,
enabled: enabled,
hint: tooltip,
button: true,
label: kIsWeb ? label : '$label\n${_tabLabel(context)}',
// Switching tabs does not unfocus a text field (the composer).
child: TextFieldTapRegion(
child: Tooltip(
message: tooltip ?? label,
excludeFromSemantics: true,
child: button,
),
),
),
);
}
String _tabLabel(BuildContext context) => MaterialLocalizations.of(
context,
).tabLabel(tabIndex: index + 1, tabCount: count);
({Color tint, Color selectedIcon, Color icon}) _colors(BuildContext context) {
final scheme = Theme.of(context).colorScheme;
return (
tint: scheme.secondaryContainer,
selectedIcon: scheme.onSecondaryContainer,
icon: enabled
? scheme.onSurfaceVariant
: scheme.onSurface.withValues(alpha: .38),
);
}
/// The button at selection progress [t] (0 unselected, 1 selected).
Widget _button(
BuildContext context,
({Color tint, Color selectedIcon, Color icon}) colors,
double t,
) {
final decoration = ShapeDecoration(
color: colors.tint.withValues(alpha: colors.tint.a * t),
shape: const CircleBorder(),
);
final Widget fill = Ink(
key: fillKey,
decoration: decoration,
child: InkResponse(
onTap: enabled ? onTap : null,
customBorder: const CircleBorder(),
containedInkWell: true,
highlightShape: BoxShape.circle,
),
);
Widget glyph = IconTheme.merge(
data: IconThemeData(
size: iconSize,
color: Color.lerp(colors.icon, colors.selectedIcon, t),
),
child: FloatingTabBounce(motion: motion, index: index, child: icon),
);
final reveal = GlassReveal.maybeOf(context);
if (reveal != null) {
// The icon sits above the glass, so it fades with it here.
glyph = FadeTransition(
opacity: reveal,
alwaysIncludeSemantics: true,
child: glyph,
);
}
return SegmentedPress(
child: SizedBox.square(
dimension: size,
child: Stack(
clipBehavior: Clip.none,
alignment: Alignment.center,
children: [
Positioned.fill(
child: GlassPill(shape: const CircleBorder(), child: fill),
),
IgnorePointer(child: glyph),
],
),
),
);
}
}