9344e6d3c0
A /runs/:id?action=decide route now opens the landed decision prompt once the named detail loads, and only when that detail genuinely awaits a person. A non-waiting run consumes the request without inventing a prompt, and dismissing the prompt leaves the loaded detail. The route flag is forwarded through the existing destination seam; submission, refusal wording and the bounded re-read are shared with the detail's Decide button.
100 lines
3.1 KiB
Dart
100 lines
3.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../features/attention/notify/notification_controller.dart';
|
|
import '../features/runs/screen.dart';
|
|
import '../ui/adaptive/host.dart';
|
|
import 'app_session.dart';
|
|
import 'connection_status.dart';
|
|
import 'server_endpoint.dart';
|
|
|
|
/// The Runs destination: the loaded screen plus an honest connection status.
|
|
///
|
|
/// Before the first successful connection there is nothing to show, so the
|
|
/// destination is a full connection screen. After that the screen stays
|
|
/// mounted through drops and reconnects: a status banner reports reconnecting
|
|
/// or not live, and the screen reloads in place without losing the open run.
|
|
class RunsDestination extends StatelessWidget {
|
|
const RunsDestination({
|
|
super.key,
|
|
required this.session,
|
|
required this.server,
|
|
this.initialRunId,
|
|
this.initialStageKey,
|
|
this.initialVisit,
|
|
this.initialDecide = false,
|
|
this.onRunSelected,
|
|
this.onBack,
|
|
this.listRefreshToken = 0,
|
|
this.notifications,
|
|
});
|
|
|
|
final AppSession session;
|
|
final ServerEndpoint server;
|
|
final int? initialRunId;
|
|
|
|
/// The stage key and optional visit a `/runs/:id/stage/:key[?visit=N]` route
|
|
/// names. They reach the detail only through [RunsScreen]; the destination
|
|
/// does not read the route itself.
|
|
final String? initialStageKey;
|
|
final int? initialVisit;
|
|
|
|
/// The route's `?action=decide`. Forwarded as-is; the loaded screen decides
|
|
/// from the run's own detail whether a prompt exists.
|
|
final bool initialDecide;
|
|
|
|
final ValueChanged<int>? onRunSelected;
|
|
final VoidCallback? onBack;
|
|
|
|
/// Advances when a launch was accepted elsewhere. The mounted Runs screen
|
|
/// re-reads its list once; no row is inserted locally.
|
|
final int listRefreshToken;
|
|
|
|
/// The app-level notification capability shared with Settings.
|
|
final NotificationController? notifications;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => AnimatedBuilder(
|
|
animation: session,
|
|
builder: (context, _) {
|
|
final cupertino = usesCupertinoHost(context);
|
|
if ((server.requiresConfiguration || server.error != null) &&
|
|
session.endpoint == null) {
|
|
return ConnectionGate(
|
|
session: session,
|
|
server: server,
|
|
cupertino: cupertino,
|
|
);
|
|
}
|
|
if (!session.everConnected) {
|
|
if (session.connected) return _runsScreen();
|
|
return ConnectionGate(
|
|
session: session,
|
|
server: server,
|
|
cupertino: cupertino,
|
|
);
|
|
}
|
|
return Column(
|
|
children: [
|
|
if (!session.connected ||
|
|
session.subscription == RunSubscriptionState.refused)
|
|
ConnectionBanner(session: session, cupertino: cupertino),
|
|
Expanded(child: _runsScreen()),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
|
|
Widget _runsScreen() => RunsScreen(
|
|
gateway: session.gateway,
|
|
initialRunId: initialRunId,
|
|
initialStageKey: initialStageKey,
|
|
initialVisit: initialVisit,
|
|
initialDecide: initialDecide,
|
|
syncToken: session.connectionEpoch,
|
|
listRefreshToken: listRefreshToken,
|
|
notifications: notifications,
|
|
onRunSelected: onRunSelected,
|
|
onBack: onBack,
|
|
);
|
|
}
|