Merge pull request #679 from pangeachat/handle-header-overflow

added header height to overflow calculations when scrolling overlay t…
This commit is contained in:
ggurdin 2024-09-13 12:20:18 -04:00 committed by GitHub
commit 82c95e4825
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -66,7 +66,7 @@ class MessageSelectionOverlayState extends State<MessageSelectionOverlay>
screenHeight - messageOffset!.dy - messageSize!.height;
final bool hasHeaderOverflow =
messageOffset!.dy < AppConfig.toolbarMaxHeight;
messageOffset!.dy < (AppConfig.toolbarMaxHeight + headerHeight);
final bool hasFooterOverflow = footerHeight > currentBottomOffset;
if (!hasHeaderOverflow && !hasFooterOverflow) return;
@ -75,19 +75,27 @@ class MessageSelectionOverlayState extends State<MessageSelectionOverlay>
double animationEndOffset = 0;
final midpoint = (headerBottomOffset + footerBottomOffset) / 2;
if (hasHeaderOverflow) {
// if the overlay would have a footer overflow for this message,
// check if shifting the overlay up could cause a header overflow
final bottomOffsetDifference = footerHeight - currentBottomOffset;
final newTopOffset = messageOffset!.dy - bottomOffsetDifference;
final bool upshiftCausesHeaderOverflow = hasFooterOverflow &&
newTopOffset < (headerHeight + AppConfig.toolbarMaxHeight);
if (hasHeaderOverflow || upshiftCausesHeaderOverflow) {
animationEndOffset = midpoint - messageSize!.height;
final totalTopOffset =
animationEndOffset + messageSize!.height + AppConfig.toolbarMaxHeight;
final remainingSpace = screenHeight - totalTopOffset;
if (remainingSpace < headerHeight) {
// the overlay could run over the header, so it needs to be shifted down
animationEndOffset -= (headerHeight - remainingSpace);
}
scrollOffset = animationEndOffset - currentBottomOffset;
} else if (hasFooterOverflow) {
scrollOffset = footerHeight - currentBottomOffset;
animationEndOffset = footerHeight;
final bottomOffsetDifference = footerHeight - currentBottomOffset;
final newTopOffset = messageOffset!.dy - bottomOffsetDifference;
if (newTopOffset < (headerHeight + AppConfig.toolbarMaxHeight)) {
animationEndOffset = midpoint - messageSize!.height;
scrollOffset = animationEndOffset - currentBottomOffset;
}
}
_overlayPositionAnimation = Tween<double>(