From cdad9b760eeda162fa0cdab3c0b9d87ce645ce5b Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Tue, 21 Jul 2026 18:00:52 -0400 Subject: [PATCH] add settings to login page, but gate login settings --- lib/controllers/settings_sections.dart | 70 +++++++++++++------------- lib/pages/select_server.dart | 11 +++- 2 files changed, 46 insertions(+), 35 deletions(-) diff --git a/lib/controllers/settings_sections.dart b/lib/controllers/settings_sections.dart index 1704ed0..c82947d 100644 --- a/lib/controllers/settings_sections.dart +++ b/lib/controllers/settings_sections.dart @@ -5,6 +5,7 @@ import "package:flutter_riverpod/flutter_riverpod.dart"; import "package:intl/intl.dart"; import "package:m3e_buttons/m3e_buttons.dart"; import "package:nexus/controllers/client.dart"; +import "package:nexus/controllers/client_state.dart"; import "package:nexus/controllers/settings.dart"; import "package:nexus/models/settings_category.dart"; import "package:nexus/main.dart"; @@ -89,41 +90,42 @@ class SettingsSectionsController ]), ), ]), - "Account": .new([ - .new(title: "Profile", icon: Icons.person, settings: .new([])), - .new( - title: "Other", - icon: Icons.key, - settings: .new([ - .new( - title: "Log Out", - description: - "Log out of your account, returning you to the login page.", - builder: (title, description, icon) => Builder( - builder: (context) { - final colorScheme = Theme.of(context).colorScheme; - return M3EButton.icon( - onPressed: () async { - await ref - .watch(ClientController.provider.notifier) - .logout(); - if (context.mounted) Navigator.of(context).pop(); - }, - label: Text(title), - icon: Icon(icon), - tooltip: description, - decoration: .styleFrom( - backgroundColor: colorScheme.errorContainer, - foregroundColor: colorScheme.onErrorContainer, - ), - ); - }, + if (ref.watch(ClientStateController.provider)?.isLoggedIn == true) + "Account": .new([ + .new(title: "Profile", icon: Icons.person, settings: .new([])), + .new( + title: "Other", + icon: Icons.key, + settings: .new([ + .new( + title: "Log Out", + description: + "Log out of your account, returning you to the login page.", + builder: (title, description, icon) => Builder( + builder: (context) { + final colorScheme = Theme.of(context).colorScheme; + return M3EButton.icon( + onPressed: () async { + await ref + .watch(ClientController.provider.notifier) + .logout(); + if (context.mounted) Navigator.of(context).pop(); + }, + label: Text(title), + icon: Icon(icon), + tooltip: description, + decoration: .styleFrom( + backgroundColor: colorScheme.errorContainer, + foregroundColor: colorScheme.onErrorContainer, + ), + ); + }, + ), + icon: Icons.logout, ), - icon: Icons.logout, - ), - ]), - ), - ]), + ]), + ), + ]), }); } diff --git a/lib/pages/select_server.dart b/lib/pages/select_server.dart index 118e70a..2f49480 100644 --- a/lib/pages/select_server.dart +++ b/lib/pages/select_server.dart @@ -9,6 +9,7 @@ import "package:nexus/controllers/client_id.dart"; import "package:nexus/helpers/launch_helper.dart"; import "package:nexus/main.dart"; import "package:nexus/models/homeserver.dart"; +import "package:nexus/pages/settings.dart"; import "package:nexus/widgets/appbar.dart"; import "package:nexus/widgets/divider_text.dart"; @@ -92,7 +93,15 @@ class SelectServerPage extends HookConsumerWidget { } return Scaffold( - appBar: Appbar(), + appBar: Appbar( + actions: .new([ + IconButton( + onPressed: () => + showDialog(context: context, builder: (_) => SettingsPage()), + icon: Icon(Icons.settings), + ), + ]), + ), body: SafeArea( child: Center( child: ConstrainedBox(