From 6502c3d26c141ab881f40ea637c3f08bad12310f Mon Sep 17 00:00:00 2001 From: ggurdin <46800240+ggurdin@users.noreply.github.com> Date: Tue, 11 Mar 2025 15:08:22 -0400 Subject: [PATCH] chore: remove popup button in menu, go directly to settings (#2109) --- lib/config/routes.dart | 6 +- lib/pages/chat_list/chat_list_header.dart | 10 +- .../chat_list/client_chooser_button.dart | 360 +++++++----------- .../learning_progress_indicators.dart | 57 ++- .../learning_settings_button.dart | 2 +- 5 files changed, 205 insertions(+), 230 deletions(-) diff --git a/lib/config/routes.dart b/lib/config/routes.dart index 465649d14..643c30207 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -181,8 +181,10 @@ abstract class AppRoutes { ) // #Pangea // : child, - : state.fullPath?.split("/").reversed.elementAt(1) == 'rooms' && - state.pathParameters['roomid'] != null + : FluffyThemes.isColumnMode(context) || + (state.fullPath?.split("/").reversed.elementAt(1) == + 'rooms' && + state.pathParameters['roomid'] != null) ? child : BottomNavLayout(mainView: child), // Pangea# diff --git a/lib/pages/chat_list/chat_list_header.dart b/lib/pages/chat_list/chat_list_header.dart index 93d5a4da6..b2a2aa761 100644 --- a/lib/pages/chat_list/chat_list_header.dart +++ b/lib/pages/chat_list/chat_list_header.dart @@ -124,16 +124,10 @@ class ChatListHeader extends StatelessWidget implements PreferredSizeWidget { maxLines: 2, ), ) - // #Pangea - // : SizedBox( - // width: 0, - // child: ClientChooserButton(controller), - // ), - : const SizedBox( + : SizedBox( width: 0, - child: ClientChooserButton(), + child: ClientChooserButton(controller), ), - // Pangea# ), ); }, diff --git a/lib/pages/chat_list/client_chooser_button.dart b/lib/pages/chat_list/client_chooser_button.dart index 6d3b5bce7..386bb0e2b 100644 --- a/lib/pages/chat_list/client_chooser_button.dart +++ b/lib/pages/chat_list/client_chooser_button.dart @@ -4,80 +4,58 @@ import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:go_router/go_router.dart'; import 'package:matrix/matrix.dart'; -import 'package:fluffychat/pangea/learning_settings/pages/settings_learning.dart'; -import 'package:fluffychat/pangea/user/utils/p_logout.dart'; import 'package:fluffychat/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart'; import 'package:fluffychat/widgets/avatar.dart'; import 'package:fluffychat/widgets/matrix.dart'; +import '../../utils/fluffy_share.dart'; +import 'chat_list.dart'; class ClientChooserButton extends StatelessWidget { - // #Pangea - // final ChatListController controller; - // Pangea# + final ChatListController controller; - const ClientChooserButton( - // #Pangea - // this.controller, - // Pangea# - { - super.key, - }); + const ClientChooserButton(this.controller, {super.key}); List> _bundleMenuItems(BuildContext context) { - // #Pangea - // final matrix = Matrix.of(context); - // final bundles = matrix.accountBundles.keys.toList() - // ..sort( - // (a, b) => a!.isValidMatrixId == b!.isValidMatrixId - // ? 0 - // : a.isValidMatrixId && !b.isValidMatrixId - // ? -1 - // : 1, - // ); - // Pangea# + final matrix = Matrix.of(context); + final bundles = matrix.accountBundles.keys.toList() + ..sort( + (a, b) => a!.isValidMatrixId == b!.isValidMatrixId + ? 0 + : a.isValidMatrixId && !b.isValidMatrixId + ? -1 + : 1, + ); return >[ - // #Pangea - // PopupMenuItem( - // value: SettingsAction.newGroup, - // child: Row( - // children: [ - // const Icon(Icons.group_add_outlined), - // const SizedBox(width: 18), - // Text(L10n.of(context).createGroup), - // ], - // ), - // ), - // PopupMenuItem( - // value: SettingsAction.setStatus, - // child: Row( - // children: [ - // const Icon(Icons.edit_outlined), - // const SizedBox(width: 18), - // Text(L10n.of(context).setStatus), - // ], - // ), - // ), PopupMenuItem( - value: SettingsAction.learning, + value: SettingsAction.newGroup, + child: Row( + children: [ + const Icon(Icons.group_add_outlined), + const SizedBox(width: 18), + Text(L10n.of(context).createGroup), + ], + ), + ), + PopupMenuItem( + value: SettingsAction.setStatus, + child: Row( + children: [ + const Icon(Icons.edit_outlined), + const SizedBox(width: 18), + Text(L10n.of(context).setStatus), + ], + ), + ), + PopupMenuItem( + value: SettingsAction.invite, child: Row( children: [ - const Icon(Icons.psychology_outlined), + Icon(Icons.adaptive.share_outlined), const SizedBox(width: 18), - Expanded(child: Text(L10n.of(context).learningSettings)), + Text(L10n.of(context).inviteContact), ], ), ), - // PopupMenuItem( - // value: SettingsAction.invite, - // child: Row( - // children: [ - // Icon(Icons.adaptive.share_outlined), - // const SizedBox(width: 18), - // Text(L10n.of(context).inviteContact), - // ], - // ), - // ), - // Pangea# // Currently disabled because of: // https://github.com/matrix-org/matrix-react-sdk/pull/12286 /*PopupMenuItem( @@ -100,88 +78,76 @@ class ClientChooserButton extends StatelessWidget { ], ), ), - // #Pangea + const PopupMenuDivider(), + for (final bundle in bundles) ...[ + if (matrix.accountBundles[bundle]!.length != 1 || + matrix.accountBundles[bundle]!.single!.userID != bundle) + PopupMenuItem( + value: null, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + bundle!, + style: TextStyle( + color: Theme.of(context).textTheme.titleMedium!.color, + fontSize: 14, + ), + ), + const Divider(height: 1), + ], + ), + ), + ...matrix.accountBundles[bundle]!.map( + (client) => PopupMenuItem( + value: client, + child: FutureBuilder( + // analyzer does not understand this type cast for error + // handling + // + // ignore: unnecessary_cast + future: (client!.fetchOwnProfile() as Future) + .onError((e, s) => null), + builder: (context, snapshot) => Row( + children: [ + Avatar( + mxContent: snapshot.data?.avatarUrl, + name: + snapshot.data?.displayName ?? client.userID!.localpart, + size: 32, + ), + const SizedBox(width: 12), + Expanded( + child: Text( + snapshot.data?.displayName ?? client.userID!.localpart!, + overflow: TextOverflow.ellipsis, + ), + ), + const SizedBox(width: 12), + IconButton( + icon: const Icon(Icons.edit_outlined), + onPressed: () => controller.editBundlesForAccount( + client.userID, + bundle, + ), + ), + ], + ), + ), + ), + ), + ], PopupMenuItem( - value: SettingsAction.logout, + value: SettingsAction.addAccount, child: Row( children: [ - const Icon(Icons.logout_outlined), + const Icon(Icons.person_add_outlined), const SizedBox(width: 18), - Expanded(child: Text(L10n.of(context).logout)), + Text(L10n.of(context).addAccount), ], ), ), - // const PopupMenuDivider(), - // for (final bundle in bundles) ...[ - // if (matrix.accountBundles[bundle]!.length != 1 || - // matrix.accountBundles[bundle]!.single!.userID != bundle) - // PopupMenuItem( - // value: null, - // child: Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // mainAxisSize: MainAxisSize.min, - // children: [ - // Text( - // bundle!, - // style: TextStyle( - // color: Theme.of(context).textTheme.titleMedium!.color, - // fontSize: 14, - // ), - // ), - // const Divider(height: 1), - // ], - // ), - // ), - // ...matrix.accountBundles[bundle]!.map( - // (client) => PopupMenuItem( - // value: client, - // child: FutureBuilder( - // // analyzer does not understand this type cast for error - // // handling - // // - // // ignore: unnecessary_cast - // future: (client!.fetchOwnProfile() as Future) - // .onError((e, s) => null), - // builder: (context, snapshot) => Row( - // children: [ - // Avatar( - // mxContent: snapshot.data?.avatarUrl, - // name: - // snapshot.data?.displayName ?? client.userID!.localpart, - // size: 32, - // ), - // const SizedBox(width: 12), - // Expanded( - // child: Text( - // snapshot.data?.displayName ?? client.userID!.localpart!, - // overflow: TextOverflow.ellipsis, - // ), - // ), - // const SizedBox(width: 12), - // IconButton( - // icon: const Icon(Icons.edit_outlined), - // onPressed: () => controller.editBundlesForAccount( - // client.userID, - // bundle, - // ), - // ), - // ], - // ), - // ), - // ), - // ), - // ], - // PopupMenuItem( - // value: SettingsAction.addAccount, - // child: Row( - // children: [ - // const Icon(Icons.person_add_outlined), - // const SizedBox(width: 18), - // Text(L10n.of(context).addAccount), - // ], - // ), - // ), - // Pangea# ]; } @@ -191,61 +157,45 @@ class ClientChooserButton extends StatelessWidget { var clientCount = 0; matrix.accountBundles.forEach((key, value) => clientCount += value.length); - // #Pangea - return matrix.client.userID == null - ? const SizedBox( - height: 16, - width: 16, - child: CircularProgressIndicator.adaptive(), - ) - : - // Pangea# - FutureBuilder( - future: matrix.client.fetchOwnProfile(), - builder: (context, snapshot) => Stack( - alignment: Alignment.center, - children: [ - ...List.generate( - clientCount, - (index) => const SizedBox.shrink(), - ), - const SizedBox.shrink(), - const SizedBox.shrink(), - PopupMenuButton( - onSelected: (o) => _clientSelected(o, context), - itemBuilder: _bundleMenuItems, - child: Material( - color: Colors.transparent, - borderRadius: BorderRadius.circular(99), - child: Avatar( - mxContent: snapshot.data?.avatarUrl, - name: snapshot.data?.displayName ?? - matrix.client.userID!.localpart, - // #Pangea - presenceUserId: matrix.client.userID!, - // size: 32, - size: 60, - // Pangea# - ), - ), - ), - ], + return FutureBuilder( + future: matrix.client.fetchOwnProfile(), + builder: (context, snapshot) => Stack( + alignment: Alignment.center, + children: [ + ...List.generate( + clientCount, + (index) => const SizedBox.shrink(), + ), + const SizedBox.shrink(), + const SizedBox.shrink(), + PopupMenuButton( + onSelected: (o) => _clientSelected(o, context), + itemBuilder: _bundleMenuItems, + child: Material( + color: Colors.transparent, + borderRadius: BorderRadius.circular(99), + child: Avatar( + mxContent: snapshot.data?.avatarUrl, + name: snapshot.data?.displayName ?? + matrix.client.userID!.localpart, + size: 32, + ), ), - ); + ), + ], + ), + ); } void _clientSelected( Object object, BuildContext context, ) async { - // #Pangea - // if (object is Client) { - // controller.setActiveClient(object); - // } else if (object is String) { - // controller.setActiveBundle(object); - // } else - if (object is SettingsAction) { - // Pangea# + if (object is Client) { + controller.setActiveClient(object); + } else if (object is String) { + controller.setActiveBundle(object); + } else if (object is SettingsAction) { switch (object) { case SettingsAction.addAccount: final consent = await showOkCancelAlertDialog( @@ -258,35 +208,21 @@ class ClientChooserButton extends StatelessWidget { if (consent != OkCancelResult.ok) return; context.go('/rooms/settings/addaccount'); break; - // #Pangea - // case SettingsAction.newGroup: - // context.go('/rooms/newgroup'); - // break; - // case SettingsAction.invite: - // FluffyShare.shareInviteLink(context); - // break; - // Pangea# + case SettingsAction.newGroup: + context.go('/rooms/newgroup'); + break; + case SettingsAction.invite: + FluffyShare.shareInviteLink(context); + break; case SettingsAction.settings: context.go('/rooms/settings'); break; - // #Pangea - // case SettingsAction.archive: - // context.go('/rooms/archive'); - // break; - // case SettingsAction.setStatus: - // controller.setStatus(); - // break; - case SettingsAction.learning: - showDialog( - context: context, - builder: (c) => const SettingsLearning(), - barrierDismissible: false, - ); + case SettingsAction.archive: + context.go('/rooms/archive'); break; - case SettingsAction.logout: - pLogoutAction(context); + case SettingsAction.setStatus: + controller.setStatus(); break; - // Pangea# } } } @@ -294,15 +230,9 @@ class ClientChooserButton extends StatelessWidget { enum SettingsAction { addAccount, - // #Pangea - // newGroup, - // setStatus, - // invite, - // Pangea# + newGroup, + setStatus, + invite, settings, - // #Pangea - // archive, - learning, - logout, - // Pangea# + archive, } diff --git a/lib/pangea/analytics_summary/learning_progress_indicators.dart b/lib/pangea/analytics_summary/learning_progress_indicators.dart index 1d536c399..b88c5cd1b 100644 --- a/lib/pangea/analytics_summary/learning_progress_indicators.dart +++ b/lib/pangea/analytics_summary/learning_progress_indicators.dart @@ -3,9 +3,9 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; +import 'package:go_router/go_router.dart'; import 'package:matrix/matrix.dart'; -import 'package:fluffychat/pages/chat_list/client_chooser_button.dart'; import 'package:fluffychat/pangea/analytics_details_popup/analytics_details_popup.dart'; import 'package:fluffychat/pangea/analytics_misc/construct_list_model.dart'; import 'package:fluffychat/pangea/analytics_misc/construct_type_enum.dart'; @@ -17,6 +17,7 @@ import 'package:fluffychat/pangea/analytics_summary/level_bar_popup.dart'; import 'package:fluffychat/pangea/analytics_summary/progress_indicator.dart'; import 'package:fluffychat/pangea/analytics_summary/progress_indicators_enum.dart'; import 'package:fluffychat/pangea/learning_settings/pages/settings_learning.dart'; +import 'package:fluffychat/widgets/avatar.dart'; import 'package:fluffychat/widgets/matrix.dart'; /// A summary of "My Analytics" shown at the top of the chat list @@ -94,18 +95,66 @@ class LearningProgressIndicatorsState @override Widget build(BuildContext context) { - if (Matrix.of(context).client.userID == null) { + final client = Matrix.of(context).client; + if (client.userID == null) { return const SizedBox(); } final userL2 = MatrixState.pangeaController.languageController.userL2; - final mxid = Matrix.of(context).client.userID ?? L10n.of(context).user; + final mxid = client.userID ?? L10n.of(context).user; final displayname = _profile?.displayName ?? mxid.localpart ?? mxid; return Row( children: [ - const ClientChooserButton(), + Tooltip( + message: L10n.of(context).settings, + child: MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () => context.go("/rooms/settings"), + child: Stack( + children: [ + FutureBuilder( + future: client.fetchOwnProfile(), + builder: (context, snapshot) => Stack( + alignment: Alignment.center, + children: [ + Material( + color: Colors.transparent, + borderRadius: BorderRadius.circular(99), + child: Avatar( + mxContent: snapshot.data?.avatarUrl, + name: snapshot.data?.displayName ?? + client.userID!.localpart, + size: 60, + ), + ), + ], + ), + ), + Positioned( + bottom: -3, + right: -3, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Theme.of(context).colorScheme.surfaceBright, + ), + padding: const EdgeInsets.all(4.0), + child: Icon( + size: 14, + Icons.settings_outlined, + color: Theme.of(context).colorScheme.primary, + weight: 1000, + ), + ), + ), + ], + ), + ), + ), + ), const SizedBox(width: 10), Expanded( child: Column( diff --git a/lib/pangea/analytics_summary/learning_settings_button.dart b/lib/pangea/analytics_summary/learning_settings_button.dart index 4bc119b2c..996ba7918 100644 --- a/lib/pangea/analytics_summary/learning_settings_button.dart +++ b/lib/pangea/analytics_summary/learning_settings_button.dart @@ -44,7 +44,7 @@ class LearningSettingsButton extends StatelessWidget { padding: const EdgeInsets.all(4.0), child: Icon( size: 14, - Icons.settings_outlined, + Icons.language_outlined, color: Theme.of(context).colorScheme.primary, weight: 1000, ),