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.
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import '../ui/adaptive/segmented_bar.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
@@ -102,32 +103,37 @@ class _SchedulesDestinationState extends State<SchedulesDestination> {
|
|||||||
final body = _body(cupertino);
|
final body = _body(cupertino);
|
||||||
if (cupertino) {
|
if (cupertino) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: CupertinoNavigationBar(
|
navigationBar: SegmentedBar(
|
||||||
|
cupertino: true,
|
||||||
leading: CupertinoButton(
|
leading: CupertinoButton(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
onPressed: widget.onBack,
|
onPressed: widget.onBack,
|
||||||
child: const Icon(CupertinoIcons.back, semanticLabel: 'Back'),
|
child: const Icon(CupertinoIcons.back, semanticLabel: 'Back'),
|
||||||
),
|
),
|
||||||
middle: const Text('Schedules'),
|
title: 'Schedules',
|
||||||
),
|
),
|
||||||
child: SafeArea(child: body),
|
child: SafeArea(child: body),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
extendBodyBehindAppBar: true,
|
||||||
|
appBar: SegmentedBar(
|
||||||
|
cupertino: false,
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
onPressed: widget.onBack,
|
onPressed: widget.onBack,
|
||||||
icon: const Icon(Icons.arrow_back, semanticLabel: 'Back'),
|
icon: const Icon(Icons.arrow_back, semanticLabel: 'Back'),
|
||||||
),
|
),
|
||||||
title: const Text('Schedules'),
|
title: 'Schedules',
|
||||||
),
|
),
|
||||||
body: body,
|
body: SafeArea(left: false, right: false, bottom: false, child: body),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _body(bool cupertino) {
|
Widget _body(bool cupertino) {
|
||||||
if (!widget.session.everConnected) {
|
if (!widget.session.everConnected) {
|
||||||
return const Center(child: Text('Connect to the server to see schedules.'));
|
return const Center(
|
||||||
|
child: Text('Connect to the server to see schedules.'),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return SchedulesListView(
|
return SchedulesListView(
|
||||||
controller: _controller,
|
controller: _controller,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../ui/adaptive/segmented_bar.dart';
|
||||||
import '../core/api_gateway.dart';
|
import '../core/api_gateway.dart';
|
||||||
import '../features/search/search_screen.dart';
|
import '../features/search/search_screen.dart';
|
||||||
import '../ui/adaptive/host.dart';
|
import '../ui/adaptive/host.dart';
|
||||||
@@ -119,11 +120,12 @@ class _SearchPage extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => cupertino
|
Widget build(BuildContext context) => cupertino
|
||||||
? CupertinoPageScaffold(
|
? CupertinoPageScaffold(
|
||||||
navigationBar: const CupertinoNavigationBar(middle: Text('Search')),
|
navigationBar: const SegmentedBar(cupertino: true, title: 'Search'),
|
||||||
child: SafeArea(child: child),
|
child: SafeArea(child: child),
|
||||||
)
|
)
|
||||||
: Scaffold(
|
: Scaffold(
|
||||||
appBar: AppBar(title: const Text('Search')),
|
extendBodyBehindAppBar: true,
|
||||||
|
appBar: const SegmentedBar(cupertino: false, title: 'Search'),
|
||||||
body: SafeArea(child: child),
|
body: SafeArea(child: child),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../ui/adaptive/segmented_bar.dart';
|
||||||
import '../core/api_gateway.dart';
|
import '../core/api_gateway.dart';
|
||||||
import '../features/templates/screen.dart';
|
import '../features/templates/screen.dart';
|
||||||
import '../ui/adaptive/host.dart';
|
import '../ui/adaptive/host.dart';
|
||||||
@@ -96,7 +97,8 @@ class _TemplatesPage extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (cupertino) {
|
if (cupertino) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: CupertinoNavigationBar(
|
navigationBar: SegmentedBar(
|
||||||
|
cupertino: true,
|
||||||
leading: CupertinoButton(
|
leading: CupertinoButton(
|
||||||
key: templatesPageBackKey,
|
key: templatesPageBackKey,
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
@@ -106,20 +108,22 @@ class _TemplatesPage extends StatelessWidget {
|
|||||||
semanticLabel: 'Back to Settings',
|
semanticLabel: 'Back to Settings',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
middle: const Text('Templates'),
|
title: 'Templates',
|
||||||
),
|
),
|
||||||
child: SafeArea(child: child),
|
child: SafeArea(child: child),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
extendBodyBehindAppBar: true,
|
||||||
|
appBar: SegmentedBar(
|
||||||
|
cupertino: false,
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
key: templatesPageBackKey,
|
key: templatesPageBackKey,
|
||||||
tooltip: 'Back to Settings',
|
tooltip: 'Back to Settings',
|
||||||
onPressed: onBack,
|
onPressed: onBack,
|
||||||
icon: const Icon(Icons.arrow_back),
|
icon: const Icon(Icons.arrow_back),
|
||||||
),
|
),
|
||||||
title: const Text('Templates'),
|
title: 'Templates',
|
||||||
),
|
),
|
||||||
body: SafeArea(child: child),
|
body: SafeArea(child: child),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import '../../../ui/adaptive/segmented_bar.dart';
|
||||||
import '../../../ui/theme/app_theme.dart';
|
import '../../../ui/theme/app_theme.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -392,15 +393,17 @@ class _ArtifactGalleryPageState extends State<ArtifactGalleryPage> {
|
|||||||
// Sections paint the grouped background; the page must match it or a
|
// Sections paint the grouped background; the page must match it or a
|
||||||
// white seam shows below the last section in light mode.
|
// white seam shows below the last section in light mode.
|
||||||
backgroundColor: AppColors.groupedBackground,
|
backgroundColor: AppColors.groupedBackground,
|
||||||
navigationBar: const CupertinoNavigationBar(
|
navigationBar: const SegmentedBar(
|
||||||
middle: Text(artifactGalleryTitle),
|
cupertino: true,
|
||||||
|
title: artifactGalleryTitle,
|
||||||
),
|
),
|
||||||
child: SafeArea(child: body),
|
child: SafeArea(child: body),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: const Text(artifactGalleryTitle)),
|
extendBodyBehindAppBar: true,
|
||||||
body: SafeArea(top: false, child: body),
|
appBar: const SegmentedBar(cupertino: false, title: artifactGalleryTitle),
|
||||||
|
body: SafeArea(child: body),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import '../../../ui/adaptive/segmented_bar.dart';
|
||||||
import '../../../ui/theme/app_theme.dart';
|
import '../../../ui/theme/app_theme.dart';
|
||||||
import '../../../ui/input/arrow_key_pager.dart';
|
import '../../../ui/input/arrow_key_pager.dart';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
@@ -252,15 +253,14 @@ class _ArtifactViewerPageState extends State<ArtifactViewerPage> {
|
|||||||
if (usesCupertinoHost(context)) {
|
if (usesCupertinoHost(context)) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
backgroundColor: AppColors.groupedBackground,
|
backgroundColor: AppColors.groupedBackground,
|
||||||
navigationBar: CupertinoNavigationBar(
|
navigationBar: SegmentedBar(cupertino: true, title: title),
|
||||||
middle: Text(title, overflow: TextOverflow.ellipsis),
|
|
||||||
),
|
|
||||||
child: SafeArea(child: body),
|
child: SafeArea(child: body),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: Text(title, overflow: TextOverflow.ellipsis)),
|
extendBodyBehindAppBar: true,
|
||||||
body: SafeArea(top: false, child: body),
|
appBar: SegmentedBar(cupertino: false, title: title),
|
||||||
|
body: SafeArea(child: body),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import '../../../ui/adaptive/segmented_bar.dart';
|
||||||
import '../../../ui/input/arrow_key_pager.dart';
|
import '../../../ui/input/arrow_key_pager.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
@@ -302,15 +303,16 @@ class _FileDiffPageState extends State<FileDiffPage> {
|
|||||||
);
|
);
|
||||||
if (cupertino) {
|
if (cupertino) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: CupertinoNavigationBar(middle: Text(name)),
|
navigationBar: SegmentedBar(cupertino: true, title: name),
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
child: Theme(data: hostTextTheme(context), child: body),
|
child: Theme(data: hostTextTheme(context), child: body),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: Text(name)),
|
extendBodyBehindAppBar: true,
|
||||||
body: SafeArea(top: false, child: body),
|
appBar: SegmentedBar(cupertino: false, title: name),
|
||||||
|
body: SafeArea(child: body),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../ui/adaptive/segmented_bar.dart';
|
||||||
import '../ui/sessions/chat_adaptive.dart';
|
import '../ui/sessions/chat_adaptive.dart';
|
||||||
|
|
||||||
/// The open conversation's bar: separate rounded pieces on the page's own
|
/// The open conversation's bar: the app's [SegmentedBar] above the
|
||||||
/// background above the transcript, instead of one solid app bar.
|
/// transcript.
|
||||||
///
|
///
|
||||||
/// From the leading edge: a round Back (only where the page can go back), a
|
/// From the leading edge: a round Back (only where the page can go back), a
|
||||||
/// pill with the conversation's title and folder that opens the chat's
|
/// pill with the conversation's title and folder that opens the chat's
|
||||||
@@ -37,206 +38,26 @@ class ChatThreadHeader extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final cupertino =
|
final cupertino =
|
||||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||||
final background = cupertino
|
return SegmentedBar(
|
||||||
? CupertinoTheme.of(context).scaffoldBackgroundColor
|
cupertino: cupertino,
|
||||||
: Theme.of(context).colorScheme.surface;
|
automaticallyImplyLeading: false,
|
||||||
return ColoredBox(
|
// The platform's own Back, so it reads and behaves as every other
|
||||||
color: background,
|
// page's Back; its key stays for finders.
|
||||||
child: SafeArea(
|
leading: showBack
|
||||||
bottom: false,
|
? SegmentedBackButton(
|
||||||
child: Padding(
|
key: const Key('chat-back'),
|
||||||
padding: const EdgeInsetsDirectional.fromSTEB(12, 8, 12, 16),
|
cupertino: cupertino,
|
||||||
child: LayoutBuilder(
|
onPressed: onBack,
|
||||||
builder: (context, constraints) => Row(
|
)
|
||||||
children: [
|
: null,
|
||||||
if (showBack) ...[
|
title: title.isEmpty ? 'Chat' : title,
|
||||||
_ChatHeaderPill(
|
subtitle: folder,
|
||||||
circle: true,
|
subtitleIcon: cupertino ? CupertinoIcons.folder : Icons.folder_outlined,
|
||||||
child: _BackControl(
|
onTitlePressed: onInfo,
|
||||||
cupertino: cupertino,
|
titleSemanticLabel: 'Chat information',
|
||||||
onPressed: onBack,
|
titleKey: const Key('chat-info'),
|
||||||
),
|
actions: controls,
|
||||||
),
|
bottomPadding: 16,
|
||||||
const SizedBox(width: 8),
|
|
||||||
],
|
|
||||||
Expanded(
|
|
||||||
child: Align(
|
|
||||||
alignment: AlignmentDirectional.centerStart,
|
|
||||||
child: _TitlePill(
|
|
||||||
title: title,
|
|
||||||
folder: folder,
|
|
||||||
cupertino: cupertino,
|
|
||||||
onPressed: onInfo,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (controls.isNotEmpty) ...[
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
// The controls keep to the trailing edge and at most about
|
|
||||||
// half the bar, so the title always has room; each control
|
|
||||||
// ellipsises its own label, the model's taking the larger share.
|
|
||||||
ConstrainedBox(
|
|
||||||
constraints: BoxConstraints(
|
|
||||||
maxWidth: constraints.maxWidth * 0.45,
|
|
||||||
),
|
|
||||||
child: _ChatHeaderPill(
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Flexible(flex: 3, child: controls.first),
|
|
||||||
for (final control in controls.skip(1))
|
|
||||||
Flexible(flex: 2, child: control),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// One rounded, filled piece of the bar in the host's raised surface role.
|
|
||||||
class _ChatHeaderPill extends StatelessWidget {
|
|
||||||
const _ChatHeaderPill({required this.child, this.circle = false});
|
|
||||||
|
|
||||||
final Widget child;
|
|
||||||
final bool circle;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final cupertino =
|
|
||||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
|
||||||
final fill = cupertino
|
|
||||||
? CupertinoColors.systemGrey6.resolveFrom(context)
|
|
||||||
: Theme.of(context).colorScheme.surfaceContainerHigh;
|
|
||||||
final shape = circle
|
|
||||||
? const CircleBorder()
|
|
||||||
: const StadiumBorder() as ShapeBorder;
|
|
||||||
if (cupertino) {
|
|
||||||
return ClipPath(
|
|
||||||
clipper: ShapeBorderClipper(shape: shape),
|
|
||||||
child: ColoredBox(color: fill, child: child),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Material(
|
|
||||||
color: fill,
|
|
||||||
shape: shape,
|
|
||||||
clipBehavior: Clip.antiAlias,
|
|
||||||
child: child,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The platform's own Back control, so it reads and behaves as every other
|
|
||||||
/// page's Back; its key and the conversation's destination wording stay.
|
|
||||||
class _BackControl extends StatelessWidget {
|
|
||||||
const _BackControl({required this.cupertino, required this.onPressed});
|
|
||||||
|
|
||||||
final bool cupertino;
|
|
||||||
final VoidCallback? onPressed;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) => KeyedSubtree(
|
|
||||||
key: const Key('chat-back'),
|
|
||||||
child: cupertino
|
|
||||||
? CupertinoNavigationBarBackButton(onPressed: onPressed)
|
|
||||||
: BackButton(onPressed: onPressed),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The title and its folder in one pill; pressing it opens the chat's
|
|
||||||
/// information.
|
|
||||||
class _TitlePill extends StatelessWidget {
|
|
||||||
const _TitlePill({
|
|
||||||
required this.title,
|
|
||||||
required this.folder,
|
|
||||||
required this.cupertino,
|
|
||||||
required this.onPressed,
|
|
||||||
});
|
|
||||||
|
|
||||||
final String title;
|
|
||||||
final String folder;
|
|
||||||
final bool cupertino;
|
|
||||||
final VoidCallback onPressed;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final TextStyle? titleStyle;
|
|
||||||
final TextStyle? folderStyle;
|
|
||||||
if (cupertino) {
|
|
||||||
final text = CupertinoTheme.of(context).textTheme;
|
|
||||||
titleStyle = text.textStyle.copyWith(fontWeight: FontWeight.w600);
|
|
||||||
folderStyle = text.tabLabelTextStyle.copyWith(
|
|
||||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
final theme = Theme.of(context);
|
|
||||||
titleStyle = theme.textTheme.titleSmall;
|
|
||||||
folderStyle = theme.textTheme.labelSmall?.copyWith(
|
|
||||||
color: theme.colorScheme.onSurfaceVariant,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final content = Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
title.isEmpty ? 'Chat' : title,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: titleStyle,
|
|
||||||
),
|
|
||||||
if (folder.isNotEmpty)
|
|
||||||
Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
cupertino ? CupertinoIcons.folder : Icons.folder_outlined,
|
|
||||||
size: folderStyle?.fontSize,
|
|
||||||
color: folderStyle?.color,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 4),
|
|
||||||
Flexible(
|
|
||||||
child: Text(
|
|
||||||
folder,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: folderStyle,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return _ChatHeaderPill(
|
|
||||||
child: Semantics(
|
|
||||||
button: true,
|
|
||||||
label: 'Chat information',
|
|
||||||
child: cupertino
|
|
||||||
? CupertinoButton(
|
|
||||||
key: const Key('chat-info'),
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
minimumSize: Size.zero,
|
|
||||||
onPressed: onPressed,
|
|
||||||
child: DefaultTextStyle.merge(
|
|
||||||
style: titleStyle,
|
|
||||||
child: content,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: InkWell(
|
|
||||||
key: const Key('chat-info'),
|
|
||||||
onTap: onPressed,
|
|
||||||
child: content,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import 'chat_models.dart';
|
|||||||
import 'chat_row_keys.dart';
|
import 'chat_row_keys.dart';
|
||||||
import 'chat_scroll.dart';
|
import 'chat_scroll.dart';
|
||||||
import 'chat_thread_controller.dart';
|
import 'chat_thread_controller.dart';
|
||||||
|
import '../../../ui/adaptive/segmented_bar_overlay.dart';
|
||||||
import 'chat_thread_header.dart';
|
import 'chat_thread_header.dart';
|
||||||
import 'chat_transcript_cache.dart';
|
import 'chat_transcript_cache.dart';
|
||||||
import 'chat_permission_card_model.dart';
|
import 'chat_permission_card_model.dart';
|
||||||
@@ -718,121 +719,135 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
|||||||
final inShellBar = ShellBar.available(context);
|
final inShellBar = ShellBar.available(context);
|
||||||
final column = Column(
|
final column = Column(
|
||||||
children: [
|
children: [
|
||||||
// The conversation's own floating bar, above its transcript.
|
|
||||||
_header(context, inShellBar),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: NotificationListener<ScrollMetricsNotification>(
|
// The conversation's own bar floats over its transcript, which
|
||||||
onNotification: _onScrollMetrics,
|
// scrolls behind it.
|
||||||
child: NotificationListener<ScrollNotification>(
|
child: SegmentedBarOverlay(
|
||||||
onNotification: _onScrollNotification,
|
bar: _header(context, inShellBar),
|
||||||
child: Stack(
|
child: NotificationListener<ScrollMetricsNotification>(
|
||||||
children: [
|
onNotification: _onScrollMetrics,
|
||||||
ListView(
|
child: NotificationListener<ScrollNotification>(
|
||||||
key: ValueKey<String>('chat-thread-${widget.sessionId}'),
|
onNotification: _onScrollNotification,
|
||||||
controller: _scroll,
|
child: Stack(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
children: [
|
||||||
children: [
|
Builder(
|
||||||
if (initialLoad)
|
// At rest the first item starts below the floating bar.
|
||||||
Padding(
|
builder: (context) => ListView(
|
||||||
key: const Key('chat-thread-loading'),
|
key: ValueKey<String>(
|
||||||
padding: const EdgeInsets.all(16),
|
'chat-thread-${widget.sessionId}',
|
||||||
child: Center(
|
|
||||||
child: cupertino
|
|
||||||
? const CupertinoActivityIndicator()
|
|
||||||
: const CircularProgressIndicator(),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
if (_controller.hasMore)
|
controller: _scroll,
|
||||||
Padding(
|
padding: EdgeInsets.only(
|
||||||
key: const Key('chat-load-older'),
|
top: MediaQuery.paddingOf(context).top + 8,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
bottom: 8,
|
||||||
child: Align(
|
|
||||||
alignment: AlignmentDirectional.centerStart,
|
|
||||||
child: cupertino
|
|
||||||
? CupertinoButton(
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
onPressed: _controller.loading
|
|
||||||
? null
|
|
||||||
: _controller.loadOlder,
|
|
||||||
child: const Text('Load older'),
|
|
||||||
)
|
|
||||||
: TextButton(
|
|
||||||
onPressed: _controller.loading
|
|
||||||
? null
|
|
||||||
: _controller.loadOlder,
|
|
||||||
child: const Text('Load older'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
if (historyNotice != null)
|
children: [
|
||||||
_ChatNoticeLine(
|
if (initialLoad)
|
||||||
key: const Key('chat-history-error'),
|
Padding(
|
||||||
notice: historyNotice,
|
key: const Key('chat-thread-loading'),
|
||||||
onDismiss: _dismiss,
|
padding: const EdgeInsets.all(16),
|
||||||
onRetry: _controller.load,
|
child: Center(
|
||||||
),
|
child: cupertino
|
||||||
if (liveNotice != null)
|
? const CupertinoActivityIndicator()
|
||||||
_ChatNoticeLine(
|
: const CircularProgressIndicator(),
|
||||||
key: const Key('chat-live-error'),
|
),
|
||||||
notice: liveNotice,
|
),
|
||||||
onDismiss: _dismiss,
|
if (_controller.hasMore)
|
||||||
onRetry: _controller.resync,
|
Padding(
|
||||||
),
|
key: const Key('chat-load-older'),
|
||||||
if (_controller.loaded &&
|
padding: const EdgeInsets.symmetric(
|
||||||
allRows.isEmpty &&
|
horizontal: 16,
|
||||||
allNotices.isEmpty &&
|
),
|
||||||
_commandNotices.isEmpty &&
|
child: Align(
|
||||||
_controller.error == null)
|
alignment: AlignmentDirectional.centerStart,
|
||||||
const Padding(
|
child: cupertino
|
||||||
key: Key('chat-thread-empty'),
|
? CupertinoButton(
|
||||||
padding: EdgeInsets.all(16),
|
padding: EdgeInsets.zero,
|
||||||
child: Text('No messages in this chat yet.'),
|
onPressed: _controller.loading
|
||||||
),
|
? null
|
||||||
for (var index = 0; index < rows.length; index++)
|
: _controller.loadOlder,
|
||||||
Padding(
|
child: const Text('Load older'),
|
||||||
key: ValueKey<String>(keys[index]),
|
)
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
: TextButton(
|
||||||
child: _transcriptRow(
|
onPressed: _controller.loading
|
||||||
rows[index],
|
? null
|
||||||
onDismissCompaction:
|
: _controller.loadOlder,
|
||||||
compactionNotice != null &&
|
child: const Text('Load older'),
|
||||||
chatNoticeActivityCondition(
|
),
|
||||||
rows[index],
|
),
|
||||||
) ==
|
),
|
||||||
compactionNotice.condition
|
if (historyNotice != null)
|
||||||
? () => _dismiss(compactionNotice)
|
_ChatNoticeLine(
|
||||||
: null,
|
key: const Key('chat-history-error'),
|
||||||
),
|
notice: historyNotice,
|
||||||
),
|
onDismiss: _dismiss,
|
||||||
// The conversation's own command lines sit after the
|
onRetry: _controller.load,
|
||||||
// turns, as on the web; they are never bubbles.
|
),
|
||||||
for (final notice in _commandNotices)
|
if (liveNotice != null)
|
||||||
_ChatNoticeLine(
|
_ChatNoticeLine(
|
||||||
key: ValueKey<String>(
|
key: const Key('chat-live-error'),
|
||||||
'chat-command-notice-${notice.condition}',
|
notice: liveNotice,
|
||||||
),
|
onDismiss: _dismiss,
|
||||||
notice: notice,
|
onRetry: _controller.resync,
|
||||||
onDismiss: _dismiss,
|
),
|
||||||
),
|
if (_controller.loaded &&
|
||||||
],
|
allRows.isEmpty &&
|
||||||
),
|
allNotices.isEmpty &&
|
||||||
if (showJump)
|
_commandNotices.isEmpty &&
|
||||||
PositionedDirectional(
|
_controller.error == null)
|
||||||
end: 16,
|
const Padding(
|
||||||
bottom: 16,
|
key: Key('chat-thread-empty'),
|
||||||
child: _ChatJumpToLatest(
|
padding: EdgeInsets.all(16),
|
||||||
key: const Key('chat-jump-to-latest'),
|
child: Text('No messages in this chat yet.'),
|
||||||
label: chatJumpToLatestLabel(newMessages),
|
),
|
||||||
cupertino: cupertino,
|
for (var index = 0; index < rows.length; index++)
|
||||||
onPressed: _followLatest,
|
Padding(
|
||||||
|
key: ValueKey<String>(keys[index]),
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 16,
|
||||||
|
),
|
||||||
|
child: _transcriptRow(
|
||||||
|
rows[index],
|
||||||
|
onDismissCompaction:
|
||||||
|
compactionNotice != null &&
|
||||||
|
chatNoticeActivityCondition(
|
||||||
|
rows[index],
|
||||||
|
) ==
|
||||||
|
compactionNotice.condition
|
||||||
|
? () => _dismiss(compactionNotice)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// The conversation's own command lines sit after the
|
||||||
|
// turns, as on the web; they are never bubbles.
|
||||||
|
for (final notice in _commandNotices)
|
||||||
|
_ChatNoticeLine(
|
||||||
|
key: ValueKey<String>(
|
||||||
|
'chat-command-notice-${notice.condition}',
|
||||||
|
),
|
||||||
|
notice: notice,
|
||||||
|
onDismiss: _dismiss,
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
if (showJump)
|
||||||
|
PositionedDirectional(
|
||||||
|
end: 16,
|
||||||
|
bottom: 16,
|
||||||
|
child: _ChatJumpToLatest(
|
||||||
|
key: const Key('chat-jump-to-latest'),
|
||||||
|
label: chatJumpToLatestLabel(newMessages),
|
||||||
|
cupertino: cupertino,
|
||||||
|
onPressed: _followLatest,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
ChatComposerBar(
|
ChatComposerBar(
|
||||||
key: ValueKey<String>('chat-composer-${widget.sessionId}'),
|
key: ValueKey<String>('chat-composer-${widget.sessionId}'),
|
||||||
composer: _composer,
|
composer: _composer,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import '../../../../ui/adaptive/segmented_bar.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
@@ -205,28 +206,28 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
|
|||||||
children: [
|
children: [
|
||||||
ContentWidth(
|
ContentWidth(
|
||||||
child: ChatSessionsBody(
|
child: ChatSessionsBody(
|
||||||
sessions: _controller.sessions,
|
sessions: _controller.sessions,
|
||||||
activeSessionId: widget.activeSessionId,
|
activeSessionId: widget.activeSessionId,
|
||||||
query: _search.text,
|
query: _search.text,
|
||||||
loading: _controller.loading,
|
loading: _controller.loading,
|
||||||
error: _controller.error,
|
error: _controller.error,
|
||||||
onOpen: _open,
|
onOpen: _open,
|
||||||
onRename: _rename,
|
onRename: _rename,
|
||||||
onClose: _close,
|
onClose: _close,
|
||||||
onReopen: (session) =>
|
onReopen: (session) =>
|
||||||
_controller.reopen(_sessionId(session)),
|
_controller.reopen(_sessionId(session)),
|
||||||
onStar: (session) => _controller.star(
|
onStar: (session) => _controller.star(
|
||||||
_sessionId(session),
|
_sessionId(session),
|
||||||
session['starred'] != true,
|
session['starred'] != true,
|
||||||
),
|
),
|
||||||
onHide: _hide,
|
onHide: _hide,
|
||||||
onClearSearch: () {
|
onClearSearch: () {
|
||||||
_search.clear();
|
_search.clear();
|
||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
isUnseen: _controller.isUnseen,
|
isUnseen: _controller.isUnseen,
|
||||||
errorFor: _controller.errorFor,
|
errorFor: _controller.errorFor,
|
||||||
onDismissError: _controller.dismissError,
|
onDismissError: _controller.dismissError,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// The web's hide report is a fixed overlay: replacing or
|
// The web's hide report is a fixed overlay: replacing or
|
||||||
@@ -285,19 +286,22 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
|
|||||||
|
|
||||||
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
|
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: CupertinoNavigationBar(
|
navigationBar: SegmentedBar(
|
||||||
middle: const Text('Chats'),
|
cupertino: true,
|
||||||
trailing: Row(
|
title: 'Chats',
|
||||||
mainAxisSize: MainAxisSize.min,
|
actions: _actions(),
|
||||||
children: _actions(),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
child: SafeArea(child: body),
|
child: SafeArea(child: body),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: const Text('Chats'), actions: _actions()),
|
extendBodyBehindAppBar: true,
|
||||||
body: body,
|
appBar: SegmentedBar(
|
||||||
|
cupertino: false,
|
||||||
|
title: 'Chats',
|
||||||
|
actions: _actions(),
|
||||||
|
),
|
||||||
|
body: SafeArea(left: false, right: false, bottom: false, child: body),
|
||||||
floatingActionButton: FloatingActionButton.extended(
|
floatingActionButton: FloatingActionButton.extended(
|
||||||
key: const Key('chat-new-chat-fab'),
|
key: const Key('chat-new-chat-fab'),
|
||||||
onPressed: _newChat,
|
onPressed: _newChat,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import '../../../../ui/adaptive/segmented_bar.dart';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
@@ -46,12 +47,13 @@ class ChatImageViewer extends StatelessWidget {
|
|||||||
void close() => Navigator.of(context).maybePop();
|
void close() => Navigator.of(context).maybePop();
|
||||||
if (cupertino) {
|
if (cupertino) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: CupertinoNavigationBar(
|
navigationBar: SegmentedBar(
|
||||||
|
cupertino: true,
|
||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
middle: Text(name, overflow: TextOverflow.ellipsis),
|
title: name,
|
||||||
leading: CupertinoButton(
|
leading: CupertinoButton(
|
||||||
key: const Key('chat-image-viewer-close'),
|
key: const Key('chat-image-viewer-close'),
|
||||||
padding: EdgeInsets.zero,
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
onPressed: close,
|
onPressed: close,
|
||||||
child: const Text(chatImageViewerClose),
|
child: const Text(chatImageViewerClose),
|
||||||
),
|
),
|
||||||
@@ -60,7 +62,9 @@ class ChatImageViewer extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
extendBodyBehindAppBar: true,
|
||||||
|
appBar: SegmentedBar(
|
||||||
|
cupertino: false,
|
||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
key: const Key('chat-image-viewer-close'),
|
key: const Key('chat-image-viewer-close'),
|
||||||
@@ -68,7 +72,7 @@ class ChatImageViewer extends StatelessWidget {
|
|||||||
onPressed: close,
|
onPressed: close,
|
||||||
icon: const Icon(Icons.close),
|
icon: const Icon(Icons.close),
|
||||||
),
|
),
|
||||||
title: Text(name, overflow: TextOverflow.ellipsis),
|
title: name,
|
||||||
),
|
),
|
||||||
body: body,
|
body: body,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../ui/adaptive/segmented_bar.dart';
|
||||||
import '../../../ui/adaptive/host.dart';
|
import '../../../ui/adaptive/host.dart';
|
||||||
import 'graph_viewport.dart';
|
import 'graph_viewport.dart';
|
||||||
import 'graph_viewport_controller.dart';
|
import 'graph_viewport_controller.dart';
|
||||||
@@ -102,22 +103,27 @@ class _GraphExpandedViewState extends State<GraphExpandedView> {
|
|||||||
);
|
);
|
||||||
if (usesCupertinoHost(context)) {
|
if (usesCupertinoHost(context)) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: CupertinoNavigationBar(
|
navigationBar: SegmentedBar(
|
||||||
|
cupertino: true,
|
||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
middle: Text(widget.title),
|
title: widget.title,
|
||||||
trailing: CupertinoButton(
|
actions: [
|
||||||
key: const Key('graph-expanded-close'),
|
CupertinoButton(
|
||||||
padding: EdgeInsets.zero,
|
key: const Key('graph-expanded-close'),
|
||||||
onPressed: _close,
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
child: const Text(graphExpandedClose),
|
onPressed: _close,
|
||||||
),
|
child: const Text(graphExpandedClose),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
child: SafeArea(child: body),
|
child: SafeArea(child: body),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
extendBodyBehindAppBar: true,
|
||||||
title: Text(widget.title),
|
appBar: SegmentedBar(
|
||||||
|
cupertino: false,
|
||||||
|
title: widget.title,
|
||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import '../../../ui/adaptive/segmented_bar.dart';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
@@ -141,14 +142,15 @@ Future<void> openStageDefinition(
|
|||||||
? CupertinoPageRoute<void>(
|
? CupertinoPageRoute<void>(
|
||||||
settings: settings,
|
settings: settings,
|
||||||
builder: (_) => CupertinoPageScaffold(
|
builder: (_) => CupertinoPageScaffold(
|
||||||
navigationBar: CupertinoNavigationBar(middle: Text(title)),
|
navigationBar: SegmentedBar(cupertino: true, title: title),
|
||||||
child: SafeArea(child: view),
|
child: SafeArea(child: view),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: MaterialPageRoute<void>(
|
: MaterialPageRoute<void>(
|
||||||
settings: settings,
|
settings: settings,
|
||||||
builder: (_) => Scaffold(
|
builder: (_) => Scaffold(
|
||||||
appBar: AppBar(title: Text(title)),
|
extendBodyBehindAppBar: true,
|
||||||
|
appBar: SegmentedBar(cupertino: false, title: title),
|
||||||
body: SafeArea(child: view),
|
body: SafeArea(child: view),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import '../../ui/adaptive/segmented_bar.dart';
|
||||||
import '../../shell/destination.dart';
|
import '../../shell/destination.dart';
|
||||||
import '../../shell/detail_page.dart';
|
import '../../shell/detail_page.dart';
|
||||||
import '../../shell/list_detail.dart';
|
import '../../shell/list_detail.dart';
|
||||||
@@ -351,8 +352,10 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
|||||||
|
|
||||||
Widget _materialShell(BuildContext context, Widget body) {
|
Widget _materialShell(BuildContext context, Widget body) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
extendBodyBehindAppBar: true,
|
||||||
title: const Text('Pipelines'),
|
appBar: SegmentedBar(
|
||||||
|
cupertino: false,
|
||||||
|
title: 'Pipelines',
|
||||||
actions: [
|
actions: [
|
||||||
...pipelineListActions(context, _controller),
|
...pipelineListActions(context, _controller),
|
||||||
if (widget.onOpenSchedules != null) _schedulesButton(context),
|
if (widget.onOpenSchedules != null) _schedulesButton(context),
|
||||||
@@ -365,18 +368,16 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
|||||||
|
|
||||||
Widget _cupertinoShell(BuildContext context, Widget body) {
|
Widget _cupertinoShell(BuildContext context, Widget body) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: CupertinoNavigationBar(
|
navigationBar: SegmentedBar(
|
||||||
middle: const Text('Pipelines'),
|
cupertino: true,
|
||||||
trailing: Row(
|
title: 'Pipelines',
|
||||||
mainAxisSize: MainAxisSize.min,
|
actions: [
|
||||||
children: [
|
...pipelineListActions(context, _controller),
|
||||||
...pipelineListActions(context, _controller),
|
if (widget.onOpenSchedules != null) _schedulesButton(context),
|
||||||
if (widget.onOpenSchedules != null) _schedulesButton(context),
|
_refreshButton(context),
|
||||||
_refreshButton(context),
|
],
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
child: SafeArea(top: false, child: body),
|
child: SafeArea(child: body),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../ui/adaptive/segmented_bar.dart';
|
||||||
import '../pipeline_filter.dart';
|
import '../pipeline_filter.dart';
|
||||||
import 'pipeline_controls.dart';
|
import 'pipeline_controls.dart';
|
||||||
import 'pipeline_filter_cupertino_body.dart';
|
import 'pipeline_filter_cupertino_body.dart';
|
||||||
@@ -99,20 +100,25 @@ class _PipelineFilterPageState extends State<PipelineFilterPage> {
|
|||||||
);
|
);
|
||||||
if (widget.cupertino) {
|
if (widget.cupertino) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: CupertinoNavigationBar(
|
navigationBar: SegmentedBar(
|
||||||
middle: const Text('Filter pipelines'),
|
cupertino: true,
|
||||||
trailing: CupertinoButton(
|
title: 'Filter pipelines',
|
||||||
padding: EdgeInsets.zero,
|
actions: [
|
||||||
onPressed: _apply,
|
CupertinoButton(
|
||||||
child: const Text('Done'),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
),
|
onPressed: _apply,
|
||||||
|
child: const Text('Done'),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
child: SafeArea(child: body),
|
child: SafeArea(child: body),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
extendBodyBehindAppBar: true,
|
||||||
title: const Text('Filter pipelines'),
|
appBar: SegmentedBar(
|
||||||
|
cupertino: false,
|
||||||
|
title: 'Filter pipelines',
|
||||||
actions: [TextButton(onPressed: _apply, child: const Text('Done'))],
|
actions: [TextButton(onPressed: _apply, child: const Text('Done'))],
|
||||||
),
|
),
|
||||||
body: SafeArea(child: body),
|
body: SafeArea(child: body),
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../ui/adaptive/segmented_bar.dart';
|
||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
import '../../../ui/adaptive/host.dart';
|
import '../../../ui/adaptive/host.dart';
|
||||||
import '../../changes/changes.dart';
|
import '../../changes/changes.dart';
|
||||||
@@ -185,9 +186,9 @@ class _MaterialChangesPage extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => Scaffold(
|
Widget build(BuildContext context) => Scaffold(
|
||||||
appBar: AppBar(title: Text(title)),
|
extendBodyBehindAppBar: true,
|
||||||
|
appBar: SegmentedBar(cupertino: false, title: title),
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
top: false,
|
|
||||||
child: ChangesViewer(steps: steps, showSummary: showSummary),
|
child: ChangesViewer(steps: steps, showSummary: showSummary),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -206,7 +207,7 @@ class _CupertinoChangesPage extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => CupertinoPageScaffold(
|
Widget build(BuildContext context) => CupertinoPageScaffold(
|
||||||
navigationBar: CupertinoNavigationBar(middle: Text(title)),
|
navigationBar: SegmentedBar(cupertino: true, title: title),
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
// A CupertinoApp supplies no Material theme; follow the host brightness
|
// A CupertinoApp supplies no Material theme; follow the host brightness
|
||||||
// so the viewer's Material-derived section text stays readable.
|
// so the viewer's Material-derived section text stays readable.
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import '../../../ui/adaptive/segmented_bar.dart';
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
@@ -302,25 +303,30 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
|
|||||||
final title = detailTitle(run);
|
final title = detailTitle(run);
|
||||||
if (cupertino) {
|
if (cupertino) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: CupertinoNavigationBar(
|
navigationBar: SegmentedBar(
|
||||||
leading: CupertinoNavigationBarBackButton(
|
cupertino: true,
|
||||||
|
leading: SegmentedBackButton(
|
||||||
key: const Key('run-visit-back'),
|
key: const Key('run-visit-back'),
|
||||||
|
cupertino: true,
|
||||||
onPressed: () => Navigator.of(pageContext).pop(),
|
onPressed: () => Navigator.of(pageContext).pop(),
|
||||||
),
|
),
|
||||||
middle: Text(title),
|
title: title,
|
||||||
),
|
),
|
||||||
child: SafeArea(child: pane),
|
child: SafeArea(child: pane),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
extendBodyBehindAppBar: true,
|
||||||
leading: BackButton(
|
appBar: SegmentedBar(
|
||||||
|
cupertino: false,
|
||||||
|
leading: SegmentedBackButton(
|
||||||
key: const Key('run-visit-back'),
|
key: const Key('run-visit-back'),
|
||||||
|
cupertino: false,
|
||||||
onPressed: () => Navigator.of(pageContext).pop(),
|
onPressed: () => Navigator.of(pageContext).pop(),
|
||||||
),
|
),
|
||||||
title: Text(title),
|
title: title,
|
||||||
),
|
),
|
||||||
body: SafeArea(top: false, child: pane),
|
body: SafeArea(child: pane),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../ui/adaptive/segmented_bar.dart';
|
||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
import '../../../ui/adaptive/host.dart';
|
import '../../../ui/adaptive/host.dart';
|
||||||
import '../../graph/widgets/run_graph_view.dart';
|
import '../../graph/widgets/run_graph_view.dart';
|
||||||
@@ -105,16 +106,18 @@ class RunGraphPreview extends StatelessWidget {
|
|||||||
cupertino
|
cupertino
|
||||||
? CupertinoPageRoute<void>(
|
? CupertinoPageRoute<void>(
|
||||||
builder: (page) => CupertinoPageScaffold(
|
builder: (page) => CupertinoPageScaffold(
|
||||||
navigationBar: const CupertinoNavigationBar(
|
navigationBar: const SegmentedBar(
|
||||||
middle: Text('Graph'),
|
cupertino: true,
|
||||||
|
title: 'Graph',
|
||||||
),
|
),
|
||||||
child: SafeArea(child: graphView(page)),
|
child: SafeArea(child: graphView(page)),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: MaterialPageRoute<void>(
|
: MaterialPageRoute<void>(
|
||||||
builder: (page) => Scaffold(
|
builder: (page) => Scaffold(
|
||||||
appBar: AppBar(title: const Text('Graph')),
|
extendBodyBehindAppBar: true,
|
||||||
body: SafeArea(top: false, child: graphView(page)),
|
appBar: const SegmentedBar(cupertino: false, title: 'Graph'),
|
||||||
|
body: SafeArea(child: graphView(page)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import '../../../ui/adaptive/segmented_bar.dart';
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
@@ -37,13 +38,14 @@ class RunsStatsPage extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
if (cupertino) {
|
if (cupertino) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: const CupertinoNavigationBar(middle: Text('Usage')),
|
navigationBar: const SegmentedBar(cupertino: true, title: 'Usage'),
|
||||||
child: SafeArea(child: body),
|
child: SafeArea(child: body),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: const Text('Usage')),
|
extendBodyBehindAppBar: true,
|
||||||
body: SafeArea(top: false, child: body),
|
appBar: const SegmentedBar(cupertino: false, title: 'Usage'),
|
||||||
|
body: SafeArea(child: body),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import '../../../../ui/adaptive/segmented_bar.dart';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
@@ -43,14 +44,15 @@ Future<void> openSchedulePipelineEditor(
|
|||||||
? CupertinoPageRoute<void>(
|
? CupertinoPageRoute<void>(
|
||||||
settings: settings,
|
settings: settings,
|
||||||
builder: (_) => CupertinoPageScaffold(
|
builder: (_) => CupertinoPageScaffold(
|
||||||
navigationBar: CupertinoNavigationBar(middle: Text(title)),
|
navigationBar: SegmentedBar(cupertino: true, title: title),
|
||||||
child: SafeArea(top: false, child: page),
|
child: SafeArea(child: page),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: MaterialPageRoute<void>(
|
: MaterialPageRoute<void>(
|
||||||
settings: settings,
|
settings: settings,
|
||||||
builder: (_) => Scaffold(
|
builder: (_) => Scaffold(
|
||||||
appBar: AppBar(title: Text(title)),
|
extendBodyBehindAppBar: true,
|
||||||
|
appBar: SegmentedBar(cupertino: false, title: title),
|
||||||
body: SafeArea(child: page),
|
body: SafeArea(child: page),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../ui/adaptive/segmented_bar.dart';
|
||||||
import '../../core/api_gateway.dart';
|
import '../../core/api_gateway.dart';
|
||||||
import '../../ui/adaptive/host.dart';
|
import '../../ui/adaptive/host.dart';
|
||||||
import 'data/search_repository.dart';
|
import 'data/search_repository.dart';
|
||||||
@@ -132,7 +133,8 @@ class _SearchScreenState extends State<SearchScreen> {
|
|||||||
);
|
);
|
||||||
if (widget.embedded) return body;
|
if (widget.embedded) return body;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: const Text('Search')),
|
extendBodyBehindAppBar: true,
|
||||||
|
appBar: const SegmentedBar(cupertino: false, title: 'Search'),
|
||||||
body: body,
|
body: body,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -203,7 +205,7 @@ class _SearchScreenState extends State<SearchScreen> {
|
|||||||
);
|
);
|
||||||
if (widget.embedded) return body;
|
if (widget.embedded) return body;
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: const CupertinoNavigationBar(middle: Text('Search')),
|
navigationBar: const SegmentedBar(cupertino: true, title: 'Search'),
|
||||||
child: body,
|
child: body,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../ui/adaptive/segmented_bar.dart';
|
||||||
import '../../core/servers/server_catalog.dart';
|
import '../../core/servers/server_catalog.dart';
|
||||||
import '../../ui/adaptive/host.dart';
|
import '../../ui/adaptive/host.dart';
|
||||||
|
|
||||||
@@ -177,11 +178,12 @@ class _ServerEditorState extends State<_ServerEditor> {
|
|||||||
canPop: !_saving,
|
canPop: !_saving,
|
||||||
child: cupertino
|
child: cupertino
|
||||||
? CupertinoPageScaffold(
|
? CupertinoPageScaffold(
|
||||||
navigationBar: CupertinoNavigationBar(middle: Text(title)),
|
navigationBar: SegmentedBar(cupertino: true, title: title),
|
||||||
child: body,
|
child: body,
|
||||||
)
|
)
|
||||||
: Scaffold(
|
: Scaffold(
|
||||||
appBar: AppBar(title: Text(title)),
|
extendBodyBehindAppBar: true,
|
||||||
|
appBar: SegmentedBar(cupertino: false, title: title),
|
||||||
body: body,
|
body: body,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import '../../ui/adaptive/segmented_bar.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
@@ -267,12 +268,13 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||||||
if (widget.embedded) return content;
|
if (widget.embedded) return content;
|
||||||
if (usesCupertinoControls(context)) {
|
if (usesCupertinoControls(context)) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: const CupertinoNavigationBar(middle: Text('Settings')),
|
navigationBar: const SegmentedBar(cupertino: true, title: 'Settings'),
|
||||||
child: content,
|
child: content,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: const Text('Settings')),
|
extendBodyBehindAppBar: true,
|
||||||
|
appBar: const SegmentedBar(cupertino: false, title: 'Settings'),
|
||||||
body: content,
|
body: content,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../ui/adaptive/segmented_bar.dart';
|
||||||
import '../../../ui/adaptive/host.dart';
|
import '../../../ui/adaptive/host.dart';
|
||||||
|
|
||||||
const templatesRefreshKey = ValueKey<String>('templates-refresh');
|
const templatesRefreshKey = ValueKey<String>('templates-refresh');
|
||||||
@@ -55,7 +56,8 @@ class TemplatesFrame extends StatelessWidget {
|
|||||||
|
|
||||||
Widget _cupertino(BuildContext context) {
|
Widget _cupertino(BuildContext context) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: CupertinoNavigationBar(
|
navigationBar: SegmentedBar(
|
||||||
|
cupertino: true,
|
||||||
leading: canGoBack
|
leading: canGoBack
|
||||||
? CupertinoButton(
|
? CupertinoButton(
|
||||||
key: templatesBackKey,
|
key: templatesBackKey,
|
||||||
@@ -64,8 +66,8 @@ class TemplatesFrame extends StatelessWidget {
|
|||||||
child: const Icon(CupertinoIcons.back, semanticLabel: 'Back'),
|
child: const Icon(CupertinoIcons.back, semanticLabel: 'Back'),
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
middle: const Text('Templates'),
|
title: 'Templates',
|
||||||
trailing: _refreshButton(context),
|
actions: [_refreshButton(context)],
|
||||||
),
|
),
|
||||||
child: SafeArea(child: body),
|
child: SafeArea(child: body),
|
||||||
);
|
);
|
||||||
@@ -73,8 +75,10 @@ class TemplatesFrame extends StatelessWidget {
|
|||||||
|
|
||||||
Widget _material(BuildContext context) {
|
Widget _material(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
extendBodyBehindAppBar: true,
|
||||||
title: const Text('Templates'),
|
appBar: SegmentedBar(
|
||||||
|
cupertino: false,
|
||||||
|
title: 'Templates',
|
||||||
leading: canGoBack
|
leading: canGoBack
|
||||||
? BackButton(key: templatesBackKey, onPressed: onBack)
|
? BackButton(key: templatesBackKey, onPressed: onBack)
|
||||||
: null,
|
: null,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import '../ui/motion/motion.dart';
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../ui/adaptive/segmented_bar.dart';
|
||||||
import 'attention_badge.dart';
|
import 'attention_badge.dart';
|
||||||
import 'destination.dart';
|
import 'destination.dart';
|
||||||
import 'shell_bar.dart';
|
import 'shell_bar.dart';
|
||||||
@@ -141,36 +142,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
|||||||
if (widget.cupertino) {
|
if (widget.cupertino) {
|
||||||
final spec = _bar.specFor(_selected);
|
final spec = _bar.specFor(_selected);
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: CupertinoNavigationBar(
|
navigationBar: _segmentedBar(spec, details.label),
|
||||||
// The open screen's own bar: its Back, title and actions.
|
|
||||||
leading: spec?.onBack == null
|
|
||||||
? null
|
|
||||||
: CupertinoNavigationBarBackButton(
|
|
||||||
key: const ValueKey('shell.back'),
|
|
||||||
onPressed: spec!.onBack,
|
|
||||||
),
|
|
||||||
automaticallyImplyLeading: false,
|
|
||||||
middle: Text(spec?.title ?? details.label),
|
|
||||||
trailing: spec != null && spec.actions.isNotEmpty
|
|
||||||
? MotionSwitcher(
|
|
||||||
child: Row(
|
|
||||||
key: ObjectKey(_bar.ownerFor(_selected)),
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: spec.actions,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: widget.onSearch == null
|
|
||||||
? null
|
|
||||||
: CupertinoButton(
|
|
||||||
key: const ValueKey('shell.search'),
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
onPressed: widget.onSearch,
|
|
||||||
child: const Icon(
|
|
||||||
CupertinoIcons.search,
|
|
||||||
semanticLabel: 'Search',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
child: wide
|
child: wide
|
||||||
// The web keeps a destination rail on a wide window. A native
|
// The web keeps a destination rail on a wide window. A native
|
||||||
@@ -212,53 +184,32 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
|||||||
}
|
}
|
||||||
final spec = _bar.specFor(_selected);
|
final spec = _bar.specFor(_selected);
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
extendBodyBehindAppBar: true,
|
||||||
// The open screen's own bar: its Back, title and actions.
|
appBar: _segmentedBar(spec, details.label),
|
||||||
automaticallyImplyLeading: false,
|
// Destinations start below the floating bar.
|
||||||
leading: spec?.onBack == null
|
body: SafeArea(
|
||||||
? null
|
left: false,
|
||||||
: BackButton(
|
right: false,
|
||||||
key: const ValueKey('shell.back'),
|
bottom: false,
|
||||||
onPressed: spec!.onBack,
|
child: Row(
|
||||||
|
children: [
|
||||||
|
if (wide)
|
||||||
|
NavigationRail(
|
||||||
|
selectedIndex: index,
|
||||||
|
onDestinationSelected: (value) =>
|
||||||
|
_select(AppDestination.values[value]),
|
||||||
|
labelType: NavigationRailLabelType.all,
|
||||||
|
destinations: _items((destination) {
|
||||||
|
final item = destinationDetails(destination);
|
||||||
|
return NavigationRailDestination(
|
||||||
|
icon: _icon(destination, item.icon),
|
||||||
|
label: Text(item.label),
|
||||||
|
);
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
title: Text(spec?.title ?? details.label),
|
Expanded(child: _destinationStack(contents, index)),
|
||||||
actions: [
|
],
|
||||||
if (spec != null && spec.actions.isNotEmpty)
|
),
|
||||||
// A screen taking the bar over cross-fades its actions in.
|
|
||||||
MotionSwitcher(
|
|
||||||
child: Row(
|
|
||||||
key: ObjectKey(_bar.ownerFor(_selected)),
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: spec.actions,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (widget.onSearch != null && (spec?.actions.isEmpty ?? true))
|
|
||||||
IconButton(
|
|
||||||
key: const ValueKey('shell.search'),
|
|
||||||
onPressed: widget.onSearch,
|
|
||||||
tooltip: 'Search',
|
|
||||||
icon: const Icon(Icons.search),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
body: Row(
|
|
||||||
children: [
|
|
||||||
if (wide)
|
|
||||||
NavigationRail(
|
|
||||||
selectedIndex: index,
|
|
||||||
onDestinationSelected: (value) =>
|
|
||||||
_select(AppDestination.values[value]),
|
|
||||||
labelType: NavigationRailLabelType.all,
|
|
||||||
destinations: _items((destination) {
|
|
||||||
final item = destinationDetails(destination);
|
|
||||||
return NavigationRailDestination(
|
|
||||||
icon: _icon(destination, item.icon),
|
|
||||||
label: Text(item.label),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
Expanded(child: _destinationStack(contents, index)),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
bottomNavigationBar: wide
|
bottomNavigationBar: wide
|
||||||
? null
|
? null
|
||||||
@@ -280,6 +231,57 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The open screen's own bar: its Back, title and actions, or the tab's
|
||||||
|
/// name with Search.
|
||||||
|
SegmentedBar _segmentedBar(ShellBarSpec? spec, String label) {
|
||||||
|
final cupertino = widget.cupertino;
|
||||||
|
final onBack = spec?.onBack;
|
||||||
|
final published = spec?.actions ?? const <Widget>[];
|
||||||
|
final onSearch = widget.onSearch;
|
||||||
|
return SegmentedBar(
|
||||||
|
cupertino: cupertino,
|
||||||
|
automaticallyImplyLeading: false,
|
||||||
|
leading: onBack == null
|
||||||
|
? null
|
||||||
|
: SegmentedBackButton(
|
||||||
|
key: const ValueKey('shell.back'),
|
||||||
|
cupertino: cupertino,
|
||||||
|
onPressed: onBack,
|
||||||
|
),
|
||||||
|
title: spec?.title ?? label,
|
||||||
|
actions: [
|
||||||
|
if (published.isNotEmpty)
|
||||||
|
// A screen taking the bar over cross-fades its actions in.
|
||||||
|
MotionSwitcher(
|
||||||
|
child: Row(
|
||||||
|
key: ObjectKey(_bar.ownerFor(_selected)),
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
for (final action in published) Flexible(child: action),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
else if (onSearch != null)
|
||||||
|
cupertino
|
||||||
|
? CupertinoButton(
|
||||||
|
key: const ValueKey('shell.search'),
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
onPressed: onSearch,
|
||||||
|
child: const Icon(
|
||||||
|
CupertinoIcons.search,
|
||||||
|
semanticLabel: 'Search',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: IconButton(
|
||||||
|
key: const ValueKey('shell.search'),
|
||||||
|
onPressed: onSearch,
|
||||||
|
tooltip: 'Search',
|
||||||
|
icon: const Icon(Icons.search),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _destinationStack(List<Widget> contents, int index) =>
|
Widget _destinationStack(List<Widget> contents, int index) =>
|
||||||
IndexedStack(key: _destinationStackKey, index: index, children: contents);
|
IndexedStack(key: _destinationStackKey, index: index, children: contents);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../ui/adaptive/host.dart';
|
import '../ui/adaptive/host.dart';
|
||||||
|
import '../ui/adaptive/segmented_bar.dart';
|
||||||
import 'destination.dart';
|
import 'destination.dart';
|
||||||
import 'shell_bar.dart';
|
import 'shell_bar.dart';
|
||||||
|
|
||||||
@@ -133,40 +134,25 @@ class _DetailPaneState extends State<DetailPane> {
|
|||||||
// status-bar inset itself. The scaffold and the body's place in it stay
|
// status-bar inset itself. The scaffold and the body's place in it stay
|
||||||
// the same either way, so switching never remounts the content.
|
// the same either way, so switching never remounts the content.
|
||||||
final barless = spec?.barless ?? false;
|
final barless = spec?.barless ?? false;
|
||||||
if (usesCupertinoHost(context)) {
|
final cupertino = usesCupertinoHost(context);
|
||||||
|
final bar = barless
|
||||||
|
? null
|
||||||
|
: SegmentedBar(
|
||||||
|
cupertino: cupertino,
|
||||||
|
automaticallyImplyLeading: widget.implyBack,
|
||||||
|
title: title,
|
||||||
|
actions: actions,
|
||||||
|
);
|
||||||
|
if (cupertino) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: barless
|
navigationBar: bar,
|
||||||
? null
|
|
||||||
: CupertinoNavigationBar(
|
|
||||||
automaticallyImplyLeading: widget.implyBack,
|
|
||||||
// Inline pane bars are not routes and must not join the shell's
|
|
||||||
// navigation-bar hero when resizing into a pushed phone page.
|
|
||||||
transitionBetweenRoutes: widget.implyBack,
|
|
||||||
middle: Text(title),
|
|
||||||
trailing: actions.isEmpty
|
|
||||||
? null
|
|
||||||
: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
for (final action in actions)
|
|
||||||
Flexible(child: action),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: SafeArea(child: body),
|
child: SafeArea(child: body),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: barless
|
extendBodyBehindAppBar: true,
|
||||||
? null
|
appBar: bar,
|
||||||
: AppBar(
|
body: SafeArea(child: body),
|
||||||
automaticallyImplyLeading: widget.implyBack,
|
|
||||||
title: Text(title),
|
|
||||||
actions: [
|
|
||||||
for (final action in actions) Flexible(child: action),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
body: SafeArea(top: false, child: body),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
import 'dart:ui' show ImageFilter;
|
||||||
|
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
/// A frosted-glass piece floating over content: the content behind is
|
||||||
|
/// blurred inside the piece's [shape], under a translucent fill in the host's
|
||||||
|
/// raised surface role (Material `surfaceContainerHigh`, Cupertino
|
||||||
|
/// `systemGrey6`) and a hairline border.
|
||||||
|
///
|
||||||
|
/// Under the system's high-contrast setting the fill is solid and nothing is
|
||||||
|
/// blurred. The Cupertino piece uses no Material widget; the Material piece
|
||||||
|
/// is a transparent [Material] so ink responses inside it show.
|
||||||
|
///
|
||||||
|
/// Shared by the segmented top bar and any floating bar (a tab bar) that
|
||||||
|
/// wants the same pieces.
|
||||||
|
class GlassPill extends StatelessWidget {
|
||||||
|
const GlassPill({
|
||||||
|
super.key,
|
||||||
|
required this.cupertino,
|
||||||
|
required this.child,
|
||||||
|
this.shape = const StadiumBorder(),
|
||||||
|
this.fill,
|
||||||
|
});
|
||||||
|
|
||||||
|
final bool cupertino;
|
||||||
|
final Widget child;
|
||||||
|
final OutlinedBorder shape;
|
||||||
|
|
||||||
|
/// Overrides the fill (a dark viewer's pieces); used as given.
|
||||||
|
final Color? fill;
|
||||||
|
|
||||||
|
/// Blur radius of the content behind a piece.
|
||||||
|
static const double blurSigma = 16;
|
||||||
|
|
||||||
|
/// How much of the fill covers the blurred content.
|
||||||
|
static const double fillOpacity = 0.72;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final solid = MediaQuery.maybeHighContrastOf(context) ?? false;
|
||||||
|
final Color base;
|
||||||
|
final Color edge;
|
||||||
|
if (cupertino) {
|
||||||
|
base = CupertinoColors.systemGrey6.resolveFrom(context);
|
||||||
|
edge = CupertinoColors.separator.resolveFrom(context);
|
||||||
|
} else {
|
||||||
|
final scheme = Theme.of(context).colorScheme;
|
||||||
|
base = scheme.surfaceContainerHigh;
|
||||||
|
edge = scheme.outlineVariant;
|
||||||
|
}
|
||||||
|
final color = fill ?? (solid ? base : base.withValues(alpha: fillOpacity));
|
||||||
|
final border = shape.copyWith(
|
||||||
|
side: BorderSide(
|
||||||
|
color: solid ? edge : edge.withValues(alpha: edge.a * 0.5),
|
||||||
|
width: 0.5,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
Widget surface = DecoratedBox(
|
||||||
|
decoration: ShapeDecoration(color: color, shape: border),
|
||||||
|
child: cupertino
|
||||||
|
? child
|
||||||
|
: Material(type: MaterialType.transparency, child: child),
|
||||||
|
);
|
||||||
|
if (!solid) {
|
||||||
|
// One blur per piece, clipped to it.
|
||||||
|
surface = BackdropFilter(
|
||||||
|
filter: ImageFilter.blur(sigmaX: blurSigma, sigmaY: blurSigma),
|
||||||
|
child: surface,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return ClipPath(
|
||||||
|
clipper: ShapeBorderClipper(
|
||||||
|
shape: shape,
|
||||||
|
textDirection: Directionality.maybeOf(context),
|
||||||
|
),
|
||||||
|
child: surface,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,253 @@
|
|||||||
|
import 'dart:math' as math;
|
||||||
|
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'segmented_bar_pieces.dart';
|
||||||
|
|
||||||
|
export 'segmented_bar_pieces.dart' show SegmentedBackButton, SegmentedPill;
|
||||||
|
|
||||||
|
/// The app's top bar: separate frosted-glass pieces floating over the page's
|
||||||
|
/// content, on a scrim of the page's background that fades out downwards.
|
||||||
|
///
|
||||||
|
/// From the leading edge: a round piece holding [leading] (the platform's
|
||||||
|
/// Back, implied as the stock bars do when [automaticallyImplyLeading]), a
|
||||||
|
/// pill with the [title] and an optional one-line [subtitle] that runs
|
||||||
|
/// [onTitlePressed] when given, and a pill holding the [actions] at the
|
||||||
|
/// trailing edge. The actions take their natural width first and the title
|
||||||
|
/// shrinks; only when the title is down to [minTitleShare] of the bar does
|
||||||
|
/// the first action ellipsise.
|
||||||
|
///
|
||||||
|
/// Only the pieces take taps: a tap between them reaches the content behind.
|
||||||
|
/// It works as a [Scaffold.appBar] (with `extendBodyBehindAppBar`) and a
|
||||||
|
/// [CupertinoPageScaffold.navigationBar], which inset the content by the
|
||||||
|
/// bar's height through [MediaQuery.paddingOf], so a page keeps its
|
||||||
|
/// scaffold's structure; [SegmentedBarOverlay] does the same anywhere else.
|
||||||
|
/// It handles the top safe area itself.
|
||||||
|
class SegmentedBar extends StatelessWidget
|
||||||
|
implements ObstructingPreferredSizeWidget {
|
||||||
|
const SegmentedBar({
|
||||||
|
super.key,
|
||||||
|
required this.cupertino,
|
||||||
|
required this.title,
|
||||||
|
this.leading,
|
||||||
|
this.automaticallyImplyLeading = true,
|
||||||
|
this.subtitle,
|
||||||
|
this.subtitleIcon,
|
||||||
|
this.onTitlePressed,
|
||||||
|
this.titleSemanticLabel,
|
||||||
|
this.titleKey,
|
||||||
|
this.actions = const [],
|
||||||
|
this.backgroundColor,
|
||||||
|
this.pillColor,
|
||||||
|
this.foregroundColor,
|
||||||
|
this.bottomPadding = 8,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// Which control family to draw. Required because the bar's reserved
|
||||||
|
/// height differs: a Cupertino navigation bar never scales its text, so it
|
||||||
|
/// reserves exactly its height, while a Material app bar grows with text.
|
||||||
|
final bool cupertino;
|
||||||
|
|
||||||
|
/// The title; empty shows no title pill unless there is a [subtitle].
|
||||||
|
final String title;
|
||||||
|
|
||||||
|
/// The leading control, normally a [SegmentedBackButton].
|
||||||
|
final Widget? leading;
|
||||||
|
|
||||||
|
/// Whether to show the platform's Back (or close, on a full-screen dialog)
|
||||||
|
/// when [leading] is null and the route can go back.
|
||||||
|
final bool automaticallyImplyLeading;
|
||||||
|
final String? subtitle;
|
||||||
|
final IconData? subtitleIcon;
|
||||||
|
|
||||||
|
/// Makes the title pill a button (an information page, a picker).
|
||||||
|
final VoidCallback? onTitlePressed;
|
||||||
|
final String? titleSemanticLabel;
|
||||||
|
|
||||||
|
/// The key of the title's button (or its content when not pressable).
|
||||||
|
final Key? titleKey;
|
||||||
|
final List<Widget> actions;
|
||||||
|
|
||||||
|
/// The bar's backdrop; defaults to the enclosing scaffold's background.
|
||||||
|
final Color? backgroundColor;
|
||||||
|
|
||||||
|
/// The pieces' fill; defaults to the host's raised surface role.
|
||||||
|
final Color? pillColor;
|
||||||
|
|
||||||
|
/// The title's color, for a bar over a dark backdrop.
|
||||||
|
final Color? foregroundColor;
|
||||||
|
|
||||||
|
/// Space between the pieces and the content below.
|
||||||
|
final double bottomPadding;
|
||||||
|
|
||||||
|
static const double _topPadding = 8;
|
||||||
|
|
||||||
|
/// The share of the bar the title keeps before the actions shrink.
|
||||||
|
static const double minTitleShare = 0.25;
|
||||||
|
|
||||||
|
/// Bar text grows with the reader's setting up to this factor, like the
|
||||||
|
/// stock app bar caps its title, so the bar never takes over the page.
|
||||||
|
static const double maxTextScale = 2;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Size get preferredSize {
|
||||||
|
final piece = segmentedPieceHeight(cupertino);
|
||||||
|
if (cupertino) {
|
||||||
|
// CupertinoPageScaffold disables text scaling for its navigation bar
|
||||||
|
// and reserves exactly this height for it.
|
||||||
|
return Size.fromHeight(_topPadding + piece + bottomPadding);
|
||||||
|
}
|
||||||
|
// A Material scaffold only caps its app bar at this height and lets it
|
||||||
|
// size to its content: room for a title and subtitle at the largest
|
||||||
|
// text scale.
|
||||||
|
return Size.fromHeight(_topPadding + piece * maxTextScale + bottomPadding);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
// Content scrolls behind the bar; the scaffold insets it by the bar's
|
||||||
|
// height through the media padding instead.
|
||||||
|
bool shouldFullyObstruct(BuildContext context) => false;
|
||||||
|
|
||||||
|
Color _background(BuildContext context) {
|
||||||
|
if (backgroundColor case final color?) return color;
|
||||||
|
if (cupertino) {
|
||||||
|
return context
|
||||||
|
.dependOnInheritedWidgetOfExactType<
|
||||||
|
CupertinoPageScaffoldBackgroundColor
|
||||||
|
>()
|
||||||
|
?.color ??
|
||||||
|
CupertinoTheme.of(context).scaffoldBackgroundColor;
|
||||||
|
}
|
||||||
|
return Scaffold.maybeOf(context)?.widget.backgroundColor ??
|
||||||
|
Theme.of(context).scaffoldBackgroundColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final leading =
|
||||||
|
this.leading ??
|
||||||
|
(automaticallyImplyLeading
|
||||||
|
? impliedSegmentedLeading(context, cupertino)
|
||||||
|
: null);
|
||||||
|
final showTitle = title.isNotEmpty || (subtitle ?? '').isNotEmpty;
|
||||||
|
final Widget bar = LayoutBuilder(
|
||||||
|
builder: (context, constraints) => Row(
|
||||||
|
children: [
|
||||||
|
if (leading != null) ...[
|
||||||
|
SegmentedPill(
|
||||||
|
cupertino: cupertino,
|
||||||
|
fill: pillColor,
|
||||||
|
child: leading,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
],
|
||||||
|
Expanded(
|
||||||
|
// Only as tall as the title: a Material scaffold offers its app
|
||||||
|
// bar more height than it needs.
|
||||||
|
child: Align(
|
||||||
|
alignment: AlignmentDirectional.centerStart,
|
||||||
|
heightFactor: 1,
|
||||||
|
child: showTitle
|
||||||
|
? SegmentedTitlePill(
|
||||||
|
cupertino: cupertino,
|
||||||
|
title: title,
|
||||||
|
subtitle: subtitle,
|
||||||
|
subtitleIcon: subtitleIcon,
|
||||||
|
onPressed: onTitlePressed,
|
||||||
|
semanticLabel: titleSemanticLabel,
|
||||||
|
buttonKey: titleKey,
|
||||||
|
foreground: foregroundColor,
|
||||||
|
fill: pillColor,
|
||||||
|
)
|
||||||
|
: const SizedBox.shrink(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (actions.isNotEmpty) ...[
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
// The actions keep to the trailing edge at their natural width,
|
||||||
|
// so a model name shows whole while the title has room; only past
|
||||||
|
// the title's minimum share does the first action ellipsise.
|
||||||
|
ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
maxWidth: math.max(
|
||||||
|
0,
|
||||||
|
constraints.maxWidth -
|
||||||
|
(leading == null
|
||||||
|
? 0
|
||||||
|
: segmentedPieceHeight(cupertino) + 8) -
|
||||||
|
8 -
|
||||||
|
constraints.maxWidth * minTitleShare,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: SegmentedPill(
|
||||||
|
cupertino: cupertino,
|
||||||
|
fill: pillColor,
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Flexible(child: actions.first),
|
||||||
|
...actions.skip(1),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final background = _background(context);
|
||||||
|
final inset = MediaQuery.paddingOf(context).top;
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
// The scrim: the page's background, opaque at the edge and fading out
|
||||||
|
// towards the content, so content scrolled behind the pieces still
|
||||||
|
// reads. It takes no taps; only the pieces do.
|
||||||
|
Positioned.fill(
|
||||||
|
child: IgnorePointer(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: inset,
|
||||||
|
child: ColoredBox(color: background),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: DecoratedBox(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
colors: [
|
||||||
|
background,
|
||||||
|
background.withValues(alpha: background.a * 0.85),
|
||||||
|
background.withValues(alpha: 0),
|
||||||
|
],
|
||||||
|
stops: const [0, 0.45, 1],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SafeArea(
|
||||||
|
bottom: false,
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsetsDirectional.fromSTEB(
|
||||||
|
12,
|
||||||
|
_topPadding,
|
||||||
|
12,
|
||||||
|
bottomPadding,
|
||||||
|
),
|
||||||
|
child: MediaQuery.withClampedTextScaling(
|
||||||
|
maxScaleFactor: maxTextScale,
|
||||||
|
child: bar,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
/// Floats [bar] over the top of [child], the way a scaffold with
|
||||||
|
/// `extendBodyBehindAppBar` does, for a bar that is not a scaffold's.
|
||||||
|
///
|
||||||
|
/// [child] fills the whole area and scrolls behind the bar; it learns the
|
||||||
|
/// bar's measured height (status-bar inset included) as its
|
||||||
|
/// [MediaQuery.paddingOf] top, so a list can pad its first item below the bar
|
||||||
|
/// at rest. Taps the bar does not take reach [child].
|
||||||
|
class SegmentedBarOverlay extends StatelessWidget {
|
||||||
|
const SegmentedBarOverlay({
|
||||||
|
super.key,
|
||||||
|
required this.bar,
|
||||||
|
required this.child,
|
||||||
|
});
|
||||||
|
|
||||||
|
final Widget bar;
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => CustomMultiChildLayout(
|
||||||
|
delegate: _OverlayLayout(),
|
||||||
|
children: [
|
||||||
|
// Painted first, so the bar draws (and takes taps) above it.
|
||||||
|
LayoutId(
|
||||||
|
id: _Slot.content,
|
||||||
|
child: LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
final barHeight = constraints is _ContentConstraints
|
||||||
|
? constraints.barHeight
|
||||||
|
: 0.0;
|
||||||
|
final media = MediaQuery.of(context);
|
||||||
|
return MediaQuery(
|
||||||
|
data: media.copyWith(
|
||||||
|
padding: media.padding.copyWith(top: barHeight),
|
||||||
|
),
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
LayoutId(id: _Slot.bar, child: bar),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
enum _Slot { content, bar }
|
||||||
|
|
||||||
|
/// The content's tight constraints, carrying the bar's height so the content
|
||||||
|
/// rebuilds its inset when the bar grows or shrinks.
|
||||||
|
class _ContentConstraints extends BoxConstraints {
|
||||||
|
_ContentConstraints(Size size, {required this.barHeight})
|
||||||
|
: super(
|
||||||
|
minWidth: size.width,
|
||||||
|
maxWidth: size.width,
|
||||||
|
minHeight: size.height,
|
||||||
|
maxHeight: size.height,
|
||||||
|
);
|
||||||
|
|
||||||
|
final double barHeight;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) =>
|
||||||
|
other is _ContentConstraints &&
|
||||||
|
super == other &&
|
||||||
|
other.barHeight == barHeight;
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(super.hashCode, barHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
class _OverlayLayout extends MultiChildLayoutDelegate {
|
||||||
|
@override
|
||||||
|
void performLayout(Size size) {
|
||||||
|
final bar = layoutChild(
|
||||||
|
_Slot.bar,
|
||||||
|
BoxConstraints(
|
||||||
|
maxWidth: size.width,
|
||||||
|
minWidth: size.width,
|
||||||
|
).copyWith(maxHeight: size.height),
|
||||||
|
);
|
||||||
|
positionChild(_Slot.bar, Offset.zero);
|
||||||
|
layoutChild(
|
||||||
|
_Slot.content,
|
||||||
|
_ContentConstraints(size, barHeight: bar.height),
|
||||||
|
);
|
||||||
|
positionChild(_Slot.content, Offset.zero);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool shouldRelayout(_OverlayLayout oldDelegate) => false;
|
||||||
|
}
|
||||||
@@ -0,0 +1,203 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'glass_pill.dart';
|
||||||
|
|
||||||
|
/// The smallest height of every piece of a [SegmentedBar]: the platform's
|
||||||
|
/// minimum touch target, so a round Back is a circle.
|
||||||
|
double segmentedPieceHeight(bool cupertino) =>
|
||||||
|
cupertino ? kMinInteractiveDimensionCupertino : kMinInteractiveDimension;
|
||||||
|
|
||||||
|
/// One rounded piece of a segmented bar: a [GlassPill] at least the
|
||||||
|
/// platform's touch-target size.
|
||||||
|
class SegmentedPill extends StatelessWidget {
|
||||||
|
const SegmentedPill({
|
||||||
|
super.key,
|
||||||
|
required this.cupertino,
|
||||||
|
required this.child,
|
||||||
|
this.fill,
|
||||||
|
});
|
||||||
|
|
||||||
|
final bool cupertino;
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
/// Overrides the fill (a dark viewer's pieces).
|
||||||
|
final Color? fill;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final height = segmentedPieceHeight(cupertino);
|
||||||
|
// A stadium whose content is as wide as it is tall is a circle.
|
||||||
|
return GlassPill(
|
||||||
|
cupertino: cupertino,
|
||||||
|
fill: fill,
|
||||||
|
child: ConstrainedBox(
|
||||||
|
// The minimum reaches the content, so a pressable piece is pressable
|
||||||
|
// (and ripples) across its whole height.
|
||||||
|
constraints: BoxConstraints(minHeight: height, minWidth: height),
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The platform's own Back for a segmented bar: Material [BackButton],
|
||||||
|
/// Cupertino [CupertinoNavigationBarBackButton]. A null [onPressed] keeps the
|
||||||
|
/// stock action (pop the route).
|
||||||
|
class SegmentedBackButton extends StatelessWidget {
|
||||||
|
const SegmentedBackButton({
|
||||||
|
super.key,
|
||||||
|
required this.cupertino,
|
||||||
|
this.onPressed,
|
||||||
|
});
|
||||||
|
|
||||||
|
final bool cupertino;
|
||||||
|
final VoidCallback? onPressed;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => cupertino
|
||||||
|
? CupertinoNavigationBarBackButton(onPressed: onPressed)
|
||||||
|
: BackButton(onPressed: onPressed);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// What a bar implies on the leading edge when the page gave none, matching
|
||||||
|
/// the stock bars: Back on a route that can go back, the platform's close
|
||||||
|
/// control on a full-screen dialog, nothing on a root page.
|
||||||
|
Widget? impliedSegmentedLeading(BuildContext context, bool cupertino) {
|
||||||
|
final route = ModalRoute.of(context);
|
||||||
|
if (route == null) return null;
|
||||||
|
final dialog = route is PageRoute && route.fullscreenDialog;
|
||||||
|
if (cupertino) {
|
||||||
|
if (!route.canPop) return null;
|
||||||
|
if (dialog) {
|
||||||
|
return CupertinoButton(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
onPressed: () => route.navigator?.maybePop(),
|
||||||
|
child: Text(CupertinoLocalizations.of(context).cancelButtonLabel),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return const SegmentedBackButton(cupertino: true);
|
||||||
|
}
|
||||||
|
if (!route.impliesAppBarDismissal) return null;
|
||||||
|
return dialog ? const CloseButton() : const BackButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The title, with an optional one-line subtitle, in one pill; pressing it
|
||||||
|
/// runs [onPressed] when given.
|
||||||
|
class SegmentedTitlePill extends StatelessWidget {
|
||||||
|
const SegmentedTitlePill({
|
||||||
|
super.key,
|
||||||
|
required this.cupertino,
|
||||||
|
required this.title,
|
||||||
|
this.subtitle,
|
||||||
|
this.subtitleIcon,
|
||||||
|
this.onPressed,
|
||||||
|
this.semanticLabel,
|
||||||
|
this.buttonKey,
|
||||||
|
this.foreground,
|
||||||
|
this.fill,
|
||||||
|
});
|
||||||
|
|
||||||
|
final bool cupertino;
|
||||||
|
final String title;
|
||||||
|
final String? subtitle;
|
||||||
|
final IconData? subtitleIcon;
|
||||||
|
final VoidCallback? onPressed;
|
||||||
|
final String? semanticLabel;
|
||||||
|
|
||||||
|
/// The key of the pressable title, for finders.
|
||||||
|
final Key? buttonKey;
|
||||||
|
final Color? foreground;
|
||||||
|
final Color? fill;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final TextStyle titleStyle;
|
||||||
|
final TextStyle subtitleStyle;
|
||||||
|
if (cupertino) {
|
||||||
|
final text = CupertinoTheme.of(context).textTheme;
|
||||||
|
titleStyle = text.textStyle.copyWith(
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: foreground,
|
||||||
|
);
|
||||||
|
subtitleStyle = text.tabLabelTextStyle.copyWith(
|
||||||
|
color:
|
||||||
|
foreground ?? CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
titleStyle = (theme.textTheme.titleSmall ?? const TextStyle()).copyWith(
|
||||||
|
color: foreground ?? theme.colorScheme.onSurface,
|
||||||
|
);
|
||||||
|
subtitleStyle = (theme.textTheme.labelSmall ?? const TextStyle())
|
||||||
|
.copyWith(color: foreground ?? theme.colorScheme.onSurfaceVariant);
|
||||||
|
}
|
||||||
|
final subtitle = this.subtitle ?? '';
|
||||||
|
final content = Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Semantics(
|
||||||
|
header: true,
|
||||||
|
child: Text(
|
||||||
|
title,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: titleStyle,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (subtitle.isNotEmpty)
|
||||||
|
// One line that ellipsises as a whole, so a narrow pill never
|
||||||
|
// overflows on the icon.
|
||||||
|
Text.rich(
|
||||||
|
TextSpan(
|
||||||
|
children: [
|
||||||
|
if (subtitleIcon != null) ...[
|
||||||
|
WidgetSpan(
|
||||||
|
alignment: PlaceholderAlignment.middle,
|
||||||
|
child: Icon(
|
||||||
|
subtitleIcon,
|
||||||
|
size: subtitleStyle.fontSize,
|
||||||
|
color: subtitleStyle.color,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const TextSpan(text: ' '),
|
||||||
|
],
|
||||||
|
TextSpan(text: subtitle),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: subtitleStyle,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final onPressed = this.onPressed;
|
||||||
|
final Widget body;
|
||||||
|
if (onPressed == null) {
|
||||||
|
body = KeyedSubtree(key: buttonKey, child: content);
|
||||||
|
} else {
|
||||||
|
body = Semantics(
|
||||||
|
button: true,
|
||||||
|
label: semanticLabel,
|
||||||
|
child: cupertino
|
||||||
|
? CupertinoButton(
|
||||||
|
key: buttonKey,
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
minimumSize: Size.zero,
|
||||||
|
onPressed: onPressed,
|
||||||
|
child: DefaultTextStyle.merge(
|
||||||
|
style: titleStyle,
|
||||||
|
child: content,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: InkWell(key: buttonKey, onTap: onPressed, child: content),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return SegmentedPill(cupertino: cupertino, fill: fill, child: body);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
# Segmented top bar across the app
|
||||||
|
|
||||||
|
The ChatGPT-style bar the chat introduced (round Back, title pill, actions
|
||||||
|
pill on the page's own background) is now the app's only top bar.
|
||||||
|
|
||||||
|
## Shared pieces (`lib/ui/adaptive/`)
|
||||||
|
|
||||||
|
- `segmented_bar.dart` — `SegmentedBar({required bool cupertino, required
|
||||||
|
String title, Widget? leading, bool automaticallyImplyLeading = true,
|
||||||
|
String? subtitle, IconData? subtitleIcon, VoidCallback? onTitlePressed,
|
||||||
|
String? titleSemanticLabel, Key? titleKey, List<Widget> actions,
|
||||||
|
Color? backgroundColor, Color? pillColor, Color? foregroundColor,
|
||||||
|
double bottomPadding = 8})`. An `ObstructingPreferredSizeWidget`: use it as
|
||||||
|
`Scaffold.appBar` (with `extendBodyBehindAppBar: true`) or
|
||||||
|
`CupertinoPageScaffold.navigationBar`; it handles the top safe area and
|
||||||
|
implies Back / close (Material `BackButton`/`CloseButton`, Cupertino
|
||||||
|
`CupertinoNavigationBarBackButton`/Cancel) like the stock bars.
|
||||||
|
- Layout: actions take their natural width first; the title shrinks and
|
||||||
|
ellipsises, keeping at least `minTitleShare` (25%) of the bar; only then
|
||||||
|
does the first action ellipsise.
|
||||||
|
- Background: a scrim of the page background, opaque over the status-bar
|
||||||
|
inset and fading out downwards. It ignores pointers: only the pills take
|
||||||
|
taps; taps between them reach the content behind.
|
||||||
|
- `preferredSize`: Cupertino reserves exactly 8 + 44 + bottom (the scaffold
|
||||||
|
disables text scaling in its navigation bar); Material reports a cap
|
||||||
|
(8 + 48×2 + bottom) and the scaffold sizes the bar to its content. Bar text
|
||||||
|
is clamped at 2× (the stock app bar clamps its title too).
|
||||||
|
- `segmented_bar_pieces.dart` — `SegmentedPill`, `SegmentedBackButton`,
|
||||||
|
`SegmentedTitlePill`, `impliedSegmentedLeading`.
|
||||||
|
- `glass_pill.dart` — `GlassPill`: the reusable frosted piece (one
|
||||||
|
`BackdropFilter` blur, sigma 16, clipped to the shape; fill
|
||||||
|
`surfaceContainerHigh` / `systemGrey6` at 72%; hairline `outlineVariant` /
|
||||||
|
`separator` border). Under `MediaQuery.highContrast` the fill is solid and
|
||||||
|
nothing blurs. Intended for the floating tab bar follow-up too.
|
||||||
|
- `segmented_bar_overlay.dart` — `SegmentedBarOverlay(bar:, child:)`: floats a
|
||||||
|
bar over content outside a scaffold (like `extendBodyBehindAppBar`), giving
|
||||||
|
the content the bar's measured height as `MediaQuery.paddingOf(context).top`.
|
||||||
|
|
||||||
|
## Floating behind the bar
|
||||||
|
|
||||||
|
- Material scaffolds use `extendBodyBehindAppBar: true`; Cupertino bars do not
|
||||||
|
fully obstruct. Either way content receives the bar height as media padding.
|
||||||
|
- The conversation transcript floats: `ChatThreadView` lays its header over
|
||||||
|
the transcript with `SegmentedBarOverlay`; the list pads its first item by
|
||||||
|
the bar height, so at rest nothing is hidden and scrolled history passes
|
||||||
|
behind the glass pills.
|
||||||
|
- Other pages keep their content inset with `SafeArea` (bodies that used
|
||||||
|
`SafeArea(top: false)` now use the full `SafeArea`; the shell, chat list and
|
||||||
|
schedules bodies gained a top-only `SafeArea`). They show the new bar but
|
||||||
|
their content does not yet scroll behind it — each list has its own fixed
|
||||||
|
padding/headers and needs a per-screen change to consume the media padding.
|
||||||
|
- The bottom tab bar is unchanged (floating tab bars are a separate change).
|
||||||
|
|
||||||
|
## Converted
|
||||||
|
|
||||||
|
Shell bar (`shell/adaptive_shell.dart`), `DetailPane` (`shell/detail_page.dart`,
|
||||||
|
still drops only its app bar for barless content so the body never remounts),
|
||||||
|
chat header (`chat_thread_header.dart`, keys `chat-thread-header`, `chat-info`,
|
||||||
|
`chat-back`, `chat-model` kept), and every page-level bar in `lib/`:
|
||||||
|
application/{schedules,search,templates}_destination, artifacts gallery and
|
||||||
|
viewer, file diff viewer, chat sessions, chat image viewer, graph expanded
|
||||||
|
view, stage definition view, pipelines screen and filter page, run changes,
|
||||||
|
run visit page, run graph preview, usage stats, schedule pipeline editor,
|
||||||
|
search screen, saved server editor, settings, templates frame.
|
||||||
|
No `AppBar(`, `CupertinoNavigationBar(`, `SliverAppBar` or
|
||||||
|
`CupertinoSliverNavigationBar` remains in `lib/`. No converted bar had a
|
||||||
|
`bottom:` tab strip (run detail tabs live in the body).
|
||||||
|
|
||||||
|
## Evidence
|
||||||
|
|
||||||
|
Captures in `/tmp/segmented-bar-evidence/` (headless Chrome, web builds of
|
||||||
|
`tool/chat_composer_probe_entry.dart` with the new `CHAT_COMPOSER_PROBE_LONG`,
|
||||||
|
`CHAT_COMPOSER_PROBE_MODEL` and `CHAT_COMPOSER_PROBE_WIDTH` defines, and
|
||||||
|
`tool/chat_sessions_probe_entry.dart`).
|
||||||
@@ -11,6 +11,7 @@ import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_screen.dar
|
|||||||
|
|
||||||
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
||||||
import '../native_back.dart';
|
import '../native_back.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||||
|
|
||||||
ServerEndpoint webServer() => ServerEndpoint.resolve(
|
ServerEndpoint webServer() => ServerEndpoint.resolve(
|
||||||
base: Uri.parse('http://127.0.0.1:8096/'),
|
base: Uri.parse('http://127.0.0.1:8096/'),
|
||||||
@@ -215,13 +216,10 @@ void main() {
|
|||||||
find.byType(NavigationRail),
|
find.byType(NavigationRail),
|
||||||
cupertino ? findsNothing : findsOneWidget,
|
cupertino ? findsNothing : findsOneWidget,
|
||||||
);
|
);
|
||||||
if (cupertino) {
|
// The shell's bar and the conversation's own header.
|
||||||
expect(find.byType(CupertinoNavigationBar), findsOneWidget);
|
expect(find.byType(SegmentedBar), findsNWidgets(2));
|
||||||
expect(find.byType(AppBar), findsNothing);
|
expect(find.byType(AppBar), findsNothing);
|
||||||
} else {
|
expect(find.byType(CupertinoNavigationBar), findsNothing);
|
||||||
expect(find.byType(AppBar), findsOneWidget);
|
|
||||||
expect(find.byType(CupertinoNavigationBar), findsNothing);
|
|
||||||
}
|
|
||||||
expect(find.byKey(const Key('chat-thread-header')), findsOneWidget);
|
expect(find.byKey(const Key('chat-thread-header')), findsOneWidget);
|
||||||
expect(findNativeBack(), findsNothing);
|
expect(findNativeBack(), findsNothing);
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import '../features/pipelines/fixtures.dart';
|
|||||||
import '../features/pipelines/test_helpers.dart' show selectableText;
|
import '../features/pipelines/test_helpers.dart' show selectableText;
|
||||||
import 'pipelines_app_test.dart' show webServer;
|
import 'pipelines_app_test.dart' show webServer;
|
||||||
import 'pipelines_replies.dart';
|
import 'pipelines_replies.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
for (final cupertino in [false, true]) {
|
for (final cupertino in [false, true]) {
|
||||||
@@ -56,21 +57,17 @@ void main() {
|
|||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|
||||||
expect(find.text('Alpha review'), findsOneWidget);
|
expect(find.text('Alpha review'), findsOneWidget);
|
||||||
expect(
|
expect(find.text('2 stages · 1 schedule'), findsOneWidget);
|
||||||
find.text('2 stages · 1 schedule'),
|
|
||||||
findsOneWidget,
|
|
||||||
);
|
|
||||||
expect(find.text('Pipelines — Not implemented'), findsNothing);
|
expect(find.text('Pipelines — Not implemented'), findsNothing);
|
||||||
expect(sockets, 1);
|
expect(sockets, 1);
|
||||||
|
|
||||||
// The shell owns the only navigation bar; the embedded screen adds no
|
// The shell owns the only navigation bar; the embedded screen adds no
|
||||||
// second AppBar or CupertinoNavigationBar.
|
// second bar.
|
||||||
|
expect(find.byType(SegmentedBar), findsOneWidget);
|
||||||
if (cupertino) {
|
if (cupertino) {
|
||||||
expect(find.byType(CupertinoNavigationBar), findsOneWidget);
|
|
||||||
expect(find.byType(CupertinoPageScaffold), findsOneWidget);
|
expect(find.byType(CupertinoPageScaffold), findsOneWidget);
|
||||||
expect(find.byType(Material), findsNothing);
|
expect(find.byType(Material), findsNothing);
|
||||||
} else {
|
} else {
|
||||||
expect(find.byType(AppBar), findsOneWidget);
|
|
||||||
expect(find.byType(Scaffold), findsOneWidget);
|
expect(find.byType(Scaffold), findsOneWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
|||||||
import '../features/pipelines/fixtures.dart';
|
import '../features/pipelines/fixtures.dart';
|
||||||
import 'pipelines_app_test.dart' show webServer, requestOf;
|
import 'pipelines_app_test.dart' show webServer, requestOf;
|
||||||
import 'pipelines_replies.dart';
|
import 'pipelines_replies.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
for (final cupertino in [false, true]) {
|
for (final cupertino in [false, true]) {
|
||||||
@@ -65,10 +66,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
expect(find.text('Settings — Not implemented'), findsNothing);
|
expect(find.text('Settings — Not implemented'), findsNothing);
|
||||||
expect(sockets, 1);
|
expect(sockets, 1);
|
||||||
expect(
|
expect(find.byType(SegmentedBar), findsOneWidget);
|
||||||
cupertino ? find.byType(CupertinoNavigationBar) : find.byType(AppBar),
|
|
||||||
findsOneWidget,
|
|
||||||
);
|
|
||||||
final ping = requestOf(channel, 'ping')!;
|
final ping = requestOf(channel, 'ping')!;
|
||||||
channel.incoming.add(
|
channel.incoming.add(
|
||||||
jsonEncode({
|
jsonEncode({
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/application/pipelines_app.dart';
|
import 'package:pipelines_app/application/pipelines_app.dart';
|
||||||
@@ -19,6 +18,7 @@ import '../features/templates/ui/template_gallery_test_support.dart'
|
|||||||
show GalleryGateway, galleryTemplates, pumpGallery, templatesReply;
|
show GalleryGateway, galleryTemplates, pumpGallery, templatesReply;
|
||||||
import 'pipelines_app_test.dart' show webServer;
|
import 'pipelines_app_test.dart' show webServer;
|
||||||
import 'pipelines_replies.dart';
|
import 'pipelines_replies.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||||
|
|
||||||
List<Map<String, dynamic>> requestsOf(FakeChannel channel, String type) =>
|
List<Map<String, dynamic>> requestsOf(FakeChannel channel, String type) =>
|
||||||
channel.outgoing
|
channel.outgoing
|
||||||
@@ -152,7 +152,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
await pumpGallery(tester, gateway);
|
await pumpGallery(tester, gateway);
|
||||||
|
|
||||||
expect(find.byType(AppBar), findsOneWidget);
|
expect(find.byType(SegmentedBar), findsOneWidget);
|
||||||
await tester.tap(find.byKey(templateRowKey('release')));
|
await tester.tap(find.byKey(templateRowKey('release')));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(find.text('Definition source'), findsOneWidget);
|
expect(find.text('Definition source'), findsOneWidget);
|
||||||
@@ -204,10 +204,7 @@ void main() {
|
|||||||
expect(find.text('Release workflow'), findsOneWidget);
|
expect(find.text('Release workflow'), findsOneWidget);
|
||||||
// One visible navigation bar: the Templates page owns it, the shell is
|
// One visible navigation bar: the Templates page owns it, the shell is
|
||||||
// preserved underneath.
|
// preserved underneath.
|
||||||
expect(
|
expect(find.byType(SegmentedBar), findsOneWidget);
|
||||||
find.byType(cupertino ? CupertinoNavigationBar : AppBar),
|
|
||||||
findsOneWidget,
|
|
||||||
);
|
|
||||||
if (cupertino) {
|
if (cupertino) {
|
||||||
expect(find.byType(Material), findsNothing);
|
expect(find.byType(Material), findsNothing);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -281,7 +281,14 @@ void main() {
|
|||||||
// Drag like an operator: a programmatic scroll is undone by the
|
// Drag like an operator: a programmatic scroll is undone by the
|
||||||
// view's follow-to-latest, while a user drag stops following.
|
// view's follow-to-latest, while a user drag stops following.
|
||||||
final list = find.byKey(const ValueKey<String>('chat-thread-s'));
|
final list = find.byKey(const ValueKey<String>('chat-thread-s'));
|
||||||
final viewport = tester.getRect(list);
|
// The transcript scrolls behind the floating header; only the part
|
||||||
|
// below it is visible.
|
||||||
|
final viewport = Rect.fromLTRB(
|
||||||
|
tester.getRect(list).left,
|
||||||
|
tester.getRect(find.byKey(const Key('chat-thread-header'))).bottom,
|
||||||
|
tester.getRect(list).right,
|
||||||
|
tester.getRect(list).bottom,
|
||||||
|
);
|
||||||
for (var i = 0; i < 10; i++) {
|
for (var i = 0; i < 10; i++) {
|
||||||
final rect = tester.getRect(control);
|
final rect = tester.getRect(control);
|
||||||
if (rect.top >= viewport.top && rect.bottom <= viewport.bottom) break;
|
if (rect.top >= viewport.top && rect.bottom <= viewport.bottom) break;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
import 'package:pipelines_app/core/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
import 'package:pipelines_app/features/graph/domain/stage_definition.dart';
|
import 'package:pipelines_app/features/graph/domain/stage_definition.dart';
|
||||||
import 'package:pipelines_app/features/graph/widgets/stage_definition_view.dart';
|
import 'package:pipelines_app/features/graph/widgets/stage_definition_view.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||||
|
|
||||||
JsonMap _graph() => <String, dynamic>{
|
JsonMap _graph() => <String, dynamic>{
|
||||||
'stages': <dynamic>[
|
'stages': <dynamic>[
|
||||||
@@ -174,7 +175,7 @@ void main() {
|
|||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
expect(_text('plan definition'), findsOneWidget);
|
expect(_text('plan definition'), findsOneWidget);
|
||||||
expect(find.byType(AppBar), findsOneWidget);
|
expect(find.byType(SegmentedBar), findsOneWidget);
|
||||||
expect(find.byType(BackButton), findsOneWidget);
|
expect(find.byType(BackButton), findsOneWidget);
|
||||||
final route = ModalRoute.of(
|
final route = ModalRoute.of(
|
||||||
tester.element(find.byType(StageDefinitionView)),
|
tester.element(find.byType(StageDefinitionView)),
|
||||||
@@ -215,7 +216,7 @@ void main() {
|
|||||||
|
|
||||||
expect(_text('Success definition'), findsOneWidget);
|
expect(_text('Success definition'), findsOneWidget);
|
||||||
expect(_text('#success definition'), findsNothing);
|
expect(_text('#success definition'), findsNothing);
|
||||||
expect(find.byType(CupertinoNavigationBar), findsOneWidget);
|
expect(find.byType(SegmentedBar), findsOneWidget);
|
||||||
expect(find.byType(CupertinoNavigationBarBackButton), findsOneWidget);
|
expect(find.byType(CupertinoNavigationBarBackButton), findsOneWidget);
|
||||||
expect(_text('Incoming routes'), findsOneWidget);
|
expect(_text('Incoming routes'), findsOneWidget);
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import 'package:pipelines_app/core/api_gateway.dart';
|
|||||||
import 'package:pipelines_app/features/runs/screen.dart';
|
import 'package:pipelines_app/features/runs/screen.dart';
|
||||||
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
|
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
|
||||||
import 'run_detail_finders.dart';
|
import 'run_detail_finders.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||||
|
|
||||||
class _Gateway implements ApiGateway {
|
class _Gateway implements ApiGateway {
|
||||||
final framesController = StreamController<JsonMap>.broadcast();
|
final framesController = StreamController<JsonMap>.broadcast();
|
||||||
@@ -310,7 +311,9 @@ void main() {
|
|||||||
await _mountList(tester, gateway);
|
await _mountList(tester, gateway);
|
||||||
|
|
||||||
expect(find.byType(CupertinoPageScaffold), findsNWidgets(2));
|
expect(find.byType(CupertinoPageScaffold), findsNWidgets(2));
|
||||||
expect(find.byType(CupertinoNavigationBar), findsNWidgets(2));
|
// The host's own bar and the detail pane's segmented bar.
|
||||||
|
expect(find.byType(CupertinoNavigationBar), findsOneWidget);
|
||||||
|
expect(find.byType(SegmentedBar), findsOneWidget);
|
||||||
expect(find.text('Loading run details…'), findsOneWidget);
|
expect(find.text('Loading run details…'), findsOneWidget);
|
||||||
expect(find.byType(CupertinoActivityIndicator), findsOneWidget);
|
expect(find.byType(CupertinoActivityIndicator), findsOneWidget);
|
||||||
expect(find.text('Back to list'), findsOneWidget);
|
expect(find.text('Back to list'), findsOneWidget);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import 'package:pipelines_app/features/settings/settings_screen.dart';
|
|||||||
import 'package:pipelines_app/features/settings/settings_store.dart';
|
import 'package:pipelines_app/features/settings/settings_store.dart';
|
||||||
|
|
||||||
import 'fake_channel.dart';
|
import 'fake_channel.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('renders idle settings without opening a connection', (
|
testWidgets('renders idle settings without opening a connection', (
|
||||||
@@ -241,7 +242,7 @@ void main() {
|
|||||||
|
|
||||||
await _pump(tester, client, platform: TargetPlatform.iOS);
|
await _pump(tester, client, platform: TargetPlatform.iOS);
|
||||||
|
|
||||||
expect(find.byType(CupertinoNavigationBar), findsOneWidget);
|
expect(find.byType(SegmentedBar), findsOneWidget);
|
||||||
expect(find.byType(CupertinoTextField), findsNWidgets(2));
|
expect(find.byType(CupertinoTextField), findsNWidgets(2));
|
||||||
expect(find.byType(TextField), findsNothing);
|
expect(find.byType(TextField), findsNothing);
|
||||||
expect(find.byType(FilledButton), findsNothing);
|
expect(find.byType(FilledButton), findsNothing);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import 'package:pipelines_app/features/templates/ui/template_detail.dart';
|
|||||||
|
|
||||||
import '../data/template_test_support.dart' show source;
|
import '../data/template_test_support.dart' show source;
|
||||||
import 'template_gallery_test_support.dart';
|
import 'template_gallery_test_support.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('loading shows the exact line, then the server catalogue', (
|
testWidgets('loading shows the exact line, then the server catalogue', (
|
||||||
@@ -210,7 +211,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
await pumpGallery(tester, gateway, embedded: true);
|
await pumpGallery(tester, gateway, embedded: true);
|
||||||
|
|
||||||
expect(find.byType(AppBar), findsNothing);
|
expect(find.byType(SegmentedBar), findsNothing);
|
||||||
expect(find.byKey(templatesRefreshKey), findsOneWidget);
|
expect(find.byKey(templatesRefreshKey), findsOneWidget);
|
||||||
await tester.tap(find.byKey(templateRowKey('release')));
|
await tester.tap(find.byKey(templateRowKey('release')));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|||||||
@@ -0,0 +1,194 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/rendering.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/segmented_bar_overlay.dart';
|
||||||
|
|
||||||
|
void _size(WidgetTester tester, double width, {double scale = 1}) {
|
||||||
|
tester.view.physicalSize = Size(width, 700);
|
||||||
|
tester.view.devicePixelRatio = 1;
|
||||||
|
tester.platformDispatcher.textScaleFactorTestValue = scale;
|
||||||
|
addTearDown(tester.view.resetPhysicalSize);
|
||||||
|
addTearDown(tester.view.resetDevicePixelRatio);
|
||||||
|
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _ellipsised(WidgetTester tester, String text) {
|
||||||
|
final paragraph = tester.renderObject<RenderParagraph>(find.text(text));
|
||||||
|
return paragraph.didExceedMaxLines ||
|
||||||
|
paragraph.size.width <
|
||||||
|
(TextPainter(
|
||||||
|
text: TextSpan(text: text, style: paragraph.text.style),
|
||||||
|
textDirection: TextDirection.ltr,
|
||||||
|
textScaler: paragraph.textScaler,
|
||||||
|
)..layout()).width -
|
||||||
|
0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _modelAction(String model) => TextButton(
|
||||||
|
onPressed: () {},
|
||||||
|
child: Text(model, maxLines: 1, overflow: TextOverflow.ellipsis),
|
||||||
|
);
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
// The test font draws every glyph a square, so names run wider than in
|
||||||
|
// a browser; each width takes the longest id that fits it there.
|
||||||
|
for (final (width, model) in [
|
||||||
|
(390.0, 'gpt-5.6-luna'),
|
||||||
|
(560.0, 'claude-opus-5-5'),
|
||||||
|
]) {
|
||||||
|
testWidgets('a long model name ($model) shows whole at ${width}px', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
_size(tester, width);
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
extendBodyBehindAppBar: true,
|
||||||
|
appBar: SegmentedBar(
|
||||||
|
cupertino: false,
|
||||||
|
leading: const BackButton(),
|
||||||
|
title: 'A conversation with a rather long title indeed',
|
||||||
|
subtitle: 'tank',
|
||||||
|
actions: [_modelAction(model)],
|
||||||
|
),
|
||||||
|
body: const SizedBox.expand(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
expect(_ellipsised(tester, model), isFalse);
|
||||||
|
// The title gives way first.
|
||||||
|
expect(
|
||||||
|
_ellipsised(tester, 'A conversation with a rather long title indeed'),
|
||||||
|
isTrue,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
testWidgets('320px at 2x text lays out without overflow', (tester) async {
|
||||||
|
_size(tester, 320, scale: 2);
|
||||||
|
for (final cupertino in [false, true]) {
|
||||||
|
final bar = SegmentedBar(
|
||||||
|
cupertino: cupertino,
|
||||||
|
leading: SegmentedBackButton(cupertino: cupertino, onPressed: () {}),
|
||||||
|
title: 'A long conversation title',
|
||||||
|
subtitle: 'a-working-folder',
|
||||||
|
subtitleIcon: Icons.folder_outlined,
|
||||||
|
onTitlePressed: () {},
|
||||||
|
actions: cupertino
|
||||||
|
? [
|
||||||
|
CupertinoButton(
|
||||||
|
onPressed: () {},
|
||||||
|
child: const Text(
|
||||||
|
'gpt-5.6-luna',
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
: [
|
||||||
|
_modelAction('gpt-5.6-luna'),
|
||||||
|
IconButton(onPressed: () {}, icon: const Icon(Icons.refresh)),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
// A Cupertino bar over content (the conversation's own) scales its
|
||||||
|
// text; as a navigation bar the scaffold turns scaling off.
|
||||||
|
await tester.pumpWidget(
|
||||||
|
cupertino
|
||||||
|
? CupertinoApp(
|
||||||
|
home: CupertinoPageScaffold(
|
||||||
|
child: SegmentedBarOverlay(
|
||||||
|
bar: bar,
|
||||||
|
child: const SizedBox.expand(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
extendBodyBehindAppBar: true,
|
||||||
|
appBar: bar,
|
||||||
|
body: const SizedBox.expand(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
expect(tester.takeException(), isNull, reason: 'cupertino: $cupertino');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('taps between the pieces reach the content behind', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
_size(tester, 560);
|
||||||
|
var behind = 0;
|
||||||
|
var back = 0;
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
extendBodyBehindAppBar: true,
|
||||||
|
appBar: SegmentedBar(
|
||||||
|
cupertino: false,
|
||||||
|
leading: BackButton(onPressed: () => back++),
|
||||||
|
title: 'Short',
|
||||||
|
),
|
||||||
|
body: GestureDetector(
|
||||||
|
behavior: HitTestBehavior.opaque,
|
||||||
|
onTap: () => behind++,
|
||||||
|
child: const SizedBox.expand(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final barRect = tester.getRect(find.byType(SegmentedBar));
|
||||||
|
// The empty middle of the bar, right of the short title.
|
||||||
|
await tester.tapAt(Offset(barRect.width * 0.75, barRect.center.dy));
|
||||||
|
expect(behind, 1);
|
||||||
|
await tester.tap(find.byType(BackButton));
|
||||||
|
expect(back, 1);
|
||||||
|
expect(behind, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('content starts below the bar at rest', (tester) async {
|
||||||
|
_size(tester, 560);
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
body: SegmentedBarOverlay(
|
||||||
|
bar: const SegmentedBar(cupertino: false, title: 'Overlay'),
|
||||||
|
child: ListView(
|
||||||
|
children: const [ListTile(title: Text('First row'))],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final bar = tester.getRect(find.byType(SegmentedBar));
|
||||||
|
final row = tester.getRect(find.text('First row'));
|
||||||
|
expect(row.top, greaterThanOrEqualTo(bar.bottom));
|
||||||
|
// The list itself reaches the top, behind the bar.
|
||||||
|
expect(tester.getRect(find.byType(ListView)).top, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('pieces are frosted glass, solid under high contrast', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
Widget app(bool highContrast) => CupertinoApp(
|
||||||
|
home: MediaQuery(
|
||||||
|
data: MediaQueryData(highContrast: highContrast),
|
||||||
|
child: const CupertinoPageScaffold(
|
||||||
|
navigationBar: SegmentedBar(cupertino: true, title: 'Glass'),
|
||||||
|
child: SizedBox.expand(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await tester.pumpWidget(app(false));
|
||||||
|
expect(find.byType(GlassPill), findsOneWidget);
|
||||||
|
expect(find.byType(BackdropFilter), findsOneWidget);
|
||||||
|
// The Cupertino bar draws no Material widget.
|
||||||
|
expect(find.byType(Material), findsNothing);
|
||||||
|
|
||||||
|
await tester.pumpWidget(app(true));
|
||||||
|
expect(find.byType(BackdropFilter), findsNothing);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
import 'package:pipelines_app/main.dart';
|
import 'package:pipelines_app/main.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
for (final width in [390.0, 1000.0]) {
|
for (final width in [390.0, 1000.0]) {
|
||||||
@@ -46,7 +47,8 @@ void main() {
|
|||||||
addTearDown(tester.view.resetPhysicalSize);
|
addTearDown(tester.view.resetPhysicalSize);
|
||||||
addTearDown(tester.view.resetDevicePixelRatio);
|
addTearDown(tester.view.resetDevicePixelRatio);
|
||||||
await tester.pumpWidget(const MyApp(cupertino: true));
|
await tester.pumpWidget(const MyApp(cupertino: true));
|
||||||
expect(find.byType(CupertinoNavigationBar), findsOneWidget);
|
expect(find.byType(SegmentedBar), findsOneWidget);
|
||||||
|
expect(find.byType(CupertinoNavigationBar), findsNothing);
|
||||||
expect(find.byType(CupertinoTabBar), findsOneWidget);
|
expect(find.byType(CupertinoTabBar), findsOneWidget);
|
||||||
expect(find.text('Pipelines — Not implemented'), findsOneWidget);
|
expect(find.text('Pipelines — Not implemented'), findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -31,6 +31,21 @@ class _ProbeGateway implements ApiGateway {
|
|||||||
return {
|
return {
|
||||||
'chat_history': {
|
'chat_history': {
|
||||||
'messages': [
|
'messages': [
|
||||||
|
// A long history scrolls behind the floating header.
|
||||||
|
if (_probeLong)
|
||||||
|
for (var i = 0; i < 12; i++)
|
||||||
|
{
|
||||||
|
'id': 'probe-history-$i',
|
||||||
|
'role': i.isEven ? 'user' : 'assistant',
|
||||||
|
'parts': [
|
||||||
|
{
|
||||||
|
'type': 'text',
|
||||||
|
'text':
|
||||||
|
'Earlier message ${i + 1}: a line of history so '
|
||||||
|
'the transcript is taller than the window.',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
'id': 'probe-user',
|
'id': 'probe-user',
|
||||||
'role': 'user',
|
'role': 'user',
|
||||||
@@ -97,6 +112,22 @@ class _ProbeGateway implements ApiGateway {
|
|||||||
String nextOperation() => 'probe-op-${++_sequence}';
|
String nextOperation() => 'probe-op-${++_sequence}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const _probeLong = bool.fromEnvironment('CHAT_COMPOSER_PROBE_LONG');
|
||||||
|
const _probeModel = String.fromEnvironment(
|
||||||
|
'CHAT_COMPOSER_PROBE_MODEL',
|
||||||
|
defaultValue: 'claude-opus-5-5',
|
||||||
|
);
|
||||||
|
|
||||||
|
/// A phone-width frame inside a wider browser window (headless Chrome crops
|
||||||
|
/// windows narrower than about 500px); zero uses the whole window.
|
||||||
|
const _probeWidth = int.fromEnvironment('CHAT_COMPOSER_PROBE_WIDTH');
|
||||||
|
|
||||||
|
Widget _framed(Widget child) => _probeWidth == 0
|
||||||
|
? child
|
||||||
|
: Center(
|
||||||
|
child: SizedBox(width: _probeWidth.toDouble(), child: child),
|
||||||
|
);
|
||||||
|
|
||||||
const _probeStyle = String.fromEnvironment(
|
const _probeStyle = String.fromEnvironment(
|
||||||
'CHAT_COMPOSER_PROBE_STYLE',
|
'CHAT_COMPOSER_PROBE_STYLE',
|
||||||
defaultValue: 'material',
|
defaultValue: 'material',
|
||||||
@@ -111,7 +142,7 @@ void main() {
|
|||||||
session: const {
|
session: const {
|
||||||
'id': 'probe-composer',
|
'id': 'probe-composer',
|
||||||
'backend': 'opencode',
|
'backend': 'opencode',
|
||||||
'model': 'claude-opus-5-5',
|
'model': _probeModel,
|
||||||
'directory': '/Users/ada/repos/tank',
|
'directory': '/Users/ada/repos/tank',
|
||||||
},
|
},
|
||||||
onBack: () {},
|
onBack: () {},
|
||||||
@@ -122,7 +153,7 @@ void main() {
|
|||||||
runApp(
|
runApp(
|
||||||
CupertinoApp(
|
CupertinoApp(
|
||||||
theme: const CupertinoThemeData(brightness: Brightness.dark),
|
theme: const CupertinoThemeData(brightness: Brightness.dark),
|
||||||
home: CupertinoPageScaffold(child: SafeArea(child: thread)),
|
home: CupertinoPageScaffold(child: _framed(SafeArea(child: thread))),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
@@ -133,7 +164,7 @@ void main() {
|
|||||||
platform: TargetPlatform.android,
|
platform: TargetPlatform.android,
|
||||||
brightness: Brightness.light,
|
brightness: Brightness.light,
|
||||||
),
|
),
|
||||||
home: Scaffold(body: SafeArea(child: thread)),
|
home: Scaffold(body: _framed(SafeArea(child: thread))),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user