mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-16 05:40:46 +10:00
feat: add ChatScrollController and JumpToBottomButton for improved chat scrolling experience
- Implemented ChatScrollController to manage scroll behavior and visibility of jump-to-bottom button. - Added functionality to automatically scroll to the bottom when the keyboard opens. - Created JumpToBottomButton widget that appears when the user scrolls up, allowing quick navigation back to the bottom of the chat.
This commit is contained in:
@@ -146,6 +146,7 @@ class MeshCoreConnector extends ChangeNotifier {
|
||||
final Set<String> _knownContactKeys = {};
|
||||
final Map<String, int> _contactLastReadMs = {};
|
||||
final Map<int, int> _channelLastReadMs = {};
|
||||
bool _unreadStateLoaded = false;
|
||||
final Map<String, _RepeaterAckContext> _pendingRepeaterAcks = {};
|
||||
String? _activeContactKey;
|
||||
int? _activeChannelIndex;
|
||||
@@ -317,6 +318,7 @@ class MeshCoreConnector extends ChangeNotifier {
|
||||
}
|
||||
|
||||
int getUnreadCountForContactKey(String contactKeyHex) {
|
||||
if (!_unreadStateLoaded) return 0;
|
||||
if (!_shouldTrackUnreadForContactKey(contactKeyHex)) return 0;
|
||||
final messages = _conversations[contactKeyHex];
|
||||
if (messages == null || messages.isEmpty) return 0;
|
||||
@@ -336,6 +338,7 @@ class MeshCoreConnector extends ChangeNotifier {
|
||||
}
|
||||
|
||||
int getUnreadCountForChannelIndex(int channelIndex) {
|
||||
if (!_unreadStateLoaded) return 0;
|
||||
final messages = _channelMessages[channelIndex];
|
||||
if (messages == null || messages.isEmpty) return 0;
|
||||
final lastReadMs = _channelLastReadMs[channelIndex] ?? 0;
|
||||
@@ -350,6 +353,7 @@ class MeshCoreConnector extends ChangeNotifier {
|
||||
}
|
||||
|
||||
int getTotalUnreadCount() {
|
||||
if (!_unreadStateLoaded) return 0;
|
||||
var total = 0;
|
||||
// Count unread contact messages
|
||||
for (final contact in _contacts) {
|
||||
@@ -381,6 +385,7 @@ class MeshCoreConnector extends ChangeNotifier {
|
||||
_channelLastReadMs
|
||||
..clear()
|
||||
..addAll(await _unreadStore.loadChannelLastRead());
|
||||
_unreadStateLoaded = true;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user