mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-23 20:49:26 +01:00
chore: ScrollToEventId duration for jump in timeline
This commit is contained in:
parent
dda90c85a4
commit
742dcb8f41
@ -783,7 +783,7 @@ class ChatController extends State<ChatPageWithRoom> {
|
|||||||
inputFocus.requestFocus();
|
inputFocus.requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void scrollToEventId(String eventId) async {
|
void scrollToEventId(String eventId, {Duration? duration}) async {
|
||||||
var eventIndex = timeline!.events.indexWhere((e) => e.eventId == eventId);
|
var eventIndex = timeline!.events.indexWhere((e) => e.eventId == eventId);
|
||||||
if (eventIndex == -1) {
|
if (eventIndex == -1) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -799,6 +799,7 @@ class ChatController extends State<ChatPageWithRoom> {
|
|||||||
await scrollController.scrollToIndex(
|
await scrollController.scrollToIndex(
|
||||||
eventIndex,
|
eventIndex,
|
||||||
preferPosition: AutoScrollPosition.middle,
|
preferPosition: AutoScrollPosition.middle,
|
||||||
|
duration: duration ?? scrollAnimationDuration,
|
||||||
);
|
);
|
||||||
_updateScrollController();
|
_updateScrollController();
|
||||||
}
|
}
|
||||||
|
@ -345,8 +345,10 @@ class ChatView extends StatelessWidget {
|
|||||||
child: Center(
|
child: Center(
|
||||||
child: FloatingActionButton.extended(
|
child: FloatingActionButton.extended(
|
||||||
icon: const Icon(Icons.arrow_upward_outlined),
|
icon: const Icon(Icons.arrow_upward_outlined),
|
||||||
onPressed: () => controller
|
onPressed: () => controller.scrollToEventId(
|
||||||
.scrollToEventId(controller.room.fullyRead),
|
controller.room.fullyRead,
|
||||||
|
duration: Duration.zero,
|
||||||
|
),
|
||||||
label: Row(
|
label: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
|
Loading…
Reference in New Issue
Block a user