Merge pull request #196 from GetStream/hotfix/mentions
Only 4 mentions allowed at a time
This commit is contained in:
+133
-61
@@ -1132,12 +1132,13 @@ 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(
|
||||||
return Positioned(
|
builder: (context) {
|
||||||
bottom: size.height + MediaQuery.of(context).viewInsets.bottom,
|
return Positioned(
|
||||||
left: 0,
|
bottom: size.height + MediaQuery.of(context).viewInsets.bottom,
|
||||||
right: 0,
|
left: 0,
|
||||||
child: TweenAnimationBuilder<double>(
|
right: 0,
|
||||||
|
child: TweenAnimationBuilder<double>(
|
||||||
tween: Tween(begin: 0.0, end: 1.0),
|
tween: Tween(begin: 0.0, end: 1.0),
|
||||||
duration: Duration(milliseconds: 300),
|
duration: Duration(milliseconds: 300),
|
||||||
curve: Curves.easeInOutExpo,
|
curve: Curves.easeInOutExpo,
|
||||||
@@ -1153,70 +1154,141 @@ 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,
|
||||||
),
|
),
|
||||||
child: FutureBuilder<List<Member>>(
|
child: FutureBuilder<List<Member>>(
|
||||||
future: queryMembers ?? Future.value(members),
|
future: queryMembers ?? Future.value(members),
|
||||||
initialData: members,
|
initialData: members,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
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(
|
...snapshot.data.map(
|
||||||
40,
|
(m) {
|
||||||
40,
|
return Material(
|
||||||
),
|
color: StreamChatTheme.of(context)
|
||||||
|
.colorTheme
|
||||||
|
.white,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
_mentionedUsers.add(m.user);
|
||||||
|
|
||||||
|
splits[splits.length - 1] = m.user.name;
|
||||||
|
final rejoin = splits.join('@');
|
||||||
|
|
||||||
|
textEditingController.value =
|
||||||
|
TextEditingValue(
|
||||||
|
text: rejoin +
|
||||||
|
textEditingController.text
|
||||||
|
.substring(textEditingController
|
||||||
|
.selection.start),
|
||||||
|
selection: TextSelection.collapsed(
|
||||||
|
offset: rejoin.length,
|
||||||
),
|
),
|
||||||
user: m.user,
|
);
|
||||||
),
|
_debounce.cancel();
|
||||||
title: Text(
|
_mentionsOverlay?.remove();
|
||||||
'${m.user.name}',
|
_mentionsOverlay = null;
|
||||||
style: TextStyle(
|
},
|
||||||
fontWeight: FontWeight.bold),
|
child: Container(
|
||||||
),
|
height: 56.0,
|
||||||
subtitle: Text('@${m.userId}'),
|
child: Row(
|
||||||
trailing: StreamSvgIcon.mentions(
|
crossAxisAlignment:
|
||||||
color: StreamChatTheme.of(context)
|
CrossAxisAlignment.center,
|
||||||
.colorTheme
|
children: [
|
||||||
.accentBlue,
|
SizedBox(
|
||||||
),
|
width: 16.0,
|
||||||
onTap: () {
|
|
||||||
_mentionedUsers.add(m.user);
|
|
||||||
|
|
||||||
splits[splits.length - 1] = m.user.name;
|
|
||||||
final rejoin = splits.join('@');
|
|
||||||
|
|
||||||
textEditingController.value =
|
|
||||||
TextEditingValue(
|
|
||||||
text: rejoin +
|
|
||||||
textEditingController.text
|
|
||||||
.substring(
|
|
||||||
textEditingController
|
|
||||||
.selection.start),
|
|
||||||
selection: TextSelection.collapsed(
|
|
||||||
offset: rejoin.length,
|
|
||||||
),
|
),
|
||||||
);
|
UserAvatar(
|
||||||
_debounce.cancel();
|
constraints: BoxConstraints.tight(
|
||||||
_mentionsOverlay?.remove();
|
Size(
|
||||||
_mentionsOverlay = null;
|
40,
|
||||||
},
|
40,
|
||||||
))
|
),
|
||||||
.toList(),
|
),
|
||||||
);
|
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() {
|
||||||
|
|||||||
@@ -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([
|
||||||
text: 'hello',
|
Message(
|
||||||
user: User(id: 'other-user'),
|
text: 'hello',
|
||||||
));
|
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(
|
||||||
|
|||||||
Reference in New Issue
Block a user