feat: Added sticky header to display position data
This commit is contained in:
@@ -150,7 +150,6 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
List<Message> _newMessageList = [];
|
List<Message> _newMessageList = [];
|
||||||
Function _onThreadTap;
|
Function _onThreadTap;
|
||||||
bool _showScrollToBottom = false;
|
bool _showScrollToBottom = false;
|
||||||
var positionData;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -164,7 +163,8 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
children: [
|
children: [
|
||||||
NotificationListener<ScrollNotification>(
|
NotificationListener<ScrollNotification>(
|
||||||
onNotification: (_) {
|
onNotification: (_) {
|
||||||
if (_scrollController.offset < 150 && _newMessageList.isNotEmpty) {
|
if (_scrollController.offset < 150 &&
|
||||||
|
_newMessageList.isNotEmpty) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_messages.insertAll(0, _newMessageList);
|
_messages.insertAll(0, _newMessageList);
|
||||||
_newMessageList.clear();
|
_newMessageList.clear();
|
||||||
@@ -193,7 +193,8 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
buildParentMessage(widget.parentMessage),
|
buildParentMessage(widget.parentMessage),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 32),
|
padding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 32),
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -273,7 +274,10 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return VisibleNotifierWidget(child: messageWidget, data: i,);
|
return VisibleNotifierWidget(
|
||||||
|
child: messageWidget,
|
||||||
|
data: i,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
childCount: _messages.length + 2,
|
childCount: _messages.length + 2,
|
||||||
findChildIndexCallback: (key) {
|
findChildIndexCallback: (key) {
|
||||||
@@ -297,19 +301,19 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
}
|
}
|
||||||
return _buildScrollToBottom(streamChannel);
|
return _buildScrollToBottom(streamChannel);
|
||||||
}),
|
}),
|
||||||
if(positionData != null)
|
|
||||||
Positioned(
|
Positioned(
|
||||||
top: 20.0,
|
top: 20.0,
|
||||||
child: WidgetsVisibilityListener(
|
child: WidgetsVisibilityConsumer(
|
||||||
listener: (context, event) {
|
builder: (context, event) {
|
||||||
setState(() {
|
if(event.positionDataList == null || event.positionDataList.isEmpty) {
|
||||||
positionData = event.positionDataList.isNotEmpty ? event.positionDataList[0].data : null;
|
return Container();
|
||||||
});
|
}
|
||||||
},
|
|
||||||
child: DateDivider(
|
return DateDivider(
|
||||||
dateTime: _messages[positionData].createdAt.toLocal(),
|
dateTime: _messages[event.positionDataList[0].data].createdAt.toLocal(),
|
||||||
),
|
);
|
||||||
),
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user