Files
pipelines/app/lib/features/templates/ui/templates_frame.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

109 lines
3.0 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/segmented_bar.dart';
import '../../../ui/adaptive/host.dart';
const templatesRefreshKey = ValueKey<String>('templates-refresh');
const templatesBackKey = ValueKey<String>('templates-back');
/// The screen's native chrome.
///
/// Standalone use keeps the host's own app bar with Back and Refresh. A shell
/// that already owns navigation passes [embedded], which drops the bar and
/// keeps Refresh at the top of the body.
class TemplatesFrame extends StatelessWidget {
const TemplatesFrame({
super.key,
required this.body,
required this.embedded,
required this.canGoBack,
required this.refreshing,
required this.onBack,
required this.onRefresh,
});
final Widget body;
final bool embedded;
final bool canGoBack;
final bool refreshing;
final VoidCallback onBack;
final VoidCallback onRefresh;
@override
Widget build(BuildContext context) {
if (embedded) return _embedded(context);
return usesCupertinoHost(context)
? _cupertino(context)
: _material(context);
}
Widget _embedded(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Align(
alignment: AlignmentDirectional.centerEnd,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: _refreshButton(context),
),
),
Expanded(child: body),
],
);
}
Widget _cupertino(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: SegmentedBar(
cupertino: true,
leading: canGoBack
? CupertinoButton(
key: templatesBackKey,
padding: EdgeInsets.zero,
onPressed: onBack,
child: const Icon(CupertinoIcons.back, semanticLabel: 'Back'),
)
: null,
title: 'Templates',
actions: [_refreshButton(context)],
),
child: SafeArea(child: body),
);
}
Widget _material(BuildContext context) {
return Scaffold(
extendBodyBehindAppBar: true,
appBar: SegmentedBar(
cupertino: false,
title: 'Templates',
leading: canGoBack
? BackButton(key: templatesBackKey, onPressed: onBack)
: null,
actions: [_refreshButton(context)],
),
body: SafeArea(child: body),
);
}
Widget _refreshButton(BuildContext context) {
final onPressed = refreshing ? null : onRefresh;
if (usesCupertinoHost(context)) {
return CupertinoButton(
key: templatesRefreshKey,
padding: EdgeInsets.zero,
onPressed: onPressed,
child: const Icon(CupertinoIcons.refresh, semanticLabel: 'Refresh'),
);
}
return IconButton(
key: templatesRefreshKey,
tooltip: 'Refresh',
onPressed: onPressed,
icon: const Icon(Icons.refresh),
);
}
}