fix: Crash in settings when using MAS
This commit is contained in:
parent
7a83927833
commit
99c49e3df2
3 changed files with 188 additions and 201 deletions
|
|
@ -199,14 +199,6 @@ class SettingsController extends State<Settings> {
|
||||||
checkBootstrap();
|
checkBootstrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String?> getOidcAccountManageUrl() async {
|
|
||||||
final client = Matrix.of(context).client;
|
|
||||||
final wellKnown = client.wellKnown ?? await client.getWellknown();
|
|
||||||
return wellKnown.additionalProperties
|
|
||||||
.tryGetMap<String, Object?>('org.matrix.msc2965.authentication')
|
|
||||||
?.tryGet<String>('account');
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final client = Matrix.of(context).client;
|
final client = Matrix.of(context).client;
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,12 @@ class SettingsView extends StatelessWidget {
|
||||||
final showChatBackupBanner = controller.showChatBackupBanner;
|
final showChatBackupBanner = controller.showChatBackupBanner;
|
||||||
final activeRoute =
|
final activeRoute =
|
||||||
GoRouter.of(context).routeInformationProvider.value.uri.path;
|
GoRouter.of(context).routeInformationProvider.value.uri.path;
|
||||||
|
final accountManageUrl = Matrix.of(context)
|
||||||
|
.client
|
||||||
|
.wellKnown
|
||||||
|
?.additionalProperties
|
||||||
|
.tryGetMap<String, Object?>('org.matrix.msc2965.authentication')
|
||||||
|
?.tryGet<String>('account');
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
if (FluffyThemes.isColumnMode(context)) ...[
|
if (FluffyThemes.isColumnMode(context)) ...[
|
||||||
|
|
@ -52,208 +58,197 @@ class SettingsView extends StatelessWidget {
|
||||||
),
|
),
|
||||||
body: ListTileTheme(
|
body: ListTileTheme(
|
||||||
iconColor: theme.colorScheme.onSurface,
|
iconColor: theme.colorScheme.onSurface,
|
||||||
child: FutureBuilder(
|
child: ListView(
|
||||||
future: controller.getOidcAccountManageUrl(),
|
key: const Key('SettingsListViewContent'),
|
||||||
builder: (context, snapshot) {
|
children: <Widget>[
|
||||||
final accountManageUrl = snapshot.data;
|
FutureBuilder<Profile>(
|
||||||
return ListView(
|
future: controller.profileFuture,
|
||||||
key: const Key('SettingsListViewContent'),
|
builder: (context, snapshot) {
|
||||||
children: <Widget>[
|
final profile = snapshot.data;
|
||||||
FutureBuilder<Profile>(
|
final mxid = Matrix.of(context).client.userID ??
|
||||||
future: controller.profileFuture,
|
L10n.of(context).user;
|
||||||
builder: (context, snapshot) {
|
final displayname =
|
||||||
final profile = snapshot.data;
|
profile?.displayName ?? mxid.localpart ?? mxid;
|
||||||
final mxid = Matrix.of(context).client.userID ??
|
return Row(
|
||||||
L10n.of(context).user;
|
children: [
|
||||||
final displayname =
|
Padding(
|
||||||
profile?.displayName ?? mxid.localpart ?? mxid;
|
padding: const EdgeInsets.all(32.0),
|
||||||
return Row(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Avatar(
|
||||||
padding: const EdgeInsets.all(32.0),
|
mxContent: profile?.avatarUrl,
|
||||||
child: Stack(
|
name: displayname,
|
||||||
children: [
|
size: Avatar.defaultSize * 2.5,
|
||||||
Avatar(
|
|
||||||
mxContent: profile?.avatarUrl,
|
|
||||||
name: displayname,
|
|
||||||
size: Avatar.defaultSize * 2.5,
|
|
||||||
),
|
|
||||||
if (profile != null)
|
|
||||||
Positioned(
|
|
||||||
bottom: 0,
|
|
||||||
right: 0,
|
|
||||||
child: FloatingActionButton.small(
|
|
||||||
elevation: 2,
|
|
||||||
onPressed: controller.setAvatarAction,
|
|
||||||
heroTag: null,
|
|
||||||
child: const Icon(
|
|
||||||
Icons.camera_alt_outlined,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
if (profile != null)
|
||||||
Expanded(
|
Positioned(
|
||||||
child: Column(
|
bottom: 0,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
right: 0,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: FloatingActionButton.small(
|
||||||
children: [
|
elevation: 2,
|
||||||
TextButton.icon(
|
onPressed: controller.setAvatarAction,
|
||||||
onPressed:
|
heroTag: null,
|
||||||
controller.setDisplaynameAction,
|
child: const Icon(
|
||||||
icon: const Icon(
|
Icons.camera_alt_outlined,
|
||||||
Icons.edit_outlined,
|
|
||||||
size: 16,
|
|
||||||
),
|
|
||||||
style: TextButton.styleFrom(
|
|
||||||
foregroundColor:
|
|
||||||
theme.colorScheme.onSurface,
|
|
||||||
iconColor: theme.colorScheme.onSurface,
|
|
||||||
),
|
|
||||||
label: Text(
|
|
||||||
displayname,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 18,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
TextButton.icon(
|
),
|
||||||
onPressed: () =>
|
],
|
||||||
FluffyShare.share(mxid, context),
|
),
|
||||||
icon: const Icon(
|
|
||||||
Icons.copy_outlined,
|
|
||||||
size: 14,
|
|
||||||
),
|
|
||||||
style: TextButton.styleFrom(
|
|
||||||
foregroundColor:
|
|
||||||
theme.colorScheme.secondary,
|
|
||||||
iconColor: theme.colorScheme.secondary,
|
|
||||||
),
|
|
||||||
label: Text(
|
|
||||||
mxid,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
// style: const TextStyle(fontSize: 12),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
if (accountManageUrl != null)
|
|
||||||
ListTile(
|
|
||||||
leading: const Icon(Icons.account_circle_outlined),
|
|
||||||
title: Text(L10n.of(context).manageAccount),
|
|
||||||
trailing: const Icon(Icons.open_in_new_outlined),
|
|
||||||
onTap: () => launchUrlString(
|
|
||||||
accountManageUrl,
|
|
||||||
mode: LaunchMode.inAppBrowserView,
|
|
||||||
),
|
),
|
||||||
),
|
Expanded(
|
||||||
Divider(color: theme.dividerColor),
|
child: Column(
|
||||||
if (showChatBackupBanner == null)
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
ListTile(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
leading: const Icon(Icons.backup_outlined),
|
children: [
|
||||||
title: Text(L10n.of(context).chatBackup),
|
TextButton.icon(
|
||||||
trailing: const CircularProgressIndicator.adaptive(),
|
onPressed: controller.setDisplaynameAction,
|
||||||
)
|
icon: const Icon(
|
||||||
else
|
Icons.edit_outlined,
|
||||||
SwitchListTile.adaptive(
|
size: 16,
|
||||||
controlAffinity: ListTileControlAffinity.trailing,
|
),
|
||||||
value: controller.showChatBackupBanner == false,
|
style: TextButton.styleFrom(
|
||||||
secondary: const Icon(Icons.backup_outlined),
|
foregroundColor:
|
||||||
title: Text(L10n.of(context).chatBackup),
|
theme.colorScheme.onSurface,
|
||||||
onChanged: controller.firstRunBootstrapAction,
|
iconColor: theme.colorScheme.onSurface,
|
||||||
),
|
),
|
||||||
Divider(
|
label: Text(
|
||||||
color: theme.dividerColor,
|
displayname,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextButton.icon(
|
||||||
|
onPressed: () =>
|
||||||
|
FluffyShare.share(mxid, context),
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.copy_outlined,
|
||||||
|
size: 14,
|
||||||
|
),
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
foregroundColor:
|
||||||
|
theme.colorScheme.secondary,
|
||||||
|
iconColor: theme.colorScheme.secondary,
|
||||||
|
),
|
||||||
|
label: Text(
|
||||||
|
mxid,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
// style: const TextStyle(fontSize: 12),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (accountManageUrl != null)
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.account_circle_outlined),
|
||||||
|
title: Text(L10n.of(context).manageAccount),
|
||||||
|
trailing: const Icon(Icons.open_in_new_outlined),
|
||||||
|
onTap: () => launchUrlString(
|
||||||
|
accountManageUrl,
|
||||||
|
mode: LaunchMode.inAppBrowserView,
|
||||||
),
|
),
|
||||||
ListTile(
|
),
|
||||||
leading: const Icon(Icons.format_paint_outlined),
|
Divider(color: theme.dividerColor),
|
||||||
title: Text(L10n.of(context).changeTheme),
|
if (showChatBackupBanner == null)
|
||||||
tileColor:
|
ListTile(
|
||||||
activeRoute.startsWith('/rooms/settings/style')
|
leading: const Icon(Icons.backup_outlined),
|
||||||
? theme.colorScheme.surfaceContainerHigh
|
title: Text(L10n.of(context).chatBackup),
|
||||||
: null,
|
trailing: const CircularProgressIndicator.adaptive(),
|
||||||
onTap: () => context.go('/rooms/settings/style'),
|
)
|
||||||
),
|
else
|
||||||
ListTile(
|
SwitchListTile.adaptive(
|
||||||
leading: const Icon(Icons.notifications_outlined),
|
controlAffinity: ListTileControlAffinity.trailing,
|
||||||
title: Text(L10n.of(context).notifications),
|
value: controller.showChatBackupBanner == false,
|
||||||
tileColor: activeRoute
|
secondary: const Icon(Icons.backup_outlined),
|
||||||
.startsWith('/rooms/settings/notifications')
|
title: Text(L10n.of(context).chatBackup),
|
||||||
|
onChanged: controller.firstRunBootstrapAction,
|
||||||
|
),
|
||||||
|
Divider(
|
||||||
|
color: theme.dividerColor,
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.format_paint_outlined),
|
||||||
|
title: Text(L10n.of(context).changeTheme),
|
||||||
|
tileColor: activeRoute.startsWith('/rooms/settings/style')
|
||||||
|
? theme.colorScheme.surfaceContainerHigh
|
||||||
|
: null,
|
||||||
|
onTap: () => context.go('/rooms/settings/style'),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.notifications_outlined),
|
||||||
|
title: Text(L10n.of(context).notifications),
|
||||||
|
tileColor:
|
||||||
|
activeRoute.startsWith('/rooms/settings/notifications')
|
||||||
? theme.colorScheme.surfaceContainerHigh
|
? theme.colorScheme.surfaceContainerHigh
|
||||||
: null,
|
: null,
|
||||||
onTap: () =>
|
onTap: () => context.go('/rooms/settings/notifications'),
|
||||||
context.go('/rooms/settings/notifications'),
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.devices_outlined),
|
||||||
|
title: Text(L10n.of(context).devices),
|
||||||
|
onTap: () => context.go('/rooms/settings/devices'),
|
||||||
|
tileColor: activeRoute.startsWith('/rooms/settings/devices')
|
||||||
|
? theme.colorScheme.surfaceContainerHigh
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.forum_outlined),
|
||||||
|
title: Text(L10n.of(context).chat),
|
||||||
|
onTap: () => context.go('/rooms/settings/chat'),
|
||||||
|
tileColor: activeRoute.startsWith('/rooms/settings/chat')
|
||||||
|
? theme.colorScheme.surfaceContainerHigh
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.shield_outlined),
|
||||||
|
title: Text(L10n.of(context).security),
|
||||||
|
onTap: () => context.go('/rooms/settings/security'),
|
||||||
|
tileColor:
|
||||||
|
activeRoute.startsWith('/rooms/settings/security')
|
||||||
|
? theme.colorScheme.surfaceContainerHigh
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
Divider(color: theme.dividerColor),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.dns_outlined),
|
||||||
|
title: Text(
|
||||||
|
L10n.of(context).aboutHomeserver(
|
||||||
|
Matrix.of(context).client.userID?.domain ??
|
||||||
|
'homeserver',
|
||||||
),
|
),
|
||||||
ListTile(
|
),
|
||||||
leading: const Icon(Icons.devices_outlined),
|
onTap: () => context.go('/rooms/settings/homeserver'),
|
||||||
title: Text(L10n.of(context).devices),
|
tileColor:
|
||||||
onTap: () => context.go('/rooms/settings/devices'),
|
activeRoute.startsWith('/rooms/settings/homeserver')
|
||||||
tileColor:
|
? theme.colorScheme.surfaceContainerHigh
|
||||||
activeRoute.startsWith('/rooms/settings/devices')
|
: null,
|
||||||
? theme.colorScheme.surfaceContainerHigh
|
),
|
||||||
: null,
|
ListTile(
|
||||||
),
|
leading: const Icon(Icons.privacy_tip_outlined),
|
||||||
ListTile(
|
title: Text(L10n.of(context).privacy),
|
||||||
leading: const Icon(Icons.forum_outlined),
|
onTap: () => launchUrlString(AppConfig.privacyUrl),
|
||||||
title: Text(L10n.of(context).chat),
|
),
|
||||||
onTap: () => context.go('/rooms/settings/chat'),
|
ListTile(
|
||||||
tileColor:
|
leading: const Icon(Icons.info_outline_rounded),
|
||||||
activeRoute.startsWith('/rooms/settings/chat')
|
title: Text(L10n.of(context).about),
|
||||||
? theme.colorScheme.surfaceContainerHigh
|
onTap: () => PlatformInfos.showDialog(context),
|
||||||
: null,
|
),
|
||||||
),
|
Divider(color: theme.dividerColor),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: const Icon(Icons.shield_outlined),
|
leading: const Icon(Icons.logout_outlined),
|
||||||
title: Text(L10n.of(context).security),
|
title: Text(L10n.of(context).logout),
|
||||||
onTap: () => context.go('/rooms/settings/security'),
|
onTap: controller.logoutAction,
|
||||||
tileColor:
|
),
|
||||||
activeRoute.startsWith('/rooms/settings/security')
|
],
|
||||||
? theme.colorScheme.surfaceContainerHigh
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
Divider(color: theme.dividerColor),
|
|
||||||
ListTile(
|
|
||||||
leading: const Icon(Icons.dns_outlined),
|
|
||||||
title: Text(
|
|
||||||
L10n.of(context).aboutHomeserver(
|
|
||||||
Matrix.of(context).client.userID?.domain ??
|
|
||||||
'homeserver',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () => context.go('/rooms/settings/homeserver'),
|
|
||||||
tileColor:
|
|
||||||
activeRoute.startsWith('/rooms/settings/homeserver')
|
|
||||||
? theme.colorScheme.surfaceContainerHigh
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: const Icon(Icons.privacy_tip_outlined),
|
|
||||||
title: Text(L10n.of(context).privacy),
|
|
||||||
onTap: () => launchUrlString(AppConfig.privacyUrl),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: const Icon(Icons.info_outline_rounded),
|
|
||||||
title: Text(L10n.of(context).about),
|
|
||||||
onTap: () => PlatformInfos.showDialog(context),
|
|
||||||
),
|
|
||||||
Divider(color: theme.dividerColor),
|
|
||||||
ListTile(
|
|
||||||
leading: const Icon(Icons.logout_outlined),
|
|
||||||
title: Text(L10n.of(context).logout),
|
|
||||||
onTap: controller.logoutAction,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ class SettingsHomeserverView extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: MaxWidthBody(
|
body: MaxWidthBody(
|
||||||
withScrolling: false,
|
withScrolling: true,
|
||||||
child: SelectionArea(
|
child: SelectionArea(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue