feat: Added sticky header to display position data
This commit is contained in:
@@ -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/message_widget.dart';
|
||||||
import 'package:stream_chat_flutter/src/system_message.dart';
|
import 'package:stream_chat_flutter/src/system_message.dart';
|
||||||
import 'package:visibility_detector/visibility_detector.dart';
|
import 'package:visibility_detector/visibility_detector.dart';
|
||||||
|
import 'package:widgets_visibility_provider/widgets_visibility_provider.dart';
|
||||||
|
|
||||||
import '../stream_chat_flutter.dart';
|
import '../stream_chat_flutter.dart';
|
||||||
import 'date_divider.dart';
|
import 'date_divider.dart';
|
||||||
@@ -149,13 +150,16 @@ 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) {
|
||||||
final streamChannel = StreamChannel.of(context);
|
final streamChannel = StreamChannel.of(context);
|
||||||
|
|
||||||
/// TODO: find a better solution when (https://github.com/flutter/flutter/issues/21023) is fixed
|
/// TODO: find a better solution when (https://github.com/flutter/flutter/issues/21023) is fixed
|
||||||
return Stack(
|
return WidgetsVisibilityProvider(
|
||||||
|
condition: (c) => null,
|
||||||
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
NotificationListener<ScrollNotification>(
|
NotificationListener<ScrollNotification>(
|
||||||
onNotification: (_) {
|
onNotification: (_) {
|
||||||
@@ -268,7 +272,7 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return messageWidget;
|
return VisibleNotifierWidget(child: messageWidget);
|
||||||
},
|
},
|
||||||
childCount: _messages.length + 2,
|
childCount: _messages.length + 2,
|
||||||
findChildIndexCallback: (key) {
|
findChildIndexCallback: (key) {
|
||||||
@@ -292,7 +296,21 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
}
|
}
|
||||||
return _buildScrollToBottom(streamChannel);
|
return _buildScrollToBottom(streamChannel);
|
||||||
}),
|
}),
|
||||||
|
Positioned(
|
||||||
|
top: 20.0,
|
||||||
|
child: WidgetsVisibilityListener(
|
||||||
|
listener: (context, event) {
|
||||||
|
setState(() {
|
||||||
|
positionData = event.positionDataList.first.startPosition;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Chip(
|
||||||
|
label: Text(positionData.toString()),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ dependencies:
|
|||||||
flutter_slidable: ^0.5.4
|
flutter_slidable: ^0.5.4
|
||||||
carousel_slider: ^2.2.1
|
carousel_slider: ^2.2.1
|
||||||
clipboard: ^0.1.2+8
|
clipboard: ^0.1.2+8
|
||||||
|
widgets_visibility_provider: ^2.0.2
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
fonts:
|
fonts:
|
||||||
|
|||||||
Reference in New Issue
Block a user