diff --git a/android/gradle.properties b/android/gradle.properties index 3b5b324..1551eb0 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,3 +1,7 @@ org.gradle.jvmargs=-Xmx4G -XX:+HeapDumpOnOutOfMemoryError android.useAndroidX=true android.enableJetifier=true +# This builtInKotlin flag was added automatically by Flutter migrator +android.builtInKotlin=false +# This newDsl flag was added automatically by Flutter migrator +android.newDsl=false diff --git a/lib/controllers/client.dart b/lib/controllers/client.dart index cd67a62..ef0f372 100644 --- a/lib/controllers/client.dart +++ b/lib/controllers/client.dart @@ -266,6 +266,8 @@ class ClientController extends AsyncNotifier { Future setMembership(SetMembershipRequest request) => _sendCommand("set_membership", request.toJson()); + Future logout() => _sendCommand("logout"); + Future markRead(Room room) async { final eventRowId = room.timeline[room.timeline.keys.reduce(max)]; final event = eventRowId == null ? null : room.events[eventRowId]; diff --git a/lib/controllers/settings_sections.dart b/lib/controllers/settings_sections.dart index 88a9c7e..1704ed0 100644 --- a/lib/controllers/settings_sections.dart +++ b/lib/controllers/settings_sections.dart @@ -3,6 +3,8 @@ import "package:fast_immutable_collections/fast_immutable_collections.dart"; import "package:flutter/material.dart"; 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/settings.dart"; import "package:nexus/models/settings_category.dart"; import "package:nexus/main.dart"; @@ -87,11 +89,46 @@ 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, + ), + ); + }, + ), + icon: Icons.logout, + ), + ]), + ), + ]), }); } static final provider = - AsyncNotifierProvider< + AsyncNotifierProvider.autoDispose< SettingsSectionsController, IMap> >(SettingsSectionsController.new);