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.
This commit is contained in:
2026-10-31 03:07:20 +00:00
parent ea0f22dfc7
commit 3ec580c2d9
23 changed files with 1103 additions and 677 deletions
+71 -160
View File
@@ -6,11 +6,11 @@ import 'package:flutter/material.dart';
import '../../core/transport/pipelines_client.dart' as transport;
import '../attention/notify/notification_controller.dart';
import '../attention/notify/notification_models.dart';
import 'default_endpoint.dart';
import 'settings_controller.dart';
import 'settings_controls.dart';
import 'settings_layout.dart';
import 'settings_group.dart';
import 'settings_page_body.dart';
import 'settings_notifications_section.dart';
import 'settings_ntfy_section.dart';
import 'settings_android_download_section.dart';
@@ -24,7 +24,6 @@ import 'settings_templates_section.dart';
import 'server_connections.dart';
import 'saved_servers_section.dart';
import 'managed_connection_section.dart';
import '../../ui/adaptive/floating_bar_layout.dart';
/// The Settings destination: the server connection and the server-side
/// workspace, in native Material (native platforms) or Cupertino (iOS) controls.
@@ -133,148 +132,79 @@ class _SettingsScreenState extends State<SettingsScreen> {
super.dispose();
}
String get _endpoint => widget.servers == null
? _controller.serverUrl
: widget.client.endpoint?.toString() ?? '';
void _reconnectAfterSignIn() {
final endpoint = widget.client.endpoint;
if (endpoint != null) {
widget.client.connectAny(
widget.client.endpoints.isEmpty ? [endpoint] : widget.client.endpoints,
);
}
}
@override
Widget build(BuildContext context) {
// The content scrolls behind a floating tab bar and pads its end clear of
// it (or of the system inset on its own page).
final content = SafeArea(
bottom: false,
child: SingleChildScrollView(
// Web `.settings` page insets: 20 above the title, 16 at the sides and
// a clear 32 below the last section.
padding: withFloatingBarClearance(
context,
const EdgeInsetsDirectional.fromSTEB(
settingsPageSidePadding,
settingsPageTopPadding,
settingsPageSidePadding,
settingsPageBottomPadding,
final servers = widget.servers;
final content = SettingsPageBody(
children: <Widget>[
if (servers != null) ...<Widget>[
SavedServersSection(connections: servers),
ManagedConnectionSection(
client: widget.client,
controller: _controller,
),
),
child: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: settingsContentMaxWidth,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
if (widget.servers != null) ...[
_SettingsSection(
title: 'Servers',
child: SavedServersSection(connections: widget.servers!),
),
const SizedBox(height: settingsSectionGap),
],
_SettingsSection(
title: 'Connection',
child: widget.servers != null
? ManagedConnectionSection(
client: widget.client,
controller: _controller,
)
: SettingsConnectionSection(
controller: _controller,
serverUrlField: _serverUrlField,
),
),
// A phone signs in at the web login; a browser has its own.
if (widget.showSignIn) ...<Widget>[
const SizedBox(height: settingsSectionGap),
_SettingsSection(
title: 'Sign in',
child: SettingsSignInSection(
endpoint: widget.servers == null
? _controller.serverUrl
: widget.client.endpoint?.toString() ?? '',
onChanged: () {
final endpoint = widget.client.endpoint;
if (endpoint != null) {
widget.client.connectAny(
widget.client.endpoints.isEmpty
? [endpoint]
: widget.client.endpoints,
);
}
},
),
),
],
// The web page links the Android app the server offers.
if (widget.showAndroidDownload) ...<Widget>[
const SizedBox(height: settingsSectionGap),
const _SettingsSection(
title: 'Android app',
child: SettingsAndroidDownloadSection(),
),
],
// A phone installs newer builds from the server.
if (widget.showSignIn && appUpdatesSupported) ...<Widget>[
const SizedBox(height: settingsSectionGap),
_SettingsSection(
title: 'App updates',
child: SettingsUpdatesSection(
endpoint: widget.servers == null
? _controller.serverUrl
: widget.client.endpoint?.toString() ?? '',
),
),
],
const SizedBox(height: settingsSectionGap),
_SettingsSection(
title: 'Workspace',
child: SettingsWorkspaceSection(
controller: _controller,
workspaceField: _workspaceField,
),
),
if (widget.notifications != null) ...<Widget>[
const SizedBox(height: settingsSectionGap),
_SettingsSection(
title: notificationSectionTitle,
child: SettingsNotificationsSection(
controller: widget.notifications!,
),
),
],
// The server's ntfy choices, beside the in-app permission.
const SizedBox(height: settingsSectionGap),
_SettingsSection(
title: ntfySectionTitle,
child: SettingsNtfySection(
gateway: widget.client,
connected:
widget.client.state.kind ==
transport.ConnectionKind.connected,
),
),
if (widget.onOpenSchedules != null) ...<Widget>[
const SizedBox(height: settingsSectionGap),
_SettingsSection(
title: 'Schedules',
child: SettingsSchedulesSection(
onOpen: widget.onOpenSchedules!,
),
),
],
if (widget.onOpenTemplates != null) ...<Widget>[
const SizedBox(height: settingsSectionGap),
_SettingsSection(
title: 'Templates',
child: SettingsTemplatesSection(
onOpen: widget.onOpenTemplates!,
),
),
],
],
] else
SettingsConnectionSection(
controller: _controller,
serverUrlField: _serverUrlField,
),
// A phone signs in at the web login; a browser has its own.
if (widget.showSignIn)
_single(
'Sign in',
SettingsSignInSection(
endpoint: _endpoint,
onChanged: _reconnectAfterSignIn,
),
),
// The web page links the Android app the server offers.
if (widget.showAndroidDownload)
_single('Android app', const SettingsAndroidDownloadSection()),
// A phone installs newer builds from the server.
if (widget.showSignIn && appUpdatesSupported)
_single('App updates', SettingsUpdatesSection(endpoint: _endpoint)),
SettingsWorkspaceSection(
controller: _controller,
workspaceField: _workspaceField,
),
),
if (widget.notifications case final notifications?)
SettingsNotificationsSection(controller: notifications),
// The server's ntfy choices, beside the in-app permission.
SettingsNtfySection(
gateway: widget.client,
connected:
widget.client.state.kind == transport.ConnectionKind.connected,
),
if (widget.onOpenSchedules != null || widget.onOpenTemplates != null)
SettingsGroup(
title: 'Library',
leadingRows: true,
children: <Widget>[
if (widget.onOpenSchedules case final open?)
SettingsSchedulesSection(onOpen: open),
if (widget.onOpenTemplates case final open?)
SettingsTemplatesSection(onOpen: open),
],
),
],
);
if (widget.embedded) return content;
if (usesCupertinoControls(context)) {
return CupertinoPageScaffold(
backgroundColor: settingsCupertinoBackground,
navigationBar: const SegmentedBar(cupertino: true, title: 'Settings'),
child: content,
);
@@ -285,29 +215,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
body: content,
);
}
}
/// One grouped Settings section: a compact title followed by its body at the
/// web's 8px title gap. Sections are separated by [settingsSectionGap]. A null
/// title lets a body (the notification tile) draw its own compact heading.
class _SettingsSection extends StatelessWidget {
const _SettingsSection({required this.child, this.title});
final String? title;
final Widget child;
@override
Widget build(BuildContext context) {
final title = this.title;
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
if (title != null) ...<Widget>[
Text(title, style: settingsTextStyle(context, title: true)),
const SizedBox(height: settingsTitleGap),
],
child,
],
);
}
/// A group holding one free-form block (a form, a status with buttons).
Widget _single(String title, Widget child) => SettingsGroup(
title: title,
children: <Widget>[SettingsGroupItem(child: child)],
);
}