Keep chat controls readable and expose labeled app navigation
This commit is contained in:
@@ -29,6 +29,7 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
|
|||||||
final mode = selected == null || !beside
|
final mode = selected == null || !beside
|
||||||
? ChatSidebarMode.expanded
|
? ChatSidebarMode.expanded
|
||||||
: _sidebarMode;
|
: _sidebarMode;
|
||||||
|
final navigation = ShellBarScope.maybeOf(context);
|
||||||
return Stack(
|
return Stack(
|
||||||
fit: StackFit.expand,
|
fit: StackFit.expand,
|
||||||
children: [
|
children: [
|
||||||
@@ -41,6 +42,15 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
|
|||||||
),
|
),
|
||||||
if (mode == ChatSidebarMode.compact)
|
if (mode == ChatSidebarMode.compact)
|
||||||
ChatCompactSidebar(
|
ChatCompactSidebar(
|
||||||
|
navigation: navigation?.registry.canNavigate == true
|
||||||
|
? ShellDestinationMenu(
|
||||||
|
cupertino:
|
||||||
|
chatControlsStyleOf(context) ==
|
||||||
|
ChatControlsStyle.cupertino,
|
||||||
|
current: AppDestination.chat,
|
||||||
|
onSelected: navigation!.registry.navigateTo,
|
||||||
|
)
|
||||||
|
: null,
|
||||||
controller: _sessionsForSidebar,
|
controller: _sessionsForSidebar,
|
||||||
folds: _foldsForSidebar,
|
folds: _foldsForSidebar,
|
||||||
activeSessionId: selected,
|
activeSessionId: selected,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
|
import '../../../ui/adaptive/segmented_bar_overlay.dart';
|
||||||
import '../domain/chat_colors.dart';
|
import '../domain/chat_colors.dart';
|
||||||
import '../ui/sessions/chat_color_palette.dart';
|
import '../ui/sessions/chat_color_palette.dart';
|
||||||
|
|
||||||
@@ -65,12 +66,13 @@ class ChatColorWash extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
final top = MediaQuery.paddingOf(context).top;
|
final top = MediaQuery.paddingOf(context).top;
|
||||||
|
final barHeight = top + SegmentedBarOverlay.reservedHeightOf(context);
|
||||||
return Positioned(
|
return Positioned(
|
||||||
top: top,
|
top: top,
|
||||||
left: 0,
|
left: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
height: fadeBelowBar,
|
height: fadeBelowBar,
|
||||||
child: wash(top, top, top + fadeBelowBar),
|
child: wash(barHeight, barHeight, barHeight + fadeBelowBar),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,10 @@ class ChatModeControl extends StatefulWidget {
|
|||||||
required this.mode,
|
required this.mode,
|
||||||
required this.modeName,
|
required this.modeName,
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
|
this.showLabel = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
final bool showLabel;
|
||||||
final ApiGateway gateway;
|
final ApiGateway gateway;
|
||||||
final String sessionId;
|
final String sessionId;
|
||||||
|
|
||||||
@@ -98,7 +100,8 @@ class _ChatModeControlState extends State<ChatModeControl> {
|
|||||||
final label = _name;
|
final label = _name;
|
||||||
// At phone widths the title and a named mode cannot both remain useful.
|
// At phone widths the title and a named mode cannot both remain useful.
|
||||||
// Keep the mode's shield, whose semantic label and picker still name it.
|
// Keep the mode's shield, whose semantic label and picker still name it.
|
||||||
final iconOnly = MediaQuery.sizeOf(context).width < 600;
|
final iconOnly =
|
||||||
|
!widget.showLabel && MediaQuery.sizeOf(context).width < 600;
|
||||||
final content = Row(
|
final content = Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class ChatModelControl extends StatefulWidget {
|
|||||||
required this.sessionId,
|
required this.sessionId,
|
||||||
required this.session,
|
required this.session,
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
|
this.showLabel = false,
|
||||||
this.answeredBy = '',
|
this.answeredBy = '',
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -29,6 +30,7 @@ class ChatModelControl extends StatefulWidget {
|
|||||||
/// no model on record.
|
/// no model on record.
|
||||||
final String answeredBy;
|
final String answeredBy;
|
||||||
|
|
||||||
|
final bool showLabel;
|
||||||
final ApiGateway gateway;
|
final ApiGateway gateway;
|
||||||
final String sessionId;
|
final String sessionId;
|
||||||
|
|
||||||
@@ -116,7 +118,7 @@ class _ChatModelControlState extends State<ChatModelControl> {
|
|||||||
: widget.answeredBy.isNotEmpty
|
: widget.answeredBy.isNotEmpty
|
||||||
? widget.answeredBy
|
? widget.answeredBy
|
||||||
: '${backend.isEmpty ? 'opencode' : backend} default';
|
: '${backend.isEmpty ? 'opencode' : backend} default';
|
||||||
final compact = MediaQuery.sizeOf(context).width < 600;
|
final compact = !widget.showLabel && MediaQuery.sizeOf(context).width < 600;
|
||||||
final content = compact
|
final content = compact
|
||||||
? const Icon(Icons.memory_outlined)
|
? const Icon(Icons.memory_outlined)
|
||||||
: Row(
|
: Row(
|
||||||
|
|||||||
@@ -48,55 +48,86 @@ class ChatThreadHeader extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final cupertino =
|
final cupertino =
|
||||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||||
return SegmentedBar(
|
return LayoutBuilder(
|
||||||
cupertino: cupertino,
|
builder: (context, constraints) {
|
||||||
automaticallyImplyLeading: false,
|
final narrow = constraints.maxWidth < 800;
|
||||||
// The platform's own Back, so it reads and behaves as every other
|
final bar = SegmentedBar(
|
||||||
// page's Back; its key stays for finders.
|
cupertino: cupertino,
|
||||||
leading: showBack
|
automaticallyImplyLeading: false,
|
||||||
? SegmentedBackButton(
|
// The platform's own Back, so it reads and behaves as every other
|
||||||
key: const Key('chat-back'),
|
// page's Back; its key stays for finders.
|
||||||
cupertino: cupertino,
|
leading: showBack
|
||||||
onPressed: onBack,
|
? SegmentedBackButton(
|
||||||
)
|
key: const Key('chat-back'),
|
||||||
: null,
|
cupertino: cupertino,
|
||||||
title: title.isEmpty ? 'Chat' : title,
|
onPressed: onBack,
|
||||||
subtitle: folder,
|
)
|
||||||
subtitleIcon: cupertino ? CupertinoIcons.folder : Icons.folder_outlined,
|
: null,
|
||||||
onTitlePressed: onInfo,
|
title: title.isEmpty ? 'Chat' : title,
|
||||||
titleSemanticLabel: 'Chat information',
|
subtitle: folder,
|
||||||
titleKey: const Key('chat-info'),
|
subtitleIcon: cupertino
|
||||||
separateActionIslands: true,
|
? CupertinoIcons.folder
|
||||||
actions: [
|
: Icons.folder_outlined,
|
||||||
if (controls.isNotEmpty)
|
onTitlePressed: onInfo,
|
||||||
_ControlIsland(
|
titleSemanticLabel: 'Chat information',
|
||||||
key: const Key('chat-model-permission-island'),
|
titleKey: const Key('chat-info'),
|
||||||
children: controls,
|
separateActionIslands: true,
|
||||||
),
|
actions: [
|
||||||
if (actions.isNotEmpty || moreActions.isNotEmpty)
|
if (!narrow && controls.isNotEmpty)
|
||||||
Row(
|
_ControlIsland(
|
||||||
key: const Key('chat-actions-island'),
|
key: const Key('chat-model-permission-island'),
|
||||||
|
children: controls,
|
||||||
|
),
|
||||||
|
if (actions.isNotEmpty || moreActions.isNotEmpty)
|
||||||
|
Row(
|
||||||
|
key: const Key('chat-actions-island'),
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
...actions,
|
||||||
|
// Unknown action widgets retain their original behavior and stay
|
||||||
|
// visible; only the explicit overflow contract becomes a menu.
|
||||||
|
for (final action in moreActions)
|
||||||
|
if (action is! SegmentedOverflowable) action,
|
||||||
|
if (moreActions.whereType<SegmentedOverflowable>().isNotEmpty)
|
||||||
|
SegmentedMoreButton(
|
||||||
|
cupertino: cupertino,
|
||||||
|
entries: [
|
||||||
|
for (final action
|
||||||
|
in moreActions.whereType<SegmentedOverflowable>())
|
||||||
|
action.overflowEntry,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
bottomPadding: narrow ? 8 : 16,
|
||||||
|
backdrop: backdrop,
|
||||||
|
);
|
||||||
|
return ColoredBox(
|
||||||
|
color: cupertino
|
||||||
|
? CupertinoTheme.of(context).scaffoldBackgroundColor
|
||||||
|
: Theme.of(context).colorScheme.surface,
|
||||||
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
...actions,
|
bar,
|
||||||
// Unknown action widgets retain their original behavior and stay
|
if (narrow && controls.isNotEmpty)
|
||||||
// visible; only the explicit overflow contract becomes a menu.
|
Padding(
|
||||||
for (final action in moreActions)
|
padding: const EdgeInsets.fromLTRB(12, 0, 12, 8),
|
||||||
if (action is! SegmentedOverflowable) action,
|
child: SegmentedPill(
|
||||||
if (moreActions.whereType<SegmentedOverflowable>().isNotEmpty)
|
cupertino: cupertino,
|
||||||
SegmentedMoreButton(
|
child: _ControlIsland(
|
||||||
cupertino: cupertino,
|
key: const Key('chat-model-permission-island'),
|
||||||
entries: [
|
fill: true,
|
||||||
for (final action
|
vertical: constraints.maxWidth < 340,
|
||||||
in moreActions.whereType<SegmentedOverflowable>())
|
children: controls,
|
||||||
action.overflowEntry,
|
),
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
);
|
||||||
bottomPadding: 16,
|
},
|
||||||
backdrop: backdrop,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,11 +135,27 @@ class ChatThreadHeader extends StatelessWidget {
|
|||||||
/// Related selectors share the available width. Each remains a real control;
|
/// Related selectors share the available width. Each remains a real control;
|
||||||
/// they never migrate into the unrelated actions menu.
|
/// they never migrate into the unrelated actions menu.
|
||||||
class _ControlIsland extends StatelessWidget {
|
class _ControlIsland extends StatelessWidget {
|
||||||
const _ControlIsland({super.key, required this.children});
|
const _ControlIsland({
|
||||||
|
super.key,
|
||||||
|
required this.children,
|
||||||
|
this.fill = false,
|
||||||
|
this.vertical = false,
|
||||||
|
});
|
||||||
final List<Widget> children;
|
final List<Widget> children;
|
||||||
|
final bool fill;
|
||||||
|
final bool vertical;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => Row(
|
Widget build(BuildContext context) => vertical
|
||||||
mainAxisSize: MainAxisSize.min,
|
? Column(
|
||||||
children: [for (final child in children) Flexible(child: child)],
|
mainAxisSize: MainAxisSize.min,
|
||||||
);
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: children,
|
||||||
|
)
|
||||||
|
: Row(
|
||||||
|
mainAxisSize: fill ? MainAxisSize.max : MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
for (final child in children)
|
||||||
|
if (fill) Expanded(child: child) else Flexible(child: child),
|
||||||
|
],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1040,8 +1040,8 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
|||||||
// Under the app shell the conversation takes over the app's bar (title,
|
// Under the app shell the conversation takes over the app's bar (title,
|
||||||
// Back, model, information) instead of drawing a second bar below it.
|
// Back, model, information) instead of drawing a second bar below it.
|
||||||
final inShellBar = ShellBar.available(context);
|
final inShellBar = ShellBar.available(context);
|
||||||
// The conversation's bar floats over the transcript's top and history
|
// The measured header owns its space so scrolled text never falls
|
||||||
// scrolls behind it; the transcript ends at the composer's top edge, so
|
// behind the controls; the transcript ends at the composer's top edge, so
|
||||||
// nothing renders behind the composer and the viewport shrinks as the
|
// nothing renders behind the composer and the viewport shrinks as the
|
||||||
// composer grows.
|
// composer grows.
|
||||||
// Every input of the composer comes from this widget's configuration,
|
// Every input of the composer comes from this widget's configuration,
|
||||||
@@ -1072,6 +1072,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
|||||||
final page = FloatingBarOverlay(
|
final page = FloatingBarOverlay(
|
||||||
bar: ChatPaneBarReveal(bar: composerBar),
|
bar: ChatPaneBarReveal(bar: composerBar),
|
||||||
child: SegmentedBarOverlay(
|
child: SegmentedBarOverlay(
|
||||||
|
reserveSpace: true,
|
||||||
bar: ChatPaneBarReveal(bar: _header(context, inShellBar)),
|
bar: ChatPaneBarReveal(bar: _header(context, inShellBar)),
|
||||||
child: NotificationListener<ScrollMetricsNotification>(
|
child: NotificationListener<ScrollMetricsNotification>(
|
||||||
onNotification: _onScrollMetrics,
|
onNotification: _onScrollMetrics,
|
||||||
@@ -1341,6 +1342,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
|||||||
controls: [
|
controls: [
|
||||||
if (hasModel)
|
if (hasModel)
|
||||||
ChatModelControl(
|
ChatModelControl(
|
||||||
|
showLabel: true,
|
||||||
key: ValueKey<String>('chat-model-${widget.sessionId}'),
|
key: ValueKey<String>('chat-model-${widget.sessionId}'),
|
||||||
gateway: widget.gateway,
|
gateway: widget.gateway,
|
||||||
sessionId: widget.sessionId,
|
sessionId: widget.sessionId,
|
||||||
@@ -1356,6 +1358,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
|||||||
/// The session's permission mode, keyed per session so another chat
|
/// The session's permission mode, keyed per session so another chat
|
||||||
/// re-reads its own modes.
|
/// re-reads its own modes.
|
||||||
Widget _modeControl() => ChatModeControl(
|
Widget _modeControl() => ChatModeControl(
|
||||||
|
showLabel: true,
|
||||||
key: ValueKey<String>('chat-mode-${widget.sessionId}'),
|
key: ValueKey<String>('chat-mode-${widget.sessionId}'),
|
||||||
gateway: widget.gateway,
|
gateway: widget.gateway,
|
||||||
sessionId: widget.sessionId,
|
sessionId: widget.sessionId,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import '../../shell/destination.dart';
|
import '../../shell/destination.dart';
|
||||||
import '../../shell/shell_bar.dart';
|
import '../../shell/shell_bar.dart';
|
||||||
|
import '../../shell/shell_destination_menu.dart';
|
||||||
import '../../shell/detail_page.dart';
|
import '../../shell/detail_page.dart';
|
||||||
import '../../shell/empty_detail_pane.dart';
|
import '../../shell/empty_detail_pane.dart';
|
||||||
import '../../shell/list_detail.dart';
|
import '../../shell/list_detail.dart';
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
_bar.onNavigate = _select;
|
||||||
_selected = widget.destination ?? AppDestination.pipelines;
|
_selected = widget.destination ?? AppDestination.pipelines;
|
||||||
_visited.add(_selected);
|
_visited.add(_selected);
|
||||||
HardwareKeyboard.instance.addHandler(_handleDestinationKeyEvent);
|
HardwareKeyboard.instance.addHandler(_handleDestinationKeyEvent);
|
||||||
@@ -192,6 +193,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
|||||||
preferredWidth: _paneWidths.widthFor(_selected.name),
|
preferredWidth: _paneWidths.widthFor(_selected.name),
|
||||||
alignment: AlignmentDirectional.bottomStart,
|
alignment: AlignmentDirectional.bottomStart,
|
||||||
child: FloatingDestinationBar(
|
child: FloatingDestinationBar(
|
||||||
|
showLabels: true,
|
||||||
cupertino: widget.cupertino,
|
cupertino: widget.cupertino,
|
||||||
currentIndex: index,
|
currentIndex: index,
|
||||||
onTap: (value) => _select(shellTabDestinations[value]),
|
onTap: (value) => _select(shellTabDestinations[value]),
|
||||||
|
|||||||
@@ -64,6 +64,12 @@ class ShellBarSpec {
|
|||||||
/// on a run event) then rebuilds nothing, and a badge change rebuilds only
|
/// on a run event) then rebuilds nothing, and a badge change rebuilds only
|
||||||
/// the tab bar.
|
/// the tab bar.
|
||||||
class ShellBarRegistry extends ChangeNotifier {
|
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, (Object, ShellBarSpec)> _specs = {};
|
||||||
final Map<(AppDestination, ShellBadgeKind), int> _badges = {};
|
final Map<(AppDestination, ShellBadgeKind), int> _badges = {};
|
||||||
final _Notifier _bar = _Notifier();
|
final _Notifier _bar = _Notifier();
|
||||||
|
|||||||
@@ -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),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import '../motion/motion.dart';
|
|||||||
import 'floating_bar_layout.dart';
|
import 'floating_bar_layout.dart';
|
||||||
import 'floating_tab_button.dart';
|
import 'floating_tab_button.dart';
|
||||||
import 'floating_tab_motion.dart';
|
import 'floating_tab_motion.dart';
|
||||||
|
import 'floating_destination_labels.dart';
|
||||||
|
|
||||||
/// A tab bar which floats above the bottom edge as a row of separate round
|
/// A tab bar which floats above the bottom edge as a row of separate round
|
||||||
/// frosted [GlassPill] buttons, one per tab, instead of a full-width system
|
/// frosted [GlassPill] buttons, one per tab, instead of a full-width system
|
||||||
@@ -37,10 +38,14 @@ class FloatingDestinationBar extends StatefulWidget {
|
|||||||
required this.items,
|
required this.items,
|
||||||
this.edge = FloatingBarEdge.bottom,
|
this.edge = FloatingBarEdge.bottom,
|
||||||
this.alignment,
|
this.alignment,
|
||||||
|
this.showLabels = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
final bool cupertino;
|
final bool cupertino;
|
||||||
|
|
||||||
|
/// Main app navigation keeps names visible; dense page tabs can stay icons.
|
||||||
|
final bool showLabels;
|
||||||
|
|
||||||
/// Where the row sits in the width it is given, at [FloatingBarEdge.bottom]:
|
/// Where the row sits in the width it is given, at [FloatingBarEdge.bottom]:
|
||||||
/// the trailing end by default. The shell centres its tabs under the list
|
/// the trailing end by default. The shell centres its tabs under the list
|
||||||
/// pane while a list shows beside an open item.
|
/// pane while a list shows beside an open item.
|
||||||
@@ -194,6 +199,17 @@ class _FloatingDestinationBarState extends State<FloatingDestinationBar>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _row(BuildContext context, double width) {
|
Widget _row(BuildContext context, double width) {
|
||||||
|
if (widget.showLabels) {
|
||||||
|
return FloatingDestinationLabels(
|
||||||
|
key: FloatingDestinationBar.rowKey,
|
||||||
|
cupertino: cupertino,
|
||||||
|
labels: [for (final item in items) item.label],
|
||||||
|
selected: currentIndex,
|
||||||
|
buttonBuilder: (index) => _button(context, index),
|
||||||
|
onTap: widget.onTap,
|
||||||
|
backdrop: _backdrop,
|
||||||
|
);
|
||||||
|
}
|
||||||
final gap = _gap(width);
|
final gap = _gap(width);
|
||||||
// As tall as the selected (largest) button; the others are centred on
|
// As tall as the selected (largest) button; the others are centred on
|
||||||
// it, and every gap stays the same while a button grows or shrinks.
|
// it, and every gap stays the same while a button grows or shrinks.
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
import 'dart:ui' show SemanticsRole;
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
/// Content-driven main navigation captions keep names visible without scaling
|
||||||
|
/// down touch targets. Narrow lists and large text wrap into another row.
|
||||||
|
class FloatingDestinationLabels extends StatelessWidget {
|
||||||
|
const FloatingDestinationLabels({
|
||||||
|
super.key,
|
||||||
|
required this.cupertino,
|
||||||
|
required this.labels,
|
||||||
|
required this.selected,
|
||||||
|
required this.buttonBuilder,
|
||||||
|
required this.onTap,
|
||||||
|
required this.backdrop,
|
||||||
|
});
|
||||||
|
final bool cupertino;
|
||||||
|
final List<String> labels;
|
||||||
|
final int selected;
|
||||||
|
final Widget Function(int) buttonBuilder;
|
||||||
|
final ValueChanged<int> onTap;
|
||||||
|
final BackdropKey backdrop;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final color = cupertino
|
||||||
|
? CupertinoColors.label.resolveFrom(context)
|
||||||
|
: Theme.of(context).colorScheme.onSurface;
|
||||||
|
final surface = cupertino
|
||||||
|
? CupertinoColors.secondarySystemBackground.resolveFrom(context)
|
||||||
|
: Theme.of(context).colorScheme.surfaceContainer;
|
||||||
|
final style = cupertino
|
||||||
|
? CupertinoTheme.of(context).textTheme.tabLabelTextStyle
|
||||||
|
: Theme.of(context).textTheme.labelSmall!;
|
||||||
|
return Semantics(
|
||||||
|
role: SemanticsRole.tabBar,
|
||||||
|
container: true,
|
||||||
|
explicitChildNodes: true,
|
||||||
|
child: DecoratedBox(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: surface,
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
child: BackdropGroup(
|
||||||
|
backdropKey: backdrop,
|
||||||
|
child: Wrap(
|
||||||
|
alignment: WrapAlignment.center,
|
||||||
|
crossAxisAlignment: WrapCrossAlignment.center,
|
||||||
|
spacing: 8,
|
||||||
|
runSpacing: 8,
|
||||||
|
children: [
|
||||||
|
for (var index = 0; index < labels.length; index++)
|
||||||
|
GestureDetector(
|
||||||
|
key: ValueKey('destination-label-${labels[index]}'),
|
||||||
|
excludeFromSemantics: true,
|
||||||
|
onTap: () => onTap(index),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
buttonBuilder(index),
|
||||||
|
ExcludeSemantics(
|
||||||
|
child: Text(
|
||||||
|
labels[index],
|
||||||
|
style: style.copyWith(
|
||||||
|
color: color,
|
||||||
|
fontWeight: index == selected
|
||||||
|
? FontWeight.w600
|
||||||
|
: style.fontWeight,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,14 +12,24 @@ class SegmentedBarOverlay extends StatelessWidget {
|
|||||||
super.key,
|
super.key,
|
||||||
required this.bar,
|
required this.bar,
|
||||||
required this.child,
|
required this.child,
|
||||||
|
this.reserveSpace = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
final Widget bar;
|
final Widget bar;
|
||||||
final Widget child;
|
final Widget child;
|
||||||
|
|
||||||
|
/// Gives reading content its own viewport below the measured bar.
|
||||||
|
final bool reserveSpace;
|
||||||
|
|
||||||
|
static double reservedHeightOf(BuildContext context) =>
|
||||||
|
context
|
||||||
|
.dependOnInheritedWidgetOfExactType<_ReservedBarHeight>()
|
||||||
|
?.height ??
|
||||||
|
0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => CustomMultiChildLayout(
|
Widget build(BuildContext context) => CustomMultiChildLayout(
|
||||||
delegate: _OverlayLayout(),
|
delegate: _OverlayLayout(reserveSpace),
|
||||||
children: [
|
children: [
|
||||||
// Painted first, so the bar draws (and takes taps) above it.
|
// Painted first, so the bar draws (and takes taps) above it.
|
||||||
LayoutId(
|
LayoutId(
|
||||||
@@ -32,9 +42,14 @@ class SegmentedBarOverlay extends StatelessWidget {
|
|||||||
final media = MediaQuery.of(context);
|
final media = MediaQuery.of(context);
|
||||||
return MediaQuery(
|
return MediaQuery(
|
||||||
data: media.copyWith(
|
data: media.copyWith(
|
||||||
padding: media.padding.copyWith(top: barHeight),
|
padding: media.padding.copyWith(
|
||||||
|
top: reserveSpace ? 0 : barHeight,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: _ReservedBarHeight(
|
||||||
|
height: reserveSpace ? barHeight : 0,
|
||||||
|
child: child,
|
||||||
),
|
),
|
||||||
child: child,
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -70,6 +85,8 @@ class _ContentConstraints extends BoxConstraints {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _OverlayLayout extends MultiChildLayoutDelegate {
|
class _OverlayLayout extends MultiChildLayoutDelegate {
|
||||||
|
_OverlayLayout(this.reserveSpace);
|
||||||
|
final bool reserveSpace;
|
||||||
@override
|
@override
|
||||||
void performLayout(Size size) {
|
void performLayout(Size size) {
|
||||||
final bar = layoutChild(
|
final bar = layoutChild(
|
||||||
@@ -82,11 +99,26 @@ class _OverlayLayout extends MultiChildLayoutDelegate {
|
|||||||
positionChild(_Slot.bar, Offset.zero);
|
positionChild(_Slot.bar, Offset.zero);
|
||||||
layoutChild(
|
layoutChild(
|
||||||
_Slot.content,
|
_Slot.content,
|
||||||
_ContentConstraints(size, barHeight: bar.height),
|
_ContentConstraints(
|
||||||
|
Size(
|
||||||
|
size.width,
|
||||||
|
(size.height - (reserveSpace ? bar.height : 0)).clamp(0, size.height),
|
||||||
|
),
|
||||||
|
barHeight: bar.height,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
positionChild(_Slot.content, Offset.zero);
|
positionChild(_Slot.content, Offset(0, reserveSpace ? bar.height : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool shouldRelayout(_OverlayLayout oldDelegate) => false;
|
bool shouldRelayout(_OverlayLayout oldDelegate) =>
|
||||||
|
reserveSpace != oldDelegate.reserveSpace;
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ReservedBarHeight extends InheritedWidget {
|
||||||
|
const _ReservedBarHeight({required this.height, required super.child});
|
||||||
|
final double height;
|
||||||
|
@override
|
||||||
|
bool updateShouldNotify(_ReservedBarHeight oldWidget) =>
|
||||||
|
height != oldWidget.height;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ Widget _app(_Gateway gateway, {int sync = 0}) => MaterialApp(
|
|||||||
body: ChatScreen(gateway: gateway, syncToken: sync),
|
body: ChatScreen(gateway: gateway, syncToken: sync),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
Future<_Gateway> _setup(WidgetTester tester) async {
|
Future<_Gateway> _setup(WidgetTester tester, {bool inShell = false}) async {
|
||||||
SharedPreferences.setMockInitialValues({});
|
SharedPreferences.setMockInitialValues({});
|
||||||
tester.view.physicalSize = const Size(1800, 1000);
|
tester.view.physicalSize = const Size(1800, 1000);
|
||||||
tester.view.devicePixelRatio = 1;
|
tester.view.devicePixelRatio = 1;
|
||||||
@@ -60,7 +60,21 @@ Future<_Gateway> _setup(WidgetTester tester) async {
|
|||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
addTearDown(gateway.close);
|
addTearDown(gateway.close);
|
||||||
await tester.pumpWidget(_app(gateway));
|
await tester.pumpWidget(
|
||||||
|
inShell
|
||||||
|
? MaterialApp(
|
||||||
|
home: AdaptiveShell(
|
||||||
|
cupertino: false,
|
||||||
|
destination: AppDestination.chat,
|
||||||
|
destinationBodies: {
|
||||||
|
AppDestination.chat: (_) => ChatScreen(gateway: gateway),
|
||||||
|
AppDestination.runs: (_) =>
|
||||||
|
const Center(child: Text('Runs destination')),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: _app(gateway),
|
||||||
|
);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.tap(find.text('Chat a').first);
|
await tester.tap(find.text('Chat a').first);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
@@ -79,6 +93,35 @@ Future<void> _split(WidgetTester tester, String id, String action) async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
testWidgets(
|
||||||
|
'compact navigation reaches Runs and returns without losing draft',
|
||||||
|
(tester) async {
|
||||||
|
await _setup(tester, inShell: true);
|
||||||
|
final state = tester.state(_thread('a'));
|
||||||
|
await tester.enterText(_input('a'), 'Keep compact draft');
|
||||||
|
await tester.drag(
|
||||||
|
find.byKey(const ValueKey('list-detail-divider')),
|
||||||
|
const Offset(-500, 0),
|
||||||
|
);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text('Menu'), findsOneWidget);
|
||||||
|
await tester.tap(find.text('Menu'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.text('Runs'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text('Runs destination'), findsOneWidget);
|
||||||
|
await tester.tap(find.byTooltip('Chat'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text('Menu'), findsOneWidget);
|
||||||
|
expect(tester.state(_thread('a')), same(state));
|
||||||
|
expect(
|
||||||
|
tester.widget<EditableText>(_input('a')).controller.text,
|
||||||
|
'Keep compact draft',
|
||||||
|
);
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
testWidgets('phone peeks fit a small keyboard viewport at large text', (
|
testWidgets('phone peeks fit a small keyboard viewport at large text', (
|
||||||
tester,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
|
|||||||
@@ -226,44 +226,47 @@ void main() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Cupertino mode is icon-only below 600px', (tester) async {
|
testWidgets(
|
||||||
if (!cupertino) return;
|
'Cupertino narrow header displays the current permission value',
|
||||||
final semantics = tester.ensureSemantics();
|
(tester) async {
|
||||||
_size(tester, const Size(560, 800));
|
if (!cupertino) return;
|
||||||
await _pump(
|
final semantics = tester.ensureSemantics();
|
||||||
tester,
|
_size(tester, const Size(560, 800));
|
||||||
cupertino: true,
|
await _pump(
|
||||||
messages: 1,
|
tester,
|
||||||
session: const {
|
cupertino: true,
|
||||||
'id': 's',
|
messages: 1,
|
||||||
'backend': 'opencode',
|
session: const {
|
||||||
'model': 'p/sonnet-4-5',
|
'id': 's',
|
||||||
'mode': 'default',
|
'backend': 'opencode',
|
||||||
'mode_name': 'Ask for permission',
|
'model': 'p/sonnet-4-5',
|
||||||
},
|
'mode': 'default',
|
||||||
);
|
'mode_name': 'Ask for permission',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
final mode = find.byKey(const Key('chat-mode'));
|
final mode = find.byKey(const Key('chat-mode'));
|
||||||
expect(mode, findsOneWidget);
|
expect(mode, findsOneWidget);
|
||||||
expect(
|
expect(
|
||||||
find.descendant(of: mode, matching: find.text('Ask for permission')),
|
find.descendant(of: mode, matching: find.text('Ask for permission')),
|
||||||
findsNothing,
|
findsOneWidget,
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
tester.getSemantics(mode).label,
|
tester.getSemantics(mode).label,
|
||||||
contains('Change mode, currently Ask for permission'),
|
contains('Change mode, currently Ask for permission'),
|
||||||
);
|
);
|
||||||
await tester.tap(mode);
|
await tester.tap(mode);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(find.byKey(const Key('chat-mode-sheet')), findsOneWidget);
|
expect(find.byKey(const Key('chat-mode-sheet')), findsOneWidget);
|
||||||
// The fixture has no chat_modes catalog, but the recorded session mode
|
// The fixture has no chat_modes catalog, but the recorded session mode
|
||||||
// remains visible in the sheet.
|
// remains visible in the sheet.
|
||||||
expect(
|
expect(
|
||||||
find.byKey(const ValueKey('chat-mode-option-default')),
|
find.byKey(const ValueKey('chat-mode-option-default')),
|
||||||
findsOneWidget,
|
findsOneWidget,
|
||||||
);
|
);
|
||||||
expect(find.text('Ask for permission'), findsOneWidget);
|
expect(find.text('Ask for permission'), findsWidgets);
|
||||||
semantics.dispose();
|
semantics.dispose();
|
||||||
});
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,8 +65,11 @@ void main() {
|
|||||||
) async {
|
) async {
|
||||||
await _pump(tester, peek: false, reveal: 1);
|
await _pump(tester, peek: false, reveal: 1);
|
||||||
expect(header, findsOneWidget);
|
expect(header, findsOneWidget);
|
||||||
expect(listTop(tester), greaterThan(8));
|
expect(listTop(tester), 8);
|
||||||
expect(listTop(tester), closeTo(tester.getSize(header).height + 8, .5));
|
expect(
|
||||||
|
tester.getTopLeft(find.byType(ChatTranscriptScrollView)).dy,
|
||||||
|
closeTo(tester.getBottomLeft(header).dy, .5),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('a resting peek keeps its bar offstage and reads from the top', (
|
testWidgets('a resting peek keeps its bar offstage and reads from the top', (
|
||||||
@@ -95,8 +98,8 @@ void main() {
|
|||||||
await _pump(tester, peek: true, reveal: .4);
|
await _pump(tester, peek: true, reveal: .4);
|
||||||
expect(header, findsOneWidget);
|
expect(header, findsOneWidget);
|
||||||
expect(
|
expect(
|
||||||
listTop(tester),
|
tester.getTopLeft(find.byType(ChatTranscriptScrollView)).dy,
|
||||||
closeTo(tester.getSize(header).height * .4 + 8, .5),
|
closeTo(tester.getSize(header).height * .4, .5),
|
||||||
);
|
);
|
||||||
final fade = tester.widget<FadeTransition>(
|
final fade = tester.widget<FadeTransition>(
|
||||||
find.ancestor(of: header, matching: find.byType(FadeTransition)).first,
|
find.ancestor(of: header, matching: find.byType(FadeTransition)).first,
|
||||||
|
|||||||
@@ -41,62 +41,69 @@ void main() {
|
|||||||
for (final cupertino in [false, true]) {
|
for (final cupertino in [false, true]) {
|
||||||
final host = cupertino ? 'Cupertino' : 'Material';
|
final host = cupertino ? 'Cupertino' : 'Material';
|
||||||
|
|
||||||
testWidgets('$host header keeps back, title pill and model on one row', (
|
testWidgets(
|
||||||
tester,
|
'$host narrow header keeps native back/title and readable model',
|
||||||
) async {
|
(tester) async {
|
||||||
_useNarrowText(tester);
|
_useNarrowText(tester);
|
||||||
final semantics = tester.ensureSemantics();
|
final semantics = tester.ensureSemantics();
|
||||||
final gateway = FakeChatGateway();
|
final gateway = FakeChatGateway();
|
||||||
addTearDown(gateway.close);
|
addTearDown(gateway.close);
|
||||||
gateway.history = (_) async => chatPage(const []);
|
gateway.history = (_) async => chatPage(const []);
|
||||||
gateway.subscribe = () async => const {};
|
gateway.subscribe = () async => const {};
|
||||||
var backed = 0;
|
var backed = 0;
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
_host(
|
_host(
|
||||||
ChatThreadView(
|
ChatThreadView(
|
||||||
gateway: gateway,
|
gateway: gateway,
|
||||||
sessionId: 's',
|
sessionId: 's',
|
||||||
title: _title,
|
title: _title,
|
||||||
session: _session,
|
session: _session,
|
||||||
onBack: () => backed++,
|
onBack: () => backed++,
|
||||||
|
),
|
||||||
|
cupertino: cupertino,
|
||||||
),
|
),
|
||||||
cupertino: cupertino,
|
);
|
||||||
),
|
await tester.pumpAndSettle();
|
||||||
);
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
|
|
||||||
final title = find.text(_title);
|
final title = find.text(_title);
|
||||||
final model = find.byKey(const Key('chat-model'));
|
final model = find.byKey(const Key('chat-model'));
|
||||||
final info = find.byKey(const Key('chat-info'));
|
final info = find.byKey(const Key('chat-info'));
|
||||||
final back = find.byKey(const Key('chat-back'));
|
final back = find.byKey(const Key('chat-back'));
|
||||||
expect(title, findsOneWidget);
|
expect(title, findsOneWidget);
|
||||||
expect(model, findsOneWidget);
|
expect(model, findsOneWidget);
|
||||||
expect(info, findsOneWidget);
|
expect(info, findsOneWidget);
|
||||||
expect(back, findsOneWidget);
|
expect(back, findsOneWidget);
|
||||||
expect(tester.takeException(), isNull);
|
expect(tester.takeException(), isNull);
|
||||||
// Back is the platform's own control, as on every other page.
|
// Back is the platform's own control, as on every other page.
|
||||||
expect(
|
expect(
|
||||||
find.descendant(of: back, matching: findNativeBack()),
|
find.descendant(of: back, matching: findNativeBack()),
|
||||||
findsOneWidget,
|
findsOneWidget,
|
||||||
);
|
);
|
||||||
|
|
||||||
// One floating row of separate pieces: the round Back, the title pill
|
// One floating row of separate pieces: the round Back, the title pill
|
||||||
// (which is the information control and holds the title), then the
|
// (which is the information control and holds the title), then the
|
||||||
// model in the trailing pill.
|
// model in the trailing pill.
|
||||||
double centerY(Finder finder) => tester.getCenter(finder).dy;
|
double centerY(Finder finder) => tester.getCenter(finder).dy;
|
||||||
expect((centerY(back) - centerY(info)).abs(), lessThan(16));
|
expect((centerY(back) - centerY(info)).abs(), lessThan(16));
|
||||||
expect((centerY(model) - centerY(info)).abs(), lessThan(16));
|
expect(
|
||||||
expect(find.descendant(of: info, matching: title), findsOneWidget);
|
tester.getTopLeft(model).dy,
|
||||||
double right(Finder finder) => tester.getTopRight(finder).dx;
|
greaterThanOrEqualTo(tester.getBottomLeft(info).dy),
|
||||||
expect(right(back), lessThanOrEqualTo(tester.getTopLeft(info).dx));
|
);
|
||||||
expect(right(info), lessThanOrEqualTo(tester.getTopLeft(model).dx));
|
expect(find.descendant(of: info, matching: title), findsOneWidget);
|
||||||
|
double right(Finder finder) => tester.getTopRight(finder).dx;
|
||||||
|
expect(right(back), lessThanOrEqualTo(tester.getTopLeft(info).dx));
|
||||||
|
expect(
|
||||||
|
find.textContaining('an-extremely-long-recorded-model-id'),
|
||||||
|
findsOneWidget,
|
||||||
|
);
|
||||||
|
|
||||||
await tester.tap(back);
|
await tester.tap(back);
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(backed, 1);
|
expect(backed, 1);
|
||||||
semantics.dispose();
|
semantics.dispose();
|
||||||
});
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final cupertino in [false, true]) {
|
for (final cupertino in [false, true]) {
|
||||||
@@ -151,10 +158,17 @@ void main() {
|
|||||||
final actions = find.byKey(const Key('chat-actions-island'));
|
final actions = find.byKey(const Key('chat-actions-island'));
|
||||||
expect(selectors, findsOneWidget);
|
expect(selectors, findsOneWidget);
|
||||||
expect(actions, findsOneWidget);
|
expect(actions, findsOneWidget);
|
||||||
expect(
|
if (width >= 800) {
|
||||||
tester.getTopRight(selectors).dx,
|
expect(
|
||||||
lessThan(tester.getTopLeft(actions).dx),
|
tester.getTopRight(selectors).dx,
|
||||||
);
|
lessThan(tester.getTopLeft(actions).dx),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
expect(
|
||||||
|
tester.getTopLeft(selectors).dy,
|
||||||
|
greaterThanOrEqualTo(tester.getBottomLeft(actions).dy),
|
||||||
|
);
|
||||||
|
}
|
||||||
expect(find.byKey(const Key('chat-next')), findsNothing);
|
expect(find.byKey(const Key('chat-next')), findsNothing);
|
||||||
expect(find.text('Next chat'), findsNothing);
|
expect(find.text('Next chat'), findsNothing);
|
||||||
expect(find.byKey(const Key('chat-model')), findsOneWidget);
|
expect(find.byKey(const Key('chat-model')), findsOneWidget);
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pipelines_app/shell/shell_destination_menu.dart';
|
||||||
|
import 'package:pipelines_app/shell/destination.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
for (final cupertino in [false, true]) {
|
||||||
|
testWidgets('compact menu exposes all named destinations ($cupertino)', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
AppDestination? selected;
|
||||||
|
final menu = ShellDestinationMenu(
|
||||||
|
cupertino: cupertino,
|
||||||
|
current: AppDestination.chat,
|
||||||
|
onSelected: (value) => selected = value,
|
||||||
|
);
|
||||||
|
await tester.pumpWidget(
|
||||||
|
cupertino
|
||||||
|
? CupertinoApp(home: CupertinoPageScaffold(child: menu))
|
||||||
|
: MaterialApp(home: Scaffold(body: menu)),
|
||||||
|
);
|
||||||
|
await tester.tap(find.text('Menu'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
for (final name in ['Pipelines', 'Runs', 'Chat', 'Search', 'Settings']) {
|
||||||
|
expect(find.text(name), findsOneWidget);
|
||||||
|
}
|
||||||
|
await tester.tap(find.text('Runs'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(selected, AppDestination.runs);
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/segmented_bar_overlay.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('reserved header gives scrolling text an independent viewport', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
final scroll = ScrollController();
|
||||||
|
addTearDown(scroll.dispose);
|
||||||
|
double? topPadding;
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
body: SegmentedBarOverlay(
|
||||||
|
reserveSpace: true,
|
||||||
|
bar: const SizedBox(key: Key('header'), height: 80),
|
||||||
|
child: Builder(
|
||||||
|
builder: (context) {
|
||||||
|
topPadding = MediaQuery.paddingOf(context).top;
|
||||||
|
return ListView(
|
||||||
|
controller: scroll,
|
||||||
|
children: List.generate(
|
||||||
|
50,
|
||||||
|
(i) => ListTile(title: Text('Line $i')),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
tester.getTopLeft(find.byType(ListView)).dy,
|
||||||
|
tester.getBottomLeft(find.byKey(const Key('header'))).dy,
|
||||||
|
);
|
||||||
|
expect(topPadding, 0);
|
||||||
|
await tester.drag(find.byType(ListView), const Offset(0, -300));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(scroll.offset, greaterThan(0));
|
||||||
|
expect(tester.getTopLeft(find.byType(ListView)).dy, 80);
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -95,6 +95,10 @@ JsonMap _chatRow(int i) {
|
|||||||
'title': _colorTitles[i % _colorTitles.length],
|
'title': _colorTitles[i % _colorTitles.length],
|
||||||
'directory': i.isEven ? '/workspace/demo' : '/workspace/site',
|
'directory': i.isEven ? '/workspace/demo' : '/workspace/site',
|
||||||
'model': 'claude-opus',
|
'model': 'claude-opus',
|
||||||
|
if (_params['header'] == '1') ...{
|
||||||
|
'mode': 'default',
|
||||||
|
'mode_name': 'Ask for permission',
|
||||||
|
},
|
||||||
'backend': 'claude',
|
'backend': 'claude',
|
||||||
'updated_at': DateTime.now().millisecondsSinceEpoch - (i + 1) * 600000,
|
'updated_at': DateTime.now().millisecondsSinceEpoch - (i + 1) * 600000,
|
||||||
if (_colorStarred.contains(i)) 'starred': true,
|
if (_colorStarred.contains(i)) 'starred': true,
|
||||||
|
|||||||
Reference in New Issue
Block a user