Skip to content

Commit 4220965

Browse files
committed
chore: test size transitions
1 parent e3a6d30 commit 4220965

File tree

2 files changed

+87
-79
lines changed

2 files changed

+87
-79
lines changed

lib/chat/view/chat_room/chat_timeline_list.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ class _ChatTimelineListState extends State<ChatTimelineList> {
110110
index: i,
111111
controller: _controller,
112112
key: ValueKey('${event.eventId}tag'),
113-
child: FadeTransition(
114-
opacity: animation,
113+
child: SizeTransition(
114+
sizeFactor: animation,
115115
child: ChatEventColumn(
116116
key: ValueKey('${event.eventId}column'),
117117
event: event,

lib/chat/view/events/chat_message_bubble.dart

Lines changed: 85 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -136,91 +136,99 @@ class _ChatMessageBubbleContent extends StatelessWidget {
136136
final messageStyle = textTheme.bodyMedium;
137137
final displayEvent = event.getDisplayEvent(timeline);
138138

139-
return Row(
140-
crossAxisAlignment: CrossAxisAlignment.start,
141-
mainAxisSize: MainAxisSize.min,
142-
spacing: kSmallPadding,
143-
children: [
144-
Padding(
145-
padding: const EdgeInsets.all(kSmallPadding),
146-
child: hideAvatar || event.messageType == MessageTypes.BadEncrypted
147-
? const SizedBox.shrink()
148-
: event.messageType == MessageTypes.Text
149-
? ChatAvatar(
150-
avatarUri: event.senderFromMemoryOrFallback.avatarUrl,
151-
onTap: () => showDialog(
152-
context: context,
153-
builder: (context) =>
154-
ChatProfileDialog(userId: event.senderId),
155-
),
156-
fallBackColor: getMonochromeBg(
157-
theme: context.theme,
158-
factor: 10,
159-
darkFactor: yaru ? 1 : null,
160-
),
161-
)
162-
: ChatMessageMediaAvatar(event: event),
163-
),
164-
Flexible(
165-
child: Column(
166-
crossAxisAlignment: CrossAxisAlignment.start,
167-
mainAxisSize: MainAxisSize.min,
168-
children: [
169-
const SizedBox(
170-
height: kSmallPadding,
139+
final hide = hideAvatar && event.messageType == MessageTypes.Text;
140+
141+
final Widget chatBubbleAvatar;
142+
if (hide) {
143+
chatBubbleAvatar = const SizedBox.shrink();
144+
} else {
145+
chatBubbleAvatar = event.messageType == MessageTypes.Text
146+
? ChatAvatar(
147+
avatarUri: event.senderFromMemoryOrFallback.avatarUrl,
148+
onTap: () => showDialog(
149+
context: context,
150+
builder: (context) => ChatProfileDialog(userId: event.senderId),
171151
),
172-
Row(
173-
mainAxisSize: MainAxisSize.min,
174-
children: [
175-
Flexible(
176-
child: Text(
177-
event.senderFromMemoryOrFallback.calcDisplayname(),
178-
style: textTheme.labelSmall,
179-
),
180-
),
181-
if (!event.redacted)
152+
fallBackColor: getMonochromeBg(
153+
theme: context.theme,
154+
factor: 10,
155+
darkFactor: yaru ? 1 : null,
156+
),
157+
)
158+
: ChatMessageMediaAvatar(event: event);
159+
}
160+
return Material(
161+
color: Colors.transparent,
162+
child: Row(
163+
crossAxisAlignment: CrossAxisAlignment.start,
164+
mainAxisSize: MainAxisSize.min,
165+
spacing: kSmallPadding,
166+
children: [
167+
Padding(
168+
padding: const EdgeInsets.all(kSmallPadding),
169+
child: chatBubbleAvatar,
170+
),
171+
Flexible(
172+
child: Column(
173+
crossAxisAlignment: CrossAxisAlignment.start,
174+
mainAxisSize: MainAxisSize.min,
175+
children: [
176+
const SizedBox(
177+
height: kSmallPadding,
178+
),
179+
Row(
180+
mainAxisSize: MainAxisSize.min,
181+
children: [
182182
Flexible(
183-
child: ChatMessageReplyHeader(
184-
event: event,
185-
timeline: timeline,
186-
onReplyOriginClick: onReplyOriginClick,
183+
child: Text(
184+
event.senderFromMemoryOrFallback.calcDisplayname(),
185+
style: textTheme.labelSmall,
187186
),
188187
),
189-
],
190-
),
191-
Opacity(
192-
opacity: event.redacted ? 0.5 : 1,
193-
child: event.redacted
194-
? LocalizedDisplayEventText(
195-
displayEvent: displayEvent,
196-
style: messageStyle?.copyWith(
197-
decoration: TextDecoration.lineThrough,
188+
if (!event.redacted)
189+
Flexible(
190+
child: ChatMessageReplyHeader(
191+
event: event,
192+
timeline: timeline,
193+
onReplyOriginClick: onReplyOriginClick,
198194
),
199-
)
200-
: event.isRichMessage
201-
? HtmlMessage(
202-
html: html,
203-
room: timeline.room,
204-
defaultTextColor: context.colorScheme.onSurface,
205-
)
206-
: SelectableText.rich(
207-
TextSpan(
195+
),
196+
],
197+
),
198+
Opacity(
199+
opacity: event.redacted ? 0.5 : 1,
200+
child: event.redacted
201+
? LocalizedDisplayEventText(
202+
displayEvent: displayEvent,
203+
style: messageStyle?.copyWith(
204+
decoration: TextDecoration.lineThrough,
205+
),
206+
)
207+
: event.isRichMessage
208+
? HtmlMessage(
209+
html: html,
210+
room: timeline.room,
211+
defaultTextColor: context.colorScheme.onSurface,
212+
)
213+
: SelectableText.rich(
214+
TextSpan(
215+
style: messageStyle,
216+
text: displayEvent.body,
217+
),
208218
style: messageStyle,
209-
text: displayEvent.body,
210219
),
211-
style: messageStyle,
212-
),
213-
),
214-
const SizedBox(
215-
height: kBigPadding,
216-
),
217-
],
220+
),
221+
const SizedBox(
222+
height: kBigPadding,
223+
),
224+
],
225+
),
218226
),
219-
),
220-
const SizedBox(
221-
height: kSmallPadding,
222-
),
223-
],
227+
const SizedBox(
228+
height: kSmallPadding,
229+
),
230+
],
231+
),
224232
);
225233
}
226234
}

0 commit comments

Comments
 (0)