@@ -6,6 +6,7 @@ import 'package:stream_chat/stream_chat.dart';
|
||||
import 'package:stream_chat_flutter/src/message_widget.dart';
|
||||
import 'package:stream_chat_flutter/src/system_message.dart';
|
||||
import 'package:visibility_detector/visibility_detector.dart';
|
||||
import 'package:widgets_visibility_provider/widgets_visibility_provider.dart';
|
||||
|
||||
import '../stream_chat_flutter.dart';
|
||||
import 'date_divider.dart';
|
||||
@@ -155,11 +156,15 @@ class _MessageListViewState extends State<MessageListView> {
|
||||
final streamChannel = StreamChannel.of(context);
|
||||
|
||||
/// TODO: find a better solution when (https://github.com/flutter/flutter/issues/21023) is fixed
|
||||
return Stack(
|
||||
return WidgetsVisibilityProvider(
|
||||
condition: (c) => null,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
NotificationListener<ScrollNotification>(
|
||||
onNotification: (_) {
|
||||
if (_scrollController.offset < 150 && _newMessageList.isNotEmpty) {
|
||||
if (_scrollController.offset < 150 &&
|
||||
_newMessageList.isNotEmpty) {
|
||||
setState(() {
|
||||
_messages.insertAll(0, _newMessageList);
|
||||
_newMessageList.clear();
|
||||
@@ -188,7 +193,8 @@ class _MessageListViewState extends State<MessageListView> {
|
||||
children: <Widget>[
|
||||
buildParentMessage(widget.parentMessage),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 32),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 32),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Text(
|
||||
@@ -251,7 +257,9 @@ class _MessageListViewState extends State<MessageListView> {
|
||||
if (nextMessage != null &&
|
||||
!Jiffy(message.createdAt.toLocal())
|
||||
.isSame(nextMessage.createdAt.toLocal(), Units.DAY)) {
|
||||
return Column(
|
||||
return VisibleNotifierWidget(
|
||||
data: i,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
messageWidget,
|
||||
@@ -265,10 +273,14 @@ class _MessageListViewState extends State<MessageListView> {
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return messageWidget;
|
||||
return VisibleNotifierWidget(
|
||||
child: messageWidget,
|
||||
data: i,
|
||||
);
|
||||
},
|
||||
childCount: _messages.length + 2,
|
||||
findChildIndexCallback: (key) {
|
||||
@@ -292,7 +304,23 @@ class _MessageListViewState extends State<MessageListView> {
|
||||
}
|
||||
return _buildScrollToBottom(streamChannel);
|
||||
}),
|
||||
Positioned(
|
||||
top: 20.0,
|
||||
child: WidgetsVisibilityConsumer(
|
||||
listener: (context, event,) {},
|
||||
builder: (context, event) {
|
||||
if(event.positionDataList == null || event.positionDataList.isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
return DateDivider(
|
||||
dateTime: _messages[event.positionDataList.last.data].createdAt.toLocal(),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ dependencies:
|
||||
flutter_slidable: ^0.5.4
|
||||
carousel_slider: ^2.2.1
|
||||
clipboard: ^0.1.2+8
|
||||
widgets_visibility_provider: ^2.0.2
|
||||
|
||||
flutter:
|
||||
fonts:
|
||||
|
||||
Reference in New Issue
Block a user