From 5668bfbad8e2172b926d297e9f962c82f37ee83f Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Sat, 15 Oct 2022 11:11:36 +0200 Subject: [PATCH] chore: Follow up nicer state events --- assets/l10n/intl_en.arb | 26 +++++----- lib/pages/chat/events/state_message.dart | 48 ++++++------------- .../filtered_timeline_extension.dart | 6 ++- 3 files changed, 31 insertions(+), 49 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index f6a35c1d6..06826c30f 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -28,7 +28,7 @@ "type": "text", "placeholders": {} }, - "acceptedTheInvitation": "{username} accepted the invitation", + "acceptedTheInvitation": "👍 {username} accepted the invitation", "@acceptedTheInvitation": { "type": "text", "placeholders": { @@ -45,7 +45,7 @@ "type": "text", "placeholders": {} }, - "activatedEndToEndEncryption": "{username} activated end to end encryption", + "activatedEndToEndEncryption": "🔐 {username} activated end to end encryption", "@activatedEndToEndEncryption": { "type": "text", "placeholders": { @@ -702,7 +702,7 @@ "type": "text", "placeholders": {} }, - "createdTheChat": "{username} created the chat", + "createdTheChat": "💬 {username} created the chat", "@createdTheChat": { "type": "text", "placeholders": { @@ -1209,7 +1209,7 @@ "type": "text", "placeholders": {} }, - "invitedUser": "{username} invited {targetName}", + "invitedUser": "📩 {username} invited {targetName}", "@invitedUser": { "type": "text", "placeholders": { @@ -1245,7 +1245,7 @@ "type": "text", "placeholders": {} }, - "joinedTheChat": "{username} joined the chat", + "joinedTheChat": "👋 {username} joined the chat", "@joinedTheChat": { "type": "text", "placeholders": { @@ -1267,7 +1267,7 @@ "type": "text", "placeholders": {} }, - "kicked": "{username} kicked {targetName}", + "kicked": "👞 {username} kicked {targetName}", "@kicked": { "type": "text", "placeholders": { @@ -1275,7 +1275,7 @@ "targetName": {} } }, - "kickedAndBanned": "{username} kicked and banned {targetName}", + "kickedAndBanned": "🙅 {username} kicked and banned {targetName}", "@kickedAndBanned": { "type": "text", "placeholders": { @@ -2452,7 +2452,7 @@ "username": {} } }, - "userLeftTheChat": "{username} left the chat", + "userLeftTheChat": "🚪 {username} left the chat", "@userLeftTheChat": { "type": "text", "placeholders": { @@ -2837,7 +2837,7 @@ "@youRejectedTheInvitation": {}, "youJoinedTheChat": "You joined the chat", "@youJoinedTheChat": {}, - "youAcceptedTheInvitation": "You accepted the invitation", + "youAcceptedTheInvitation": "👍 You accepted the invitation", "@youAcceptedTheInvitation": {}, "youBannedUser": "You banned {user}", "@youBannedUser": { @@ -2851,25 +2851,25 @@ "user": {} } }, - "youInvitedBy": "You have been invited by {user}", + "youInvitedBy": "📩 You have been invited by {user}", "@youInvitedBy": { "placeholders": { "user": {} } }, - "youInvitedUser": "You invited {user}", + "youInvitedUser": "📩 You invited {user}", "@youInvitedUser": { "placeholders": { "user": {} } }, - "youKicked": "You kicked {user}", + "youKicked": "👞 You kicked {user}", "@youKicked": { "placeholders": { "user": {} } }, - "youKickedAndBanned": "You kicked and banned {user}", + "youKickedAndBanned": "🙅 You kicked and banned {user}", "@youKickedAndBanned": { "placeholders": { "user": {} diff --git a/lib/pages/chat/events/state_message.dart b/lib/pages/chat/events/state_message.dart index c4c77edb5..9a77a624f 100644 --- a/lib/pages/chat/events/state_message.dart +++ b/lib/pages/chat/events/state_message.dart @@ -12,11 +12,6 @@ class StateMessage extends StatelessWidget { @override Widget build(BuildContext context) { - if (event.unsigned!['im.fluffychat.collapsed_state_event'] == true) { - return Container(); - } - final int counter = - event.unsigned!['im.fluffychat.collapsed_state_event_count'] ?? 0; return Padding( padding: const EdgeInsets.symmetric( horizontal: 8.0, @@ -26,41 +21,26 @@ class StateMessage extends StatelessWidget { child: Container( padding: const EdgeInsets.all(8), decoration: BoxDecoration( - color: Theme.of(context).brightness == Brightness.light - ? Colors.white - : Colors.grey.shade900, + color: Theme.of(context).colorScheme.secondaryContainer, borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2), ), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - FutureBuilder( - future: - event.calcLocalizedBody(MatrixLocals(L10n.of(context)!)), - builder: (context, snapshot) { - return Text( - snapshot.data ?? - event.calcLocalizedBodyFallback( - MatrixLocals(L10n.of(context)!)), - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 14 * AppConfig.fontSizeFactor, - color: Theme.of(context).textTheme.bodyText2!.color, - decoration: - event.redacted ? TextDecoration.lineThrough : null, + child: FutureBuilder( + future: event.calcLocalizedBody(MatrixLocals(L10n.of(context)!)), + builder: (context, snapshot) { + return Text( + snapshot.data ?? + event.calcLocalizedBodyFallback( + MatrixLocals(L10n.of(context)!), ), - ); - }), - if (counter != 0) - Text( - L10n.of(context)!.moreEvents(counter), + textAlign: TextAlign.center, style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 14 * AppConfig.fontSizeFactor, + color: Theme.of(context).colorScheme.onSecondaryContainer, + decoration: + event.redacted ? TextDecoration.lineThrough : null, ), - ), - ], - ), + ); + }), ), ), ); diff --git a/lib/utils/matrix_sdk_extensions.dart/filtered_timeline_extension.dart b/lib/utils/matrix_sdk_extensions.dart/filtered_timeline_extension.dart index 76d746b6c..479685c14 100644 --- a/lib/utils/matrix_sdk_extensions.dart/filtered_timeline_extension.dart +++ b/lib/utils/matrix_sdk_extensions.dart/filtered_timeline_extension.dart @@ -22,10 +22,12 @@ extension IsStateExtension on Event { (!AppConfig.hideUnimportantStateEvents || !isState || importantStateEvents.contains(type)) && - // hide member events in public rooms + // hide simple join/leave member events in public rooms (!AppConfig.hideUnimportantStateEvents || type != EventTypes.RoomMember || - room.joinRules != JoinRules.public); + room.joinRules != JoinRules.public || + content.tryGet('membership') == 'ban' || + stateKey != senderId); static const Set importantStateEvents = { EventTypes.Encryption,