Album: Fix background color during selection (#1494)
This commit is contained in:
parent
d0cd729b38
commit
90a695a0cd
@ -5,9 +5,10 @@ import { withGlobal } from '../../../lib/teact/teactn';
|
|||||||
|
|
||||||
import { GlobalActions } from '../../../global/types';
|
import { GlobalActions } from '../../../global/types';
|
||||||
import { ApiMessage, ApiMessageEntityTypes, ApiWebPage } from '../../../api/types';
|
import { ApiMessage, ApiMessageEntityTypes, ApiWebPage } from '../../../api/types';
|
||||||
|
import { ISettings } from '../../../types';
|
||||||
|
|
||||||
import { RE_LINK_TEMPLATE } from '../../../config';
|
import { RE_LINK_TEMPLATE } from '../../../config';
|
||||||
import { selectNoWebPage } from '../../../modules/selectors';
|
import { selectNoWebPage, selectTheme } from '../../../modules/selectors';
|
||||||
import { pick } from '../../../util/iteratees';
|
import { pick } from '../../../util/iteratees';
|
||||||
import parseMessageInput from './helpers/parseMessageInput';
|
import parseMessageInput from './helpers/parseMessageInput';
|
||||||
import useOnChange from '../../../hooks/useOnChange';
|
import useOnChange from '../../../hooks/useOnChange';
|
||||||
@ -30,6 +31,7 @@ type OwnProps = {
|
|||||||
type StateProps = {
|
type StateProps = {
|
||||||
webPagePreview?: ApiWebPage;
|
webPagePreview?: ApiWebPage;
|
||||||
noWebPage?: boolean;
|
noWebPage?: boolean;
|
||||||
|
theme: ISettings['theme'];
|
||||||
};
|
};
|
||||||
type DispatchProps = Pick<GlobalActions, 'loadWebPagePreview' | 'clearWebPagePreview' | 'toggleMessageWebPage'>;
|
type DispatchProps = Pick<GlobalActions, 'loadWebPagePreview' | 'clearWebPagePreview' | 'toggleMessageWebPage'>;
|
||||||
|
|
||||||
@ -42,6 +44,7 @@ const WebPagePreview: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
disabled,
|
disabled,
|
||||||
webPagePreview,
|
webPagePreview,
|
||||||
noWebPage,
|
noWebPage,
|
||||||
|
theme,
|
||||||
loadWebPagePreview,
|
loadWebPagePreview,
|
||||||
clearWebPagePreview,
|
clearWebPagePreview,
|
||||||
toggleMessageWebPage,
|
toggleMessageWebPage,
|
||||||
@ -103,7 +106,7 @@ const WebPagePreview: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
<Button round faded color="translucent" ariaLabel="Clear Webpage Preview" onClick={handleClearWebpagePreview}>
|
<Button round faded color="translucent" ariaLabel="Clear Webpage Preview" onClick={handleClearWebpagePreview}>
|
||||||
<i className="icon-close" />
|
<i className="icon-close" />
|
||||||
</Button>
|
</Button>
|
||||||
<WebPage message={messageStub} inPreview />
|
<WebPage message={messageStub} inPreview theme={theme} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -113,6 +116,7 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
(global, { chatId, threadId }): StateProps => {
|
(global, { chatId, threadId }): StateProps => {
|
||||||
const noWebPage = selectNoWebPage(global, chatId, threadId);
|
const noWebPage = selectNoWebPage(global, chatId, threadId);
|
||||||
return {
|
return {
|
||||||
|
theme: selectTheme(global),
|
||||||
webPagePreview: global.webPagePreview,
|
webPagePreview: global.webPagePreview,
|
||||||
noWebPage,
|
noWebPage,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import React, { FC, useCallback } from '../../../lib/teact/teact';
|
|||||||
|
|
||||||
import { GlobalActions, GlobalState } from '../../../global/types';
|
import { GlobalActions, GlobalState } from '../../../global/types';
|
||||||
import { ApiMessage } from '../../../api/types';
|
import { ApiMessage } from '../../../api/types';
|
||||||
import { IAlbum } from '../../../types';
|
import { IAlbum, ISettings } from '../../../types';
|
||||||
import { AlbumRectPart, IAlbumLayout } from './helpers/calculateAlbumLayout';
|
import { AlbumRectPart, IAlbumLayout } from './helpers/calculateAlbumLayout';
|
||||||
|
|
||||||
import { getMessageContent } from '../../../modules/helpers';
|
import { getMessageContent } from '../../../modules/helpers';
|
||||||
@ -10,6 +10,7 @@ import { withGlobal } from '../../../lib/teact/teactn';
|
|||||||
import { pick } from '../../../util/iteratees';
|
import { pick } from '../../../util/iteratees';
|
||||||
import withSelectControl from './hocs/withSelectControl';
|
import withSelectControl from './hocs/withSelectControl';
|
||||||
import { ObserveFn } from '../../../hooks/useIntersectionObserver';
|
import { ObserveFn } from '../../../hooks/useIntersectionObserver';
|
||||||
|
import { selectTheme } from '../../../modules/selectors';
|
||||||
|
|
||||||
import Photo from './Photo';
|
import Photo from './Photo';
|
||||||
import Video from './Video';
|
import Video from './Video';
|
||||||
@ -32,6 +33,7 @@ type OwnProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type StateProps = {
|
type StateProps = {
|
||||||
|
theme: ISettings['theme'];
|
||||||
uploadsById: GlobalState['fileUploads']['byMessageLocalId'];
|
uploadsById: GlobalState['fileUploads']['byMessageLocalId'];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -48,6 +50,7 @@ const Album: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
albumLayout,
|
albumLayout,
|
||||||
onMediaClick,
|
onMediaClick,
|
||||||
uploadsById,
|
uploadsById,
|
||||||
|
theme,
|
||||||
cancelSendingMessage,
|
cancelSendingMessage,
|
||||||
}) => {
|
}) => {
|
||||||
const mediaCount = album.messages.length;
|
const mediaCount = album.messages.length;
|
||||||
@ -79,6 +82,7 @@ const Album: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
dimensions={dimensions}
|
dimensions={dimensions}
|
||||||
onClick={onMediaClick}
|
onClick={onMediaClick}
|
||||||
onCancelUpload={handleCancelUpload}
|
onCancelUpload={handleCancelUpload}
|
||||||
|
theme={theme}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else if (video) {
|
} else if (video) {
|
||||||
@ -94,6 +98,7 @@ const Album: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
dimensions={dimensions}
|
dimensions={dimensions}
|
||||||
onClick={onMediaClick}
|
onClick={onMediaClick}
|
||||||
onCancelUpload={handleCancelUpload}
|
onCancelUpload={handleCancelUpload}
|
||||||
|
theme={theme}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -116,7 +121,9 @@ const Album: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
|
|
||||||
export default withGlobal<OwnProps>(
|
export default withGlobal<OwnProps>(
|
||||||
(global): StateProps => {
|
(global): StateProps => {
|
||||||
|
const theme = selectTheme(global);
|
||||||
return {
|
return {
|
||||||
|
theme,
|
||||||
uploadsById: global.fileUploads.byMessageLocalId,
|
uploadsById: global.fileUploads.byMessageLocalId,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
@ -18,7 +18,6 @@
|
|||||||
--meta-safe-area-size: calc(var(--meta-safe-area-base) + var(--meta-safe-author-width) + var(--meta-safe-area-extra-width));
|
--meta-safe-area-size: calc(var(--meta-safe-area-base) + var(--meta-safe-author-width) + var(--meta-safe-area-extra-width));
|
||||||
--deleting-translate-x: -50%;
|
--deleting-translate-x: -50%;
|
||||||
--select-message-scale: 0.9;
|
--select-message-scale: 0.9;
|
||||||
--select-background-color: white;
|
|
||||||
|
|
||||||
&.is-swiped {
|
&.is-swiped {
|
||||||
transform: translateX(-2.5rem) !important;
|
transform: translateX(-2.5rem) !important;
|
||||||
@ -57,11 +56,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.is-in-selection-mode {
|
&.is-in-selection-mode {
|
||||||
.Album {
|
|
||||||
border: 1px var(--select-background-color) solid;
|
|
||||||
background-color: var(--select-background-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
body.is-android & {
|
body.is-android & {
|
||||||
.can-select-text {
|
.can-select-text {
|
||||||
z-index: var(--z-message-select-control);
|
z-index: var(--z-message-select-control);
|
||||||
@ -261,11 +255,6 @@
|
|||||||
left: unset;
|
left: unset;
|
||||||
}
|
}
|
||||||
|
|
||||||
.media-inner {
|
|
||||||
border: 0 var(--select-background-color) solid;
|
|
||||||
transition: border-width var(--select-transition);
|
|
||||||
}
|
|
||||||
|
|
||||||
img, video {
|
img, video {
|
||||||
transition: transform var(--select-transition), opacity ease 300ms;
|
transition: transform var(--select-transition), opacity ease 300ms;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -533,6 +533,7 @@ const Message: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
shouldAffectAppendix={hasCustomAppendix}
|
shouldAffectAppendix={hasCustomAppendix}
|
||||||
onClick={handleMediaClick}
|
onClick={handleMediaClick}
|
||||||
onCancelUpload={handleCancelUpload}
|
onCancelUpload={handleCancelUpload}
|
||||||
|
theme={theme}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{!isAlbum && video && video.isRound && (
|
{!isAlbum && video && video.isRound && (
|
||||||
@ -611,6 +612,7 @@ const Message: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
lastSyncTime={lastSyncTime}
|
lastSyncTime={lastSyncTime}
|
||||||
onMediaClick={handleMediaClick}
|
onMediaClick={handleMediaClick}
|
||||||
onCancelMediaTransfer={handleCancelUpload}
|
onCancelMediaTransfer={handleCancelUpload}
|
||||||
|
theme={theme}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{invoice && <Invoice message={message} />}
|
{invoice && <Invoice message={message} />}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import React, {
|
|||||||
} from '../../../lib/teact/teact';
|
} from '../../../lib/teact/teact';
|
||||||
|
|
||||||
import { ApiMessage } from '../../../api/types';
|
import { ApiMessage } from '../../../api/types';
|
||||||
|
import { ISettings } from '../../../types';
|
||||||
import { IMediaDimensions } from './helpers/calculateAlbumLayout';
|
import { IMediaDimensions } from './helpers/calculateAlbumLayout';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -37,6 +38,7 @@ export type OwnProps = {
|
|||||||
shouldAffectAppendix?: boolean;
|
shouldAffectAppendix?: boolean;
|
||||||
dimensions?: IMediaDimensions & { isSmall?: boolean };
|
dimensions?: IMediaDimensions & { isSmall?: boolean };
|
||||||
nonInteractive?: boolean;
|
nonInteractive?: boolean;
|
||||||
|
theme: ISettings['theme'];
|
||||||
onClick?: (id: number) => void;
|
onClick?: (id: number) => void;
|
||||||
onCancelUpload?: (message: ApiMessage) => void;
|
onCancelUpload?: (message: ApiMessage) => void;
|
||||||
};
|
};
|
||||||
@ -56,6 +58,7 @@ const Photo: FC<OwnProps> = ({
|
|||||||
dimensions,
|
dimensions,
|
||||||
nonInteractive,
|
nonInteractive,
|
||||||
shouldAffectAppendix,
|
shouldAffectAppendix,
|
||||||
|
theme,
|
||||||
onClick,
|
onClick,
|
||||||
onCancelUpload,
|
onCancelUpload,
|
||||||
}) => {
|
}) => {
|
||||||
@ -108,14 +111,14 @@ const Photo: FC<OwnProps> = ({
|
|||||||
const contentEl = ref.current!.closest<HTMLDivElement>('.message-content')!;
|
const contentEl = ref.current!.closest<HTMLDivElement>('.message-content')!;
|
||||||
|
|
||||||
if (fullMediaData) {
|
if (fullMediaData) {
|
||||||
getCustomAppendixBg(fullMediaData, isOwn, isInSelectMode, isSelected).then((appendixBg) => {
|
getCustomAppendixBg(fullMediaData, isOwn, isInSelectMode, isSelected, theme).then((appendixBg) => {
|
||||||
contentEl.style.setProperty('--appendix-bg', appendixBg);
|
contentEl.style.setProperty('--appendix-bg', appendixBg);
|
||||||
contentEl.setAttribute(CUSTOM_APPENDIX_ATTRIBUTE, '');
|
contentEl.setAttribute(CUSTOM_APPENDIX_ATTRIBUTE, '');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
contentEl.classList.add('has-appendix-thumb');
|
contentEl.classList.add('has-appendix-thumb');
|
||||||
}
|
}
|
||||||
}, [fullMediaData, isOwn, shouldAffectAppendix, isInSelectMode, isSelected]);
|
}, [fullMediaData, isOwn, shouldAffectAppendix, isInSelectMode, isSelected, theme]);
|
||||||
|
|
||||||
const { width, height, isSmall } = dimensions || calculateMediaDimensions(message, noAvatars);
|
const { width, height, isSmall } = dimensions || calculateMediaDimensions(message, noAvatars);
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import React, { FC, memo, useCallback } from '../../../lib/teact/teact';
|
|||||||
|
|
||||||
import { ApiMessage } from '../../../api/types';
|
import { ApiMessage } from '../../../api/types';
|
||||||
import { ObserveFn } from '../../../hooks/useIntersectionObserver';
|
import { ObserveFn } from '../../../hooks/useIntersectionObserver';
|
||||||
|
import { ISettings } from '../../../types';
|
||||||
|
|
||||||
import { getMessageWebPage } from '../../../modules/helpers';
|
import { getMessageWebPage } from '../../../modules/helpers';
|
||||||
import { calculateMediaDimensions } from './helpers/mediaDimensions';
|
import { calculateMediaDimensions } from './helpers/mediaDimensions';
|
||||||
@ -25,6 +26,7 @@ type OwnProps = {
|
|||||||
shouldAutoPlay?: boolean;
|
shouldAutoPlay?: boolean;
|
||||||
inPreview?: boolean;
|
inPreview?: boolean;
|
||||||
lastSyncTime?: number;
|
lastSyncTime?: number;
|
||||||
|
theme: ISettings['theme'];
|
||||||
onMediaClick?: () => void;
|
onMediaClick?: () => void;
|
||||||
onCancelMediaTransfer?: () => void;
|
onCancelMediaTransfer?: () => void;
|
||||||
};
|
};
|
||||||
@ -37,6 +39,7 @@ const WebPage: FC<OwnProps> = ({
|
|||||||
shouldAutoPlay,
|
shouldAutoPlay,
|
||||||
inPreview,
|
inPreview,
|
||||||
lastSyncTime,
|
lastSyncTime,
|
||||||
|
theme,
|
||||||
onMediaClick,
|
onMediaClick,
|
||||||
onCancelMediaTransfer,
|
onCancelMediaTransfer,
|
||||||
}) => {
|
}) => {
|
||||||
@ -91,6 +94,7 @@ const WebPage: FC<OwnProps> = ({
|
|||||||
nonInteractive={!isMediaInteractive}
|
nonInteractive={!isMediaInteractive}
|
||||||
onClick={isMediaInteractive ? handleMediaClick : undefined}
|
onClick={isMediaInteractive ? handleMediaClick : undefined}
|
||||||
onCancelUpload={onCancelMediaTransfer}
|
onCancelUpload={onCancelMediaTransfer}
|
||||||
|
theme={theme}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<div className="WebPage-text">
|
<div className="WebPage-text">
|
||||||
|
|||||||
@ -1,7 +1,23 @@
|
|||||||
const SELECTED_APPENDIX_BACKGROUND = Promise.resolve('rgba(255,255,255,1)');
|
import { ISettings } from '../../../../types';
|
||||||
|
|
||||||
export default function getCustomAppendixBg(src: string, isOwn: boolean, inSelectMode?: boolean, isSelected?: boolean) {
|
const SELECTED_APPENDIX_COLORS = {
|
||||||
return isSelected ? SELECTED_APPENDIX_BACKGROUND : getAppendixColorFromImage(src, isOwn);
|
dark: {
|
||||||
|
outgoing: 'rgb(135,116,225)',
|
||||||
|
incoming: 'rgb(33,33,33)',
|
||||||
|
},
|
||||||
|
light: {
|
||||||
|
outgoing: 'rgb(238,255,222)',
|
||||||
|
incoming: 'rgb(255,255,255)',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function getCustomAppendixBg(
|
||||||
|
src: string, isOwn: boolean, inSelectMode?: boolean, isSelected?: boolean, theme?: ISettings['theme'],
|
||||||
|
) {
|
||||||
|
if (isSelected) {
|
||||||
|
return Promise.resolve(SELECTED_APPENDIX_COLORS[theme || 'light'][isOwn ? 'outgoing' : 'incoming']);
|
||||||
|
}
|
||||||
|
return getAppendixColorFromImage(src, isOwn);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getAppendixColorFromImage(src: string, isOwn: boolean) {
|
async function getAppendixColorFromImage(src: string, isOwn: boolean) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user