chore: remove popup button in menu, go directly to settings (#2109)
This commit is contained in:
parent
07cbf2426a
commit
6502c3d26c
5 changed files with 205 additions and 230 deletions
|
|
@ -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#
|
||||
|
|
|
|||
|
|
@ -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#
|
||||
),
|
||||
);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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<PopupMenuEntry<Object>> _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 <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(
|
||||
value: SettingsAction.learning,
|
||||
value: SettingsAction.newGroup,
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.psychology_outlined),
|
||||
const Icon(Icons.group_add_outlined),
|
||||
const SizedBox(width: 18),
|
||||
Expanded(child: Text(L10n.of(context).learningSettings)),
|
||||
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: [
|
||||
Icon(Icons.adaptive.share_outlined),
|
||||
const SizedBox(width: 18),
|
||||
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<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.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<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;
|
||||
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<Profile>(
|
||||
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<Object>(
|
||||
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<Profile>(
|
||||
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<Object>(
|
||||
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,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<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),
|
||||
Expanded(
|
||||
child: Column(
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue