Files
pipelines/app/lib/application/templates_destination.dart
T
alan c6c6dcfe18 fix(app): float content behind top bars and give each wide pane its own bar row
- Top-bar clearance helpers (withTopBarClearance, withBarClearance,
  SliverTopBarClearance, BelowTopBar, TopBarNotices); shell, DetailPane and
  the runs/pipelines/templates/artifacts/stage definition/filter/usage pages
  drop their top SafeArea and pad their own lists, pinned headers pin at the
  inset.
- Wide windows: the shell bar narrows to the list pane (ShellPaneSplit) and
  the open item's bar shares its row; item tabs float at the pane's top
  (PageTabsEdge) instead of stacking on the shell's tab bar; the floating
  tab pill no longer swells over leftover media padding.
- Pipeline detail is a DetailPane on wide too; Run/Runs move from FABs into
  the bar's actions; name and identity live in the title pill.
- Run detail title pill shows the real title with Run N, pipeline and
  version (the pill links to the pipeline); the body keeps only status,
  actions and notices; standalone detail draws the same segmented bar.
- One Runs tab badge: attention outranks running.
- Tests for content-behind-bar padding and the no-stacking wide layout;
  notes/app-chrome-fixes.md.
2026-10-31 03:36:22 +00:00

170 lines
4.9 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../ui/adaptive/segmented_bar.dart';
import '../core/api_gateway.dart';
import '../features/templates/screen.dart';
import '../shell/destination.dart';
import '../shell/shell_bar.dart';
import '../ui/adaptive/host.dart';
import '../ui/adaptive/floating_bar_layout.dart';
import '../ui/adaptive/top_bar_notices.dart';
import 'app_session.dart';
import 'connection_status.dart';
import 'server_endpoint.dart';
/// The Back control of the app-level Templates page.
const templatesPageBackKey = ValueKey<String>('templates-page-back');
/// The Templates destination: the landed gallery over the app's shared gateway.
///
/// The gallery is rendered in embedded mode, so the shell owns navigation; this
/// destination contributes the page's one native bar (Back + Templates) and the
/// same honest connection states as the other destinations. No socket is opened
/// here: [session] owns the only connection, and a template read, validate or
/// create request travels over it.
///
/// [onCreated] forwards the server-confirmed detail once, so the caller can
/// invalidate the Pipelines list. This screen never inserts a row itself.
class TemplatesDestination extends StatelessWidget {
const TemplatesDestination({
super.key,
required this.session,
required this.server,
required this.onBack,
this.onCreated,
this.initialKey,
});
final AppSession session;
final ServerEndpoint server;
/// Closes this page and restores the Settings destination underneath.
final VoidCallback onBack;
final ValueChanged<JsonMap>? onCreated;
/// The template detail the route names, or null for the gallery.
final String? initialKey;
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
return AnimatedBuilder(
animation: session,
builder: (context, _) => _TemplatesPage(
cupertino: cupertino,
onBack: onBack,
child: _body(cupertino),
),
);
}
Widget _body(bool cupertino) {
if (!session.everConnected) {
return BelowTopBar(
child: ConnectionGate(
session: session,
server: server,
cupertino: cupertino,
),
);
}
return TopBarNotices(
notices: [
if (!session.connected)
ConnectionBanner(session: session, cupertino: cupertino),
],
child: TemplatesScreen(
gateway: session.gateway,
embedded: true,
onCreated: onCreated,
initialKey: initialKey,
),
);
}
}
/// The page's standard native bar. Back is named explicitly so it cannot be
/// confused with the gallery's own Back-to-gallery control. The gallery puts
/// Refresh in this bar ([ShellBar]); its content scrolls behind the bar.
class _TemplatesPage extends StatefulWidget {
const _TemplatesPage({
required this.cupertino,
required this.onBack,
required this.child,
});
final bool cupertino;
final VoidCallback onBack;
final Widget child;
@override
State<_TemplatesPage> createState() => _TemplatesPageState();
}
class _TemplatesPageState extends State<_TemplatesPage> {
final ShellBarRegistry _bar = ShellBarRegistry();
@override
void dispose() {
_bar.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final cupertino = widget.cupertino;
// The page reaches its top edge; the gallery pads its lists by the bar.
final body = SafeArea(
top: false,
bottom: false,
child: ShellBarScope(
registry: _bar,
destination: AppDestination.settings,
child: widget.child,
),
);
return ListenableBuilder(
listenable: _bar,
builder: (context, _) {
final actions =
_bar.specFor(AppDestination.settings)?.actions ?? const <Widget>[];
if (cupertino) {
return CupertinoPageScaffold(
navigationBar: SegmentedBar(
cupertino: true,
leading: CupertinoButton(
key: templatesPageBackKey,
padding: EdgeInsets.zero,
onPressed: widget.onBack,
child: const Icon(
CupertinoIcons.back,
semanticLabel: 'Back to Settings',
),
),
title: 'Templates',
actions: actions,
),
child: body,
);
}
return Scaffold(
extendBodyBehindAppBar: true,
appBar: SegmentedBar(
cupertino: false,
leading: IconButton(
key: templatesPageBackKey,
tooltip: 'Back to Settings',
onPressed: widget.onBack,
icon: const Icon(Icons.arrow_back),
),
title: 'Templates',
actions: actions,
),
body: body,
);
},
);
}
}