9551eceaed
Remove obsolete control-family flags and icon metadata across all callers, dead alternate themes and host helpers, obsolete test setup, and the unused icon-font dependency. Preserve native Material Back transitions. Make navigation fixtures independent of update plugins and answer auxiliary shell snapshots so the complete application suite can run deterministically.
168 lines
5.3 KiB
Dart
168 lines
5.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../core/transport/connection_state.dart';
|
|
import 'app_session.dart';
|
|
import 'server_endpoint.dart';
|
|
|
|
/// The full connection screen shown before a destination has ever loaded.
|
|
///
|
|
/// A missing native endpoint is a configuration state, not a server failure,
|
|
/// so it is explained without opening a socket. Otherwise the screen reports
|
|
/// connecting, then an honest unavailable state with a native Retry action.
|
|
class ConnectionGate extends StatelessWidget {
|
|
const ConnectionGate({
|
|
super.key,
|
|
required this.session,
|
|
required this.server,
|
|
});
|
|
|
|
final AppSession session;
|
|
final ServerEndpoint server;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final state = session.connection;
|
|
if (server.requiresConfiguration) {
|
|
return _status(
|
|
context,
|
|
title: 'Server endpoint not configured',
|
|
detail:
|
|
'Build the native app with an explicit Pipelines endpoint, for '
|
|
'example --dart-define=PIPELINES_SERVER_URL=ws://host:port/connect.',
|
|
);
|
|
}
|
|
if (server.error != null) {
|
|
return _status(context, title: server.error!, detail: '');
|
|
}
|
|
// Only the very first attempt is "connecting". A failed attempt keeps the
|
|
// same honest unavailable state while the client retries behind it, so the
|
|
// screen no longer flickers between unavailable and connecting.
|
|
if (state.kind == ConnectionKind.connecting && state.attempt <= 1) {
|
|
return _status(
|
|
context,
|
|
title: 'Connecting to Pipelines…',
|
|
detail: '',
|
|
progress: true,
|
|
);
|
|
}
|
|
return _status(
|
|
context,
|
|
title: 'Pipelines server unavailable',
|
|
detail: state.retrying
|
|
? 'Retrying automatically. Check that the Pipelines server is running.'
|
|
: 'Check that the Pipelines server is running, then try again.',
|
|
onRetry: session.retry,
|
|
);
|
|
}
|
|
|
|
Widget _status(
|
|
BuildContext context, {
|
|
required String title,
|
|
required String detail,
|
|
bool progress = false,
|
|
VoidCallback? onRetry,
|
|
}) {
|
|
final theme = Theme.of(context);
|
|
return Center(
|
|
child: SingleChildScrollView(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
if (progress)
|
|
Padding(
|
|
padding: const EdgeInsets.only(bottom: 12),
|
|
child: const CircularProgressIndicator(),
|
|
),
|
|
Semantics(
|
|
liveRegion: true,
|
|
child: Text(
|
|
title,
|
|
textAlign: TextAlign.center,
|
|
style: theme.textTheme.titleMedium,
|
|
),
|
|
),
|
|
if (detail.isNotEmpty) ...[
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
detail,
|
|
textAlign: TextAlign.center,
|
|
style: theme.textTheme.bodyMedium,
|
|
),
|
|
],
|
|
if (onRetry != null) ...[
|
|
const SizedBox(height: 16),
|
|
FilledButton(onPressed: onRetry, child: const Text('Retry')),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// A compact status bar above retained content after the first connection.
|
|
class ConnectionBanner extends StatelessWidget {
|
|
const ConnectionBanner({super.key, required this.session});
|
|
|
|
final AppSession session;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final state = session.connection;
|
|
final refused = session.subscription == RunSubscriptionState.refused;
|
|
final reconnecting =
|
|
!session.connected &&
|
|
(state.kind == ConnectionKind.connecting || state.retrying);
|
|
final String title;
|
|
final String detail;
|
|
final VoidCallback onRetry;
|
|
if (session.connected && refused) {
|
|
title = 'Not live — run updates are unavailable.';
|
|
detail = session.subscriptionError;
|
|
onRetry = session.resubscribe;
|
|
} else if (reconnecting) {
|
|
title = 'Reconnecting to Pipelines…';
|
|
detail = '';
|
|
onRetry = session.retry;
|
|
} else {
|
|
title = 'Not live — Pipelines server unavailable.';
|
|
detail = 'Check that the Pipelines server is running.';
|
|
onRetry = session.retry;
|
|
}
|
|
final textStyle = Theme.of(context).textTheme.bodyMedium;
|
|
return ColoredBox(
|
|
color: Theme.of(context).colorScheme.surfaceContainerHighest,
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
child: Row(
|
|
children: [
|
|
if (reconnecting) ...[
|
|
const SizedBox(
|
|
width: 14,
|
|
height: 14,
|
|
child: CircularProgressIndicator(strokeWidth: 2),
|
|
),
|
|
const SizedBox(width: 10),
|
|
],
|
|
Expanded(
|
|
child: Semantics(
|
|
liveRegion: true,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(title, style: textStyle),
|
|
if (detail.isNotEmpty) Text(detail, style: textStyle),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(width: 8),
|
|
TextButton(onPressed: onRetry, child: const Text('Retry')),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|