merge(app): land section bodies, arrow keys and chat bar
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import '../../../ui/input/arrow_key_pager.dart';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
@@ -219,7 +220,7 @@ class _ArtifactViewerPageState extends State<ArtifactViewerPage> {
|
|||||||
final title = page == null
|
final title = page == null
|
||||||
? artifactViewerTitle
|
? artifactViewerTitle
|
||||||
: artifactDisplayName(page.artifact);
|
: artifactDisplayName(page.artifact);
|
||||||
final body = page == null || plan == null
|
Widget body = page == null || plan == null
|
||||||
? const Center(child: Text('No previewable artifacts recorded.'))
|
? const Center(child: Text('No previewable artifacts recorded.'))
|
||||||
: ArtifactViewerBody(
|
: ArtifactViewerBody(
|
||||||
page: page,
|
page: page,
|
||||||
@@ -239,6 +240,12 @@ class _ArtifactViewerPageState extends State<ArtifactViewerPage> {
|
|||||||
onOpen: plan.resolved == null ? () {} : () => _open(plan.resolved!),
|
onOpen: plan.resolved == null ? () {} : () => _open(plan.resolved!),
|
||||||
onCopy: plan.resolved == null ? () {} : () => _copy(plan.resolved!),
|
onCopy: plan.resolved == null ? () {} : () => _copy(plan.resolved!),
|
||||||
);
|
);
|
||||||
|
// Left/right arrows walk the same list as the Previous/Next buttons.
|
||||||
|
body = ArrowKeyPager(
|
||||||
|
onPrevious: () => _step(-1),
|
||||||
|
onNext: () => _step(1),
|
||||||
|
child: body,
|
||||||
|
);
|
||||||
if (usesCupertinoHost(context)) {
|
if (usesCupertinoHost(context)) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
backgroundColor: CupertinoColors.systemGroupedBackground,
|
backgroundColor: CupertinoColors.systemGroupedBackground,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import '../../../ui/input/arrow_key_pager.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
@@ -287,12 +288,17 @@ class _FileDiffPageState extends State<FileDiffPage> {
|
|||||||
onPrevious: _index > 0 ? () => _step(-1) : null,
|
onPrevious: _index > 0 ? () => _step(-1) : null,
|
||||||
onNext: _index < count - 1 ? () => _step(1) : null,
|
onNext: _index < count - 1 ? () => _step(1) : null,
|
||||||
);
|
);
|
||||||
final body = Column(
|
// Left/right arrows step between changed files, like the chevrons.
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
final body = ArrowKeyPager(
|
||||||
children: [
|
onPrevious: _index > 0 ? () => _step(-1) : null,
|
||||||
Expanded(child: viewer),
|
onNext: _index < count - 1 ? () => _step(1) : null,
|
||||||
?pager,
|
child: Column(
|
||||||
],
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
Expanded(child: viewer),
|
||||||
|
?pager,
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
if (cupertino) {
|
if (cupertino) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
|
|
||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
|
import '../../../shell/shell_bar.dart';
|
||||||
import '../data/chat_repository.dart';
|
import '../data/chat_repository.dart';
|
||||||
import '../domain/chat_activity_detail.dart';
|
import '../domain/chat_activity_detail.dart';
|
||||||
import '../domain/chat_notice.dart';
|
import '../domain/chat_notice.dart';
|
||||||
@@ -631,73 +632,77 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
|||||||
// Place the first loaded transcript and keep a following view at the end.
|
// Place the first loaded transcript and keep a following view at the end.
|
||||||
// Scheduling after the build means the new extent is already laid out.
|
// Scheduling after the build means the new extent is already laid out.
|
||||||
_scheduleFollow();
|
_scheduleFollow();
|
||||||
return Column(
|
// Under the app shell the conversation takes over the app's bar (title,
|
||||||
|
// Back, model, information) instead of drawing a second bar below it.
|
||||||
|
final inShellBar = ShellBar.available(context);
|
||||||
|
final column = Column(
|
||||||
children: [
|
children: [
|
||||||
// The conversation's own bar first, outside the transcript's scroller,
|
// The conversation's own bar first, outside the transcript's scroller,
|
||||||
// as on the web (chat-bar, then background tasks, then transcript).
|
// as on the web (chat-bar, then background tasks, then transcript).
|
||||||
Padding(
|
if (!inShellBar)
|
||||||
key: const Key('chat-thread-header'),
|
Padding(
|
||||||
padding: const EdgeInsetsDirectional.fromSTEB(4, 8, 4, 4),
|
key: const Key('chat-thread-header'),
|
||||||
child: LayoutBuilder(
|
padding: const EdgeInsetsDirectional.fromSTEB(4, 8, 4, 4),
|
||||||
builder: (context, constraints) {
|
child: LayoutBuilder(
|
||||||
final title = widget.title.trim();
|
builder: (context, constraints) {
|
||||||
final session = widget.session;
|
final title = widget.title.trim();
|
||||||
final hasModel =
|
final session = widget.session;
|
||||||
session != null &&
|
final hasModel =
|
||||||
supportsChatModels('${session['backend'] ?? ''}');
|
session != null &&
|
||||||
// One compact row, as on the web: back, the conversation's
|
supportsChatModels('${session['backend'] ?? ''}');
|
||||||
// name, its model and the information action. The title
|
// One compact row, as on the web: back, the conversation's
|
||||||
// takes the remaining width and ellipsises; the model keeps
|
// name, its model and the information action. The title
|
||||||
// a bounded share so neither control is pushed off a narrow
|
// takes the remaining width and ellipsises; the model keeps
|
||||||
// 2x phone and the header never wraps onto a second line.
|
// a bounded share so neither control is pushed off a narrow
|
||||||
return Row(
|
// 2x phone and the header never wraps onto a second line.
|
||||||
children: [
|
return Row(
|
||||||
_backButton(cupertino),
|
children: [
|
||||||
Expanded(
|
_backButton(cupertino),
|
||||||
child: Padding(
|
Expanded(
|
||||||
padding: const EdgeInsetsDirectional.only(start: 4),
|
child: Padding(
|
||||||
child: title.isEmpty
|
padding: const EdgeInsetsDirectional.only(start: 4),
|
||||||
? const SizedBox.shrink()
|
child: title.isEmpty
|
||||||
: Text(
|
? const SizedBox.shrink()
|
||||||
title,
|
: Text(
|
||||||
maxLines: 1,
|
title,
|
||||||
overflow: TextOverflow.ellipsis,
|
maxLines: 1,
|
||||||
style: cupertino
|
overflow: TextOverflow.ellipsis,
|
||||||
? CupertinoTheme.of(
|
style: cupertino
|
||||||
context,
|
? CupertinoTheme.of(
|
||||||
).textTheme.navTitleTextStyle
|
context,
|
||||||
: Theme.of(context).textTheme.titleLarge,
|
).textTheme.navTitleTextStyle
|
||||||
),
|
: Theme.of(context).textTheme.titleLarge,
|
||||||
),
|
),
|
||||||
),
|
|
||||||
if (hasModel)
|
|
||||||
ConstrainedBox(
|
|
||||||
constraints: BoxConstraints(
|
|
||||||
maxWidth: constraints.maxWidth * 0.4,
|
|
||||||
),
|
),
|
||||||
child: ChatModelControl(
|
),
|
||||||
key: ValueKey<String>(
|
if (hasModel)
|
||||||
'chat-model-${widget.sessionId}',
|
ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
maxWidth: constraints.maxWidth * 0.4,
|
||||||
|
),
|
||||||
|
child: ChatModelControl(
|
||||||
|
key: ValueKey<String>(
|
||||||
|
'chat-model-${widget.sessionId}',
|
||||||
|
),
|
||||||
|
gateway: widget.gateway,
|
||||||
|
sessionId: widget.sessionId,
|
||||||
|
session: session,
|
||||||
|
onChanged: widget.onModelChanged,
|
||||||
|
answeredBy: latestReplyModel(_controller.messages),
|
||||||
),
|
),
|
||||||
gateway: widget.gateway,
|
|
||||||
sessionId: widget.sessionId,
|
|
||||||
session: session,
|
|
||||||
onChanged: widget.onModelChanged,
|
|
||||||
answeredBy: latestReplyModel(_controller.messages),
|
|
||||||
),
|
),
|
||||||
|
ChatBarAction(
|
||||||
|
key: const Key('chat-info'),
|
||||||
|
label: 'Chat information',
|
||||||
|
onPressed: _openInfo,
|
||||||
|
materialIcon: Icons.info_outline,
|
||||||
|
cupertinoIcon: CupertinoIcons.info,
|
||||||
),
|
),
|
||||||
ChatBarAction(
|
],
|
||||||
key: const Key('chat-info'),
|
);
|
||||||
label: 'Chat information',
|
},
|
||||||
onPressed: _openInfo,
|
),
|
||||||
materialIcon: Icons.info_outline,
|
|
||||||
cupertinoIcon: CupertinoIcons.info,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
|
||||||
// The session's still-running background tasks, above the transcript
|
// The session's still-running background tasks, above the transcript
|
||||||
// and outside its scroller (web C11). It removes itself when the last
|
// and outside its scroller (web C11). It removes itself when the last
|
||||||
// task exits and never draws a finished task.
|
// task exits and never draws a finished task.
|
||||||
@@ -829,6 +834,37 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
if (!inShellBar) return column;
|
||||||
|
final session = widget.session;
|
||||||
|
final hasModel =
|
||||||
|
session != null && supportsChatModels('${session['backend'] ?? ''}');
|
||||||
|
final title = widget.title.trim();
|
||||||
|
return ShellBar(
|
||||||
|
title: title.isEmpty ? null : title,
|
||||||
|
onBack: widget.onBack,
|
||||||
|
actions: [
|
||||||
|
if (hasModel)
|
||||||
|
ConstrainedBox(
|
||||||
|
constraints: const BoxConstraints(maxWidth: 180),
|
||||||
|
child: ChatModelControl(
|
||||||
|
key: ValueKey<String>('chat-model-${widget.sessionId}'),
|
||||||
|
gateway: widget.gateway,
|
||||||
|
sessionId: widget.sessionId,
|
||||||
|
session: session,
|
||||||
|
onChanged: widget.onModelChanged,
|
||||||
|
answeredBy: latestReplyModel(_controller.messages),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ChatBarAction(
|
||||||
|
key: const Key('chat-info'),
|
||||||
|
label: 'Chat information',
|
||||||
|
onPressed: _openInfo,
|
||||||
|
materialIcon: Icons.info_outline,
|
||||||
|
cupertinoIcon: CupertinoIcons.info,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
child: column,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
/// Left and right arrow keys step to the previous and next item (an
|
||||||
|
/// artifact, a changed file) wherever a keyboard is attached. A field that
|
||||||
|
/// takes the arrows itself (a text box) keeps them while it has focus.
|
||||||
|
class ArrowKeyPager extends StatelessWidget {
|
||||||
|
const ArrowKeyPager({
|
||||||
|
super.key,
|
||||||
|
required this.onPrevious,
|
||||||
|
required this.onNext,
|
||||||
|
required this.child,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// Null at the first item.
|
||||||
|
final VoidCallback? onPrevious;
|
||||||
|
|
||||||
|
/// Null at the last item.
|
||||||
|
final VoidCallback? onNext;
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => CallbackShortcuts(
|
||||||
|
bindings: {
|
||||||
|
const SingleActivator(LogicalKeyboardKey.arrowLeft): () =>
|
||||||
|
onPrevious?.call(),
|
||||||
|
const SingleActivator(LogicalKeyboardKey.arrowRight): () =>
|
||||||
|
onNext?.call(),
|
||||||
|
},
|
||||||
|
child: Focus(autofocus: true, child: child),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -9,12 +9,17 @@ import '../adaptive/host.dart';
|
|||||||
class SectionHeadingStyle {
|
class SectionHeadingStyle {
|
||||||
const SectionHeadingStyle({
|
const SectionHeadingStyle({
|
||||||
required this.background,
|
required this.background,
|
||||||
|
required this.body,
|
||||||
required this.accent,
|
required this.accent,
|
||||||
required this.title,
|
required this.title,
|
||||||
required this.line,
|
required this.line,
|
||||||
});
|
});
|
||||||
|
|
||||||
final Color background;
|
final Color background;
|
||||||
|
|
||||||
|
/// The surface under a section's content: between the page and the title,
|
||||||
|
/// so the content reads as belonging to its section.
|
||||||
|
final Color body;
|
||||||
final Color accent;
|
final Color accent;
|
||||||
final TextStyle title;
|
final TextStyle title;
|
||||||
final Color line;
|
final Color line;
|
||||||
@@ -23,8 +28,12 @@ class SectionHeadingStyle {
|
|||||||
if (usesCupertinoHost(context)) {
|
if (usesCupertinoHost(context)) {
|
||||||
final base = CupertinoTheme.of(context).textTheme.textStyle;
|
final base = CupertinoTheme.of(context).textTheme.textStyle;
|
||||||
return SectionHeadingStyle(
|
return SectionHeadingStyle(
|
||||||
background: CupertinoColors.secondarySystemGroupedBackground
|
background: CupertinoColors.tertiarySystemGroupedBackground.resolveFrom(
|
||||||
.resolveFrom(context),
|
context,
|
||||||
|
),
|
||||||
|
body: CupertinoColors.secondarySystemGroupedBackground.resolveFrom(
|
||||||
|
context,
|
||||||
|
),
|
||||||
accent: CupertinoTheme.of(context).primaryColor,
|
accent: CupertinoTheme.of(context).primaryColor,
|
||||||
title: base.copyWith(
|
title: base.copyWith(
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
@@ -35,7 +44,8 @@ class SectionHeadingStyle {
|
|||||||
}
|
}
|
||||||
final scheme = Theme.of(context).colorScheme;
|
final scheme = Theme.of(context).colorScheme;
|
||||||
return SectionHeadingStyle(
|
return SectionHeadingStyle(
|
||||||
background: scheme.surfaceContainerHigh,
|
background: scheme.surfaceContainerHighest,
|
||||||
|
body: scheme.surfaceContainerLow,
|
||||||
accent: scheme.primary,
|
accent: scheme.primary,
|
||||||
title: (Theme.of(context).textTheme.titleSmall ?? const TextStyle())
|
title: (Theme.of(context).textTheme.titleSmall ?? const TextStyle())
|
||||||
.copyWith(fontWeight: FontWeight.w700, color: scheme.onSurface),
|
.copyWith(fontWeight: FontWeight.w700, color: scheme.onSurface),
|
||||||
|
|||||||
@@ -52,14 +52,17 @@ class StickySection extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// The content grows and shrinks under the pinned title.
|
// The content grows and shrinks under the pinned title, on its own
|
||||||
|
// surface with the title's accent continuing down its edge.
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: ClipRect(
|
child: ClipRect(
|
||||||
child: AnimatedSize(
|
child: AnimatedSize(
|
||||||
duration: Motion.of(context, Motion.standard),
|
duration: Motion.of(context, Motion.standard),
|
||||||
curve: Motion.curve,
|
curve: Motion.curve,
|
||||||
alignment: Alignment.topCenter,
|
alignment: Alignment.topCenter,
|
||||||
child: open ? body : const SizedBox(width: double.infinity),
|
child: open
|
||||||
|
? _SectionBody(child: body)
|
||||||
|
: const SizedBox(width: double.infinity),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -96,61 +99,121 @@ class StickySectionTitle extends StatelessWidget {
|
|||||||
final style = color == null
|
final style = color == null
|
||||||
? heading.title
|
? heading.title
|
||||||
: heading.title.copyWith(color: color);
|
: heading.title.copyWith(color: color);
|
||||||
return DecoratedBox(
|
final chevron = AnimatedRotation(
|
||||||
decoration: BoxDecoration(
|
turns: open ? 0.5 : 0,
|
||||||
color: heading.background,
|
duration: Motion.of(context, Motion.standard),
|
||||||
border: Border(
|
curve: Motion.curve,
|
||||||
left: BorderSide(color: heading.accent, width: 3),
|
child: Icon(
|
||||||
bottom: BorderSide(color: heading.line, width: 0.5),
|
cupertino ? CupertinoIcons.chevron_down : Icons.expand_more,
|
||||||
),
|
color: muted,
|
||||||
),
|
),
|
||||||
child: Padding(
|
);
|
||||||
padding: const EdgeInsetsDirectional.only(start: 13, end: 8),
|
final row = Padding(
|
||||||
child: Row(
|
padding: const EdgeInsetsDirectional.only(start: 13, end: 8),
|
||||||
children: [
|
child: Row(
|
||||||
Expanded(
|
children: [
|
||||||
child: Semantics(
|
Expanded(
|
||||||
container: true,
|
// The title is the section's heading and its toggle for
|
||||||
header: true,
|
// assistive tech; the strip's own tap target is not announced.
|
||||||
button: true,
|
child: Semantics(
|
||||||
expanded: open,
|
container: true,
|
||||||
label: title,
|
header: true,
|
||||||
excludeSemantics: true,
|
button: true,
|
||||||
onTap: onToggle,
|
expanded: open,
|
||||||
child: GestureDetector(
|
label: title,
|
||||||
behavior: HitTestBehavior.opaque,
|
excludeSemantics: true,
|
||||||
onTap: onToggle,
|
onTap: onToggle,
|
||||||
child: Row(
|
child: Text(
|
||||||
children: [
|
title,
|
||||||
Expanded(
|
style: style,
|
||||||
child: Text(
|
maxLines: 1,
|
||||||
title,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: style,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
AnimatedRotation(
|
|
||||||
turns: open ? 0.5 : 0,
|
|
||||||
duration: Motion.of(context, Motion.standard),
|
|
||||||
curve: Motion.curve,
|
|
||||||
child: Icon(
|
|
||||||
cupertino
|
|
||||||
? CupertinoIcons.chevron_down
|
|
||||||
: Icons.expand_more,
|
|
||||||
color: muted,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
...trailing,
|
),
|
||||||
],
|
...trailing,
|
||||||
),
|
ExcludeSemantics(child: chevron),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
final decoration = BoxDecoration(
|
||||||
|
color: heading.background,
|
||||||
|
border: Border(
|
||||||
|
left: BorderSide(color: heading.accent, width: 3),
|
||||||
|
bottom: BorderSide(color: heading.line, width: 0.5),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
// The whole strip opens and closes the section; its own buttons (copy)
|
||||||
|
// still take their taps first.
|
||||||
|
final Widget strip = cupertino
|
||||||
|
? GestureDetector(
|
||||||
|
behavior: HitTestBehavior.opaque,
|
||||||
|
excludeFromSemantics: true,
|
||||||
|
onTap: onToggle,
|
||||||
|
child: DecoratedBox(decoration: decoration, child: row),
|
||||||
|
)
|
||||||
|
: Material(
|
||||||
|
color: heading.background,
|
||||||
|
child: Ink(
|
||||||
|
decoration: decoration,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: onToggle,
|
||||||
|
excludeFromSemantics: true,
|
||||||
|
child: row,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return Stack(
|
||||||
|
clipBehavior: Clip.none,
|
||||||
|
fit: StackFit.expand,
|
||||||
|
children: [
|
||||||
|
// A few pixels of the title's colour above it: at fractional pixel
|
||||||
|
// ratios content scrolling under a pinned title could peek through.
|
||||||
|
Positioned(
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
top: -3,
|
||||||
|
height: 4,
|
||||||
|
child: ColoredBox(color: heading.background),
|
||||||
|
),
|
||||||
|
MouseRegion(cursor: SystemMouseCursors.click, child: strip),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A section's open content: its own surface, a faint continuation of the
|
||||||
|
/// title's accent, and room between the title and the first line.
|
||||||
|
class _SectionBody extends StatelessWidget {
|
||||||
|
const _SectionBody({required this.child});
|
||||||
|
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final heading = SectionHeadingStyle.of(context);
|
||||||
|
final decoration = BoxDecoration(
|
||||||
|
color: heading.body,
|
||||||
|
border: Border(
|
||||||
|
left: BorderSide(
|
||||||
|
color: heading.accent.withValues(alpha: 0.35),
|
||||||
|
width: 3,
|
||||||
|
),
|
||||||
|
bottom: BorderSide(color: heading.line, width: 0.5),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final content = Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 12, bottom: 4),
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
if (usesCupertinoHost(context)) {
|
||||||
|
return DecoratedBox(decoration: decoration, child: content);
|
||||||
|
}
|
||||||
|
// Rows inside paint their ripples on this surface.
|
||||||
|
return Material(
|
||||||
|
color: heading.body,
|
||||||
|
child: Ink(decoration: decoration, child: content),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -231,9 +231,12 @@ void main() {
|
|||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(find.text('A live line arrived.'), findsOneWidget);
|
expect(find.text('A live line arrived.'), findsOneWidget);
|
||||||
|
|
||||||
// One compact icon-only Back control in the thread header; its
|
// The open chat takes over the app bar: one Back there, and no
|
||||||
// accessible name is the destination, and both hosts share the key.
|
// second header row under it.
|
||||||
await tester.tap(find.byKey(const Key('chat-back')));
|
expect(find.byKey(const Key('chat-thread-header')), findsNothing);
|
||||||
|
await tester.tap(find.byKey(const ValueKey('shell.back')));
|
||||||
|
await tester.pump();
|
||||||
|
// The bar hands back to the list on the next frame.
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(provider.value.uri.path, '/chat');
|
expect(provider.value.uri.path, '/chat');
|
||||||
expect(find.byType(ChatThreadView), findsNothing);
|
expect(find.byType(ChatThreadView), findsNothing);
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pipelines_app/features/changes/domain/change_kind.dart';
|
||||||
|
import 'package:pipelines_app/features/changes/domain/file_change.dart';
|
||||||
|
import 'package:pipelines_app/features/changes/widgets/file_diff_viewer.dart';
|
||||||
|
|
||||||
|
FileChange _file(String path) => FileChange(
|
||||||
|
path: path,
|
||||||
|
kind: ChangeKind.modified,
|
||||||
|
patch: '--- a/$path\n+++ b/$path\n@@ -1 +1 @@\n-a\n+b\n',
|
||||||
|
);
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('left and right arrows step between changed files', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: FileDiffPage(
|
||||||
|
files: [_file('lib/one.dart'), _file('lib/two.dart')],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text('one.dart'), findsWidgets);
|
||||||
|
|
||||||
|
await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text('two.dart'), findsWidgets);
|
||||||
|
|
||||||
|
// The last file stays put; left goes back.
|
||||||
|
await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text('two.dart'), findsWidgets);
|
||||||
|
await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text('one.dart'), findsWidgets);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -46,4 +46,19 @@ void main() {
|
|||||||
expect(find.text('line 40'), findsNothing);
|
expect(find.text('line 40'), findsNothing);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
testWidgets('a tap anywhere on the title strip toggles the section', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
tester.view.physicalSize = const Size(390, 600);
|
||||||
|
tester.view.devicePixelRatio = 1;
|
||||||
|
addTearDown(tester.view.reset);
|
||||||
|
await tester.pumpWidget(const MaterialApp(home: Scaffold(body: _Host())));
|
||||||
|
expect(find.text('line 0'), findsOneWidget);
|
||||||
|
// Empty space well right of the short title, left of the chevron.
|
||||||
|
final strip = tester.getRect(find.byType(StickySectionTitle));
|
||||||
|
await tester.tapAt(Offset(strip.center.dx + 60, strip.center.dy));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text('line 0'), findsNothing);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user