Album: Fix layout on small screen resolution (#5232)
This commit is contained in:
parent
5ae78bfce8
commit
896c8b99a8
@ -60,12 +60,11 @@ function getMaxMessageWidthRem(fromOwnMessage?: boolean, noAvatars?: boolean, is
|
|||||||
|
|
||||||
export function getAvailableWidth(
|
export function getAvailableWidth(
|
||||||
fromOwnMessage?: boolean,
|
fromOwnMessage?: boolean,
|
||||||
asForwarded?: boolean,
|
|
||||||
isWebPageMedia?: boolean,
|
isWebPageMedia?: boolean,
|
||||||
noAvatars?: boolean,
|
noAvatars?: boolean,
|
||||||
isMobile?: boolean,
|
isMobile?: boolean,
|
||||||
) {
|
) {
|
||||||
const extraPaddingRem = asForwarded && isWebPageMedia ? 2.25 : (asForwarded || isWebPageMedia ? 1.625 : 0);
|
const extraPaddingRem = isWebPageMedia ? 1.625 : 0;
|
||||||
const availableWidthRem = getMaxMessageWidthRem(fromOwnMessage, noAvatars, isMobile) - extraPaddingRem;
|
const availableWidthRem = getMaxMessageWidthRem(fromOwnMessage, noAvatars, isMobile) - extraPaddingRem;
|
||||||
|
|
||||||
return availableWidthRem * REM;
|
return availableWidthRem * REM;
|
||||||
@ -86,7 +85,6 @@ export function calculateDimensionsForMessageMedia({
|
|||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
fromOwnMessage,
|
fromOwnMessage,
|
||||||
asForwarded,
|
|
||||||
isWebPageMedia,
|
isWebPageMedia,
|
||||||
isGif,
|
isGif,
|
||||||
noAvatars,
|
noAvatars,
|
||||||
@ -102,7 +100,7 @@ export function calculateDimensionsForMessageMedia({
|
|||||||
isMobile?: boolean;
|
isMobile?: boolean;
|
||||||
}): ApiDimensions {
|
}): ApiDimensions {
|
||||||
const aspectRatio = height / width;
|
const aspectRatio = height / width;
|
||||||
const availableWidth = getAvailableWidth(fromOwnMessage, asForwarded, isWebPageMedia, noAvatars, isMobile);
|
const availableWidth = getAvailableWidth(fromOwnMessage, isWebPageMedia, noAvatars, isMobile);
|
||||||
const availableHeight = getAvailableHeight(isGif, aspectRatio);
|
const availableHeight = getAvailableHeight(isGif, aspectRatio);
|
||||||
const mediaWidth = isGif ? Math.max(GIF_MIN_WIDTH, width) : width;
|
const mediaWidth = isGif ? Math.max(GIF_MIN_WIDTH, width) : width;
|
||||||
const mediaHeight = isGif ? height * (mediaWidth / width) : height;
|
const mediaHeight = isGif ? height * (mediaWidth / width) : height;
|
||||||
|
|||||||
@ -889,9 +889,9 @@ const Message: FC<OwnProps & StateProps> = ({
|
|||||||
|
|
||||||
const albumLayout = useMemo(() => {
|
const albumLayout = useMemo(() => {
|
||||||
return isAlbum
|
return isAlbum
|
||||||
? calculateAlbumLayout(isOwn, Boolean(asForwarded), Boolean(noAvatars), album!, isMobile)
|
? calculateAlbumLayout(isOwn, Boolean(noAvatars), album!, isMobile)
|
||||||
: undefined;
|
: undefined;
|
||||||
}, [isAlbum, isOwn, asForwarded, noAvatars, album, isMobile]);
|
}, [isAlbum, isOwn, noAvatars, album, isMobile]);
|
||||||
|
|
||||||
const extraPadding = asForwarded && !isCustomShape ? 28 : 0;
|
const extraPadding = asForwarded && !isCustomShape ? 28 : 0;
|
||||||
|
|
||||||
|
|||||||
@ -570,6 +570,10 @@
|
|||||||
.no-media-corners {
|
.no-media-corners {
|
||||||
--border-top-left-radius: 0;
|
--border-top-left-radius: 0;
|
||||||
--border-top-right-radius: 0;
|
--border-top-right-radius: 0;
|
||||||
|
|
||||||
|
.Album {
|
||||||
|
margin-inline: auto !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.custom-shape.is-via-bot {
|
&.custom-shape.is-via-bot {
|
||||||
@ -958,34 +962,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.forwarded-message {
|
.forwarded-message {
|
||||||
.message-content.contact &,
|
|
||||||
.message-content.poll &,
|
|
||||||
.message-content.giveaway & {
|
|
||||||
// MessageOutgoingStatus's icon needs more space
|
|
||||||
margin-bottom: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-content:not(.custom-shape) & {
|
.message-content:not(.custom-shape) & {
|
||||||
position: relative;
|
position: relative;
|
||||||
margin-top: 0.25rem;
|
margin-top: 0.25rem;
|
||||||
|
|
||||||
.Album,
|
|
||||||
.media-inner:not(.file-preview) {
|
|
||||||
margin-left: -0.5rem;
|
|
||||||
margin-right: -0.5rem;
|
|
||||||
|
|
||||||
body.is-ios .Message.own & {
|
|
||||||
margin-left: -0.625rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
:not(.has-footer) & {
|
|
||||||
margin-bottom: -0.375rem;
|
|
||||||
|
|
||||||
body.is-ios .Message.own & {
|
|
||||||
margin-bottom: -0.4375rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
--border-top-left-radius: 0;
|
--border-top-left-radius: 0;
|
||||||
@ -997,17 +976,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.Album {
|
.Album {
|
||||||
margin-bottom: 0.125rem;
|
margin-top: 0 !important;
|
||||||
|
|
||||||
.message-content.media.text & {
|
|
||||||
margin-top: 0.25rem;
|
|
||||||
--border-bottom-left-radius: inherit;
|
|
||||||
--border-bottom-right-radius: inherit;
|
|
||||||
|
|
||||||
+ .message-paid-media-status {
|
|
||||||
margin-right: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import type { IAlbum } from '../../../../types';
|
|||||||
|
|
||||||
import { getMessageContent } from '../../../../global/helpers';
|
import { getMessageContent } from '../../../../global/helpers';
|
||||||
import { clamp } from '../../../../util/math';
|
import { clamp } from '../../../../util/math';
|
||||||
import { getAvailableWidth, REM } from '../../../common/helpers/mediaDimensions';
|
import { getAvailableWidth } from '../../../common/helpers/mediaDimensions';
|
||||||
import { calculateMediaDimensions } from './mediaDimensions';
|
import { calculateMediaDimensions } from './mediaDimensions';
|
||||||
|
|
||||||
export const AlbumRectPart = {
|
export const AlbumRectPart = {
|
||||||
@ -107,7 +107,6 @@ function calculateContainerSize(layout: IMediaLayout[]) {
|
|||||||
|
|
||||||
export function calculateAlbumLayout(
|
export function calculateAlbumLayout(
|
||||||
isOwn: boolean,
|
isOwn: boolean,
|
||||||
asForwarded: boolean,
|
|
||||||
noAvatars: boolean,
|
noAvatars: boolean,
|
||||||
album: IAlbum,
|
album: IAlbum,
|
||||||
isMobile?: boolean,
|
isMobile?: boolean,
|
||||||
@ -118,7 +117,7 @@ export function calculateAlbumLayout(
|
|||||||
const averageRatio = getAverageRatio(ratios);
|
const averageRatio = getAverageRatio(ratios);
|
||||||
const albumCount = ratios.length;
|
const albumCount = ratios.length;
|
||||||
const forceCalc = ratios.some((ratio) => ratio > 2);
|
const forceCalc = ratios.some((ratio) => ratio > 2);
|
||||||
const maxWidth = getAvailableWidth(isOwn, asForwarded, false, noAvatars, isMobile) - (asForwarded ? 2.5 : 0) * REM;
|
const maxWidth = getAvailableWidth(isOwn, false, noAvatars, isMobile);
|
||||||
const maxHeight = maxWidth;
|
const maxHeight = maxWidth;
|
||||||
|
|
||||||
let layout;
|
let layout;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user