chore: Nicer message animation

This commit is contained in:
krille-chan 2024-05-20 17:25:09 +02:00
commit 3d7dbf7ddf
No known key found for this signature in database

View file

@ -144,11 +144,12 @@ class Message extends StatelessWidget {
setState(resetAnimateIn);
});
}
return AnimatedSlide(
offset: Offset(0, animateIn ? 1 : 0),
return AnimatedSize(
duration: FluffyThemes.animationDuration,
curve: FluffyThemes.animationCurve,
child: Stack(
child: animateIn
? const SizedBox.shrink()
: Stack(
children: [
Positioned(
top: 0,
@ -201,7 +202,8 @@ class Message extends StatelessWidget {
child: event.status == EventStatus.error
? const Icon(Icons.error, color: Colors.red)
: event.fileSendingStatus != null
? const CircularProgressIndicator.adaptive(
? const CircularProgressIndicator
.adaptive(
strokeWidth: 1,
)
: null,
@ -212,8 +214,8 @@ class Message extends StatelessWidget {
FutureBuilder<User?>(
future: event.fetchSenderUser(),
builder: (context, snapshot) {
final user =
snapshot.data ?? event.senderFromMemoryOrFallback;
final user = snapshot.data ??
event.senderFromMemoryOrFallback;
return Avatar(
mxContent: user.avatarUrl,
name: user.calcDisplayname(),
@ -231,26 +233,27 @@ class Message extends StatelessWidget {
children: [
if (!nextEventSameSender)
Padding(
padding:
const EdgeInsets.only(left: 8.0, bottom: 4),
padding: const EdgeInsets.only(
left: 8.0, bottom: 4),
child: ownMessage || event.room.isDirectChat
? const SizedBox(height: 12)
: FutureBuilder<User?>(
future: event.fetchSenderUser(),
builder: (context, snapshot) {
final displayname =
snapshot.data?.calcDisplayname() ??
final displayname = snapshot.data
?.calcDisplayname() ??
event.senderFromMemoryOrFallback
.calcDisplayname();
return Text(
displayname,
style: TextStyle(
fontSize: 12,
color:
(Theme.of(context).brightness ==
color: (Theme.of(context)
.brightness ==
Brightness.light
? displayname.color
: displayname.lightColorText),
: displayname
.lightColorText),
),
);
},
@ -278,7 +281,8 @@ class Message extends StatelessWidget {
duration: FluffyThemes.animationDuration,
curve: FluffyThemes.animationCurve,
child: Material(
color: noBubble ? Colors.transparent : color,
color:
noBubble ? Colors.transparent : color,
clipBehavior: Clip.antiAlias,
shape: RoundedRectangleBorder(
borderRadius: borderRadius,
@ -296,7 +300,8 @@ class Message extends StatelessWidget {
vertical: 8,
),
constraints: const BoxConstraints(
maxWidth: FluffyThemes.columnWidth * 1.5,
maxWidth:
FluffyThemes.columnWidth * 1.5,
),
child: Column(
mainAxisSize: MainAxisSize.min,
@ -306,10 +311,12 @@ class Message extends StatelessWidget {
if (event.relationshipType ==
RelationshipTypes.reply)
FutureBuilder<Event?>(
future: event.getReplyEvent(timeline),
builder:
(BuildContext context, snapshot) {
final replyEvent = snapshot.hasData
future: event
.getReplyEvent(timeline),
builder: (BuildContext context,
snapshot) {
final replyEvent = snapshot
.hasData
? snapshot.data!
: Event(
eventId: event
@ -318,27 +325,33 @@ class Message extends StatelessWidget {
'msgtype': 'm.text',
'body': '...',
},
senderId: event.senderId,
type: 'm.room.message',
senderId:
event.senderId,
type:
'm.room.message',
room: event.room,
status: EventStatus.sent,
status:
EventStatus.sent,
originServerTs:
DateTime.now(),
);
return Padding(
padding: const EdgeInsets.only(
padding:
const EdgeInsets.only(
bottom: 4.0,
),
child: InkWell(
borderRadius:
ReplyContent.borderRadius,
onTap: () => scrollToEventId(
borderRadius: ReplyContent
.borderRadius,
onTap: () =>
scrollToEventId(
replyEvent.eventId,
),
child: AbsorbPointer(
child: ReplyContent(
replyEvent,
ownMessage: ownMessage,
ownMessage:
ownMessage,
timeline: timeline,
),
),
@ -361,18 +374,20 @@ class Message extends StatelessWidget {
top: 4.0,
),
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisSize:
MainAxisSize.min,
children: [
Icon(
Icons.edit_outlined,
color: textColor.withAlpha(164),
color: textColor
.withAlpha(164),
size: 14,
),
Text(
' - ${displayEvent.originServerTs.localizedTimeShort(context)}',
style: TextStyle(
color:
textColor.withAlpha(164),
color: textColor
.withAlpha(164),
fontSize: 12,
),
),