Message List: Various fixes for bottom padding

This commit is contained in:
Alexander Zinchuk 2021-05-31 19:50:13 +03:00
parent 7681f5998c
commit 6dd0249541
7 changed files with 36 additions and 28 deletions

View File

@ -31,6 +31,7 @@ type OwnProps = {
observeIntersection?: ObserveFn; observeIntersection?: ObserveFn;
isEmbedded?: boolean; isEmbedded?: boolean;
appearanceOrder?: number; appearanceOrder?: number;
isLastInList?: boolean;
}; };
type StateProps = { type StateProps = {
@ -50,6 +51,7 @@ const ActionMessage: FC<OwnProps & StateProps> = ({
observeIntersection, observeIntersection,
isEmbedded, isEmbedded,
appearanceOrder = 0, appearanceOrder = 0,
isLastInList,
sender, sender,
targetUser, targetUser,
targetMessage, targetMessage,
@ -98,16 +100,19 @@ const ActionMessage: FC<OwnProps & StateProps> = ({
return <span className="embedded-action-message">{renderText(content as string)}</span>; return <span className="embedded-action-message">{renderText(content as string)}</span>;
} }
const className = buildClassName(
'ActionMessage message-list-item',
isFocused && !noFocusHighlight && 'focused',
isContextMenuShown && 'has-menu-open',
isLastInList && 'last-in-list',
transitionClassNames,
);
return ( return (
<div <div
ref={ref} ref={ref}
id={`message${message.id}`} id={`message${message.id}`}
className={buildClassName( className={className}
'ActionMessage message-list-item',
isFocused && !noFocusHighlight && 'focused',
isContextMenuShown && 'has-menu-open',
transitionClassNames,
)}
data-message-id={message.id} data-message-id={message.id}
onMouseDown={handleBeforeContextMenu} onMouseDown={handleBeforeContextMenu}
onContextMenu={handleContextMenu} onContextMenu={handleContextMenu}

View File

@ -50,21 +50,21 @@
.last-in-list { .last-in-list {
margin-bottom: 1rem; margin-bottom: 1rem;
} }
&.type-pinned {
.last-in-list {
margin-bottom: 5rem;
@media (max-width: 600px) {
margin-bottom: 3.75rem;
}
}
}
} }
&.select-mode-active { &.select-mode-active, &.type-pinned {
.messages-container { margin-bottom: 0;
padding-bottom: 4.75rem;
.last-in-list {
margin-bottom: 5.675rem;
&.ActionMessage {
padding-bottom: 0.075rem;
}
@media (max-width: 600px) {
margin-bottom: 4.3125rem;
}
} }
} }

View File

@ -609,6 +609,10 @@ function renderMessages(
) => { ) => {
if (senderGroup.length === 1 && !isAlbum(senderGroup[0]) && isActionMessage(senderGroup[0])) { if (senderGroup.length === 1 && !isAlbum(senderGroup[0]) && isActionMessage(senderGroup[0])) {
const message = senderGroup[0]; const message = senderGroup[0];
const isLastInList = (
senderGroupIndex === senderGroupsArray.length - 1
&& dateGroupIndex === dateGroupsArray.length - 1
);
return compact([ return compact([
message.id === memoFirstUnreadIdRef.current && unreadDivider, message.id === memoFirstUnreadIdRef.current && unreadDivider,
@ -617,6 +621,7 @@ function renderMessages(
message={message} message={message}
observeIntersection={observeIntersectionForReading} observeIntersection={observeIntersectionForReading}
appearanceOrder={messageCountToAnimate - ++appearanceIndex} appearanceOrder={messageCountToAnimate - ++appearanceIndex}
isLastInList={isLastInList}
/>, />,
]); ]);
} }

View File

@ -4,7 +4,6 @@ import React, {
} from '../../lib/teact/teact'; } from '../../lib/teact/teact';
import { MESSAGE_LIST_SENSITIVE_AREA } from '../../config'; import { MESSAGE_LIST_SENSITIVE_AREA } from '../../config';
import { IS_SAFARI } from '../../util/environment';
import resetScroll from '../../util/resetScroll'; import resetScroll from '../../util/resetScroll';
import { useIntersectionObserver, useOnIntersect } from '../../hooks/useIntersectionObserver'; import { useIntersectionObserver, useOnIntersect } from '../../hooks/useIntersectionObserver';
import useOnChange from '../../hooks/useOnChange'; import useOnChange from '../../hooks/useOnChange';
@ -69,7 +68,7 @@ const MessageScroll: FC<OwnProps> = ({
const { offsetHeight, scrollHeight, scrollTop } = containerRef.current!; const { offsetHeight, scrollHeight, scrollTop } = containerRef.current!;
const scrollBottom = scrollHeight - scrollTop - offsetHeight; const scrollBottom = scrollHeight - scrollTop - offsetHeight;
const isNearBottom = scrollBottom <= FAB_THRESHOLD; const isNearBottom = scrollBottom <= FAB_THRESHOLD;
const isAtBottom = scrollBottom <= 0 || (IS_SAFARI && scrollBottom <= 1); const isAtBottom = scrollBottom <= 0;
onFabToggle(firstUnreadId ? !isAtBottom : !isNearBottom); onFabToggle(firstUnreadId ? !isAtBottom : !isNearBottom);
onNotchToggle(!isAtBottom); onNotchToggle(!isAtBottom);

View File

@ -203,7 +203,7 @@ const MiddleColumn: FC<StateProps & DispatchProps> = ({
const footerClassName = buildClassName( const footerClassName = buildClassName(
'middle-column-footer', 'middle-column-footer',
!renderingCanPost && 'no-composer', !renderingCanPost && 'no-composer',
renderingCanPost && isNotchShown && 'with-notch', renderingCanPost && isNotchShown && !isSelectModeActive && 'with-notch',
); );
return ( return (

View File

@ -2,11 +2,9 @@
align-items: flex-end; align-items: flex-end;
.select-mode-active + .middle-column-footer & { .select-mode-active + .middle-column-footer & {
@media (min-width: 601px) { position: absolute;
position: absolute; padding-right: 2rem;
padding-right: 2rem; bottom: 0;
bottom: 0;
}
@media (max-width: 600px) { @media (max-width: 600px) {
padding-right: 1rem; padding-right: 1rem;

View File

@ -46,7 +46,8 @@
} }
&.last-in-list { &.last-in-list {
margin-bottom: 0rem; // Forcing extra space which is taken by the appendix and causes incorrect container height calculation
margin-bottom: 0.425rem;
} }
&.is-in-selection-mode { &.is-in-selection-mode {