feat(app): an open run takes over the app bar (Back, run, more menu); Search is the fifth tab; tabs keep their last screen
This commit is contained in:
@@ -16,6 +16,7 @@ Widget buildCupertinoRunDetail({
|
||||
required BuildContext context,
|
||||
required JsonMap run,
|
||||
required Widget headerActions,
|
||||
bool inShellBar = false,
|
||||
ValueChanged<num>? onRunOpened,
|
||||
OpenPipeline? onOpenPipeline,
|
||||
required bool detailLoading,
|
||||
@@ -45,37 +46,39 @@ Widget buildCupertinoRunDetail({
|
||||
header: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 0),
|
||||
child: Wrap(
|
||||
alignment: WrapAlignment.spaceBetween,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
spacing: 8,
|
||||
runSpacing: 4,
|
||||
children: [
|
||||
CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onBack,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(CupertinoIcons.back),
|
||||
const SizedBox(width: 4),
|
||||
const Text('Back'),
|
||||
],
|
||||
// Inside the app shell, Back and the more menu are in its bar.
|
||||
if (!inShellBar)
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 0),
|
||||
child: Wrap(
|
||||
alignment: WrapAlignment.spaceBetween,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
spacing: 8,
|
||||
runSpacing: 4,
|
||||
children: [
|
||||
CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onBack,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(CupertinoIcons.back),
|
||||
const SizedBox(width: 4),
|
||||
const Text('Back'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (copying) const CupertinoActivityIndicator(),
|
||||
RunMoreMenu(
|
||||
run: run,
|
||||
gateway: gateway,
|
||||
onRunChanged: onRunChanged,
|
||||
cupertino: true,
|
||||
onRunOpened: onRunOpened,
|
||||
),
|
||||
],
|
||||
if (copying) const CupertinoActivityIndicator(),
|
||||
RunMoreMenu(
|
||||
run: run,
|
||||
gateway: gateway,
|
||||
onRunChanged: onRunChanged,
|
||||
cupertino: true,
|
||||
onRunOpened: onRunOpened,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 0),
|
||||
child: Column(
|
||||
|
||||
@@ -16,6 +16,7 @@ Widget buildMaterialRunDetail({
|
||||
required BuildContext context,
|
||||
required JsonMap run,
|
||||
required Widget headerActions,
|
||||
bool inShellBar = false,
|
||||
ValueChanged<num>? onRunOpened,
|
||||
OpenPipeline? onOpenPipeline,
|
||||
required bool detailLoading,
|
||||
@@ -45,35 +46,37 @@ Widget buildMaterialRunDetail({
|
||||
header: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 4,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
TextButton.icon(
|
||||
onPressed: onBack,
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
label: const Text('Back to list'),
|
||||
),
|
||||
],
|
||||
// Inside the app shell, Back and the more menu are in its bar.
|
||||
if (!inShellBar)
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 4,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
TextButton.icon(
|
||||
onPressed: onBack,
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
label: const Text('Back to list'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
RunMoreMenu(
|
||||
run: run,
|
||||
gateway: gateway,
|
||||
onRunChanged: onRunChanged,
|
||||
cupertino: false,
|
||||
onRunOpened: onRunOpened,
|
||||
),
|
||||
],
|
||||
RunMoreMenu(
|
||||
run: run,
|
||||
gateway: gateway,
|
||||
onRunChanged: onRunChanged,
|
||||
cupertino: false,
|
||||
onRunOpened: onRunOpened,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
|
||||
child: Align(
|
||||
|
||||
@@ -5,7 +5,9 @@ import 'package:flutter/services.dart';
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../core/transport/pipelines_client.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../shell/shell_bar.dart';
|
||||
import 'run_detail_actions.dart';
|
||||
import 'run_more_menu.dart';
|
||||
import 'run_pipeline_link.dart';
|
||||
import 'run_detail_content.dart';
|
||||
import 'run_detail_cupertino.dart';
|
||||
@@ -67,13 +69,15 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
onRunOpened: widget.onRunOpened,
|
||||
retry: false,
|
||||
);
|
||||
return cupertino
|
||||
final inShellBar = ShellBar.available(context);
|
||||
final detail = cupertino
|
||||
? buildCupertinoRunDetail(
|
||||
context: context,
|
||||
run: run,
|
||||
headerActions: headerActions,
|
||||
onRunOpened: widget.onRunOpened,
|
||||
onOpenPipeline: widget.onOpenPipeline,
|
||||
inShellBar: inShellBar,
|
||||
detailLoading: widget.controller.detailLoading,
|
||||
error: widget.controller.error,
|
||||
copying: _copying,
|
||||
@@ -92,6 +96,7 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
headerActions: headerActions,
|
||||
onRunOpened: widget.onRunOpened,
|
||||
onOpenPipeline: widget.onOpenPipeline,
|
||||
inShellBar: inShellBar,
|
||||
detailLoading: widget.controller.detailLoading,
|
||||
error: widget.controller.error,
|
||||
copying: _copying,
|
||||
@@ -104,6 +109,22 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
initialStageKey: widget.initialStageKey,
|
||||
initialVisit: widget.initialVisit,
|
||||
);
|
||||
// The app bar becomes the run's: Back to the list, the run and its
|
||||
// more menu. Search and the tab name return when the run closes.
|
||||
return ShellBar(
|
||||
title: 'Run ${run['id']}',
|
||||
onBack: widget.onBack,
|
||||
actions: [
|
||||
RunMoreMenu(
|
||||
run: run,
|
||||
gateway: widget.gateway,
|
||||
onRunChanged: widget.controller.acceptRunDetail,
|
||||
cupertino: cupertino,
|
||||
onRunOpened: widget.onRunOpened,
|
||||
),
|
||||
],
|
||||
child: detail,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -114,6 +135,14 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
: widget.controller.error ?? 'Run details unavailable.';
|
||||
// Back stays available while the detail is pending as well as after a
|
||||
// failure, so a slow or refused request can never trap the destination.
|
||||
return ShellBar(
|
||||
title: 'Run',
|
||||
onBack: widget.onBack,
|
||||
child: _placeholderBody(cupertino, loading, message),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _placeholderBody(bool cupertino, bool loading, String message) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
||||
@@ -19,6 +19,7 @@ class SearchScreen extends StatefulWidget {
|
||||
required this.gateway,
|
||||
required this.onOpen,
|
||||
this.cupertino,
|
||||
this.embedded = false,
|
||||
});
|
||||
|
||||
final ApiGateway gateway;
|
||||
@@ -28,6 +29,9 @@ class SearchScreen extends StatefulWidget {
|
||||
/// Cupertino controls and every other platform uses Material.
|
||||
final bool? cupertino;
|
||||
|
||||
/// True as the Search tab: the shell's bar names it, so no page bar.
|
||||
final bool embedded;
|
||||
|
||||
@override
|
||||
State<SearchScreen> createState() => _SearchScreenState();
|
||||
}
|
||||
@@ -112,17 +116,21 @@ class _SearchScreenState extends State<SearchScreen> {
|
||||
return cupertino ? _cupertinoScreen() : _materialScreen();
|
||||
}
|
||||
|
||||
Widget _materialScreen() => Scaffold(
|
||||
appBar: AppBar(title: const Text('Search')),
|
||||
body: SafeArea(
|
||||
Widget _materialScreen() {
|
||||
final body = SafeArea(
|
||||
child: MaterialSearchBody(
|
||||
controller: _controller,
|
||||
query: _controller.parsed.query,
|
||||
onOpen: widget.onOpen,
|
||||
header: _materialHeader(),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
if (widget.embedded) return body;
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Search')),
|
||||
body: body,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _materialHeader() => Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 8),
|
||||
@@ -175,17 +183,21 @@ class _SearchScreenState extends State<SearchScreen> {
|
||||
),
|
||||
);
|
||||
|
||||
Widget _cupertinoScreen() => CupertinoPageScaffold(
|
||||
navigationBar: const CupertinoNavigationBar(middle: Text('Search')),
|
||||
child: SafeArea(
|
||||
Widget _cupertinoScreen() {
|
||||
final body = SafeArea(
|
||||
child: CupertinoSearchBody(
|
||||
controller: _controller,
|
||||
query: _controller.parsed.query,
|
||||
onOpen: widget.onOpen,
|
||||
header: _cupertinoHeader(context),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
if (widget.embedded) return body;
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: const CupertinoNavigationBar(middle: Text('Search')),
|
||||
child: body,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertinoHeader(BuildContext context) => Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 8),
|
||||
|
||||
Reference in New Issue
Block a user