From 623c3bfc2e65d9cb3ea2774939d8e3afa108cddb Mon Sep 17 00:00:00 2001 From: Krille Date: Tue, 9 May 2023 15:14:35 +0200 Subject: [PATCH] fix: Scroll down button --- lib/pages/chat/chat.dart | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart index 64649675..4ae011c2 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -151,7 +151,10 @@ class ChatController extends State { Event? editEvent; - bool showScrollDownButton = false; + bool _scrolledUp = false; + + bool get showScrollDownButton => + _scrolledUp || timeline?.allowNewEvent == false; bool get selectMode => selectedEvents.isNotEmpty; @@ -247,11 +250,10 @@ class ChatController extends State { requestFuture(); } if (timeline?.allowNewEvent == false || - scrollController.position.pixels > 0 && showScrollDownButton == false) { - setState(() => showScrollDownButton = true); - } else if (scrollController.position.pixels == 0 && - showScrollDownButton == true) { - setState(() => showScrollDownButton = false); + scrollController.position.pixels > 0 && _scrolledUp == false) { + setState(() => _scrolledUp = true); + } else if (scrollController.position.pixels == 0 && _scrolledUp == true) { + setState(() => _scrolledUp = false); } } @@ -805,6 +807,7 @@ class ChatController extends State { if (eventIndex == -1) { setState(() { timeline = null; + _scrolledUp = false; loadTimelineFuture = _getTimeline( eventContextId: eventId, timeout: const Duration(seconds: 30), @@ -827,6 +830,7 @@ class ChatController extends State { if (!timeline!.allowNewEvent) { setState(() { timeline = null; + _scrolledUp = false; loadTimelineFuture = _getTimeline(); }); await loadTimelineFuture;