Organize settings into retained topic tabs

This commit is contained in:
2026-11-07 19:36:02 +00:00
parent 6b654693d9
commit fc4aa1652f
11 changed files with 434 additions and 101 deletions
+4 -83
View File
@@ -18,6 +18,7 @@ import 'settings_group.dart';
import 'storage/settings_storage_section.dart';
import 'health/settings_health_section.dart';
import 'settings_page_body.dart';
import 'settings_tabs.dart';
import 'settings_notifications_section.dart';
import 'settings_ntfy_section.dart';
import 'settings_device_delivery_section.dart';
@@ -35,6 +36,8 @@ import 'server_connections.dart';
import 'saved_servers_section.dart';
import 'managed_connection_section.dart';
part 'settings_topic_pages.dart';
/// The Settings destination: the server connection and the server-side
/// workspace, in native Material (native platforms) or Cupertino (iOS) controls.
///
@@ -169,83 +172,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
@override
Widget build(BuildContext context) {
final servers = widget.servers;
final content = SettingsPageBody(
children: <Widget>[
if (servers != null) ...<Widget>[
SavedServersSection(connections: servers),
ManagedConnectionSection(
client: widget.client,
controller: _controller,
),
] 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,
),
_single(
'Data management',
SettingsStorageSection(gateway: widget.client),
),
_single('Server', SettingsHealthSection(gateway: widget.client)),
// A device-local choice: a browser and a phone keep their own.
SettingsAnimationSection(
controller:
widget.animationSpeed ?? AnimationSpeedController.instance,
),
SettingsFontSection(
controller: widget.fonts ?? AppFontController.instance,
),
if (widget.notifications case final notifications?)
SettingsNotificationsSection(controller: notifications),
if (widget.deliveryService case final service? when service.supported)
SettingsDeviceDeliverySection(
bridge: service,
controller: widget.deliveryServiceController,
requestNotificationPermission: widget.notifications == null
? null
: () async {
await widget.notifications!.requestPermission();
},
),
// 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),
],
),
],
);
final content = SettingsTopicTabs(pages: _topicPages());
if (widget.embedded) {
// Under the shell's bar the Cupertino page is the grouped background
// right up to the top edge: the bar's scrim takes the same colour, so
@@ -271,10 +198,4 @@ class _SettingsScreenState extends State<SettingsScreen> {
body: content,
);
}
/// 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)],
);
}