add settings to login page, but gate login settings
This commit is contained in:
parent
06c5411dfc
commit
cdad9b760e
2 changed files with 46 additions and 35 deletions
|
|
@ -5,6 +5,7 @@ import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||||
import "package:intl/intl.dart";
|
import "package:intl/intl.dart";
|
||||||
import "package:m3e_buttons/m3e_buttons.dart";
|
import "package:m3e_buttons/m3e_buttons.dart";
|
||||||
import "package:nexus/controllers/client.dart";
|
import "package:nexus/controllers/client.dart";
|
||||||
|
import "package:nexus/controllers/client_state.dart";
|
||||||
import "package:nexus/controllers/settings.dart";
|
import "package:nexus/controllers/settings.dart";
|
||||||
import "package:nexus/models/settings_category.dart";
|
import "package:nexus/models/settings_category.dart";
|
||||||
import "package:nexus/main.dart";
|
import "package:nexus/main.dart";
|
||||||
|
|
@ -89,41 +90,42 @@ class SettingsSectionsController
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
"Account": .new([
|
if (ref.watch(ClientStateController.provider)?.isLoggedIn == true)
|
||||||
.new(title: "Profile", icon: Icons.person, settings: .new([])),
|
"Account": .new([
|
||||||
.new(
|
.new(title: "Profile", icon: Icons.person, settings: .new([])),
|
||||||
title: "Other",
|
.new(
|
||||||
icon: Icons.key,
|
title: "Other",
|
||||||
settings: .new([
|
icon: Icons.key,
|
||||||
.new(
|
settings: .new([
|
||||||
title: "Log Out",
|
.new(
|
||||||
description:
|
title: "Log Out",
|
||||||
"Log out of your account, returning you to the login page.",
|
description:
|
||||||
builder: (title, description, icon) => Builder(
|
"Log out of your account, returning you to the login page.",
|
||||||
builder: (context) {
|
builder: (title, description, icon) => Builder(
|
||||||
final colorScheme = Theme.of(context).colorScheme;
|
builder: (context) {
|
||||||
return M3EButton.icon(
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
onPressed: () async {
|
return M3EButton.icon(
|
||||||
await ref
|
onPressed: () async {
|
||||||
.watch(ClientController.provider.notifier)
|
await ref
|
||||||
.logout();
|
.watch(ClientController.provider.notifier)
|
||||||
if (context.mounted) Navigator.of(context).pop();
|
.logout();
|
||||||
},
|
if (context.mounted) Navigator.of(context).pop();
|
||||||
label: Text(title),
|
},
|
||||||
icon: Icon(icon),
|
label: Text(title),
|
||||||
tooltip: description,
|
icon: Icon(icon),
|
||||||
decoration: .styleFrom(
|
tooltip: description,
|
||||||
backgroundColor: colorScheme.errorContainer,
|
decoration: .styleFrom(
|
||||||
foregroundColor: colorScheme.onErrorContainer,
|
backgroundColor: colorScheme.errorContainer,
|
||||||
),
|
foregroundColor: colorScheme.onErrorContainer,
|
||||||
);
|
),
|
||||||
},
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
icon: Icons.logout,
|
||||||
),
|
),
|
||||||
icon: Icons.logout,
|
]),
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
),
|
|
||||||
]),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import "package:nexus/controllers/client_id.dart";
|
||||||
import "package:nexus/helpers/launch_helper.dart";
|
import "package:nexus/helpers/launch_helper.dart";
|
||||||
import "package:nexus/main.dart";
|
import "package:nexus/main.dart";
|
||||||
import "package:nexus/models/homeserver.dart";
|
import "package:nexus/models/homeserver.dart";
|
||||||
|
import "package:nexus/pages/settings.dart";
|
||||||
import "package:nexus/widgets/appbar.dart";
|
import "package:nexus/widgets/appbar.dart";
|
||||||
import "package:nexus/widgets/divider_text.dart";
|
import "package:nexus/widgets/divider_text.dart";
|
||||||
|
|
||||||
|
|
@ -92,7 +93,15 @@ class SelectServerPage extends HookConsumerWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: Appbar(),
|
appBar: Appbar(
|
||||||
|
actions: .new([
|
||||||
|
IconButton(
|
||||||
|
onPressed: () =>
|
||||||
|
showDialog(context: context, builder: (_) => SettingsPage()),
|
||||||
|
icon: Icon(Icons.settings),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
),
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Center(
|
child: Center(
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue