Keep chat controls readable and expose labeled app navigation

This commit is contained in:
2026-11-07 20:46:02 +00:00
parent 68c0ad3caa
commit 4bbbe01633
20 changed files with 582 additions and 159 deletions
+2
View File
@@ -74,6 +74,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
@override
void initState() {
super.initState();
_bar.onNavigate = _select;
_selected = widget.destination ?? AppDestination.pipelines;
_visited.add(_selected);
HardwareKeyboard.instance.addHandler(_handleDestinationKeyEvent);
@@ -192,6 +193,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
preferredWidth: _paneWidths.widthFor(_selected.name),
alignment: AlignmentDirectional.bottomStart,
child: FloatingDestinationBar(
showLabels: true,
cupertino: widget.cupertino,
currentIndex: index,
onTap: (value) => _select(shellTabDestinations[value]),
+6
View File
@@ -64,6 +64,12 @@ class ShellBarSpec {
/// on a run event) then rebuilds nothing, and a badge change rebuilds only
/// the tab bar.
class ShellBarRegistry extends ChangeNotifier {
ValueChanged<AppDestination>? onNavigate;
bool get canNavigate => onNavigate != null && !_disposed;
void navigateTo(AppDestination destination) {
if (!_disposed) onNavigate?.call(destination);
}
final Map<AppDestination, (Object, ShellBarSpec)> _specs = {};
final Map<(AppDestination, ShellBadgeKind), int> _badges = {};
final _Notifier _bar = _Notifier();
+69
View File
@@ -0,0 +1,69 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'destination.dart';
/// Native, labeled destination access when the full tab bar cannot fit a rail.
class ShellDestinationMenu extends StatelessWidget {
const ShellDestinationMenu({
super.key,
required this.cupertino,
required this.current,
required this.onSelected,
});
final bool cupertino;
final AppDestination current;
final ValueChanged<AppDestination> onSelected;
Future<void> _choose(BuildContext context) async {
final value = await showCupertinoModalPopup<AppDestination>(
context: context,
builder: (context) => CupertinoActionSheet(
title: const Text('Main navigation'),
actions: [
for (final destination in AppDestination.values)
CupertinoActionSheetAction(
isDefaultAction: destination == current,
onPressed: () => Navigator.pop(context, destination),
child: Text(destinationDetails(destination).label),
),
],
cancelButton: CupertinoActionSheetAction(
onPressed: () => Navigator.pop(context),
child: const Text('Cancel'),
),
),
);
if (value != null && context.mounted) onSelected(value);
}
@override
Widget build(BuildContext context) {
final child = Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(cupertino ? CupertinoIcons.square_grid_2x2 : Icons.apps),
const Text('Menu'),
],
);
if (cupertino) {
return Semantics(
button: true,
label: 'Main navigation',
child: CupertinoButton(onPressed: () => _choose(context), child: child),
);
}
return PopupMenuButton<AppDestination>(
tooltip: 'Main navigation',
onSelected: onSelected,
itemBuilder: (context) => [
for (final destination in AppDestination.values)
CheckedPopupMenuItem(
value: destination,
checked: destination == current,
child: Text(destinationDetails(destination).label),
),
],
child: Padding(padding: const EdgeInsets.all(8), child: child),
);
}
}