c6c6dcfe18
- 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.
158 lines
4.7 KiB
Dart
158 lines
4.7 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../core/api_gateway.dart';
|
|
import '../features/templates/screen.dart';
|
|
import '../features/templates/ui/template_detail.dart'
|
|
show templateDetailBackKey;
|
|
import '../shell/destination.dart';
|
|
import '../shell/shell_bar.dart';
|
|
import '../ui/adaptive/host.dart';
|
|
import '../ui/adaptive/segmented_bar.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 and publishes its controls to
|
|
/// this page's one segmented bar (through a [ShellBarScope] the page owns):
|
|
/// the round Back closes the page from the gallery and returns to the gallery
|
|
/// from an open template, and Refresh sits in the actions pill. 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 StatefulWidget {
|
|
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
|
|
State<TemplatesDestination> createState() => _TemplatesDestinationState();
|
|
}
|
|
|
|
class _TemplatesDestinationState extends State<TemplatesDestination> {
|
|
final ShellBarRegistry _bar = ShellBarRegistry();
|
|
|
|
@override
|
|
void dispose() {
|
|
_bar.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final cupertino = usesCupertinoHost(context);
|
|
final body = ShellBarScope(
|
|
registry: _bar,
|
|
destination: AppDestination.settings,
|
|
child: AnimatedBuilder(
|
|
animation: widget.session,
|
|
builder: (context, _) => _body(cupertino),
|
|
),
|
|
);
|
|
final bar = ListenableBuilder(
|
|
listenable: _bar,
|
|
builder: (context, _) => _segmentedBar(cupertino),
|
|
);
|
|
if (cupertino) {
|
|
return CupertinoPageScaffold(
|
|
navigationBar: _BarSlot(cupertino: true, child: bar),
|
|
child: SafeArea(child: body),
|
|
);
|
|
}
|
|
return Scaffold(
|
|
extendBodyBehindAppBar: true,
|
|
appBar: _BarSlot(cupertino: false, child: bar),
|
|
body: SafeArea(child: body),
|
|
);
|
|
}
|
|
|
|
SegmentedBar _segmentedBar(bool cupertino) {
|
|
final spec = _bar.specFor(AppDestination.settings);
|
|
final onDetailBack = spec?.onBack;
|
|
return SegmentedBar(
|
|
cupertino: cupertino,
|
|
leading: onDetailBack != null
|
|
? SegmentedBackButton(
|
|
key: templateDetailBackKey,
|
|
cupertino: cupertino,
|
|
onPressed: onDetailBack,
|
|
)
|
|
: SegmentedBackButton(
|
|
key: templatesPageBackKey,
|
|
cupertino: cupertino,
|
|
onPressed: widget.onBack,
|
|
),
|
|
title: spec?.title ?? 'Templates',
|
|
actions: spec?.actions ?? const [],
|
|
);
|
|
}
|
|
|
|
Widget _body(bool cupertino) {
|
|
final session = widget.session;
|
|
if (!session.everConnected) {
|
|
return ConnectionGate(
|
|
session: session,
|
|
server: widget.server,
|
|
cupertino: cupertino,
|
|
);
|
|
}
|
|
return Column(
|
|
children: [
|
|
if (!session.connected)
|
|
ConnectionBanner(session: session, cupertino: cupertino),
|
|
Expanded(
|
|
child: TemplatesScreen(
|
|
gateway: session.gateway,
|
|
embedded: true,
|
|
onCreated: widget.onCreated,
|
|
initialKey: widget.initialKey,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Gives the scaffold a [SegmentedBar]'s size and obstruction while the bar
|
|
/// itself is rebuilt from the published controls.
|
|
class _BarSlot extends StatelessWidget
|
|
implements ObstructingPreferredSizeWidget {
|
|
const _BarSlot({required this.cupertino, required this.child});
|
|
|
|
final bool cupertino;
|
|
final Widget child;
|
|
|
|
@override
|
|
Size get preferredSize =>
|
|
SegmentedBar(cupertino: cupertino, title: '').preferredSize;
|
|
|
|
@override
|
|
bool shouldFullyObstruct(BuildContext context) => false;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => child;
|
|
}
|