chore: Follow up listtilehover

This commit is contained in:
Krille 2024-07-15 16:57:19 +02:00
commit 54ba4544af
No known key found for this signature in database
GPG key ID: E067ECD60F1A0652

View file

@ -103,279 +103,284 @@ class ChatListItem extends StatelessWidget {
color: backgroundColor, color: backgroundColor,
child: FutureBuilder( child: FutureBuilder(
future: room.loadHeroUsers(), future: room.loadHeroUsers(),
builder: (context, snapshot) => ListTile( builder: (context, snapshot) => HoverBuilder(
visualDensity: const VisualDensity(vertical: -0.5), builder: (context, listTileHovered) => ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 8), visualDensity: const VisualDensity(vertical: -0.5),
onLongPress: () => onLongPress?.call(context), contentPadding: const EdgeInsets.symmetric(horizontal: 8),
leading: HoverBuilder( onLongPress: () => onLongPress?.call(context),
builder: (context, hovered) => AnimatedScale( leading: HoverBuilder(
duration: FluffyThemes.animationDuration, builder: (context, hovered) => AnimatedScale(
curve: FluffyThemes.animationCurve, duration: FluffyThemes.animationDuration,
scale: hovered ? 1.1 : 1.0, curve: FluffyThemes.animationCurve,
child: SizedBox( scale: hovered ? 1.1 : 1.0,
width: Avatar.defaultSize, child: SizedBox(
height: Avatar.defaultSize, width: Avatar.defaultSize,
child: Stack( height: Avatar.defaultSize,
children: [ child: Stack(
if (space != null) children: [
if (space != null)
Positioned(
top: 0,
left: 0,
child: Avatar(
border: BorderSide(
width: 2,
color: backgroundColor ??
Theme.of(context).colorScheme.surface,
),
borderRadius: BorderRadius.circular(
AppConfig.borderRadius / 4,
),
mxContent: space.avatar,
size: Avatar.defaultSize * 0.75,
name: space.getLocalizedDisplayname(),
onTap: () => onLongPress?.call(context),
),
),
Positioned( Positioned(
top: 0, bottom: 0,
left: 0, right: 0,
child: Avatar( child: Avatar(
border: BorderSide( border: space == null
width: 2, ? room.isSpace
color: backgroundColor ?? ? BorderSide(
Theme.of(context).colorScheme.surface, width: 0,
), color: Theme.of(context)
borderRadius: BorderRadius.circular( .colorScheme
AppConfig.borderRadius / 4, .outline,
), )
mxContent: space.avatar, : null
size: Avatar.defaultSize * 0.75, : BorderSide(
name: space.getLocalizedDisplayname(), width: 2,
color: backgroundColor ??
Theme.of(context).colorScheme.surface,
),
borderRadius: room.isSpace
? BorderRadius.circular(
AppConfig.borderRadius / 4,
)
: null,
mxContent: room.avatar,
size: space != null
? Avatar.defaultSize * 0.75
: Avatar.defaultSize,
name: displayname,
presenceUserId: directChatMatrixId,
presenceBackgroundColor: backgroundColor,
onTap: () => onLongPress?.call(context), onTap: () => onLongPress?.call(context),
), ),
), ),
Positioned( if (listTileHovered)
bottom: 0, Positioned(
right: 0, top: -2,
child: Avatar( right: -2,
border: space == null child: Material(
? room.isSpace color: backgroundColor,
? BorderSide( borderRadius: BorderRadius.circular(16),
width: 0, child: const Icon(
color: Icons.arrow_drop_down_circle_outlined,
Theme.of(context).colorScheme.outline, size: 18,
) ),
: null
: BorderSide(
width: 2,
color: backgroundColor ??
Theme.of(context).colorScheme.surface,
),
borderRadius: room.isSpace
? BorderRadius.circular(
AppConfig.borderRadius / 4,
)
: null,
mxContent: room.avatar,
size: space != null
? Avatar.defaultSize * 0.75
: Avatar.defaultSize,
name: displayname,
presenceUserId: directChatMatrixId,
presenceBackgroundColor: backgroundColor,
onTap: () => onLongPress?.call(context),
),
),
if (hovered)
Positioned(
top: -2,
right: -2,
child: Material(
color: backgroundColor,
borderRadius: BorderRadius.circular(16),
child: const Icon(
Icons.arrow_drop_down_circle_outlined,
size: 18,
), ),
), ),
), ],
], ),
), ),
), ),
), ),
), title: Row(
title: Row( children: <Widget>[
children: <Widget>[ Expanded(
Expanded(
child: Text(
displayname,
maxLines: 1,
overflow: TextOverflow.ellipsis,
softWrap: false,
style: unread || room.hasNewMessages
? const TextStyle(fontWeight: FontWeight.bold)
: null,
),
),
if (isMuted)
const Padding(
padding: EdgeInsets.only(left: 4.0),
child: Icon(
Icons.notifications_off_outlined,
size: 16,
),
),
if (room.isFavourite || room.membership == Membership.invite)
Padding(
padding: EdgeInsets.only(
right: hasNotifications ? 4.0 : 0.0,
),
child: Icon(
Icons.push_pin,
size: 16,
color: theme.colorScheme.primary,
),
),
if (!room.isSpace &&
lastEvent != null &&
room.membership != Membership.invite)
Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Text( child: Text(
lastEvent.originServerTs.localizedTimeShort(context), displayname,
style: TextStyle( maxLines: 1,
fontSize: 13, overflow: TextOverflow.ellipsis,
color: unread softWrap: false,
? theme.colorScheme.secondary style: unread || room.hasNewMessages
: theme.textTheme.bodyMedium!.color, ? const TextStyle(fontWeight: FontWeight.bold)
: null,
),
),
if (isMuted)
const Padding(
padding: EdgeInsets.only(left: 4.0),
child: Icon(
Icons.notifications_off_outlined,
size: 16,
), ),
), ),
), if (room.isFavourite || room.membership == Membership.invite)
if (room.isSpace) Padding(
const Icon( padding: EdgeInsets.only(
Icons.arrow_circle_right_outlined, right: hasNotifications ? 4.0 : 0.0,
size: 18, ),
), child: Icon(
], Icons.push_pin,
), size: 16,
subtitle: Row( color: theme.colorScheme.primary,
mainAxisAlignment: MainAxisAlignment.center, ),
children: <Widget>[ ),
if (typingText.isEmpty && if (!room.isSpace &&
ownMessage && lastEvent != null &&
room.lastEvent!.status.isSending) ...[ room.membership != Membership.invite)
const SizedBox( Padding(
width: 16, padding: const EdgeInsets.only(left: 4.0),
height: 16, child: Text(
child: CircularProgressIndicator.adaptive(strokeWidth: 2), lastEvent.originServerTs.localizedTimeShort(context),
), style: TextStyle(
const SizedBox(width: 4), fontSize: 13,
color: unread
? theme.colorScheme.secondary
: theme.textTheme.bodyMedium!.color,
),
),
),
if (room.isSpace)
const Icon(
Icons.arrow_circle_right_outlined,
size: 18,
),
], ],
AnimatedContainer( ),
width: typingText.isEmpty ? 0 : 18, subtitle: Row(
clipBehavior: Clip.hardEdge, mainAxisAlignment: MainAxisAlignment.center,
decoration: const BoxDecoration(), children: <Widget>[
duration: FluffyThemes.animationDuration, if (typingText.isEmpty &&
curve: FluffyThemes.animationCurve, ownMessage &&
padding: const EdgeInsets.only(right: 4), room.lastEvent!.status.isSending) ...[
child: Icon( const SizedBox(
Icons.edit_outlined, width: 16,
color: theme.colorScheme.secondary, height: 16,
size: 14, child: CircularProgressIndicator.adaptive(strokeWidth: 2),
),
const SizedBox(width: 4),
],
AnimatedContainer(
width: typingText.isEmpty ? 0 : 18,
clipBehavior: Clip.hardEdge,
decoration: const BoxDecoration(),
duration: FluffyThemes.animationDuration,
curve: FluffyThemes.animationCurve,
padding: const EdgeInsets.only(right: 4),
child: Icon(
Icons.edit_outlined,
color: theme.colorScheme.secondary,
size: 14,
),
), ),
), Expanded(
Expanded( child: room.isSpace && room.membership == Membership.join
child: room.isSpace && room.membership == Membership.join
? Text(
L10n.of(context)!.countChatsAndCountParticipants(
room.spaceChildren.length.toString(),
(room.summary.mJoinedMemberCount ?? 1).toString(),
),
)
: typingText.isNotEmpty
? Text(
typingText,
style: TextStyle(
color: theme.colorScheme.primary,
),
maxLines: 1,
softWrap: false,
)
: FutureBuilder(
key: ValueKey(
'${lastEvent?.eventId}_${lastEvent?.type}',
),
future: needLastEventSender
? lastEvent.calcLocalizedBody(
MatrixLocals(L10n.of(context)!),
hideReply: true,
hideEdit: true,
plaintextBody: true,
removeMarkdown: true,
withSenderNamePrefix: (!isDirectChat ||
directChatMatrixId !=
room.lastEvent?.senderId),
)
: null,
initialData: lastEvent?.calcLocalizedBodyFallback(
MatrixLocals(L10n.of(context)!),
hideReply: true,
hideEdit: true,
plaintextBody: true,
removeMarkdown: true,
withSenderNamePrefix: (!isDirectChat ||
directChatMatrixId !=
room.lastEvent?.senderId),
),
builder: (context, snapshot) => Text(
room.membership == Membership.invite
? isDirectChat
? L10n.of(context)!.invitePrivateChat
: L10n.of(context)!.inviteGroupChat
: snapshot.data ??
L10n.of(context)!.emptyChat,
softWrap: false,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontWeight: unread || room.hasNewMessages
? FontWeight.bold
: null,
color: theme.colorScheme.onSurfaceVariant,
decoration: room.lastEvent?.redacted == true
? TextDecoration.lineThrough
: null,
),
),
),
),
const SizedBox(width: 8),
AnimatedContainer(
duration: FluffyThemes.animationDuration,
curve: FluffyThemes.animationCurve,
padding: const EdgeInsets.symmetric(horizontal: 7),
height: unreadBubbleSize,
width: !hasNotifications && !unread && !room.hasNewMessages
? 0
: (unreadBubbleSize - 9) *
room.notificationCount.toString().length +
9,
decoration: BoxDecoration(
color: room.highlightCount > 0 ||
room.membership == Membership.invite
? Colors.red
: hasNotifications || room.markedUnread
? theme.colorScheme.primary
: theme.colorScheme.primaryContainer,
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
),
child: Center(
child: hasNotifications
? Text( ? Text(
room.notificationCount.toString(), L10n.of(context)!.countChatsAndCountParticipants(
style: TextStyle( room.spaceChildren.length.toString(),
color: room.highlightCount > 0 (room.summary.mJoinedMemberCount ?? 1).toString(),
? Colors.white
: hasNotifications
? theme.colorScheme.onPrimary
: theme.colorScheme.onPrimaryContainer,
fontSize: 13,
), ),
) )
: const SizedBox.shrink(), : typingText.isNotEmpty
? Text(
typingText,
style: TextStyle(
color: theme.colorScheme.primary,
),
maxLines: 1,
softWrap: false,
)
: FutureBuilder(
key: ValueKey(
'${lastEvent?.eventId}_${lastEvent?.type}',
),
future: needLastEventSender
? lastEvent.calcLocalizedBody(
MatrixLocals(L10n.of(context)!),
hideReply: true,
hideEdit: true,
plaintextBody: true,
removeMarkdown: true,
withSenderNamePrefix: (!isDirectChat ||
directChatMatrixId !=
room.lastEvent?.senderId),
)
: null,
initialData:
lastEvent?.calcLocalizedBodyFallback(
MatrixLocals(L10n.of(context)!),
hideReply: true,
hideEdit: true,
plaintextBody: true,
removeMarkdown: true,
withSenderNamePrefix: (!isDirectChat ||
directChatMatrixId !=
room.lastEvent?.senderId),
),
builder: (context, snapshot) => Text(
room.membership == Membership.invite
? isDirectChat
? L10n.of(context)!.invitePrivateChat
: L10n.of(context)!.inviteGroupChat
: snapshot.data ??
L10n.of(context)!.emptyChat,
softWrap: false,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontWeight: unread || room.hasNewMessages
? FontWeight.bold
: null,
color: theme.colorScheme.onSurfaceVariant,
decoration: room.lastEvent?.redacted == true
? TextDecoration.lineThrough
: null,
),
),
),
), ),
), const SizedBox(width: 8),
], AnimatedContainer(
duration: FluffyThemes.animationDuration,
curve: FluffyThemes.animationCurve,
padding: const EdgeInsets.symmetric(horizontal: 7),
height: unreadBubbleSize,
width: !hasNotifications && !unread && !room.hasNewMessages
? 0
: (unreadBubbleSize - 9) *
room.notificationCount.toString().length +
9,
decoration: BoxDecoration(
color: room.highlightCount > 0 ||
room.membership == Membership.invite
? Colors.red
: hasNotifications || room.markedUnread
? theme.colorScheme.primary
: theme.colorScheme.primaryContainer,
borderRadius:
BorderRadius.circular(AppConfig.borderRadius),
),
child: Center(
child: hasNotifications
? Text(
room.notificationCount.toString(),
style: TextStyle(
color: room.highlightCount > 0
? Colors.white
: hasNotifications
? theme.colorScheme.onPrimary
: theme.colorScheme.onPrimaryContainer,
fontSize: 13,
),
)
: const SizedBox.shrink(),
),
),
],
),
onTap: onTap,
trailing: onForget == null
? null
: IconButton(
icon: const Icon(Icons.delete_outlined),
onPressed: onForget,
),
), ),
onTap: onTap,
trailing: onForget == null
? null
: IconButton(
icon: const Icon(Icons.delete_outlined),
onPressed: onForget,
),
), ),
), ),
), ),