feat: Open account manage url when using MAS
This commit is contained in:
parent
b0a074c356
commit
be7a7fb671
4 changed files with 171 additions and 144 deletions
|
|
@ -2793,5 +2793,6 @@
|
||||||
"welcomeText": "Hey Hey 👋 This is FluffyChat. You can sign in to any homeserver, which is compatible with https://matrix.org. And then chat with anyone. It's a huge decentralized messaging network!",
|
"welcomeText": "Hey Hey 👋 This is FluffyChat. You can sign in to any homeserver, which is compatible with https://matrix.org. And then chat with anyone. It's a huge decentralized messaging network!",
|
||||||
"blur": "Blur:",
|
"blur": "Blur:",
|
||||||
"opacity": "Opacity:",
|
"opacity": "Opacity:",
|
||||||
"setWallpaper": "Set wallpaper"
|
"setWallpaper": "Set wallpaper",
|
||||||
|
"manageAccount": "Manage account"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,7 @@ class HomeserverPickerController extends State<HomeserverPicker> {
|
||||||
final result = await FlutterWebAuth2.authenticate(
|
final result = await FlutterWebAuth2.authenticate(
|
||||||
url: url.toString(),
|
url: url.toString(),
|
||||||
callbackUrlScheme: urlScheme,
|
callbackUrlScheme: urlScheme,
|
||||||
|
options: FlutterWebAuth2Options(useWebview: !isDefaultPlatform),
|
||||||
);
|
);
|
||||||
final token = Uri.parse(result).queryParameters['loginToken'];
|
final token = Uri.parse(result).queryParameters['loginToken'];
|
||||||
if (token?.isEmpty ?? false) return;
|
if (token?.isEmpty ?? false) return;
|
||||||
|
|
|
||||||
|
|
@ -201,6 +201,13 @@ class SettingsController extends State<Settings> {
|
||||||
checkBootstrap();
|
checkBootstrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<String?> getOidcAccountManageUrl() async {
|
||||||
|
final wellKnown = await Matrix.of(context).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;
|
||||||
|
|
|
||||||
|
|
@ -32,15 +32,19 @@ class SettingsView extends StatelessWidget {
|
||||||
),
|
),
|
||||||
body: ListTileTheme(
|
body: ListTileTheme(
|
||||||
iconColor: theme.colorScheme.onSurface,
|
iconColor: theme.colorScheme.onSurface,
|
||||||
child: ListView(
|
child: FutureBuilder(
|
||||||
|
future: controller.getOidcAccountManageUrl(),
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
final accountManageUrl = snapshot.data;
|
||||||
|
return ListView(
|
||||||
key: const Key('SettingsListViewContent'),
|
key: const Key('SettingsListViewContent'),
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
FutureBuilder<Profile>(
|
FutureBuilder<Profile>(
|
||||||
future: controller.profileFuture,
|
future: controller.profileFuture,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
final profile = snapshot.data;
|
final profile = snapshot.data;
|
||||||
final mxid =
|
final mxid = Matrix.of(context).client.userID ??
|
||||||
Matrix.of(context).client.userID ?? L10n.of(context).user;
|
L10n.of(context).user;
|
||||||
final displayname =
|
final displayname =
|
||||||
profile?.displayName ?? mxid.localpart ?? mxid;
|
profile?.displayName ?? mxid.localpart ?? mxid;
|
||||||
return Row(
|
return Row(
|
||||||
|
|
@ -62,7 +66,8 @@ class SettingsView extends StatelessWidget {
|
||||||
elevation: 2,
|
elevation: 2,
|
||||||
onPressed: controller.setAvatarAction,
|
onPressed: controller.setAvatarAction,
|
||||||
heroTag: null,
|
heroTag: null,
|
||||||
child: const Icon(Icons.camera_alt_outlined),
|
child:
|
||||||
|
const Icon(Icons.camera_alt_outlined),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
@ -92,7 +97,8 @@ class SettingsView extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
TextButton.icon(
|
TextButton.icon(
|
||||||
onPressed: () => FluffyShare.share(mxid, context),
|
onPressed: () =>
|
||||||
|
FluffyShare.share(mxid, context),
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.copy_outlined,
|
Icons.copy_outlined,
|
||||||
size: 14,
|
size: 14,
|
||||||
|
|
@ -114,6 +120,16 @@ class SettingsView extends StatelessWidget {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
Divider(color: theme.dividerColor),
|
Divider(color: theme.dividerColor),
|
||||||
if (showChatBackupBanner == null)
|
if (showChatBackupBanner == null)
|
||||||
ListTile(
|
ListTile(
|
||||||
|
|
@ -180,6 +196,8 @@ class SettingsView extends StatelessWidget {
|
||||||
onTap: controller.logoutAction,
|
onTap: controller.logoutAction,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue