feat(app): compose live Runs with deep links and reconnect retention
This commit is contained in:
@@ -36,7 +36,7 @@ Widget buildCupertinoRunDetail({
|
||||
children: [
|
||||
const Icon(CupertinoIcons.back),
|
||||
const SizedBox(width: 4),
|
||||
const Text('Runs'),
|
||||
const Text('Back'),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -28,7 +28,7 @@ Widget buildMaterialRunDetail({
|
||||
child: TextButton.icon(
|
||||
onPressed: onBack,
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
label: const Text('Runs'),
|
||||
label: const Text('Back to list'),
|
||||
),
|
||||
),
|
||||
Text(detailTitle(run), style: theme.textTheme.headlineSmall),
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import 'run_detail_content.dart';
|
||||
import 'run_detail_cupertino.dart';
|
||||
import 'run_detail_material.dart';
|
||||
@@ -29,7 +30,7 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
Widget build(BuildContext context) => AnimatedBuilder(
|
||||
animation: widget.controller,
|
||||
builder: (context, _) {
|
||||
final cupertino = _usesCupertino(context);
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final run = widget.controller.detail;
|
||||
if (run == null) return _placeholder(context, cupertino: cupertino);
|
||||
final prompt = detailPrompt(run);
|
||||
@@ -57,34 +58,24 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
},
|
||||
);
|
||||
|
||||
/// CupertinoApp supplies CupertinoLocalizations only, while MaterialApp
|
||||
/// supplies MaterialLocalizations. This distinguishes the two hosts without
|
||||
/// assuming a desktop browser's target platform.
|
||||
bool _usesCupertino(BuildContext context) =>
|
||||
Localizations.of<MaterialLocalizations>(context, MaterialLocalizations) ==
|
||||
null;
|
||||
|
||||
Widget _placeholder(BuildContext context, {required bool cupertino}) {
|
||||
if (widget.controller.detailLoading) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
final loading = widget.controller.detailLoading;
|
||||
final message = loading
|
||||
? 'Loading run details…'
|
||||
: 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 Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (loading) ...[
|
||||
if (cupertino)
|
||||
const CupertinoActivityIndicator()
|
||||
else
|
||||
const CircularProgressIndicator(),
|
||||
const SizedBox(height: 12),
|
||||
const Text('Loading run details…'),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
final message = widget.controller.error ?? 'Run details unavailable.';
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: Text(message, textAlign: TextAlign.center),
|
||||
@@ -93,12 +84,12 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
if (cupertino)
|
||||
CupertinoButton(
|
||||
onPressed: widget.onBack,
|
||||
child: const Text('Back to runs'),
|
||||
child: const Text('Back to list'),
|
||||
)
|
||||
else
|
||||
FilledButton(
|
||||
onPressed: widget.onBack,
|
||||
child: const Text('Back to runs'),
|
||||
child: const Text('Back to list'),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -61,6 +61,16 @@ class RunsController extends ChangeNotifier {
|
||||
if (initialId != null) await select(initialId);
|
||||
}
|
||||
|
||||
/// Re-reads the list and the open detail after the socket was replaced.
|
||||
///
|
||||
/// The selection is kept, so a reconnect refreshes in place instead of
|
||||
/// discarding the detail the operator had open.
|
||||
Future<void> resync() async {
|
||||
final selected = _selectedId;
|
||||
await load();
|
||||
if (selected != null && _selectedId == selected) await select(selected);
|
||||
}
|
||||
|
||||
Future<void> select(num id) async {
|
||||
final token = ++_detailGeneration;
|
||||
_cancelDetailRefresh();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../domain/run_models.dart';
|
||||
import 'runs_controller.dart';
|
||||
|
||||
@@ -16,15 +16,11 @@ class RunsList extends StatelessWidget {
|
||||
final RunsController controller;
|
||||
final ValueChanged<num> onSelected;
|
||||
|
||||
bool get _isCupertino =>
|
||||
defaultTargetPlatform == TargetPlatform.iOS ||
|
||||
defaultTargetPlatform == TargetPlatform.macOS;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (controller.loading && controller.runs.isEmpty) {
|
||||
return Center(
|
||||
child: _isCupertino
|
||||
child: usesCupertinoHost(context)
|
||||
? const CupertinoActivityIndicator()
|
||||
: const CircularProgressIndicator(),
|
||||
);
|
||||
@@ -43,7 +39,7 @@ class RunsList extends StatelessWidget {
|
||||
if (controller.error != null) _inlineError(context),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: _isCupertino
|
||||
child: usesCupertinoHost(context)
|
||||
? CupertinoSearchTextField(
|
||||
placeholder: 'Filter runs',
|
||||
onChanged: controller.setQuery,
|
||||
@@ -76,7 +72,7 @@ class RunsList extends StatelessWidget {
|
||||
children: [
|
||||
Text(controller.error!),
|
||||
const SizedBox(height: 8),
|
||||
_isCupertino
|
||||
usesCupertinoHost(context)
|
||||
? CupertinoButton(
|
||||
onPressed: controller.load,
|
||||
child: const Text('Retry'),
|
||||
@@ -94,7 +90,7 @@ class RunsList extends StatelessWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: Text(controller.error!)),
|
||||
if (_isCupertino)
|
||||
if (usesCupertinoHost(context))
|
||||
CupertinoButton(
|
||||
onPressed: controller.load,
|
||||
child: const Text('Retry'),
|
||||
@@ -106,7 +102,7 @@ class RunsList extends StatelessWidget {
|
||||
);
|
||||
|
||||
Widget _selectors(BuildContext context) {
|
||||
if (_isCupertino) {
|
||||
if (usesCupertinoHost(context)) {
|
||||
return Wrap(
|
||||
spacing: 8,
|
||||
children: [
|
||||
@@ -206,7 +202,7 @@ class RunsList extends StatelessWidget {
|
||||
final title = identity.label.isEmpty ? 'Run $id' : identity.label;
|
||||
final subtitle =
|
||||
'${run['name'] ?? 'Pipeline unavailable'} · ${run['created_at'] ?? 'Time unavailable'}${run['scheduled'] == true ? ' · Scheduled' : ''}';
|
||||
if (_isCupertino) {
|
||||
if (usesCupertinoHost(context)) {
|
||||
return CupertinoListTile(
|
||||
title: Text(title),
|
||||
subtitle: Text(subtitle),
|
||||
|
||||
Reference in New Issue
Block a user