Merge pull request #196 from GetStream/hotfix/mentions

Only 4 mentions allowed at a time
This commit is contained in:
Salvatore Giordano
2021-01-07 16:39:32 +01:00
committed by GitHub
2 changed files with 145 additions and 65 deletions
+101 -29
View File
@@ -1132,7 +1132,8 @@ class MessageInputState extends State<MessageInput> {
RenderBox renderBox = context.findRenderObject(); RenderBox renderBox = context.findRenderObject();
final size = renderBox.size; final size = renderBox.size;
return OverlayEntry(builder: (context) { return OverlayEntry(
builder: (context) {
return Positioned( return Positioned(
bottom: size.height + MediaQuery.of(context).viewInsets.bottom, bottom: size.height + MediaQuery.of(context).viewInsets.bottom,
left: 0, left: 0,
@@ -1153,7 +1154,7 @@ class MessageInputState extends State<MessageInput> {
), ),
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
child: Container( child: Container(
constraints: BoxConstraints.loose(Size.fromHeight(400)), constraints: BoxConstraints.loose(Size.fromHeight(240)),
decoration: BoxDecoration( decoration: BoxDecoration(
color: StreamChatTheme.of(context).colorTheme.white, color: StreamChatTheme.of(context).colorTheme.white,
), ),
@@ -1164,28 +1165,17 @@ class MessageInputState extends State<MessageInput> {
return ListView( return ListView(
padding: const EdgeInsets.all(0), padding: const EdgeInsets.all(0),
shrinkWrap: true, shrinkWrap: true,
children: snapshot.data children: [
.map((m) => ListTile( SizedBox(
leading: UserAvatar( height: 8.0,
constraints: BoxConstraints.tight(
Size(
40,
40,
), ),
), ...snapshot.data.map(
user: m.user, (m) {
), return Material(
title: Text(
'${m.user.name}',
style: TextStyle(
fontWeight: FontWeight.bold),
),
subtitle: Text('@${m.userId}'),
trailing: StreamSvgIcon.mentions(
color: StreamChatTheme.of(context) color: StreamChatTheme.of(context)
.colorTheme .colorTheme
.accentBlue, .white,
), child: InkWell(
onTap: () { onTap: () {
_mentionedUsers.add(m.user); _mentionedUsers.add(m.user);
@@ -1196,8 +1186,7 @@ class MessageInputState extends State<MessageInput> {
TextEditingValue( TextEditingValue(
text: rejoin + text: rejoin +
textEditingController.text textEditingController.text
.substring( .substring(textEditingController
textEditingController
.selection.start), .selection.start),
selection: TextSelection.collapsed( selection: TextSelection.collapsed(
offset: rejoin.length, offset: rejoin.length,
@@ -1207,16 +1196,99 @@ class MessageInputState extends State<MessageInput> {
_mentionsOverlay?.remove(); _mentionsOverlay?.remove();
_mentionsOverlay = null; _mentionsOverlay = null;
}, },
)) child: Container(
.toList(), height: 56.0,
); child: Row(
}), crossAxisAlignment:
CrossAxisAlignment.center,
children: [
SizedBox(
width: 16.0,
),
UserAvatar(
constraints: BoxConstraints.tight(
Size(
40,
40,
),
),
user: m.user,
),
SizedBox(
width: 8.0,
),
Expanded(
child: Align(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'${m.user.name}',
maxLines: 1,
overflow:
TextOverflow.ellipsis,
style: StreamChatTheme.of(
context)
.textTheme
.bodyBold,
),
SizedBox(
height: 2.0,
),
Text(
'@${m.userId}',
maxLines: 1,
overflow:
TextOverflow.ellipsis,
style: StreamChatTheme.of(
context)
.textTheme
.footnoteBold
.copyWith(
color: StreamChatTheme
.of(context)
.colorTheme
.grey),
),
],
),
),
),
Padding(
padding: const EdgeInsets.only(
right: 18.0, left: 8.0),
child: StreamSvgIcon.mentions(
color: StreamChatTheme.of(context)
.colorTheme
.accentBlue,
),
),
],
),
), ),
), ),
); );
}), },
).toList(),
SizedBox(
height: 8.0,
),
],
);
},
),
),
),
);
},
),
);
},
); );
});
} }
OverlayEntry _buildEmojiOverlay() { OverlayEntry _buildEmojiOverlay() {
+10 -2
View File
@@ -42,10 +42,18 @@ void main() {
user: User(id: 'user-id'), user: User(id: 'user-id'),
), ),
]); ]);
when(channelState.lastMessage).thenReturn(Message( when(channelState.messages).thenReturn([
Message(
text: 'hello', text: 'hello',
user: User(id: 'other-user'), user: User(id: 'other-user'),
)); )
]);
when(channelState.messagesStream).thenAnswer((i) => Stream.value([
Message(
text: 'hello',
user: User(id: 'other-user'),
)
]));
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: StreamChat( home: StreamChat(