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!",
|
||||
"blur": "Blur:",
|
||||
"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(
|
||||
url: url.toString(),
|
||||
callbackUrlScheme: urlScheme,
|
||||
options: FlutterWebAuth2Options(useWebview: !isDefaultPlatform),
|
||||
);
|
||||
final token = Uri.parse(result).queryParameters['loginToken'];
|
||||
if (token?.isEmpty ?? false) return;
|
||||
|
|
|
|||
|
|
@ -201,6 +201,13 @@ class SettingsController extends State<Settings> {
|
|||
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
|
||||
Widget build(BuildContext context) {
|
||||
final client = Matrix.of(context).client;
|
||||
|
|
|
|||
|
|
@ -32,15 +32,19 @@ class SettingsView extends StatelessWidget {
|
|||
),
|
||||
body: ListTileTheme(
|
||||
iconColor: theme.colorScheme.onSurface,
|
||||
child: ListView(
|
||||
child: FutureBuilder(
|
||||
future: controller.getOidcAccountManageUrl(),
|
||||
builder: (context, snapshot) {
|
||||
final accountManageUrl = snapshot.data;
|
||||
return ListView(
|
||||
key: const Key('SettingsListViewContent'),
|
||||
children: <Widget>[
|
||||
FutureBuilder<Profile>(
|
||||
future: controller.profileFuture,
|
||||
builder: (context, snapshot) {
|
||||
final profile = snapshot.data;
|
||||
final mxid =
|
||||
Matrix.of(context).client.userID ?? L10n.of(context).user;
|
||||
final mxid = Matrix.of(context).client.userID ??
|
||||
L10n.of(context).user;
|
||||
final displayname =
|
||||
profile?.displayName ?? mxid.localpart ?? mxid;
|
||||
return Row(
|
||||
|
|
@ -62,7 +66,8 @@ class SettingsView extends StatelessWidget {
|
|||
elevation: 2,
|
||||
onPressed: controller.setAvatarAction,
|
||||
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(
|
||||
onPressed: () => FluffyShare.share(mxid, context),
|
||||
onPressed: () =>
|
||||
FluffyShare.share(mxid, context),
|
||||
icon: const Icon(
|
||||
Icons.copy_outlined,
|
||||
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),
|
||||
if (showChatBackupBanner == null)
|
||||
ListTile(
|
||||
|
|
@ -180,6 +196,8 @@ class SettingsView extends StatelessWidget {
|
|||
onTap: controller.logoutAction,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue