stream-chat-flutter icon indicating copy to clipboard operation
stream-chat-flutter copied to clipboard

support to customize the duration of scrolling to bottom

Open chenbokun97 opened this issue 1 year ago • 0 comments

Please select which package this feature is related to

stream_chat_flutter

Which platforms would this feature impact?

iOS

Is your feature request related to a problem?

No response

Describe the solution that you'd like

add a parameter to customize the duration of scrolling to bottom in function scrollToBottomDefaultTapAction

Future<void> scrollToBottomDefaultTapAction(int unreadCount) async {
    this.unreadCount = unreadCount;
    if (unreadCount > 0) {
      streamChannel!.channel.markRead();
    }

    // If the channel is not up to date, we need to reload it before scrolling
    // to the end of the list.
    if (!_upToDate) {
      // Reset the pagination variables.
      initialIndex = 0;
      initialAlignment = 0;
      _bottomPaginationActive = false;

      // Reload the channel to get the latest messages.
      await streamChannel!.reloadChannel();

      // Wait for the frame to be rendered with the updated channel state.
      await WidgetsBinding.instance.endOfFrame;
    }

    // Scroll to the end of the list.
    if (_scrollController?.isAttached == true) {
      _scrollController!.scrollTo(
        index: 0,
        duration: const Duration(seconds: **customizedDuration**),
        curve: Curves.easeInOut,
      );
    }
  }

Describe alternatives that you have considered

We can pass our own scrollToBottomTapAction to solve this, but there are so many other functions in the default tap action, and it's hard to override and maintain them, such as the controller, and some private variables. Currently the scrolling speed is too slow, so could you help to add a parameter to customize this duration? It would be helpful, thanks.

Additional context

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

chenbokun97 avatar Mar 12 '24 03:03 chenbokun97