From dd392fcb025978731506dfda29a0c559c0280170 Mon Sep 17 00:00:00 2001 From: ggurdin <46800240+ggurdin@users.noreply.github.com> Date: Fri, 7 Mar 2025 15:33:44 -0500 Subject: [PATCH] chore: adjust scrolling / positioning for new toolbar buttons columns (#2086) --- lib/config/app_config.dart | 4 +- .../widgets/message_selection_positioner.dart | 37 ++++++++++--------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/lib/config/app_config.dart b/lib/config/app_config.dart index 9d7fac030..23459b96e 100644 --- a/lib/config/app_config.dart +++ b/lib/config/app_config.dart @@ -23,7 +23,7 @@ abstract class AppConfig { static const double messageFontSize = 16.0; static const bool allowOtherHomeservers = true; static const bool enableRegistration = true; - static const double toolbarMaxHeight = 300.0; + static const double toolbarMaxHeight = 175.0; static const double toolbarMinHeight = 140.0; static const double toolbarMinWidth = 350.0; static const double toolbarButtonsColumnWidth = 50.0; @@ -31,6 +31,8 @@ abstract class AppConfig { static const double defaultHeaderHeight = 56.0; static const double readingAssistanceInputBarHeight = 150; static const double toolbarSpacing = 8.0; + static const double toolbarIconSize = 24.0; + static const double toolbarButtonsColumnHeight = 240; static TextStyle messageTextStyle( Event? event, Color textColor, diff --git a/lib/pangea/toolbar/widgets/message_selection_positioner.dart b/lib/pangea/toolbar/widgets/message_selection_positioner.dart index 5377f0274..7a3ddc66d 100644 --- a/lib/pangea/toolbar/widgets/message_selection_positioner.dart +++ b/lib/pangea/toolbar/widgets/message_selection_positioner.dart @@ -113,18 +113,16 @@ class MessageSelectionPositionerState extends State // one for within the toolbar itself, one for the top, and one for the bottom ((AppConfig.toolbarSpacing * 3) + _reactionsHeight + - _toolbarButtonsHeight + AppConfig.toolbarMaxHeight); + _adjustedMessageHeight = max(_adjustedMessageHeight!, 0); } // if the overlay could have header overflow if the message wasn't shifted, we want to shift // it down so the bottom to give it enough space. if (hasHeaderOverflow) { // what is the distance between the current top offset of the toolbar and the desired top offset? - final double currentTopOffset = - _messageTopOffset - AppConfig.toolbarMaxHeight; final double neededShift = - (_headerHeight - currentTopOffset) + AppConfig.toolbarSpacing; + (_headerHeight - _totalToolbarTopOffset) + AppConfig.toolbarSpacing; adjustedBottomOffset = _totalToolbarBottomOffset - neededShift; } else if (hasFooterOverflow) { adjustedBottomOffset = _footerHeight + AppConfig.toolbarSpacing; @@ -259,10 +257,11 @@ class MessageSelectionPositionerState extends State ); } - double get _messageTopOffset => - _messageOffset.dy - - (_mediaQuery?.padding.top ?? 0) + - (_mediaQuery?.viewPadding.top ?? 0); + double get _messageTopOffset { + return _messageOffset.dy - + (_mediaQuery?.padding.top ?? 0) + + (_mediaQuery?.viewPadding.top ?? 0); + } double get _messageBottomOffset => _mediaQuery!.size.height - _messageOffset.dy - _messageHeight; @@ -312,9 +311,6 @@ class MessageSelectionPositionerState extends State widget.pangeaMessageEvent!.shouldShowToolbar && widget.pangeaMessageEvent!.event.messageType == MessageTypes.Text; - double get _toolbarButtonsHeight => - showToolbarButtons ? AppConfig.toolbarButtonsColumnWidth : 0; - bool get _hasReactions { final reactionsEvents = widget.event.aggregatedEvents( widget.chatController.timeline!, @@ -325,16 +321,23 @@ class MessageSelectionPositionerState extends State double get _reactionsHeight => _hasReactions ? 28 : 0; - double get _maxTotalToolbarHeight => - _toolbarButtonsHeight + + double get _maxTotalCenterHeight => _reactionsHeight + _messageHeight + AppConfig.toolbarSpacing + AppConfig.toolbarMaxHeight; - double get _totalToolbarTopOffset => - _messageTopOffset - - (AppConfig.toolbarSpacing + AppConfig.toolbarMaxHeight); + double get _maxTotalToolbarHeight { + return max(AppConfig.toolbarButtonsColumnHeight, _maxTotalCenterHeight); + } + + double get _totalToolbarTopOffset { + final topOffset = _messageTopOffset - + (AppConfig.toolbarSpacing + AppConfig.toolbarMaxHeight); + final addedColumnOffset = + max(AppConfig.toolbarButtonsColumnHeight - _maxTotalCenterHeight, 0); + return topOffset - addedColumnOffset; + } double get _totalToolbarBottomOffset => _messageBottomOffset - _reactionsHeight; @@ -391,7 +394,7 @@ class MessageSelectionPositionerState extends State overlayController: widget.overlayController, shouldShowToolbarButtons: showToolbarButtons, width: AppConfig.toolbarButtonsColumnWidth, - height: 100 + AppConfig.toolbarMinHeight, + height: AppConfig.toolbarButtonsColumnHeight, ), OverlayCenterContent( messageHeight: _messageHeight,