Files
pipelines/app/lib/application/templates_destination.dart
T
alan 0582bfc34f feat(app): segmented glass top bar across the app
Extract the chat's segmented bar into lib/ui/adaptive (SegmentedBar,
GlassPill, SegmentedBarOverlay) and use it for the shell bar, DetailPane
and every page-level bar. Pieces are frosted glass over a fading scrim;
only pills take taps. Actions keep their natural width so the title gives
way before a model name. The chat transcript scrolls behind its header.
2026-10-31 00:21:27 +00:00

132 lines
3.7 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 '../ui/adaptive/host.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 ConnectionGate(
session: session,
server: server,
cupertino: cupertino,
);
}
return Column(
children: [
if (!session.connected)
ConnectionBanner(session: session, cupertino: cupertino),
Expanded(
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.
class _TemplatesPage extends StatelessWidget {
const _TemplatesPage({
required this.cupertino,
required this.onBack,
required this.child,
});
final bool cupertino;
final VoidCallback onBack;
final Widget child;
@override
Widget build(BuildContext context) {
if (cupertino) {
return CupertinoPageScaffold(
navigationBar: SegmentedBar(
cupertino: true,
leading: CupertinoButton(
key: templatesPageBackKey,
padding: EdgeInsets.zero,
onPressed: onBack,
child: const Icon(
CupertinoIcons.back,
semanticLabel: 'Back to Settings',
),
),
title: 'Templates',
),
child: SafeArea(child: child),
);
}
return Scaffold(
extendBodyBehindAppBar: true,
appBar: SegmentedBar(
cupertino: false,
leading: IconButton(
key: templatesPageBackKey,
tooltip: 'Back to Settings',
onPressed: onBack,
icon: const Icon(Icons.arrow_back),
),
title: 'Templates',
),
body: SafeArea(child: child),
);
}
}