design: Improve invite chat UX

pull/524/head
krille-chan 2 years ago
parent 5302383aeb
commit 98a38113fd
No known key found for this signature in database

@ -2511,5 +2511,8 @@
"profileNotFound": "The user could not be found on the server. Maybe there is a connection problem or the user doesn't exist.", "profileNotFound": "The user could not be found on the server. Maybe there is a connection problem or the user doesn't exist.",
"setTheme": "Set theme:", "setTheme": "Set theme:",
"setColorTheme": "Set color theme:", "setColorTheme": "Set color theme:",
"invite": "Invite" "invite": "Invite",
"requests": "Requests",
"inviteGroupChat": "📨 Invite group chat",
"invitePrivateChat": "📨 Invite private chat"
} }

@ -37,6 +37,33 @@ class ChatListItem extends StatelessWidget {
if (onTap != null) return onTap!(); if (onTap != null) return onTap!();
if (activeChat) return; if (activeChat) return;
if (room.membership == Membership.invite) { if (room.membership == Membership.invite) {
final inviterId =
room.getState(EventTypes.RoomMember, room.client.userID!)?.senderId;
final profile = inviterId == null
? null
: await showFutureLoadingDialog(
context: context,
future: () => room.client.getProfileFromUserId(inviterId),
);
final consent = await showOkCancelAlertDialog(
context: context,
title: L10n.of(context)!.inviteForMe,
message: L10n.of(context)!.youInvitedBy(
profile?.result?.displayName ??
profile?.result?.userId.localpart ??
L10n.of(context)!.user,
),
okLabel: L10n.of(context)!.joinRoom,
cancelLabel: L10n.of(context)!.delete,
barrierDismissible: false,
);
if (consent == OkCancelResult.cancel) {
await showFutureLoadingDialog(
context: context,
future: room.leave,
);
return;
}
final joinResult = await showFutureLoadingDialog( final joinResult = await showFutureLoadingDialog(
context: context, context: context,
future: () async { future: () async {
@ -119,8 +146,8 @@ class ChatListItem extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final isMuted = room.pushRuleState != PushRuleState.notify; final isMuted = room.pushRuleState != PushRuleState.notify;
final typingText = room.getLocalizedTypingText(context); final typingText = room.getLocalizedTypingText(context);
final ownMessage = final lastEvent = room.lastEvent;
room.lastEvent?.senderId == Matrix.of(context).client.userID; final ownMessage = lastEvent?.senderId == Matrix.of(context).client.userID;
final unread = room.isUnread || room.membership == Membership.invite; final unread = room.isUnread || room.membership == Membership.invite;
final unreadBubbleSize = unread || room.hasNewMessages final unreadBubbleSize = unread || room.hasNewMessages
? room.notificationCount > 0 ? room.notificationCount > 0
@ -183,7 +210,7 @@ class ChatListItem extends StatelessWidget {
size: 16, size: 16,
), ),
), ),
if (room.isFavourite) if (room.isFavourite || room.membership == Membership.invite)
Padding( Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(
right: room.notificationCount > 0 ? 4.0 : 0.0, right: room.notificationCount > 0 ? 4.0 : 0.0,
@ -194,18 +221,19 @@ class ChatListItem extends StatelessWidget {
color: Theme.of(context).colorScheme.primary, color: Theme.of(context).colorScheme.primary,
), ),
), ),
Padding( if (lastEvent != null && room.membership != Membership.invite)
padding: const EdgeInsets.only(left: 4.0), Padding(
child: Text( padding: const EdgeInsets.only(left: 4.0),
room.timeCreated.localizedTimeShort(context), child: Text(
style: TextStyle( lastEvent.originServerTs.localizedTimeShort(context),
fontSize: 13, style: TextStyle(
color: unread fontSize: 13,
? Theme.of(context).colorScheme.secondary color: unread
: Theme.of(context).textTheme.bodyMedium!.color, ? Theme.of(context).colorScheme.secondary
: Theme.of(context).textTheme.bodyMedium!.color,
),
), ),
), ),
),
], ],
), ),
subtitle: Row( subtitle: Row(
@ -259,7 +287,9 @@ class ChatListItem extends StatelessWidget {
builder: (context, snapshot) { builder: (context, snapshot) {
return Text( return Text(
room.membership == Membership.invite room.membership == Membership.invite
? L10n.of(context)!.youAreInvitedToThisChat ? room.isDirectChat
? L10n.of(context)!.invitePrivateChat
: L10n.of(context)!.inviteGroupChat
: snapshot.data ?? : snapshot.data ??
room.lastEvent?.calcLocalizedBodyFallback( room.lastEvent?.calcLocalizedBodyFallback(
MatrixLocals(L10n.of(context)!), MatrixLocals(L10n.of(context)!),

Loading…
Cancel
Save