Merge branch 'worktree-agent-a992ffc22d3f335ed' into integrate/tabs-v2
This commit is contained in:
@@ -7,6 +7,11 @@ const double kFloatingBarWideWidth = 600;
|
||||
/// The gap between a floating tab bar and the edges (and bottom safe area).
|
||||
const double kFloatingBarMargin = 16;
|
||||
|
||||
/// The gap between two floating bars stacked at the bottom right of a wide
|
||||
/// window: the shell's tab bar and, above it, an open item's own tabs (the
|
||||
/// chat composer adds its own padding on top of this).
|
||||
const double kStackedBarGap = 12;
|
||||
|
||||
/// [padding] with the floating bar's clearance added at the bottom.
|
||||
///
|
||||
/// A scrollable under a floating bar (see [FloatingBarOverlay] and the shell)
|
||||
|
||||
@@ -17,6 +17,10 @@ import 'glass_pill.dart';
|
||||
/// way it keeps [kFloatingBarMargin] above the bottom safe area. Only the pill
|
||||
/// takes taps: the space beside it reaches the content behind.
|
||||
///
|
||||
/// The tabs show icons only. Each tab's label stays its accessible name (and
|
||||
/// the Material tooltip), so screen readers still announce it; the icons must
|
||||
/// be distinct within a bar.
|
||||
///
|
||||
/// The controls inside remain the platform navigation controls (Material
|
||||
/// [NavigationBar], Cupertino [CupertinoTabBar]), so tab semantics (selected
|
||||
/// state, "tab n of m") come from the host. The Cupertino path builds no
|
||||
@@ -41,11 +45,17 @@ class FloatingDestinationBar extends StatelessWidget {
|
||||
final ValueChanged<int> onTap;
|
||||
final List<FloatingDestinationItem> items;
|
||||
|
||||
/// Height of the Material bar inside the pill (the stock bar is 80).
|
||||
static const double materialHeight = 64;
|
||||
/// Height of the Material bar inside the pill (the stock bar is 80; with
|
||||
/// labels hidden the icon and its indicator need less).
|
||||
static const double materialHeight = 56;
|
||||
|
||||
/// Height of the Cupertino bar inside the pill (the stock bar is 50).
|
||||
static const double cupertinoHeight = 54;
|
||||
/// Height of the Cupertino bar inside the pill (the stock bar's 50).
|
||||
static const double cupertinoHeight = 50;
|
||||
|
||||
/// Width of one icon-only tab on a wide window: a comfortable touch target
|
||||
/// around the Material indicator (64) or the Cupertino selection capsule.
|
||||
static const double materialTabWidth = 72;
|
||||
static const double cupertinoTabWidth = 64;
|
||||
|
||||
/// The side margin at [FloatingBarEdge.top], matching the top bar's own.
|
||||
static const double topMargin = 12;
|
||||
@@ -114,41 +124,10 @@ class FloatingDestinationBar extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// The width the tabs need side by side: every tab as wide as the widest
|
||||
/// label (as the host lays them out), never narrower than a comfortable
|
||||
/// touch target.
|
||||
double _tabsWidth(BuildContext context) {
|
||||
final TextStyle? style;
|
||||
final TextScaler scaler;
|
||||
final double minimum;
|
||||
if (cupertino) {
|
||||
style = CupertinoTheme.of(context).textTheme.tabLabelTextStyle;
|
||||
scaler = TextScaler.noScaling;
|
||||
minimum = 76;
|
||||
} else {
|
||||
final theme = Theme.of(context);
|
||||
style =
|
||||
theme.navigationBarTheme.labelTextStyle?.resolve(const {
|
||||
WidgetState.selected,
|
||||
}) ??
|
||||
theme.textTheme.labelMedium;
|
||||
// NavigationBar clamps its labels at 1.3x.
|
||||
scaler = MediaQuery.textScalerOf(context).clamp(maxScaleFactor: 1.3);
|
||||
minimum = 88;
|
||||
}
|
||||
var widest = 0.0;
|
||||
for (final item in items) {
|
||||
final painter = TextPainter(
|
||||
text: TextSpan(text: item.label, style: style),
|
||||
textScaler: scaler,
|
||||
textDirection: Directionality.of(context),
|
||||
maxLines: 1,
|
||||
)..layout();
|
||||
widest = math.max(widest, painter.width);
|
||||
painter.dispose();
|
||||
}
|
||||
return math.max(minimum, widest + 24) * items.length;
|
||||
}
|
||||
/// The width the icon-only tabs need side by side. Icons do not scale with
|
||||
/// text, so the pill keeps its size at any text scale.
|
||||
double _tabsWidth(BuildContext context) =>
|
||||
(cupertino ? cupertinoTabWidth : materialTabWidth) * items.length;
|
||||
|
||||
Widget _materialBar(BuildContext context) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
@@ -159,7 +138,9 @@ class FloatingDestinationBar extends StatelessWidget {
|
||||
surfaceTintColor: Colors.transparent,
|
||||
indicatorColor: scheme.secondaryContainer,
|
||||
height: materialHeight,
|
||||
labelBehavior: NavigationDestinationLabelBehavior.alwaysShow,
|
||||
// Icons only; the label remains each tab's accessible name and its
|
||||
// tooltip.
|
||||
labelBehavior: NavigationDestinationLabelBehavior.alwaysHide,
|
||||
),
|
||||
child: NavigationBar(
|
||||
selectedIndex: currentIndex,
|
||||
@@ -177,10 +158,10 @@ class FloatingDestinationBar extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// The stock Cupertino bar, transparent inside the pill. Each tab's label is
|
||||
/// drawn with its icon (in the bar's own label style and colours) so the
|
||||
/// item's key covers the whole tab, and the selected tab's icon sits in a
|
||||
/// tinted capsule so the selection reads at a glance, not by colour alone.
|
||||
/// The stock Cupertino bar, transparent inside the pill. Each tab shows its
|
||||
/// icon only, named by its label for accessibility; the item's key covers
|
||||
/// the whole tab, and the selected tab's icon sits in a tinted capsule so
|
||||
/// the selection reads at a glance, not by colour alone.
|
||||
Widget _cupertinoBar(BuildContext context) {
|
||||
final active = CupertinoTheme.of(context).primaryColor;
|
||||
Widget tab(FloatingDestinationItem item, {required bool selected}) {
|
||||
@@ -199,14 +180,7 @@ class FloatingDestinationBar extends StatelessWidget {
|
||||
}
|
||||
return KeyedSubtree(
|
||||
key: item.key,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
icon,
|
||||
const SizedBox(height: 2),
|
||||
Text(item.label, maxLines: 1, softWrap: false),
|
||||
],
|
||||
),
|
||||
child: Semantics(label: item.label, child: icon),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -218,7 +192,7 @@ class FloatingDestinationBar extends StatelessWidget {
|
||||
// Secondary-label translucency over glass falls below text contrast
|
||||
// requirements. The host label role remains readable in both themes.
|
||||
inactiveColor: CupertinoColors.label.resolveFrom(context),
|
||||
iconSize: 24,
|
||||
iconSize: 26,
|
||||
height: cupertinoHeight,
|
||||
currentIndex: currentIndex,
|
||||
onTap: onTap,
|
||||
@@ -244,9 +218,11 @@ class FloatingDestinationItem {
|
||||
});
|
||||
|
||||
final Widget icon;
|
||||
|
||||
/// The tab's accessible name (and Material tooltip); not drawn.
|
||||
final String label;
|
||||
final Widget? selectedIcon;
|
||||
|
||||
/// Identifies the whole tab (icon and label), for tests and automation.
|
||||
/// Identifies the whole tab, for tests and automation.
|
||||
final Key? key;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user