a7c41063fa
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.
73 lines
2.2 KiB
Dart
73 lines
2.2 KiB
Dart
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()),
|
||
),
|
||
],
|
||
);
|
||
}
|
||
}
|