chore: remove popup button in menu, go directly to settings (#2109)

pull/1688/head
ggurdin 8 months ago committed by GitHub
parent 07cbf2426a
commit 6502c3d26c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -181,8 +181,10 @@ abstract class AppRoutes {
) )
// #Pangea // #Pangea
// : child, // : child,
: state.fullPath?.split("/").reversed.elementAt(1) == 'rooms' && : FluffyThemes.isColumnMode(context) ||
state.pathParameters['roomid'] != null (state.fullPath?.split("/").reversed.elementAt(1) ==
'rooms' &&
state.pathParameters['roomid'] != null)
? child ? child
: BottomNavLayout(mainView: child), : BottomNavLayout(mainView: child),
// Pangea# // Pangea#

@ -124,16 +124,10 @@ class ChatListHeader extends StatelessWidget implements PreferredSizeWidget {
maxLines: 2, maxLines: 2,
), ),
) )
// #Pangea : SizedBox(
// : SizedBox(
// width: 0,
// child: ClientChooserButton(controller),
// ),
: const SizedBox(
width: 0, width: 0,
child: ClientChooserButton(), child: ClientChooserButton(controller),
), ),
// Pangea#
), ),
); );
}, },

@ -4,80 +4,58 @@ import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:matrix/matrix.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/adaptive_dialogs/show_ok_cancel_alert_dialog.dart';
import 'package:fluffychat/widgets/avatar.dart'; import 'package:fluffychat/widgets/avatar.dart';
import 'package:fluffychat/widgets/matrix.dart'; import 'package:fluffychat/widgets/matrix.dart';
import '../../utils/fluffy_share.dart';
import 'chat_list.dart';
class ClientChooserButton extends StatelessWidget { class ClientChooserButton extends StatelessWidget {
// #Pangea final ChatListController controller;
// final ChatListController controller;
// Pangea#
const ClientChooserButton( const ClientChooserButton(this.controller, {super.key});
// #Pangea
// this.controller,
// Pangea#
{
super.key,
});
List<PopupMenuEntry<Object>> _bundleMenuItems(BuildContext context) { List<PopupMenuEntry<Object>> _bundleMenuItems(BuildContext context) {
// #Pangea final matrix = Matrix.of(context);
// final matrix = Matrix.of(context); final bundles = matrix.accountBundles.keys.toList()
// final bundles = matrix.accountBundles.keys.toList() ..sort(
// ..sort( (a, b) => a!.isValidMatrixId == b!.isValidMatrixId
// (a, b) => a!.isValidMatrixId == b!.isValidMatrixId ? 0
// ? 0 : a.isValidMatrixId && !b.isValidMatrixId
// : a.isValidMatrixId && !b.isValidMatrixId ? -1
// ? -1 : 1,
// : 1, );
// );
// Pangea#
return <PopupMenuEntry<Object>>[ return <PopupMenuEntry<Object>>[
// #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( 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( child: Row(
children: [ children: [
const Icon(Icons.psychology_outlined), Icon(Icons.adaptive.share_outlined),
const SizedBox(width: 18), 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: // Currently disabled because of:
// https://github.com/matrix-org/matrix-react-sdk/pull/12286 // https://github.com/matrix-org/matrix-react-sdk/pull/12286
/*PopupMenuItem( /*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<Profile?>(
// analyzer does not understand this type cast for error
// handling
//
// ignore: unnecessary_cast
future: (client!.fetchOwnProfile() as Future<Profile?>)
.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( PopupMenuItem(
value: SettingsAction.logout, value: SettingsAction.addAccount,
child: Row( child: Row(
children: [ children: [
const Icon(Icons.logout_outlined), const Icon(Icons.person_add_outlined),
const SizedBox(width: 18), 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<Profile?>(
// // analyzer does not understand this type cast for error
// // handling
// //
// // ignore: unnecessary_cast
// future: (client!.fetchOwnProfile() as Future<Profile?>)
// .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; var clientCount = 0;
matrix.accountBundles.forEach((key, value) => clientCount += value.length); matrix.accountBundles.forEach((key, value) => clientCount += value.length);
// #Pangea return FutureBuilder<Profile>(
return matrix.client.userID == null future: matrix.client.fetchOwnProfile(),
? const SizedBox( builder: (context, snapshot) => Stack(
height: 16, alignment: Alignment.center,
width: 16, children: [
child: CircularProgressIndicator.adaptive(), ...List.generate(
) clientCount,
: (index) => const SizedBox.shrink(),
// Pangea# ),
FutureBuilder<Profile>( const SizedBox.shrink(),
future: matrix.client.fetchOwnProfile(), const SizedBox.shrink(),
builder: (context, snapshot) => Stack( PopupMenuButton<Object>(
alignment: Alignment.center, onSelected: (o) => _clientSelected(o, context),
children: [ itemBuilder: _bundleMenuItems,
...List.generate( child: Material(
clientCount, color: Colors.transparent,
(index) => const SizedBox.shrink(), borderRadius: BorderRadius.circular(99),
), child: Avatar(
const SizedBox.shrink(), mxContent: snapshot.data?.avatarUrl,
const SizedBox.shrink(), name: snapshot.data?.displayName ??
PopupMenuButton<Object>( matrix.client.userID!.localpart,
onSelected: (o) => _clientSelected(o, context), size: 32,
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#
),
),
),
],
), ),
); ),
],
),
);
} }
void _clientSelected( void _clientSelected(
Object object, Object object,
BuildContext context, BuildContext context,
) async { ) async {
// #Pangea if (object is Client) {
// if (object is Client) { controller.setActiveClient(object);
// controller.setActiveClient(object); } else if (object is String) {
// } else if (object is String) { controller.setActiveBundle(object);
// controller.setActiveBundle(object); } else if (object is SettingsAction) {
// } else
if (object is SettingsAction) {
// Pangea#
switch (object) { switch (object) {
case SettingsAction.addAccount: case SettingsAction.addAccount:
final consent = await showOkCancelAlertDialog( final consent = await showOkCancelAlertDialog(
@ -258,35 +208,21 @@ class ClientChooserButton extends StatelessWidget {
if (consent != OkCancelResult.ok) return; if (consent != OkCancelResult.ok) return;
context.go('/rooms/settings/addaccount'); context.go('/rooms/settings/addaccount');
break; break;
// #Pangea case SettingsAction.newGroup:
// case SettingsAction.newGroup: context.go('/rooms/newgroup');
// context.go('/rooms/newgroup'); break;
// break; case SettingsAction.invite:
// case SettingsAction.invite: FluffyShare.shareInviteLink(context);
// FluffyShare.shareInviteLink(context); break;
// break;
// Pangea#
case SettingsAction.settings: case SettingsAction.settings:
context.go('/rooms/settings'); context.go('/rooms/settings');
break; break;
// #Pangea case SettingsAction.archive:
// case SettingsAction.archive: context.go('/rooms/archive');
// context.go('/rooms/archive');
// break;
// case SettingsAction.setStatus:
// controller.setStatus();
// break;
case SettingsAction.learning:
showDialog(
context: context,
builder: (c) => const SettingsLearning(),
barrierDismissible: false,
);
break; break;
case SettingsAction.logout: case SettingsAction.setStatus:
pLogoutAction(context); controller.setStatus();
break; break;
// Pangea#
} }
} }
} }
@ -294,15 +230,9 @@ class ClientChooserButton extends StatelessWidget {
enum SettingsAction { enum SettingsAction {
addAccount, addAccount,
// #Pangea newGroup,
// newGroup, setStatus,
// setStatus, invite,
// invite,
// Pangea#
settings, settings,
// #Pangea archive,
// archive,
learning,
logout,
// Pangea#
} }

@ -3,9 +3,9 @@ import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:go_router/go_router.dart';
import 'package:matrix/matrix.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_details_popup/analytics_details_popup.dart';
import 'package:fluffychat/pangea/analytics_misc/construct_list_model.dart'; import 'package:fluffychat/pangea/analytics_misc/construct_list_model.dart';
import 'package:fluffychat/pangea/analytics_misc/construct_type_enum.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_indicator.dart';
import 'package:fluffychat/pangea/analytics_summary/progress_indicators_enum.dart'; import 'package:fluffychat/pangea/analytics_summary/progress_indicators_enum.dart';
import 'package:fluffychat/pangea/learning_settings/pages/settings_learning.dart'; import 'package:fluffychat/pangea/learning_settings/pages/settings_learning.dart';
import 'package:fluffychat/widgets/avatar.dart';
import 'package:fluffychat/widgets/matrix.dart'; import 'package:fluffychat/widgets/matrix.dart';
/// A summary of "My Analytics" shown at the top of the chat list /// A summary of "My Analytics" shown at the top of the chat list
@ -94,18 +95,66 @@ class LearningProgressIndicatorsState
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (Matrix.of(context).client.userID == null) { final client = Matrix.of(context).client;
if (client.userID == null) {
return const SizedBox(); return const SizedBox();
} }
final userL2 = MatrixState.pangeaController.languageController.userL2; 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; final displayname = _profile?.displayName ?? mxid.localpart ?? mxid;
return Row( return Row(
children: [ 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<Profile>(
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), const SizedBox(width: 10),
Expanded( Expanded(
child: Column( child: Column(

@ -44,7 +44,7 @@ class LearningSettingsButton extends StatelessWidget {
padding: const EdgeInsets.all(4.0), padding: const EdgeInsets.all(4.0),
child: Icon( child: Icon(
size: 14, size: 14,
Icons.settings_outlined, Icons.language_outlined,
color: Theme.of(context).colorScheme.primary, color: Theme.of(context).colorScheme.primary,
weight: 1000, weight: 1000,
), ),

Loading…
Cancel
Save