chore: ScrollToEventId duration for jump in timeline

This commit is contained in:
Krille 2023-03-31 12:18:24 +02:00
parent dda90c85a4
commit 742dcb8f41
No known key found for this signature in database
2 changed files with 6 additions and 3 deletions

View File

@ -783,7 +783,7 @@ class ChatController extends State<ChatPageWithRoom> {
inputFocus.requestFocus();
}
void scrollToEventId(String eventId) async {
void scrollToEventId(String eventId, {Duration? duration}) async {
var eventIndex = timeline!.events.indexWhere((e) => e.eventId == eventId);
if (eventIndex == -1) {
setState(() {
@ -799,6 +799,7 @@ class ChatController extends State<ChatPageWithRoom> {
await scrollController.scrollToIndex(
eventIndex,
preferPosition: AutoScrollPosition.middle,
duration: duration ?? scrollAnimationDuration,
);
_updateScrollController();
}

View File

@ -345,8 +345,10 @@ class ChatView extends StatelessWidget {
child: Center(
child: FloatingActionButton.extended(
icon: const Icon(Icons.arrow_upward_outlined),
onPressed: () => controller
.scrollToEventId(controller.room.fullyRead),
onPressed: () => controller.scrollToEventId(
controller.room.fullyRead,
duration: Duration.zero,
),
label: Row(
mainAxisSize: MainAxisSize.min,
children: [