Organize settings into retained topic tabs
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
part of 'settings_screen.dart';
|
||||
|
||||
extension _SettingsTopicPages on _SettingsScreenState {
|
||||
Map<SettingsTopic, WidgetBuilder> _topicPages() {
|
||||
final servers = widget.servers;
|
||||
return {
|
||||
SettingsTopic.appearance: (_) => SettingsPageBody(
|
||||
children: [
|
||||
SettingsAnimationSection(
|
||||
controller:
|
||||
widget.animationSpeed ?? AnimationSpeedController.instance,
|
||||
),
|
||||
SettingsFontSection(
|
||||
controller: widget.fonts ?? AppFontController.instance,
|
||||
),
|
||||
],
|
||||
),
|
||||
SettingsTopic.connection: (_) => SettingsPageBody(
|
||||
children: [
|
||||
if (servers != null) ...[
|
||||
SavedServersSection(connections: servers),
|
||||
ManagedConnectionSection(
|
||||
client: widget.client,
|
||||
controller: _controller,
|
||||
),
|
||||
] else
|
||||
SettingsConnectionSection(
|
||||
controller: _controller,
|
||||
serverUrlField: _serverUrlField,
|
||||
),
|
||||
if (widget.showSignIn)
|
||||
_single(
|
||||
'Sign in',
|
||||
SettingsSignInSection(
|
||||
endpoint: _endpoint,
|
||||
onChanged: _reconnectAfterSignIn,
|
||||
),
|
||||
),
|
||||
SettingsWorkspaceSection(
|
||||
controller: _controller,
|
||||
workspaceField: _workspaceField,
|
||||
),
|
||||
],
|
||||
),
|
||||
SettingsTopic.notifications: (_) => SettingsPageBody(
|
||||
children: [
|
||||
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();
|
||||
},
|
||||
),
|
||||
SettingsNtfySection(
|
||||
gateway: widget.client,
|
||||
connected:
|
||||
widget.client.state.kind == transport.ConnectionKind.connected,
|
||||
),
|
||||
],
|
||||
),
|
||||
SettingsTopic.tools: (_) => SettingsPageBody(
|
||||
children: [
|
||||
_single(
|
||||
'Data management',
|
||||
SettingsStorageSection(gateway: widget.client),
|
||||
),
|
||||
_single('Server', SettingsHealthSection(gateway: widget.client)),
|
||||
if (widget.onOpenSchedules != null || widget.onOpenTemplates != null)
|
||||
SettingsGroup(
|
||||
title: 'Library',
|
||||
leadingRows: true,
|
||||
children: [
|
||||
if (widget.onOpenSchedules case final open?)
|
||||
SettingsSchedulesSection(onOpen: open),
|
||||
if (widget.onOpenTemplates case final open?)
|
||||
SettingsTemplatesSection(onOpen: open),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
SettingsTopic.updates: (_) => SettingsPageBody(
|
||||
children: [
|
||||
if (widget.showAndroidDownload)
|
||||
_single('Android app', const SettingsAndroidDownloadSection()),
|
||||
if (widget.showSignIn && appUpdatesSupported)
|
||||
_single('App updates', SettingsUpdatesSection(endpoint: _endpoint)),
|
||||
if (!widget.showAndroidDownload &&
|
||||
!(widget.showSignIn && appUpdatesSupported))
|
||||
_single(
|
||||
'App updates',
|
||||
const Text(
|
||||
'This installation is updated by its server administrator.',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
/// 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)],
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user