feat(app): glass viewer bars, graph controls and immersive image viewer
Review findings F12, F13, F25 and F1 for viewers: the artifact viewer's actions/pager and the Changes pager float as glass pills over content, file facts move to the top bar, graph overlay controls are one glass pill (duplicate fullscreen glyph removed), the image viewer is immersive, and diff/artifact/graph views let content pass behind the bar. Implemented by pipeline run #204 (Terra); its Review stopped after three rejections, the last being an empty glass bar for a single unresolved artifact, which the manager fixed here with a regression test.
This commit is contained in:
@@ -6,12 +6,13 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../../../ui/adaptive/glass_pill.dart';
|
||||
import '../actions/artifact_file_actions.dart';
|
||||
import '../actions/artifact_file_bridge.dart';
|
||||
import '../domain/artifact_preview.dart';
|
||||
import '../domain/artifact_url.dart';
|
||||
import '../domain/gallery_navigation.dart';
|
||||
import 'artifact_selection_facts.dart';
|
||||
import 'artifact_viewer_content.dart';
|
||||
import 'artifact_viewer_fetch.dart';
|
||||
|
||||
@@ -62,24 +63,11 @@ class ArtifactViewerBody extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final resolved = plan.resolved;
|
||||
// The page never scrolls: a thin strip on top, the preview filling the
|
||||
// middle (it zooms or scrolls itself), the controls along the bottom.
|
||||
// The page never scrolls: the preview fills the middle (it zooms or
|
||||
// scrolls itself) and the controls float over its bottom edge.
|
||||
final content = Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_InfoStrip(
|
||||
label: artifactViewerPositionLabel(
|
||||
index,
|
||||
count,
|
||||
page.artifact.contentType,
|
||||
),
|
||||
facts: ArtifactSelectionFacts(
|
||||
group: page.group,
|
||||
artifact: page.artifact,
|
||||
step: null,
|
||||
resolved: plan.resolved,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ArtifactPreviewBody(
|
||||
plan: plan,
|
||||
@@ -94,47 +82,51 @@ class ArtifactViewerBody extends StatelessWidget {
|
||||
);
|
||||
final hasPrevious = pagedIndex(index, -1, count) != index;
|
||||
final hasNext = pagedIndex(index, 1, count) != index;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Expanded(
|
||||
// A horizontal swipe moves to the previous or next artifact.
|
||||
child: GestureDetector(
|
||||
key: const Key('artifact-viewer-swipe'),
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onHorizontalDragEnd: (details) {
|
||||
final velocity = details.primaryVelocity ?? 0;
|
||||
if (velocity < -250 && hasNext) onNext();
|
||||
if (velocity > 250 && hasPrevious) onPrevious();
|
||||
},
|
||||
child: content,
|
||||
),
|
||||
),
|
||||
// Every action as an icon at the bottom, beside the pager.
|
||||
SafeArea(
|
||||
top: false,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Row(
|
||||
key: const Key('artifact-viewer-actions'),
|
||||
children: [
|
||||
if (resolved != null && !resolved.external)
|
||||
ArtifactFileActions(
|
||||
key: ValueKey<String>(
|
||||
'viewer-files-${page.group.stageKey}\u0000'
|
||||
'${page.group.visit}\u0000${page.artifact.url}',
|
||||
final swipe = GestureDetector(
|
||||
key: const Key('artifact-viewer-swipe'),
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onHorizontalDragEnd: (details) {
|
||||
final velocity = details.primaryVelocity ?? 0;
|
||||
if (velocity < -250 && hasNext) onNext();
|
||||
if (velocity > 250 && hasPrevious) onPrevious();
|
||||
},
|
||||
child: content,
|
||||
);
|
||||
// An unresolved single artifact has no actions and nothing to page:
|
||||
// no empty glass bar, and no bottom clearance reserved for one.
|
||||
if (resolved == null && count <= 1) return swipe;
|
||||
return FloatingBarOverlay(
|
||||
bar: SafeArea(
|
||||
top: false,
|
||||
minimum: const EdgeInsets.all(8),
|
||||
child: SizedBox(
|
||||
height: 56,
|
||||
child: GlassPill(
|
||||
cupertino: usesCupertinoHost(context),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2),
|
||||
child: Row(
|
||||
key: const Key('artifact-viewer-actions'),
|
||||
children: [
|
||||
if (resolved != null && !resolved.external)
|
||||
ArtifactFileActions(
|
||||
key: ValueKey<String>(
|
||||
'viewer-files-${page.group.stageKey}\u0000'
|
||||
'${page.group.visit}\u0000${page.artifact.url}',
|
||||
),
|
||||
artifact: page.artifact,
|
||||
resolved: resolved,
|
||||
fetch: fetch,
|
||||
bridge: fileBridge,
|
||||
compact: true,
|
||||
),
|
||||
artifact: page.artifact,
|
||||
resolved: resolved,
|
||||
fetch: fetch,
|
||||
bridge: fileBridge,
|
||||
compact: true,
|
||||
),
|
||||
if (resolved != null)
|
||||
_Actions(resolved: resolved, onOpen: onOpen, onCopy: onCopy),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.centerEnd,
|
||||
if (resolved != null)
|
||||
_Actions(
|
||||
resolved: resolved,
|
||||
onOpen: onOpen,
|
||||
onCopy: onCopy,
|
||||
),
|
||||
Expanded(
|
||||
child: _Pager(
|
||||
index: index,
|
||||
count: count,
|
||||
@@ -142,12 +134,13 @@ class ArtifactViewerBody extends StatelessWidget {
|
||||
onNext: onNext,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: swipe,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -331,10 +324,9 @@ class _Pager extends StatelessWidget {
|
||||
|
||||
/// The viewer's top edge: where this artifact sits in the list, and an
|
||||
/// information button for its recorded facts.
|
||||
class _InfoStrip extends StatelessWidget {
|
||||
const _InfoStrip({required this.label, required this.facts});
|
||||
class ArtifactViewerInfoAction extends StatelessWidget {
|
||||
const ArtifactViewerInfoAction({super.key, required this.facts});
|
||||
|
||||
final String label;
|
||||
final Widget facts;
|
||||
|
||||
void _show(BuildContext context) {
|
||||
@@ -366,35 +358,12 @@ class _InfoStrip extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final muted = usesCupertinoHost(context)
|
||||
? CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
)
|
||||
: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
);
|
||||
return Padding(
|
||||
padding: const EdgeInsetsDirectional.only(start: 16, end: 4),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
label,
|
||||
key: const Key('artifact-viewer-position'),
|
||||
style: muted,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
ArtifactIconAction(
|
||||
key: const Key('artifact-info'),
|
||||
label: 'Details',
|
||||
icon: Icons.info_outline,
|
||||
cupertinoIcon: CupertinoIcons.info,
|
||||
onPressed: () => _show(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
return ArtifactIconAction(
|
||||
key: const Key('artifact-info'),
|
||||
label: 'Details',
|
||||
icon: Icons.info_outline,
|
||||
cupertinoIcon: CupertinoIcons.info,
|
||||
onPressed: () => _show(context),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import 'artifact_selection_facts.dart';
|
||||
import '../actions/artifact_file_bridge.dart';
|
||||
import '../domain/artifact_groups.dart';
|
||||
import '../domain/artifact_preview.dart';
|
||||
@@ -222,6 +223,25 @@ class _ArtifactViewerPageState extends State<ArtifactViewerPage> {
|
||||
final title = page == null
|
||||
? artifactViewerTitle
|
||||
: artifactDisplayName(page.artifact);
|
||||
final subtitle = page == null
|
||||
? null
|
||||
: artifactViewerPositionLabel(
|
||||
_index,
|
||||
_pages.length,
|
||||
page.artifact.contentType,
|
||||
);
|
||||
final info = page == null || plan == null
|
||||
? const <Widget>[]
|
||||
: <Widget>[
|
||||
ArtifactViewerInfoAction(
|
||||
facts: ArtifactSelectionFacts(
|
||||
group: page.group,
|
||||
artifact: page.artifact,
|
||||
step: null,
|
||||
resolved: plan.resolved,
|
||||
),
|
||||
),
|
||||
];
|
||||
Widget body = page == null || plan == null
|
||||
? const Center(child: Text('No previewable artifacts recorded.'))
|
||||
: ArtifactViewerBody(
|
||||
@@ -253,14 +273,24 @@ class _ArtifactViewerPageState extends State<ArtifactViewerPage> {
|
||||
if (usesCupertinoHost(context)) {
|
||||
return CupertinoPageScaffold(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
navigationBar: SegmentedBar(cupertino: true, title: title),
|
||||
child: SafeArea(child: body),
|
||||
navigationBar: SegmentedBar(
|
||||
cupertino: true,
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
actions: info,
|
||||
),
|
||||
child: body,
|
||||
);
|
||||
}
|
||||
return Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: SegmentedBar(cupertino: false, title: title),
|
||||
body: SafeArea(child: body),
|
||||
appBar: SegmentedBar(
|
||||
cupertino: false,
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
actions: info,
|
||||
),
|
||||
body: body,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user