Merge commit '591e1eec3a69099d7ae95ddcdd07d727b4bdeb27' into pipelines/run-20261111-0432-cupertino-out-pipelines-56b8
This commit is contained in:
@@ -2,7 +2,6 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/glass_bar.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../domain/artifact_record.dart';
|
||||
import '../domain/artifact_url.dart';
|
||||
import '../ui/artifact_viewer_fetch.dart';
|
||||
@@ -81,19 +80,15 @@ class _ArtifactFileActionsState extends State<ArtifactFileActions> {
|
||||
listenable: _controller,
|
||||
builder: (context, _) => widget.compact
|
||||
? _IconActions(controller: _controller)
|
||||
: _ActionBar(
|
||||
controller: _controller,
|
||||
cupertino: usesCupertinoHost(context),
|
||||
),
|
||||
: _ActionBar(controller: _controller),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ActionBar extends StatelessWidget {
|
||||
const _ActionBar({required this.controller, required this.cupertino});
|
||||
const _ActionBar({required this.controller});
|
||||
|
||||
final ArtifactFileActionsController controller;
|
||||
final bool cupertino;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -142,14 +137,11 @@ class _ActionBar extends StatelessWidget {
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (cupertino)
|
||||
const CupertinoActivityIndicator(radius: 8)
|
||||
else
|
||||
const SizedBox(
|
||||
width: 14,
|
||||
height: 14,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 14,
|
||||
height: 14,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Flexible(child: Text(status)),
|
||||
],
|
||||
@@ -182,9 +174,6 @@ class _ActionBar extends StatelessWidget {
|
||||
required IconData icon,
|
||||
required VoidCallback? onPressed,
|
||||
}) {
|
||||
if (cupertino) {
|
||||
return CupertinoButton(onPressed: onPressed, child: Text(label));
|
||||
}
|
||||
return TextButton.icon(
|
||||
onPressed: onPressed,
|
||||
icon: Icon(icon, size: 18),
|
||||
@@ -241,28 +230,15 @@ class ArtifactIconAction extends StatelessWidget {
|
||||
|
||||
final String label;
|
||||
final IconData icon;
|
||||
|
||||
/// Retained for callers that still pass the Cupertino glyph; the Material
|
||||
/// action always draws [icon].
|
||||
final IconData cupertinoIcon;
|
||||
final VoidCallback? onPressed;
|
||||
final bool busy;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (usesCupertinoHost(context)) {
|
||||
return Semantics(
|
||||
button: true,
|
||||
label: label,
|
||||
child: CupertinoButton(
|
||||
// One square touch target, like the top bar's other actions, so a
|
||||
// round pill is centred on it and a glass bar's edge gaps hold.
|
||||
padding: EdgeInsets.zero,
|
||||
minimumSize: GlassBarMetrics.cupertinoMinimumSize(),
|
||||
onPressed: onPressed,
|
||||
child: busy
|
||||
? const CupertinoActivityIndicator(radius: 9)
|
||||
: Icon(cupertinoIcon, size: GlassBarMetrics.iconSize(true)),
|
||||
),
|
||||
);
|
||||
}
|
||||
return IconButton(
|
||||
tooltip: label,
|
||||
constraints: GlassBarMetrics.materialConstraints(),
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
|
||||
/// Open, Copy and the file actions float over the top of the content: shown
|
||||
/// when the page opens and whenever the content is touched, hidden again after
|
||||
/// a few seconds without use, so nothing needs scrolling to reach them.
|
||||
@@ -55,14 +52,9 @@ class _ArtifactControlsOverlayState extends State<ArtifactControlsOverlay> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final surface = cupertino
|
||||
? CupertinoColors.systemBackground
|
||||
.resolveFrom(context)
|
||||
.withValues(alpha: 0.92)
|
||||
: Theme.of(
|
||||
context,
|
||||
).colorScheme.surfaceContainerHigh.withValues(alpha: 0.94);
|
||||
final surface = Theme.of(
|
||||
context,
|
||||
).colorScheme.surfaceContainerHigh.withValues(alpha: 0.94);
|
||||
return Stack(
|
||||
children: [
|
||||
// Any touch on the content brings the controls back.
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import '../../../ui/layout/section_heading.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../domain/artifact_document.dart';
|
||||
import '../domain/artifact_groups.dart';
|
||||
import 'artifact_record_row.dart';
|
||||
@@ -50,23 +47,14 @@ class ArtifactDocumentSection extends StatelessWidget {
|
||||
children: rows,
|
||||
);
|
||||
}
|
||||
// Flat rows under a quiet label on both hosts: the section sits inside
|
||||
// the visit's Session page, which is itself flat, so a Cupertino inset
|
||||
// group here would be a group nested in a group.
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
// Flat rows under a quiet label: the section sits inside the visit's
|
||||
// Session page, which is itself flat.
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 12, 16, 4),
|
||||
child: Semantics(
|
||||
container: true,
|
||||
header: true,
|
||||
child: Text(
|
||||
title,
|
||||
style: cupertino ? SectionHeadingStyle.of(context).title : null,
|
||||
),
|
||||
),
|
||||
child: Semantics(container: true, header: true, child: Text(title)),
|
||||
),
|
||||
...rows,
|
||||
],
|
||||
@@ -98,42 +86,15 @@ class _AbsentDocumentRow extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!usesCupertinoHost(context)) {
|
||||
// The absence line is informational product content, so it keeps the
|
||||
// theme's normal secondary label colour. A disabled tile would paint both
|
||||
// lines at the disabled colour (about 2.7:1 in light mode); no `onTap`
|
||||
// keeps the row non-actionable without dimming it.
|
||||
return ListTile(
|
||||
title: Text(document.name),
|
||||
subtitle: Text(
|
||||
document.absence,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
final textTheme = CupertinoTheme.of(context).textTheme;
|
||||
final absenceStyle = textTheme.textStyle.copyWith(
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
);
|
||||
return Semantics(
|
||||
container: true,
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: Padding(
|
||||
padding: kCupertinoButtonPadding[CupertinoButtonSize.large]!,
|
||||
child: DefaultTextStyle.merge(
|
||||
style: textTheme.textStyle,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(document.name),
|
||||
Text(document.absence, style: absenceStyle),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
// The absence line is informational product content, so it keeps the
|
||||
// theme's normal secondary label colour. A disabled tile would paint both
|
||||
// lines at the disabled colour (about 2.7:1 in light mode); no `onTap`
|
||||
// keeps the row non-actionable without dimming it.
|
||||
return ListTile(
|
||||
title: Text(document.name),
|
||||
subtitle: Text(
|
||||
document.absence,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.onSurfaceVariant),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -30,12 +30,13 @@ class ArtifactFullscreenScope extends InheritedWidget {
|
||||
/// The full-screen view's route, pushed on the root navigator so it covers
|
||||
/// the shell's bars and list pane. A full-screen dialog route: its bar shows
|
||||
/// the platform's Close, and the system back gesture leaves it.
|
||||
///
|
||||
/// [cupertino] is retained for callers that still pass it; the route is always
|
||||
/// the Material one.
|
||||
Route<void> artifactFullscreenRoute({
|
||||
required bool cupertino,
|
||||
required WidgetBuilder builder,
|
||||
}) => cupertino
|
||||
? CupertinoPageRoute<void>(fullscreenDialog: true, builder: builder)
|
||||
: MaterialPageRoute<void>(fullscreenDialog: true, builder: builder);
|
||||
}) => MaterialPageRoute<void>(fullscreenDialog: true, builder: builder);
|
||||
|
||||
/// The zoom factors Zoom in and Zoom out step through.
|
||||
const List<double> artifactHtmlZoomSteps = [
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import 'artifact_fullscreen.dart';
|
||||
|
||||
/// Lets a viewer page open its own content as the full-screen view.
|
||||
@@ -42,7 +41,7 @@ mixin ArtifactFullscreenHost<T extends StatefulWidget> on State<T> {
|
||||
if (_fullscreen != null) return;
|
||||
htmlZoom.value = 1;
|
||||
final route = artifactFullscreenRoute(
|
||||
cupertino: usesCupertinoHost(context),
|
||||
cupertino: false,
|
||||
builder: (_) => ArtifactFullscreenScope(
|
||||
htmlZoom: htmlZoom,
|
||||
child: ListenableBuilder(
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../core/transport/pipelines_client.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import 'artifact_external_open.dart';
|
||||
import 'artifact_gallery_page.dart';
|
||||
|
||||
@@ -58,14 +56,6 @@ class RunArtifactsButton extends StatelessWidget {
|
||||
executing: _runExecuting(run),
|
||||
configuredEndpoint: configuredGatewayEndpoint(gateway),
|
||||
);
|
||||
if (usesCupertinoHost(context)) {
|
||||
return CupertinoButton.tinted(
|
||||
sizeStyle: CupertinoButtonSize.small,
|
||||
key: runArtifactsButtonKey,
|
||||
onPressed: open,
|
||||
child: const Text(artifactGalleryTitle),
|
||||
);
|
||||
}
|
||||
return OutlinedButton.icon(
|
||||
key: runArtifactsButtonKey,
|
||||
onPressed: open,
|
||||
@@ -92,9 +82,7 @@ Future<void> showArtifactGallery(
|
||||
configuredEndpoint: configuredEndpoint,
|
||||
openExternal: openExternal,
|
||||
);
|
||||
return Navigator.of(context).push<void>(
|
||||
usesCupertinoHost(context)
|
||||
? CupertinoPageRoute<void>(builder: (_) => page)
|
||||
: MaterialPageRoute<void>(builder: (_) => page),
|
||||
);
|
||||
return Navigator.of(
|
||||
context,
|
||||
).push<void>(MaterialPageRoute<void>(builder: (_) => page));
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../chat/ui/transcript/chat_markdown_view.dart';
|
||||
import '../../graph/domain/stage_visits.dart';
|
||||
import '../actions/artifact_file_actions.dart';
|
||||
@@ -289,29 +287,17 @@ class _ArtifactGalleryPageState extends State<ArtifactGalleryPage> {
|
||||
];
|
||||
final previousFocus = FocusManager.instance.primaryFocus;
|
||||
await Navigator.of(context).push<void>(
|
||||
usesCupertinoHost(context)
|
||||
? CupertinoPageRoute<void>(
|
||||
builder: (_) => ArtifactViewerPage(
|
||||
groups: viewerGroups,
|
||||
selectedIdentity: identity,
|
||||
configuredEndpoint: widget.configuredEndpoint,
|
||||
openExternal: widget.openExternal,
|
||||
fetch: widget.fetch,
|
||||
markdownBuilder: widget.markdownBuilder,
|
||||
fileBridge: widget.fileBridge,
|
||||
),
|
||||
)
|
||||
: MaterialPageRoute<void>(
|
||||
builder: (_) => ArtifactViewerPage(
|
||||
groups: viewerGroups,
|
||||
selectedIdentity: identity,
|
||||
configuredEndpoint: widget.configuredEndpoint,
|
||||
openExternal: widget.openExternal,
|
||||
fetch: widget.fetch,
|
||||
markdownBuilder: widget.markdownBuilder,
|
||||
fileBridge: widget.fileBridge,
|
||||
),
|
||||
),
|
||||
MaterialPageRoute<void>(
|
||||
builder: (_) => ArtifactViewerPage(
|
||||
groups: viewerGroups,
|
||||
selectedIdentity: identity,
|
||||
configuredEndpoint: widget.configuredEndpoint,
|
||||
openExternal: widget.openExternal,
|
||||
fetch: widget.fetch,
|
||||
markdownBuilder: widget.markdownBuilder,
|
||||
fileBridge: widget.fileBridge,
|
||||
),
|
||||
),
|
||||
);
|
||||
if (!mounted) return;
|
||||
if (previousFocus != null && previousFocus.canRequestFocus) {
|
||||
@@ -350,32 +336,6 @@ class _ArtifactGalleryPageState extends State<ArtifactGalleryPage> {
|
||||
],
|
||||
],
|
||||
);
|
||||
if (usesCupertinoHost(context)) {
|
||||
return showCupertinoDialog<void>(
|
||||
context: context,
|
||||
builder: (dialogContext) => CupertinoAlertDialog(
|
||||
title: Text(artifactDisplayName(artifact)),
|
||||
content: content,
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: () => Navigator.of(dialogContext).pop(),
|
||||
child: const Text('Close'),
|
||||
),
|
||||
if (resolved != null)
|
||||
CupertinoDialogAction(
|
||||
onPressed: () => _copyLink(resolved, dialogContext),
|
||||
child: const Text('Copy link'),
|
||||
),
|
||||
if (resolved != null)
|
||||
CupertinoDialogAction(
|
||||
isDefaultAction: true,
|
||||
onPressed: () => _open(resolved, dialogContext),
|
||||
child: const Text('Open in browser'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
@@ -509,17 +469,11 @@ class _ArtifactGalleryPageState extends State<ArtifactGalleryPage> {
|
||||
/// one line per recorded fact, never clamped or shortened.
|
||||
Widget _header(BuildContext context, String summary, {Widget? action}) {
|
||||
final notes = _captureNotes();
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final textStyle = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyMedium ?? const TextStyle();
|
||||
final headingStyle = cupertino
|
||||
? textStyle.copyWith(fontWeight: FontWeight.w600)
|
||||
: Theme.of(context).textTheme.titleSmall;
|
||||
final textStyle =
|
||||
Theme.of(context).textTheme.bodyMedium ?? const TextStyle();
|
||||
final headingStyle = Theme.of(context).textTheme.titleSmall;
|
||||
final noteStyle = textStyle.copyWith(
|
||||
color: cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
);
|
||||
return Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 12, 16, 4),
|
||||
@@ -557,33 +511,21 @@ class _ArtifactGalleryPageState extends State<ArtifactGalleryPage> {
|
||||
Widget _debugToggle(BuildContext context) {
|
||||
final showing = _showTurnDocuments;
|
||||
final label = showing ? 'Hide debugging files' : 'Show debugging files';
|
||||
// Cupertino's bundled icon font has no bug glyph; retain the universally
|
||||
// recognisable Material bug icon inside its native Cupertino button.
|
||||
final icon = showing ? Icons.bug_report : Icons.bug_report_outlined;
|
||||
void onPressed() => setState(() => _showTurnDocuments = !showing);
|
||||
final button = usesCupertinoHost(context)
|
||||
? CupertinoButton(
|
||||
key: const Key('artifact-debug-toggle'),
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onPressed,
|
||||
child: Icon(icon),
|
||||
)
|
||||
: IconButton(
|
||||
key: const Key('artifact-debug-toggle'),
|
||||
isSelected: showing,
|
||||
tooltip: label,
|
||||
onPressed: onPressed,
|
||||
icon: Icon(icon),
|
||||
);
|
||||
final semanticButton = Semantics(
|
||||
final button = IconButton(
|
||||
key: const Key('artifact-debug-toggle'),
|
||||
isSelected: showing,
|
||||
tooltip: label,
|
||||
onPressed: onPressed,
|
||||
icon: Icon(icon),
|
||||
);
|
||||
return Semantics(
|
||||
label: label,
|
||||
button: true,
|
||||
toggled: showing,
|
||||
child: button,
|
||||
);
|
||||
return usesCupertinoHost(context)
|
||||
? Tooltip(message: label, child: semanticButton)
|
||||
: semanticButton;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -617,18 +559,6 @@ class _ArtifactGalleryPageState extends State<ArtifactGalleryPage> {
|
||||
onRevealed: _revealed,
|
||||
);
|
||||
if (widget.embedded) return body;
|
||||
if (usesCupertinoHost(context)) {
|
||||
// Flat sections on the page colour, as in the run and stage details;
|
||||
// their pinned headings take the same colour.
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: SegmentedBar(
|
||||
cupertino: true,
|
||||
title: artifactGalleryTitle,
|
||||
actions: [_debugToggle(context)],
|
||||
),
|
||||
child: SafeArea(top: false, bottom: false, child: body),
|
||||
);
|
||||
}
|
||||
return Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: SegmentedBar(
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../domain/artifact_groups.dart';
|
||||
import '../domain/artifact_record.dart';
|
||||
import 'artifact_row_labels.dart';
|
||||
|
||||
/// One recorded artifact row in a gallery section.
|
||||
///
|
||||
/// Material draws a standard [ListTile]; Cupertino draws the same content in a
|
||||
/// grouped-row button. The row only reports the selection; it never resolves a
|
||||
/// url, opens a preview, downloads, shares or filters.
|
||||
/// Material draws a standard [ListTile]. The row only reports the selection; it
|
||||
/// never resolves a url, opens a preview, downloads, shares or filters.
|
||||
class ArtifactRecordRow extends StatelessWidget {
|
||||
const ArtifactRecordRow({
|
||||
super.key,
|
||||
@@ -31,58 +28,13 @@ class ArtifactRecordRow extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!usesCupertinoHost(context)) {
|
||||
return ListTile(
|
||||
selected: selected,
|
||||
leading: leading,
|
||||
title: Text(artifactDisplayName(artifact)),
|
||||
subtitle: Text(artifactFactsLabel(artifact)),
|
||||
trailing: selected ? const Icon(Icons.check) : null,
|
||||
onTap: onSelected == null ? null : () => onSelected!(group, artifact),
|
||||
);
|
||||
}
|
||||
final textTheme = CupertinoTheme.of(context).textTheme;
|
||||
final factsStyle = textTheme.textStyle.copyWith(
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
);
|
||||
final content = DefaultTextStyle.merge(
|
||||
style: textTheme.textStyle,
|
||||
child: Row(
|
||||
children: [
|
||||
if (leading != null) ...[leading!, const SizedBox(width: 12)],
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(artifactDisplayName(artifact)),
|
||||
Text(artifactFactsLabel(artifact), style: factsStyle),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (selected) const Icon(CupertinoIcons.check_mark),
|
||||
],
|
||||
),
|
||||
);
|
||||
// `container` makes this row its own semantics node, so the section
|
||||
// heading stays a separate header node and never covers the row.
|
||||
return Semantics(
|
||||
container: true,
|
||||
return ListTile(
|
||||
selected: selected,
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
// A read-only row is not a button: a disabled CupertinoButton would
|
||||
// still expose a button role to assistive technology.
|
||||
child: onSelected == null
|
||||
? Padding(
|
||||
padding: kCupertinoButtonPadding[CupertinoButtonSize.large]!,
|
||||
child: content,
|
||||
)
|
||||
: CupertinoButton(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
onPressed: () => onSelected!(group, artifact),
|
||||
child: content,
|
||||
),
|
||||
),
|
||||
leading: leading,
|
||||
title: Text(artifactDisplayName(artifact)),
|
||||
subtitle: Text(artifactFactsLabel(artifact)),
|
||||
trailing: selected ? const Icon(Icons.check) : null,
|
||||
onTap: onSelected == null ? null : () => onSelected!(group, artifact),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../graph/domain/stage_visits.dart';
|
||||
import '../domain/artifact_groups.dart';
|
||||
import '../domain/artifact_record.dart';
|
||||
@@ -53,14 +51,10 @@ class ArtifactSelectionFacts extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final recordedStep = step;
|
||||
final url = resolved;
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final primaryStyle = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyMedium ?? const TextStyle();
|
||||
final primaryStyle =
|
||||
Theme.of(context).textTheme.bodyMedium ?? const TextStyle();
|
||||
final secondaryStyle = primaryStyle.copyWith(
|
||||
color: cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../domain/artifact_table.dart';
|
||||
|
||||
/// The truncation note for a capped table preview.
|
||||
@@ -31,13 +29,8 @@ class ArtifactTableView extends StatelessWidget {
|
||||
child: Text('The table is empty.'),
|
||||
);
|
||||
}
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final border = cupertino
|
||||
? CupertinoColors.separator.resolveFrom(context)
|
||||
: Theme.of(context).dividerColor;
|
||||
final header = cupertino
|
||||
? CupertinoColors.secondarySystemFill.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.surfaceContainerHighest;
|
||||
final border = Theme.of(context).dividerColor;
|
||||
final header = Theme.of(context).colorScheme.surfaceContainerHighest;
|
||||
final columns = table.columnCount;
|
||||
Widget cell(String value, {bool head = false}) => Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../domain/artifact_groups.dart';
|
||||
import '../domain/artifact_kind.dart';
|
||||
import '../domain/artifact_record.dart';
|
||||
@@ -37,21 +35,12 @@ class ArtifactTile extends StatefulWidget {
|
||||
class _ArtifactTileState extends State<ArtifactTile> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final artifact = widget.artifact;
|
||||
final secondary = cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final surface = cupertino
|
||||
? CupertinoColors.tertiarySystemFill.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.surfaceContainerHighest;
|
||||
final secondary = Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final surface = Theme.of(context).colorScheme.surfaceContainerHighest;
|
||||
final border = widget.selected
|
||||
? (cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary)
|
||||
: (cupertino
|
||||
? CupertinoColors.separator.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.outlineVariant);
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Theme.of(context).colorScheme.outlineVariant;
|
||||
final preview = ArtifactThumbnail(
|
||||
artifact: artifact,
|
||||
configuredEndpoint: widget.configuredEndpoint,
|
||||
@@ -102,20 +91,14 @@ class _ArtifactTileState extends State<ArtifactTile> {
|
||||
label: '$name, $facts',
|
||||
excludeSemantics: true,
|
||||
onTap: onSelected == null ? null : tap,
|
||||
child: cupertino
|
||||
? GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: onSelected == null ? null : tap,
|
||||
child: decorated,
|
||||
)
|
||||
: Material(
|
||||
type: MaterialType.transparency,
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
onTap: onSelected == null ? null : tap,
|
||||
child: decorated,
|
||||
),
|
||||
),
|
||||
child: Material(
|
||||
type: MaterialType.transparency,
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
onTap: onSelected == null ? null : tap,
|
||||
child: decorated,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -168,13 +151,10 @@ class _ArtifactThumbnailState extends State<ArtifactThumbnail>
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final icon = Icon(
|
||||
artifactKindIcon(widget.artifact, cupertino: cupertino),
|
||||
artifactKindIcon(widget.artifact, cupertino: false),
|
||||
size: widget.iconSize,
|
||||
color: cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
);
|
||||
if (_image == null) return Center(child: icon);
|
||||
return FutureBuilder<ArtifactFetchResult>(
|
||||
@@ -210,30 +190,26 @@ class _ArtifactThumbnailState extends State<ArtifactThumbnail>
|
||||
}
|
||||
|
||||
/// The icon for an artifact's kind of file, when it has no thumbnail.
|
||||
///
|
||||
/// [cupertino] is retained for callers that still pass it; the icon is always
|
||||
/// the Material glyph the app draws.
|
||||
IconData artifactKindIcon(ArtifactRecord artifact, {required bool cupertino}) {
|
||||
final name = artifact.name.toLowerCase();
|
||||
final format = artifactPreviewFormat(artifact.contentType, artifact.name);
|
||||
if (name.endsWith('.zip') || name.endsWith('.tar') || name.endsWith('.gz')) {
|
||||
return cupertino ? CupertinoIcons.archivebox : Icons.folder_zip_outlined;
|
||||
return Icons.folder_zip_outlined;
|
||||
}
|
||||
if (name.endsWith('.pdf')) {
|
||||
return cupertino ? CupertinoIcons.doc_richtext : Icons.picture_as_pdf;
|
||||
return Icons.picture_as_pdf;
|
||||
}
|
||||
return switch (format) {
|
||||
ArtifactPreviewFormat.image =>
|
||||
cupertino ? CupertinoIcons.photo : Icons.image_outlined,
|
||||
ArtifactPreviewFormat.video =>
|
||||
cupertino ? CupertinoIcons.film : Icons.movie_outlined,
|
||||
ArtifactPreviewFormat.audio =>
|
||||
cupertino ? CupertinoIcons.music_note : Icons.audio_file_outlined,
|
||||
ArtifactPreviewFormat.markdown =>
|
||||
cupertino ? CupertinoIcons.doc_text : Icons.article_outlined,
|
||||
ArtifactPreviewFormat.text =>
|
||||
cupertino ? CupertinoIcons.doc_plaintext : Icons.description_outlined,
|
||||
ArtifactPreviewFormat.table =>
|
||||
cupertino ? CupertinoIcons.table : Icons.table_chart_outlined,
|
||||
ArtifactPreviewFormat.html => cupertino ? CupertinoIcons.globe : Icons.html,
|
||||
ArtifactPreviewFormat.none =>
|
||||
cupertino ? CupertinoIcons.doc : Icons.insert_drive_file_outlined,
|
||||
ArtifactPreviewFormat.image => Icons.image_outlined,
|
||||
ArtifactPreviewFormat.video => Icons.movie_outlined,
|
||||
ArtifactPreviewFormat.audio => Icons.audio_file_outlined,
|
||||
ArtifactPreviewFormat.markdown => Icons.article_outlined,
|
||||
ArtifactPreviewFormat.text => Icons.description_outlined,
|
||||
ArtifactPreviewFormat.table => Icons.table_chart_outlined,
|
||||
ArtifactPreviewFormat.html => Icons.html,
|
||||
ArtifactPreviewFormat.none => Icons.insert_drive_file_outlined,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
|
||||
/// Creates the player for one media url; tests inject a fake controller.
|
||||
typedef ArtifactVideoControllerFactory =
|
||||
VideoPlayerController Function(Uri uri);
|
||||
@@ -84,7 +81,6 @@ class _ArtifactVideoPlayerState extends State<ArtifactVideoPlayer> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_failed) return const Center(child: Text(artifactVideoError));
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
return ValueListenableBuilder<VideoPlayerValue>(
|
||||
valueListenable: _controller,
|
||||
builder: (context, value, _) {
|
||||
@@ -92,20 +88,12 @@ class _ArtifactVideoPlayerState extends State<ArtifactVideoPlayer> {
|
||||
return const Center(child: Text(artifactVideoError));
|
||||
}
|
||||
if (!value.isInitialized) {
|
||||
return Center(
|
||||
child: cupertino
|
||||
? const CupertinoActivityIndicator()
|
||||
: const CircularProgressIndicator(),
|
||||
);
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
final label = value.isPlaying
|
||||
? (widget.audio ? artifactAudioPauseLabel : artifactVideoPauseLabel)
|
||||
: (widget.audio ? artifactAudioPlayLabel : artifactVideoPlayLabel);
|
||||
final icon = cupertino
|
||||
? (value.isPlaying
|
||||
? CupertinoIcons.pause_fill
|
||||
: CupertinoIcons.play_fill)
|
||||
: (value.isPlaying ? Icons.pause : Icons.play_arrow);
|
||||
final icon = value.isPlaying ? Icons.pause : Icons.play_arrow;
|
||||
return Column(
|
||||
key: Key(widget.audio ? 'artifact-audio' : 'artifact-video'),
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -126,18 +114,12 @@ class _ArtifactVideoPlayerState extends State<ArtifactVideoPlayer> {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
child: Row(
|
||||
children: [
|
||||
cupertino
|
||||
? CupertinoButton(
|
||||
key: const Key('artifact-video-toggle'),
|
||||
onPressed: _toggle,
|
||||
child: Icon(icon, semanticLabel: label),
|
||||
)
|
||||
: IconButton(
|
||||
key: const Key('artifact-video-toggle'),
|
||||
tooltip: label,
|
||||
onPressed: _toggle,
|
||||
icon: Icon(icon),
|
||||
),
|
||||
IconButton(
|
||||
key: const Key('artifact-video-toggle'),
|
||||
tooltip: label,
|
||||
onPressed: _toggle,
|
||||
icon: Icon(icon),
|
||||
),
|
||||
Expanded(
|
||||
child: VideoProgressIndicator(
|
||||
_controller,
|
||||
|
||||
@@ -4,7 +4,6 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/glass_bar.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/navigation/chevron_pager.dart';
|
||||
import '../actions/artifact_file_actions.dart';
|
||||
import '../actions/artifact_file_bridge.dart';
|
||||
@@ -60,11 +59,8 @@ class ArtifactViewerBar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final actions = _actions(resolved, onFullscreen);
|
||||
final pagerMin = count > 1
|
||||
? 2 * GlassBarMetrics.controlExtent(cupertino)
|
||||
: 0.0;
|
||||
final pagerMin = count > 1 ? 2 * GlassBarMetrics.controlExtent(false) : 0.0;
|
||||
final pager = ChevronPager(
|
||||
index: index,
|
||||
count: count,
|
||||
@@ -87,7 +83,7 @@ class ArtifactViewerBar extends StatelessWidget {
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
heightFactor: 1,
|
||||
child: GlassControlBar(
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) => Row(
|
||||
key: const Key('artifact-viewer-actions'),
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'dart:typed_data';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../actions/artifact_file_actions.dart';
|
||||
import '../actions/artifact_file_bridge.dart';
|
||||
@@ -170,20 +169,6 @@ class ArtifactViewerInfoAction extends StatelessWidget {
|
||||
final Widget facts;
|
||||
|
||||
void _show(BuildContext context) {
|
||||
if (usesCupertinoHost(context)) {
|
||||
showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (context) => CupertinoPopupSurface(
|
||||
child: SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: facts,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
showDragHandle: true,
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
|
||||
import '../domain/artifact_preview.dart';
|
||||
import 'artifact_html_view.dart';
|
||||
import 'artifact_table_view.dart';
|
||||
@@ -219,24 +216,12 @@ class _ZoomableImageState extends State<_ZoomableImage> {
|
||||
PositionedDirectional(
|
||||
top: 8,
|
||||
end: 8,
|
||||
child: usesCupertinoHost(context)
|
||||
? Tooltip(
|
||||
message: 'Reset image zoom',
|
||||
child: CupertinoButton(
|
||||
key: const Key('artifact-image-reset-zoom'),
|
||||
sizeStyle: CupertinoButtonSize.small,
|
||||
onPressed: _reset,
|
||||
child: const Icon(
|
||||
CupertinoIcons.arrow_down_right_arrow_up_left,
|
||||
),
|
||||
),
|
||||
)
|
||||
: IconButton(
|
||||
key: const Key('artifact-image-reset-zoom'),
|
||||
tooltip: 'Reset image zoom',
|
||||
onPressed: _reset,
|
||||
icon: const Icon(Icons.zoom_out_map),
|
||||
),
|
||||
child: IconButton(
|
||||
key: const Key('artifact-image-reset-zoom'),
|
||||
tooltip: 'Reset image zoom',
|
||||
onPressed: _reset,
|
||||
icon: const Icon(Icons.zoom_out_map),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -272,7 +257,6 @@ class _Message extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final retry = onRetry;
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
@@ -282,18 +266,11 @@ class _Message extends StatelessWidget {
|
||||
Text(message, textAlign: TextAlign.center),
|
||||
if (retry != null) ...[
|
||||
const SizedBox(height: 12),
|
||||
cupertino
|
||||
? CupertinoButton.tinted(
|
||||
key: artifactPreviewRetryKey,
|
||||
sizeStyle: CupertinoButtonSize.small,
|
||||
onPressed: retry,
|
||||
child: const Text('Retry'),
|
||||
)
|
||||
: FilledButton.tonal(
|
||||
key: artifactPreviewRetryKey,
|
||||
onPressed: retry,
|
||||
child: const Text('Retry'),
|
||||
),
|
||||
FilledButton.tonal(
|
||||
key: artifactPreviewRetryKey,
|
||||
onPressed: retry,
|
||||
child: const Text('Retry'),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
|
||||
/// The viewer's page structure on either host: its [SegmentedBar] (the
|
||||
/// platform's Back, or Close on the full-screen route) over [body].
|
||||
/// The viewer's page structure: its [SegmentedBar] (the platform's Back, or
|
||||
/// Close on the full-screen route) over [body].
|
||||
class ArtifactViewerScaffold extends StatelessWidget {
|
||||
const ArtifactViewerScaffold({
|
||||
super.key,
|
||||
@@ -23,20 +20,12 @@ class ArtifactViewerScaffold extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final bar = SegmentedBar(
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
actions: actions,
|
||||
);
|
||||
if (cupertino) {
|
||||
return CupertinoPageScaffold(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
navigationBar: bar,
|
||||
child: body,
|
||||
);
|
||||
}
|
||||
return Scaffold(extendBodyBehindAppBar: true, appBar: bar, body: body);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../domain/artifact_groups.dart';
|
||||
import '../../../ui/layout/section_heading.dart';
|
||||
import '../../../ui/layout/sticky_section.dart';
|
||||
@@ -29,11 +27,10 @@ export 'artifact_row_labels.dart'
|
||||
/// artifacts. When [showTurnDocuments] is on, its debugging documents follow
|
||||
/// those artifacts in the same visit. Every recorded row shows its recorded
|
||||
/// filename, content type and size; a turn document the visit did not record
|
||||
/// stays a non-actionable row with the exact absence wording. Rendering uses the host's
|
||||
/// own controls: Material list tiles under [MaterialApp] and grouped Cupertino
|
||||
/// list sections under [CupertinoApp]. An optional [header] leads the same
|
||||
/// scroll view. It never resolves a url, opens a preview, downloads, shares or
|
||||
/// filters.
|
||||
/// stays a non-actionable row with the exact absence wording. Rendering uses
|
||||
/// the host's own controls: Material list tiles under [MaterialApp]. An
|
||||
/// optional [header] leads the same scroll view. It never resolves a url,
|
||||
/// opens a preview, downloads, shares or filters.
|
||||
/// How the gallery lays out each visit's artifacts.
|
||||
enum ArtifactGalleryMode { grid, list }
|
||||
|
||||
@@ -257,43 +254,24 @@ class _ArtifactVisitListState extends State<ArtifactVisitList> {
|
||||
);
|
||||
|
||||
Widget _modeSwitch(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final control = cupertino
|
||||
? CupertinoSlidingSegmentedControl<ArtifactGalleryMode>(
|
||||
key: const Key('artifact-gallery-mode'),
|
||||
groupValue: _mode,
|
||||
onValueChanged: (mode) {
|
||||
if (mode != null) _setMode(mode);
|
||||
},
|
||||
children: const {
|
||||
ArtifactGalleryMode.grid: Icon(
|
||||
CupertinoIcons.square_grid_2x2,
|
||||
semanticLabel: 'Grid',
|
||||
),
|
||||
ArtifactGalleryMode.list: Icon(
|
||||
CupertinoIcons.list_bullet,
|
||||
semanticLabel: 'List',
|
||||
),
|
||||
},
|
||||
)
|
||||
: SegmentedButton<ArtifactGalleryMode>(
|
||||
key: const Key('artifact-gallery-mode'),
|
||||
showSelectedIcon: false,
|
||||
segments: const [
|
||||
ButtonSegment(
|
||||
value: ArtifactGalleryMode.grid,
|
||||
icon: Icon(Icons.grid_view),
|
||||
tooltip: 'Grid',
|
||||
),
|
||||
ButtonSegment(
|
||||
value: ArtifactGalleryMode.list,
|
||||
icon: Icon(Icons.view_list),
|
||||
tooltip: 'List',
|
||||
),
|
||||
],
|
||||
selected: {_mode},
|
||||
onSelectionChanged: (mode) => _setMode(mode.single),
|
||||
);
|
||||
final control = SegmentedButton<ArtifactGalleryMode>(
|
||||
key: const Key('artifact-gallery-mode'),
|
||||
showSelectedIcon: false,
|
||||
segments: const [
|
||||
ButtonSegment(
|
||||
value: ArtifactGalleryMode.grid,
|
||||
icon: Icon(Icons.grid_view),
|
||||
tooltip: 'Grid',
|
||||
),
|
||||
ButtonSegment(
|
||||
value: ArtifactGalleryMode.list,
|
||||
icon: Icon(Icons.view_list),
|
||||
tooltip: 'List',
|
||||
),
|
||||
],
|
||||
selected: {_mode},
|
||||
onSelectionChanged: (mode) => _setMode(mode.single),
|
||||
);
|
||||
return Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 4, 16, 4),
|
||||
child: Align(alignment: AlignmentDirectional.centerEnd, child: control),
|
||||
@@ -303,9 +281,7 @@ class _ArtifactVisitListState extends State<ArtifactVisitList> {
|
||||
/// Rows keep a Material surface for their ink, as the section body's own
|
||||
/// surface was when it was one box around every row.
|
||||
Widget _inkSurface(BuildContext context, Widget child) =>
|
||||
usesCupertinoHost(context)
|
||||
? child
|
||||
: Material(type: MaterialType.transparency, child: child);
|
||||
Material(type: MaterialType.transparency, child: child);
|
||||
|
||||
/// The list view: one row per artifact with a small thumbnail beside it.
|
||||
Widget _list(ArtifactGroup group) => SliverList.builder(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
@@ -76,7 +75,6 @@ class _ChatShellCardActionsState extends State<ChatShellCardActions> {
|
||||
key: const Key('chat-shell-run-stop'),
|
||||
label: stopping ? chatShellStoppingLabel : chatShellStopLabel,
|
||||
material: Icons.stop,
|
||||
cupertino: CupertinoIcons.stop_fill,
|
||||
destructive: true,
|
||||
onPressed: stopping
|
||||
? null
|
||||
@@ -87,9 +85,6 @@ class _ChatShellCardActionsState extends State<ChatShellCardActions> {
|
||||
key: const Key('chat-shell-run-copy'),
|
||||
label: _copied ? chatShellCopiedLabel : chatShellCopyLabel,
|
||||
material: _copied ? Icons.check : Icons.copy_outlined,
|
||||
cupertino: _copied
|
||||
? CupertinoIcons.checkmark
|
||||
: CupertinoIcons.doc_on_doc,
|
||||
onPressed: () => unawaited(_copy()),
|
||||
),
|
||||
if (!run.running)
|
||||
@@ -103,9 +98,6 @@ class _ChatShellCardActionsState extends State<ChatShellCardActions> {
|
||||
material: share == ChatShellShareState.sent
|
||||
? Icons.check
|
||||
: Icons.send_outlined,
|
||||
cupertino: share == ChatShellShareState.sent
|
||||
? CupertinoIcons.checkmark
|
||||
: CupertinoIcons.paperplane,
|
||||
onPressed: share == ChatShellShareState.idle
|
||||
? () => unawaited(controller.share(run.id))
|
||||
: null,
|
||||
@@ -115,7 +107,6 @@ class _ChatShellCardActionsState extends State<ChatShellCardActions> {
|
||||
key: const Key('chat-shell-run-expand'),
|
||||
label: chatShellFullScreenLabel,
|
||||
material: Icons.fullscreen,
|
||||
cupertino: CupertinoIcons.fullscreen,
|
||||
onPressed: widget.onFullScreen,
|
||||
),
|
||||
],
|
||||
@@ -126,33 +117,9 @@ class _ChatShellCardActionsState extends State<ChatShellCardActions> {
|
||||
required Key key,
|
||||
required String label,
|
||||
required IconData material,
|
||||
required IconData cupertino,
|
||||
required VoidCallback? onPressed,
|
||||
bool destructive = false,
|
||||
}) {
|
||||
if (widget.cupertino) {
|
||||
final color = destructive
|
||||
? CupertinoColors.systemRed.resolveFrom(context)
|
||||
: null;
|
||||
return CupertinoButton(
|
||||
key: key,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
onPressed: onPressed,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(cupertino, color: onPressed == null ? null : color),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
label,
|
||||
style: onPressed == null || color == null
|
||||
? null
|
||||
: TextStyle(color: color),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
final style = destructive
|
||||
? TextButton.styleFrom(
|
||||
foregroundColor: Theme.of(context).colorScheme.error,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/segmented_bar_overflow.dart';
|
||||
@@ -22,24 +21,11 @@ class ChatShellDismissButton extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!cupertino) {
|
||||
return IconButton(
|
||||
key: const Key('chat-shell-run-dismiss'),
|
||||
tooltip: chatShellDismissLabel,
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: onPressed,
|
||||
);
|
||||
}
|
||||
return Semantics(
|
||||
label: chatShellDismissLabel,
|
||||
button: true,
|
||||
excludeSemantics: true,
|
||||
child: CupertinoButton(
|
||||
key: const Key('chat-shell-run-dismiss'),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
onPressed: onPressed,
|
||||
child: const Icon(CupertinoIcons.xmark),
|
||||
),
|
||||
return IconButton(
|
||||
key: const Key('chat-shell-run-dismiss'),
|
||||
tooltip: chatShellDismissLabel,
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: onPressed,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import '../../../shell/windows/window_scope.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/app_popups.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
import '../ui/transcript/chat_turn_chip.dart';
|
||||
import 'chat_shell_history.dart';
|
||||
import 'chat_shell_history_view.dart';
|
||||
@@ -26,20 +24,10 @@ class ChatShellHistoryChip extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final color = cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final color = Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
return ChatTurnChip(
|
||||
chipKey: const Key('chat-shell-history-chip'),
|
||||
leading: Icon(
|
||||
cupertino
|
||||
? CupertinoIcons.chevron_left_slash_chevron_right
|
||||
: Icons.terminal,
|
||||
size: 14,
|
||||
color: color,
|
||||
),
|
||||
leading: Icon(Icons.terminal, size: 14, color: color),
|
||||
label: chatShellHistoryLabel(runIds.length),
|
||||
color: color,
|
||||
semanticsLabel: chatShellHistorySemantics(runIds.length),
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
@@ -25,11 +24,7 @@ Future<void> openChatShellHistoryOutput(
|
||||
runId: runId,
|
||||
cupertino: cupertino,
|
||||
);
|
||||
return Navigator.of(context).push<void>(
|
||||
cupertino
|
||||
? CupertinoPageRoute<void>(builder: page)
|
||||
: MaterialPageRoute<void>(builder: page),
|
||||
);
|
||||
return Navigator.push<void>(context, MaterialPageRoute<void>(builder: page));
|
||||
}
|
||||
|
||||
/// One dismissed command: everything the server kept of its output in the
|
||||
@@ -93,7 +88,6 @@ class _ChatShellHistoryOutputPageState
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = widget.cupertino;
|
||||
final held = widget.controller.dismissedRun(widget.runId);
|
||||
final title = Text(
|
||||
held == null ? 'Command' : '\$ ${held.command}',
|
||||
@@ -110,28 +104,18 @@ class _ChatShellHistoryOutputPageState
|
||||
if (snapshot.hasError) {
|
||||
return Text(
|
||||
"Couldn't read the output: ${snapshot.error}",
|
||||
style: chatCardSecondaryStyle(context, cupertino),
|
||||
style: chatCardSecondaryStyle(context, false),
|
||||
);
|
||||
}
|
||||
final full = snapshot.data;
|
||||
if (full == null) {
|
||||
return Center(
|
||||
child: cupertino
|
||||
? const CupertinoActivityIndicator()
|
||||
: const CircularProgressIndicator(),
|
||||
);
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
return _content(context, full);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
if (cupertino) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(middle: title),
|
||||
child: body,
|
||||
);
|
||||
}
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: title),
|
||||
body: body,
|
||||
@@ -139,7 +123,6 @@ class _ChatShellHistoryOutputPageState
|
||||
}
|
||||
|
||||
Widget _content(BuildContext context, ChatShellRun full) {
|
||||
final cupertino = widget.cupertino;
|
||||
final session = _session ??= ChatShellTerminalSession(
|
||||
full,
|
||||
onInput: (_) {},
|
||||
@@ -155,11 +138,11 @@ class _ChatShellHistoryOutputPageState
|
||||
runSpacing: 4,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
ChatShellStatus(run: full, cupertino: cupertino),
|
||||
ChatShellStatus(run: full, cupertino: false),
|
||||
if (full.directory.isNotEmpty)
|
||||
Text(
|
||||
full.directory,
|
||||
style: chatCardSecondaryStyle(context, cupertino),
|
||||
style: chatCardSecondaryStyle(context, false),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -169,11 +152,11 @@ class _ChatShellHistoryOutputPageState
|
||||
? Text(
|
||||
'No output.',
|
||||
key: const Key('chat-shell-output-empty'),
|
||||
style: chatCardSecondaryStyle(context, cupertino),
|
||||
style: chatCardSecondaryStyle(context, false),
|
||||
)
|
||||
: ChatShellTerminalView(
|
||||
session: session,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
fill: true,
|
||||
),
|
||||
),
|
||||
@@ -203,9 +186,6 @@ class _ChatShellHistoryOutputPageState
|
||||
key: const Key('chat-shell-history-copy'),
|
||||
label: _copied ? chatShellCopiedLabel : chatShellCopyLabel,
|
||||
material: _copied ? Icons.check : Icons.copy_outlined,
|
||||
cupertino: _copied
|
||||
? CupertinoIcons.checkmark
|
||||
: CupertinoIcons.doc_on_doc,
|
||||
onPressed: () => unawaited(_copy(full)),
|
||||
),
|
||||
_button(
|
||||
@@ -218,9 +198,6 @@ class _ChatShellHistoryOutputPageState
|
||||
material: share == ChatShellShareState.sent
|
||||
? Icons.check
|
||||
: Icons.send_outlined,
|
||||
cupertino: share == ChatShellShareState.sent
|
||||
? CupertinoIcons.checkmark
|
||||
: CupertinoIcons.paperplane,
|
||||
onPressed: share == ChatShellShareState.idle
|
||||
? () => unawaited(controller.share(widget.runId))
|
||||
: null,
|
||||
@@ -229,7 +206,6 @@ class _ChatShellHistoryOutputPageState
|
||||
key: const Key('chat-shell-history-page-restore'),
|
||||
label: 'Restore',
|
||||
material: Icons.restore,
|
||||
cupertino: CupertinoIcons.arrow_counterclockwise,
|
||||
onPressed: () => unawaited(_restore()),
|
||||
),
|
||||
],
|
||||
@@ -241,8 +217,8 @@ class _ChatShellHistoryOutputPageState
|
||||
error,
|
||||
style: chatCardSecondaryStyle(
|
||||
context,
|
||||
widget.cupertino,
|
||||
)?.copyWith(color: chatCardErrorColor(context, widget.cupertino)),
|
||||
false,
|
||||
)?.copyWith(color: chatCardErrorColor(context, false)),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -253,20 +229,8 @@ class _ChatShellHistoryOutputPageState
|
||||
required Key key,
|
||||
required String label,
|
||||
required IconData material,
|
||||
required IconData cupertino,
|
||||
required VoidCallback? onPressed,
|
||||
}) {
|
||||
if (widget.cupertino) {
|
||||
return CupertinoButton(
|
||||
key: key,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
onPressed: onPressed,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [Icon(cupertino), const SizedBox(width: 6), Text(label)],
|
||||
),
|
||||
);
|
||||
}
|
||||
return TextButton.icon(
|
||||
key: key,
|
||||
onPressed: onPressed,
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/text/monospace.dart';
|
||||
import '../conversation/chat_card_styles.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
import 'chat_shell_history_output_page.dart';
|
||||
import 'chat_shell_run.dart';
|
||||
import 'chat_shell_runs_controller.dart';
|
||||
@@ -54,8 +52,6 @@ class _ChatShellHistoryViewState extends State<ChatShellHistoryView> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final list = ListenableBuilder(
|
||||
listenable: widget.controller.membership,
|
||||
builder: (context, _) {
|
||||
@@ -80,18 +76,16 @@ class _ChatShellHistoryViewState extends State<ChatShellHistoryView> {
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(
|
||||
'Every command here was restored to the transcript.',
|
||||
style: chatCardSecondaryStyle(context, cupertino),
|
||||
style: chatCardSecondaryStyle(context, false),
|
||||
),
|
||||
),
|
||||
for (final run in runs) _entry(context, run, cupertino),
|
||||
for (final run in runs) _entry(context, run),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
final style = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyMedium;
|
||||
// Entries are Material list tiles inside a Cupertino surface too.
|
||||
final style = Theme.of(context).textTheme.bodyMedium;
|
||||
// Entries are Material list tiles inside the surface.
|
||||
final content = Material(
|
||||
type: MaterialType.transparency,
|
||||
child: DefaultTextStyle.merge(style: style, child: list),
|
||||
@@ -105,8 +99,8 @@ class _ChatShellHistoryViewState extends State<ChatShellHistoryView> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _entry(BuildContext context, ChatShellRun run, bool cupertino) {
|
||||
final secondary = chatCardSecondaryStyle(context, cupertino);
|
||||
Widget _entry(BuildContext context, ChatShellRun run) {
|
||||
final secondary = chatCardSecondaryStyle(context, false);
|
||||
final refusal = _refusals[run.id];
|
||||
final command = run.purged || run.command.isEmpty
|
||||
? Text(chatShellCommandNotKept, style: secondary)
|
||||
@@ -124,7 +118,7 @@ class _ChatShellHistoryViewState extends State<ChatShellHistoryView> {
|
||||
runSpacing: 4,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
ChatShellStatus(run: run, cupertino: cupertino),
|
||||
ChatShellStatus(run: run, cupertino: false),
|
||||
Text(chatShellRunTime(context, run.startedAt), style: secondary),
|
||||
if (run.purged) Text(chatShellOutputNotKept, style: secondary),
|
||||
if (refusal != null)
|
||||
@@ -132,20 +126,13 @@ class _ChatShellHistoryViewState extends State<ChatShellHistoryView> {
|
||||
refusal,
|
||||
key: const Key('chat-shell-history-refusal'),
|
||||
style: secondary?.copyWith(
|
||||
color: chatCardErrorColor(context, cupertino),
|
||||
color: chatCardErrorColor(context, false),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
final restore = run.purged
|
||||
? null
|
||||
: cupertino
|
||||
? CupertinoButton(
|
||||
key: ValueKey<String>('chat-shell-history-restore-${run.id}'),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
onPressed: () => unawaited(_restore(run.id)),
|
||||
child: const Text(chatShellRestoreLabel),
|
||||
)
|
||||
: TextButton(
|
||||
key: ValueKey<String>('chat-shell-history-restore-${run.id}'),
|
||||
onPressed: () => unawaited(_restore(run.id)),
|
||||
@@ -164,7 +151,7 @@ class _ChatShellHistoryViewState extends State<ChatShellHistoryView> {
|
||||
context,
|
||||
controller: widget.controller,
|
||||
runId: run.id,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../conversation/chat_card_styles.dart';
|
||||
@@ -13,10 +12,8 @@ class ChatShellModeIndicator extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final accent = cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
final label = (chatCardBodyStyle(context, cupertino) ?? const TextStyle())
|
||||
final accent = Theme.of(context).colorScheme.primary;
|
||||
final label = (chatCardBodyStyle(context, false) ?? const TextStyle())
|
||||
.copyWith(color: accent, fontWeight: FontWeight.w600);
|
||||
return Semantics(
|
||||
key: const Key('chat-composer-shell-mode'),
|
||||
@@ -35,9 +32,7 @@ class ChatShellModeIndicator extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
cupertino
|
||||
? CupertinoIcons.chevron_left_slash_chevron_right
|
||||
: Icons.terminal,
|
||||
Icons.terminal,
|
||||
color: accent,
|
||||
size: MediaQuery.textScalerOf(
|
||||
context,
|
||||
@@ -49,7 +44,7 @@ class ChatShellModeIndicator extends StatelessWidget {
|
||||
),
|
||||
Text(
|
||||
chatShellModeHint,
|
||||
style: chatCardSecondaryStyle(context, cupertino),
|
||||
style: chatCardSecondaryStyle(context, false),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -36,7 +36,7 @@ class ChatShellOutputView extends StatelessWidget {
|
||||
return Text(
|
||||
'No output.',
|
||||
key: const Key('chat-shell-output-empty'),
|
||||
style: chatCardSecondaryStyle(context, cupertino),
|
||||
style: chatCardSecondaryStyle(context, false),
|
||||
);
|
||||
}
|
||||
final session = controller.terminals.session(run);
|
||||
@@ -47,7 +47,7 @@ class ChatShellOutputView extends StatelessWidget {
|
||||
ChatShellTerminalView(
|
||||
key: viewKey,
|
||||
session: session,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
autoResize: !fullScreen,
|
||||
),
|
||||
if (session.live && !fullScreen)
|
||||
@@ -55,7 +55,7 @@ class ChatShellOutputView extends StatelessWidget {
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: ChatShellTerminalKeys(
|
||||
session: session,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
field: chatShellTouchFirst(),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/text/monospace.dart';
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import '../conversation/chat_card_styles.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
import 'chat_shell_card_actions.dart';
|
||||
import 'chat_shell_dismiss.dart';
|
||||
import 'chat_shell_output_view.dart';
|
||||
@@ -43,13 +40,13 @@ class _ChatShellRunCardState extends State<ChatShellRunCard> {
|
||||
bool _fullScreen = false;
|
||||
int _viewGeneration = 0;
|
||||
|
||||
Future<void> _openFullScreen(bool cupertino) async {
|
||||
Future<void> _openFullScreen() async {
|
||||
setState(() => _fullScreen = true);
|
||||
await openChatShellTerminalPage(
|
||||
context,
|
||||
controller: widget.controller,
|
||||
runId: widget.runId,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
);
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
@@ -60,41 +57,28 @@ class _ChatShellRunCardState extends State<ChatShellRunCard> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
return ListenableBuilder(
|
||||
listenable: widget.controller,
|
||||
builder: (context, _) {
|
||||
final run = widget.controller.run(widget.runId);
|
||||
if (run == null) return const SizedBox.shrink();
|
||||
final body = _body(context, run, cupertino);
|
||||
final body = _body(context, run);
|
||||
return Semantics(
|
||||
identifier: 'chat-shell-run-card',
|
||||
container: true,
|
||||
child: cupertino
|
||||
? CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
children: [
|
||||
Padding(padding: const EdgeInsets.all(16), child: body),
|
||||
],
|
||||
)
|
||||
: Card(
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: body,
|
||||
),
|
||||
),
|
||||
child: Card(
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
child: Padding(padding: const EdgeInsets.all(16), child: body),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _body(BuildContext context, ChatShellRun run, bool cupertino) {
|
||||
Widget _body(BuildContext context, ChatShellRun run) {
|
||||
final controller = widget.controller;
|
||||
final error = controller.errorFor(run.id);
|
||||
final command = (chatCardBodyStyle(context, cupertino) ?? const TextStyle())
|
||||
final command = (chatCardBodyStyle(context, false) ?? const TextStyle())
|
||||
.copyWith(fontFamily: appMonospaceFamily, fontWeight: FontWeight.w600);
|
||||
return Column(
|
||||
key: ValueKey<String>('chat-shell-run-${run.id}'),
|
||||
@@ -107,10 +91,8 @@ class _ChatShellRunCardState extends State<ChatShellRunCard> {
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.only(end: 12),
|
||||
child: Icon(
|
||||
cupertino
|
||||
? CupertinoIcons.chevron_left_slash_chevron_right
|
||||
: Icons.terminal,
|
||||
color: chatCardSecondaryColor(context, cupertino),
|
||||
Icons.terminal,
|
||||
color: chatCardSecondaryColor(context, false),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
@@ -125,21 +107,21 @@ class _ChatShellRunCardState extends State<ChatShellRunCard> {
|
||||
if (run.directory.isNotEmpty)
|
||||
Text(
|
||||
run.directory,
|
||||
style: chatCardSecondaryStyle(context, cupertino),
|
||||
style: chatCardSecondaryStyle(context, false),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
ChatShellStatus(run: run, cupertino: cupertino),
|
||||
ChatShellStatus(run: run, cupertino: false),
|
||||
if (!run.running)
|
||||
ChatShellDismissButton(
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
onPressed: () => unawaited(
|
||||
// A refusal brings the card back with the server's reason.
|
||||
dismissChatShellRuns(context, controller, [
|
||||
run.id,
|
||||
], cupertino: cupertino),
|
||||
], cupertino: false),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -148,7 +130,7 @@ class _ChatShellRunCardState extends State<ChatShellRunCard> {
|
||||
ChatShellOutputView(
|
||||
run: run,
|
||||
controller: controller,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
viewKey: ValueKey<int>(_viewGeneration),
|
||||
fullScreen: _fullScreen,
|
||||
),
|
||||
@@ -157,15 +139,15 @@ class _ChatShellRunCardState extends State<ChatShellRunCard> {
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: Text(
|
||||
run.error,
|
||||
style: chatCardSecondaryStyle(context, cupertino),
|
||||
style: chatCardSecondaryStyle(context, false),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
ChatShellCardActions(
|
||||
run: run,
|
||||
controller: controller,
|
||||
cupertino: cupertino,
|
||||
onFullScreen: () => _openFullScreen(cupertino),
|
||||
cupertino: false,
|
||||
onFullScreen: () => _openFullScreen(),
|
||||
),
|
||||
if (error != null)
|
||||
Semantics(
|
||||
@@ -173,9 +155,8 @@ class _ChatShellRunCardState extends State<ChatShellRunCard> {
|
||||
child: Text(
|
||||
error,
|
||||
key: const Key('chat-shell-run-error'),
|
||||
style:
|
||||
(chatCardBodyStyle(context, cupertino) ?? const TextStyle())
|
||||
.copyWith(color: chatCardErrorColor(context, cupertino)),
|
||||
style: (chatCardBodyStyle(context, false) ?? const TextStyle())
|
||||
.copyWith(color: chatCardErrorColor(context, false)),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/text/monospace.dart';
|
||||
@@ -9,16 +8,10 @@ import 'chat_shell_command.dart';
|
||||
Future<String?> showChatShellRunDialog(
|
||||
BuildContext context, {
|
||||
required bool cupertino,
|
||||
}) => cupertino
|
||||
? showCupertinoDialog<String>(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (_) => const ChatShellRunDialog(cupertino: true),
|
||||
)
|
||||
: showDialog<String>(
|
||||
context: context,
|
||||
builder: (_) => const ChatShellRunDialog(cupertino: false),
|
||||
);
|
||||
}) => showDialog<String>(
|
||||
context: context,
|
||||
builder: (_) => const ChatShellRunDialog(cupertino: false),
|
||||
);
|
||||
|
||||
class ChatShellRunDialog extends StatefulWidget {
|
||||
const ChatShellRunDialog({super.key, required this.cupertino});
|
||||
@@ -48,37 +41,6 @@ class _ChatShellRunDialogState extends State<ChatShellRunDialog> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const mono = TextStyle(fontFamily: appMonospaceFamily);
|
||||
if (widget.cupertino) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text(chatShellRunDialogTitle),
|
||||
content: Column(
|
||||
children: [
|
||||
const Text(chatShellModeHint),
|
||||
const SizedBox(height: 12),
|
||||
CupertinoTextField(
|
||||
key: const Key('chat-shell-run-field'),
|
||||
controller: _text,
|
||||
autofocus: true,
|
||||
placeholder: 'Command',
|
||||
style: mono,
|
||||
onSubmitted: (_) => _submit(),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: _cancel,
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
key: const Key('chat-shell-run-confirm'),
|
||||
isDefaultAction: true,
|
||||
onPressed: _submit,
|
||||
child: const Text(chatShellRunDialogConfirm),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
return AlertDialog(
|
||||
title: const Text(chatShellRunDialogTitle),
|
||||
content: Column(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../conversation/chat_card_styles.dart';
|
||||
@@ -24,46 +23,26 @@ class ChatShellStatus extends StatelessWidget {
|
||||
return Semantics(
|
||||
key: const Key('chat-shell-run-running'),
|
||||
label: chatShellStatusLabel(run),
|
||||
child: cupertino
|
||||
? const CupertinoActivityIndicator()
|
||||
// As tall as the line of text beside it, at any text scale.
|
||||
: SizedBox.square(
|
||||
dimension: MediaQuery.textScalerOf(context).scale(20),
|
||||
child: const CircularProgressIndicator(strokeWidth: 2),
|
||||
),
|
||||
// As tall as the line of text beside it, at any text scale.
|
||||
child: SizedBox.square(
|
||||
dimension: MediaQuery.textScalerOf(context).scale(20),
|
||||
child: const CircularProgressIndicator(strokeWidth: 2),
|
||||
),
|
||||
);
|
||||
}
|
||||
final label = run.durationMs > 0
|
||||
? '${chatShellStatusLabel(run)} · ${chatShellDuration(run.durationMs)}'
|
||||
: chatShellStatusLabel(run);
|
||||
final color = switch (run.state) {
|
||||
ChatShellRunState.succeeded =>
|
||||
cupertino
|
||||
? CupertinoColors.systemGreen.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.primary,
|
||||
ChatShellRunState.failed => chatCardErrorColor(context, cupertino),
|
||||
_ => chatCardSecondaryColor(context, cupertino),
|
||||
ChatShellRunState.succeeded => Theme.of(context).colorScheme.primary,
|
||||
ChatShellRunState.failed => chatCardErrorColor(context, false),
|
||||
_ => chatCardSecondaryColor(context, false),
|
||||
};
|
||||
final icon = switch (run.state) {
|
||||
ChatShellRunState.succeeded =>
|
||||
cupertino
|
||||
? CupertinoIcons.checkmark_circle
|
||||
: Icons.check_circle_outline,
|
||||
ChatShellRunState.failed =>
|
||||
cupertino ? CupertinoIcons.xmark_circle : Icons.error_outline,
|
||||
_ => cupertino ? CupertinoIcons.stop_circle : Icons.stop_circle_outlined,
|
||||
ChatShellRunState.succeeded => Icons.check_circle_outline,
|
||||
ChatShellRunState.failed => Icons.error_outline,
|
||||
_ => Icons.stop_circle_outlined,
|
||||
};
|
||||
if (cupertino) {
|
||||
return Row(
|
||||
key: const Key('chat-shell-run-status'),
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(icon, color: color, size: 18),
|
||||
const SizedBox(width: 4),
|
||||
Text(label, style: chatCardSecondaryStyle(context, true)),
|
||||
],
|
||||
);
|
||||
}
|
||||
return Chip(
|
||||
key: const Key('chat-shell-run-status'),
|
||||
avatar: Icon(icon, color: color),
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:xterm/core.dart';
|
||||
|
||||
import 'chat_shell_terminal_session.dart';
|
||||
|
||||
/// One key of the terminal toolbar: its label, icons and what it sends.
|
||||
/// One key of the terminal toolbar: its label, icon and what it sends.
|
||||
typedef _Key = ({
|
||||
String id,
|
||||
String label,
|
||||
IconData? material,
|
||||
IconData? cupertino,
|
||||
void Function(Terminal terminal) send,
|
||||
});
|
||||
|
||||
@@ -19,56 +17,48 @@ final List<_Key> _keys = [
|
||||
id: 'enter',
|
||||
label: 'Enter',
|
||||
material: Icons.keyboard_return,
|
||||
cupertino: CupertinoIcons.return_icon,
|
||||
send: (t) => t.keyInput(TerminalKey.enter),
|
||||
),
|
||||
(
|
||||
id: 'ctrl-c',
|
||||
label: 'Ctrl-C',
|
||||
material: null,
|
||||
cupertino: null,
|
||||
send: (t) => t.textInput('\x03'),
|
||||
),
|
||||
(
|
||||
id: 'tab',
|
||||
label: 'Tab',
|
||||
material: Icons.keyboard_tab,
|
||||
cupertino: CupertinoIcons.arrow_right_to_line,
|
||||
send: (t) => t.keyInput(TerminalKey.tab),
|
||||
),
|
||||
(
|
||||
id: 'esc',
|
||||
label: 'Esc',
|
||||
material: null,
|
||||
cupertino: null,
|
||||
send: (t) => t.keyInput(TerminalKey.escape),
|
||||
),
|
||||
(
|
||||
id: 'left',
|
||||
label: 'Left',
|
||||
material: Icons.keyboard_arrow_left,
|
||||
cupertino: CupertinoIcons.arrow_left,
|
||||
send: (t) => t.keyInput(TerminalKey.arrowLeft),
|
||||
),
|
||||
(
|
||||
id: 'up',
|
||||
label: 'Up',
|
||||
material: Icons.keyboard_arrow_up,
|
||||
cupertino: CupertinoIcons.arrow_up,
|
||||
send: (t) => t.keyInput(TerminalKey.arrowUp),
|
||||
),
|
||||
(
|
||||
id: 'down',
|
||||
label: 'Down',
|
||||
material: Icons.keyboard_arrow_down,
|
||||
cupertino: CupertinoIcons.arrow_down,
|
||||
send: (t) => t.keyInput(TerminalKey.arrowDown),
|
||||
),
|
||||
(
|
||||
id: 'right',
|
||||
label: 'Right',
|
||||
material: Icons.keyboard_arrow_right,
|
||||
cupertino: CupertinoIcons.arrow_right,
|
||||
send: (t) => t.keyInput(TerminalKey.arrowRight),
|
||||
),
|
||||
];
|
||||
@@ -127,21 +117,9 @@ class _ChatShellTerminalKeysState extends State<ChatShellTerminalKeys> {
|
||||
spacing: 4,
|
||||
runSpacing: 4,
|
||||
children: [
|
||||
_button(
|
||||
'paste',
|
||||
'Paste',
|
||||
Icons.content_paste,
|
||||
CupertinoIcons.doc_on_clipboard,
|
||||
_paste,
|
||||
),
|
||||
_button('paste', 'Paste', Icons.content_paste, _paste),
|
||||
for (final key in _keys)
|
||||
_button(
|
||||
key.id,
|
||||
key.label,
|
||||
key.material,
|
||||
key.cupertino,
|
||||
() => key.send(_terminal),
|
||||
),
|
||||
_button(key.id, key.label, key.material, () => key.send(_terminal)),
|
||||
],
|
||||
);
|
||||
if (!widget.field) return keys;
|
||||
@@ -157,27 +135,6 @@ class _ChatShellTerminalKeysState extends State<ChatShellTerminalKeys> {
|
||||
|
||||
Widget _field() {
|
||||
final toggle = _hidden ? 'Show typing' : 'Hide typing';
|
||||
if (widget.cupertino) {
|
||||
return CupertinoTextField(
|
||||
key: const Key('chat-shell-terminal-field'),
|
||||
controller: _text,
|
||||
placeholder: 'Type input, then Enter',
|
||||
obscureText: _hidden,
|
||||
autocorrect: false,
|
||||
enableSuggestions: false,
|
||||
textInputAction: TextInputAction.send,
|
||||
onSubmitted: (_) => _submit(),
|
||||
suffix: CupertinoButton(
|
||||
key: const Key('chat-shell-terminal-hide'),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
onPressed: () => setState(() => _hidden = !_hidden),
|
||||
child: Icon(
|
||||
_hidden ? CupertinoIcons.eye : CupertinoIcons.eye_slash,
|
||||
semanticLabel: toggle,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return TextField(
|
||||
key: const Key('chat-shell-terminal-field'),
|
||||
controller: _text,
|
||||
@@ -202,20 +159,9 @@ class _ChatShellTerminalKeysState extends State<ChatShellTerminalKeys> {
|
||||
String id,
|
||||
String label,
|
||||
IconData? material,
|
||||
IconData? cupertino,
|
||||
VoidCallback onPressed,
|
||||
) {
|
||||
final key = Key('chat-shell-key-$id');
|
||||
if (widget.cupertino) {
|
||||
return CupertinoButton(
|
||||
key: key,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
onPressed: onPressed,
|
||||
child: cupertino == null
|
||||
? Text(label)
|
||||
: Icon(cupertino, semanticLabel: label),
|
||||
);
|
||||
}
|
||||
if (material == null) {
|
||||
return OutlinedButton(
|
||||
key: key,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/text/monospace.dart';
|
||||
@@ -20,11 +19,7 @@ Future<void> openChatShellTerminalPage(
|
||||
runId: runId,
|
||||
cupertino: cupertino,
|
||||
);
|
||||
return Navigator.of(context).push<void>(
|
||||
cupertino
|
||||
? CupertinoPageRoute<void>(builder: page)
|
||||
: MaterialPageRoute<void>(builder: page),
|
||||
);
|
||||
return Navigator.push<void>(context, MaterialPageRoute<void>(builder: page));
|
||||
}
|
||||
|
||||
class ChatShellTerminalPage extends StatelessWidget {
|
||||
@@ -63,7 +58,7 @@ class ChatShellTerminalPage extends StatelessWidget {
|
||||
Expanded(
|
||||
child: ChatShellTerminalView(
|
||||
session: session,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
fill: true,
|
||||
autofocus: true,
|
||||
),
|
||||
@@ -73,7 +68,7 @@ class ChatShellTerminalPage extends StatelessWidget {
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: ChatShellTerminalKeys(
|
||||
session: session,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
field: chatShellTouchFirst(),
|
||||
),
|
||||
),
|
||||
@@ -82,12 +77,6 @@ class ChatShellTerminalPage extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
if (cupertino) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(middle: title),
|
||||
child: body,
|
||||
);
|
||||
}
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: title),
|
||||
body: body,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:xterm/xterm.dart';
|
||||
|
||||
@@ -12,17 +11,10 @@ import '../conversation/chat_card_styles.dart';
|
||||
/// selection. The sixteen ANSI colours are the emulator's standard palette,
|
||||
/// darkened on a light surface so coloured output stays readable.
|
||||
TerminalTheme chatShellTerminalTheme(BuildContext context, bool cupertino) {
|
||||
final brightness = cupertino
|
||||
? CupertinoTheme.brightnessOf(context)
|
||||
: Theme.of(context).brightness;
|
||||
final dark = brightness == Brightness.dark;
|
||||
final background = chatCardFillColor(context, cupertino);
|
||||
final foreground = cupertino
|
||||
? CupertinoColors.label.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurface;
|
||||
final accent = cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
final dark = Theme.of(context).brightness == Brightness.dark;
|
||||
final background = chatCardFillColor(context, false);
|
||||
final foreground = Theme.of(context).colorScheme.onSurface;
|
||||
final accent = Theme.of(context).colorScheme.primary;
|
||||
final base = TerminalThemes.defaultTheme;
|
||||
Color ansi(Color color) {
|
||||
if (dark) return color;
|
||||
@@ -37,9 +29,7 @@ TerminalTheme chatShellTerminalTheme(BuildContext context, bool cupertino) {
|
||||
// Opaque: the emulator paints cells over its own background.
|
||||
background: Color.alphaBlend(
|
||||
background,
|
||||
cupertino
|
||||
? CupertinoColors.systemBackground.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.surface,
|
||||
Theme.of(context).colorScheme.surface,
|
||||
),
|
||||
black: dark ? base.black : foreground,
|
||||
red: ansi(base.red),
|
||||
@@ -65,7 +55,7 @@ TerminalTheme chatShellTerminalTheme(BuildContext context, bool cupertino) {
|
||||
|
||||
/// The terminal's text: the host's monospace family at the card body size.
|
||||
TerminalStyle chatShellTerminalStyle(BuildContext context, bool cupertino) {
|
||||
final body = chatCardBodyStyle(context, cupertino) ?? const TextStyle();
|
||||
final body = chatCardBodyStyle(context, false) ?? const TextStyle();
|
||||
return TerminalStyle(
|
||||
fontFamily: appMonospaceFamily,
|
||||
fontSize: (body.fontSize ?? 14) * 0.95,
|
||||
|
||||
@@ -155,7 +155,7 @@ class _ChatShellTerminalViewState extends State<ChatShellTerminalView> {
|
||||
Widget build(BuildContext context) {
|
||||
final session = widget.session;
|
||||
final live = session.live;
|
||||
final style = chatShellTerminalStyle(context, widget.cupertino);
|
||||
final style = chatShellTerminalStyle(context, false);
|
||||
const padding = EdgeInsets.all(8);
|
||||
Widget view = Semantics(
|
||||
identifier: 'chat-shell-terminal',
|
||||
@@ -168,7 +168,7 @@ class _ChatShellTerminalViewState extends State<ChatShellTerminalView> {
|
||||
focusNode: _focus,
|
||||
autofocus: widget.autofocus && live,
|
||||
autoResize: widget.autoResize,
|
||||
theme: chatShellTerminalTheme(context, widget.cupertino),
|
||||
theme: chatShellTerminalTheme(context, false),
|
||||
textStyle: style,
|
||||
padding: padding,
|
||||
readOnly: !live,
|
||||
|
||||
Reference in New Issue
Block a user