fix scroll to bottom button
This commit is contained in:
@@ -309,19 +309,8 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
return messageWidget;
|
return messageWidget;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if (streamChannel.channel.state.members.contains((Member e) =>
|
if (widget.showScrollToBottom && _showScrollToBottom)
|
||||||
e.userId == streamChannel.channel.client.state.user.id) &&
|
_buildScrollToBottom(),
|
||||||
widget.showScrollToBottom)
|
|
||||||
StreamBuilder<int>(
|
|
||||||
stream: streamChannel.channel.state.unreadCountStream,
|
|
||||||
builder: (context, snapshot) {
|
|
||||||
if (!_showScrollToBottom ||
|
|
||||||
!snapshot.hasData ||
|
|
||||||
snapshot.data == 0) {
|
|
||||||
return SizedBox();
|
|
||||||
}
|
|
||||||
return _buildScrollToBottom(snapshot.data);
|
|
||||||
}),
|
|
||||||
Positioned(
|
Positioned(
|
||||||
top: 20.0,
|
top: 20.0,
|
||||||
child: ValueListenableBuilder<Iterable<ItemPosition>>(
|
child: ValueListenableBuilder<Iterable<ItemPosition>>(
|
||||||
@@ -364,7 +353,8 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
position.itemLeadingEdge > max.itemLeadingEdge ? position : max);
|
position.itemLeadingEdge > max.itemLeadingEdge ? position : max);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildScrollToBottom(int unreadCount) {
|
Widget _buildScrollToBottom() {
|
||||||
|
final streamChannel = StreamChannel.of(context);
|
||||||
return Positioned(
|
return Positioned(
|
||||||
bottom: 8,
|
bottom: 8,
|
||||||
right: 8,
|
right: 8,
|
||||||
@@ -389,24 +379,34 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Positioned(
|
if (streamChannel.channel.state.members.any((Member e) =>
|
||||||
width: 20,
|
e.userId == streamChannel.channel.client.state.user.id))
|
||||||
height: 20,
|
StreamBuilder<int>(
|
||||||
left: 10,
|
stream: streamChannel.channel.state.unreadCountStream,
|
||||||
top: -10,
|
initialData: streamChannel.channel.state.unreadCount,
|
||||||
child: CircleAvatar(
|
builder: (context, snapshot) {
|
||||||
child: Padding(
|
if (!snapshot.hasData || snapshot.data <= 0) {
|
||||||
padding: const EdgeInsets.all(3.0),
|
return Offstage();
|
||||||
child: Text(
|
}
|
||||||
unreadCount.toString(),
|
return Positioned(
|
||||||
style: TextStyle(
|
width: 20,
|
||||||
fontSize: 11,
|
height: 20,
|
||||||
fontWeight: FontWeight.bold,
|
left: 10,
|
||||||
),
|
top: -10,
|
||||||
),
|
child: CircleAvatar(
|
||||||
),
|
child: Padding(
|
||||||
),
|
padding: const EdgeInsets.all(3.0),
|
||||||
),
|
child: Text(
|
||||||
|
snapshot.data.toString(),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 11,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user