Files
pipelines/app/lib/features/settings/managed_connection_section.dart
alan a7c41063fa Remove Cupertino branches from Settings
Keep the Material-only settings implementation and its focused tests while preserving public cupertino parameters for later cleanup. This removes unreachable platform-specific widgets and test variants without changing the Material path.
2026-11-11 05:05:57 +00:00

73 lines
2.2 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import '../../core/transport/pipelines_client.dart';
import 'settings_controller.dart';
import 'settings_group.dart';
import 'settings_row.dart';
import 'settings_sections.dart';
/// The short line under the managed connection's rows.
const String managedConnectionHelp =
'Reconnect tries the preferred address first, then the backups.';
/// The browser-only addition to [managedConnectionHelp].
const String managedConnectionWebHelp =
'In a browser the connection stays on this page’s origin.';
/// The saved-server connection: its state, the address actually attempted and
/// Reconnect / Disconnect rows. Status follows the actual attempted address,
/// not just the preferred URL.
class ManagedConnectionSection extends StatelessWidget {
const ManagedConnectionSection({
super.key,
required this.client,
required this.controller,
});
final PipelinesClient client;
final SettingsController controller;
@override
Widget build(BuildContext context) {
return SettingsGroup(
title: 'Connection',
leadingRows: true,
footer: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Text(
kIsWeb
? '$managedConnectionHelp $managedConnectionWebHelp'
: managedConnectionHelp,
),
const SizedBox(height: 12),
settingsConnectionFooter(controller),
],
),
children: <Widget>[
SettingsStatusRow(controller: controller),
SettingsRow(
leading: Icon(Icons.link),
title: const Text('Current address'),
subtitle: SelectableText('${client.endpoint ?? 'Not connected'}'),
),
SettingsRow(
action: true,
enabled: client.endpoints.isNotEmpty,
leading: Icon(Icons.refresh),
title: const Text('Reconnect'),
onTap: () => unawaited(client.connectAny(client.endpoints)),
),
SettingsRow(
action: true,
leading: Icon(Icons.link_off),
title: const Text('Disconnect'),
onTap: () => unawaited(client.disconnect()),
),
],
);
}
}