Files
pipelines/app/lib/features/settings/managed_connection_section.dart
T
alan 3ec580c2d9 Restyle Settings as flat grouped list sections (F9) and scroll it behind the bar (F1)
Servers become rows with a selection mark, addresses as subtitles and a
Use/Edit/Remove menu plus an Add server row; the connection is a status row
with address and Reconnect/Disconnect rows; Templates and Schedules are
chevron rows in a Library group. Material groups are flat surfaceContainer
surfaces with primary titleSmall headers (no Cards); Cupertino uses
inset-grouped sections on the grouped background, switches for the ntfy
choices. The trust warning is a footer, helper copy is shortened, Save
workspace is a legible tonal/plain button, and the column starts at the
bar's inset (max 720) instead of being centred. The page pads by the top
media padding instead of a top SafeArea.
2026-10-31 03:07:20 +00:00

80 lines
2.5 KiB
Dart
Raw 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/cupertino.dart';
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';
import 'settings_theme.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) {
final cupertino = usesCupertinoControls(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(cupertino ? CupertinoIcons.link : Icons.link),
title: const Text('Current address'),
subtitle: SelectableText('${client.endpoint ?? 'Not connected'}'),
),
SettingsRow(
action: true,
enabled: client.endpoints.isNotEmpty,
leading: Icon(
cupertino ? CupertinoIcons.arrow_clockwise : Icons.refresh,
),
title: const Text('Reconnect'),
onTap: () => unawaited(client.connectAny(client.endpoints)),
),
SettingsRow(
action: true,
leading: Icon(
cupertino ? CupertinoIcons.stop_circle : Icons.link_off,
),
title: const Text('Disconnect'),
onTap: () => unawaited(client.disconnect()),
),
],
);
}
}