Rename NAVIGATION_CLOSE_MODAL as CLOSE_BOTTOM_SHEET constant (#5952)

This commit is contained in:
Elias Nahum
2022-02-10 13:15:02 -03:00
committed by GitHub
parent 1b62c10dcc
commit 9efa4ae062
17 changed files with 83 additions and 51 deletions

View File

@@ -14,12 +14,12 @@ import {map, switchMap} from 'rxjs/operators';
import CompassIcon from '@components/compass_icon';
import SlideUpPanelItem, {ITEM_HEIGHT} from '@components/slide_up_panel_item';
import {Navigation, Preferences} from '@constants';
import {Events, Preferences} from '@constants';
import {MM_TABLES, SYSTEM_IDENTIFIERS} from '@constants/database';
import {useTheme} from '@context/theme';
import UserModel from '@database/models/server/user';
import {getTeammateNameDisplaySetting} from '@helpers/api/preference';
import {showModal, showModalOverCurrentContext} from '@screens/navigation';
import {bottomSheet, showModal} from '@screens/navigation';
import {displayUsername, getUserMentionKeys, getUsersByUsername} from '@utils/user';
import type {WithDatabaseArgs} from '@typings/database/database';
@@ -140,7 +140,7 @@ const AtMention = ({
<SlideUpPanelItem
icon='content-copy'
onPress={() => {
DeviceEventEmitter.emit(Navigation.NAVIGATION_CLOSE_MODAL);
DeviceEventEmitter.emit(Events.CLOSE_BOTTOM_SHEET);
let username = mentionName;
if (user.username) {
username = user.username;
@@ -155,7 +155,7 @@ const AtMention = ({
destructive={true}
icon='cancel'
onPress={() => {
DeviceEventEmitter.emit(Navigation.NAVIGATION_CLOSE_MODAL);
DeviceEventEmitter.emit(Events.CLOSE_BOTTOM_SHEET);
}}
testID='at_mention.bottom_sheet.cancel'
text={intl.formatMessage({id: 'mobile.post.cancel', defaultMessage: 'Cancel'})}
@@ -164,12 +164,15 @@ const AtMention = ({
);
};
showModalOverCurrentContext('BottomSheet', {
bottomSheet({
closeButtonId: 'close-at-mention',
renderContent,
snapPoints: [3 * ITEM_HEIGHT, 10],
title: intl.formatMessage({id: 'post.options.title', defaultMessage: 'Options'}),
theme,
});
}
}, [managedConfig]);
}, [managedConfig, intl, theme]);
const mentionTextStyle = [];

View File

@@ -10,9 +10,9 @@ import {DeviceEventEmitter, Keyboard, StyleSheet, Text, TextStyle, View} from 'r
import FormattedText from '@components/formatted_text';
import SlideUpPanelItem, {ITEM_HEIGHT} from '@components/slide_up_panel_item';
import TouchableWithFeedback from '@components/touchable_with_feedback';
import {Navigation} from '@constants';
import {Events} from '@constants';
import {useTheme} from '@context/theme';
import {goToScreen, showModalOverCurrentContext} from '@screens/navigation';
import {bottomSheet, goToScreen} from '@screens/navigation';
import {getDisplayNameForLanguage} from '@utils/markdown';
import {preventDoubleTap} from '@utils/tap';
import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme';
@@ -136,7 +136,7 @@ const MarkdownCodeBlock = ({language = '', content, textStyle}: MarkdownCodeBloc
<SlideUpPanelItem
icon='content-copy'
onPress={() => {
DeviceEventEmitter.emit(Navigation.NAVIGATION_CLOSE_MODAL);
DeviceEventEmitter.emit(Events.CLOSE_BOTTOM_SHEET);
Clipboard.setString(content);
}}
testID='at_mention.bottom_sheet.copy_code'
@@ -146,7 +146,7 @@ const MarkdownCodeBlock = ({language = '', content, textStyle}: MarkdownCodeBloc
destructive={true}
icon='cancel'
onPress={() => {
DeviceEventEmitter.emit(Navigation.NAVIGATION_CLOSE_MODAL);
DeviceEventEmitter.emit(Events.CLOSE_BOTTOM_SHEET);
}}
testID='at_mention.bottom_sheet.cancel'
text={intl.formatMessage({id: 'mobile.post.cancel', defaultMessage: 'Cancel'})}
@@ -155,12 +155,15 @@ const MarkdownCodeBlock = ({language = '', content, textStyle}: MarkdownCodeBloc
);
};
showModalOverCurrentContext('BottomSheet', {
bottomSheet({
closeButtonId: 'close-code-block',
renderContent,
snapPoints: [3 * ITEM_HEIGHT, 10],
title: intl.formatMessage({id: 'post.options.title', defaultMessage: 'Options'}),
theme,
});
}
}, [managedConfig]);
}, [managedConfig, intl, theme]);
const trimContent = (text: string) => {
const lines = text.split('\n');

View File

@@ -13,10 +13,11 @@ import FormattedText from '@components/formatted_text';
import ProgressiveImage from '@components/progressive_image';
import SlideUpPanelItem, {ITEM_HEIGHT} from '@components/slide_up_panel_item';
import TouchableWithFeedback from '@components/touchable_with_feedback';
import {Navigation} from '@constants';
import {Events} from '@constants';
import {useServerUrl} from '@context/server';
import {useTheme} from '@context/theme';
import {useIsTablet} from '@hooks/device';
import {showModalOverCurrentContext} from '@screens/navigation';
import {bottomSheet} from '@screens/navigation';
import {openGallerWithMockFile} from '@utils/gallery';
import {generateId} from '@utils/general';
import {calculateDimensions, getViewPortWidth, isGifTooLarge} from '@utils/images';
@@ -54,6 +55,7 @@ const MarkdownImage = ({
}: MarkdownImageProps) => {
const intl = useIntl();
const isTablet = useIsTablet();
const theme = useTheme();
const managedConfig = useManagedConfig();
const genericFileId = useRef(generateId()).current;
const metadata = imagesMetadata?.[source] || Object.values(imagesMetadata || {})[0];
@@ -120,7 +122,7 @@ const MarkdownImage = ({
<SlideUpPanelItem
icon='content-copy'
onPress={() => {
DeviceEventEmitter.emit(Navigation.NAVIGATION_CLOSE_MODAL);
DeviceEventEmitter.emit(Events.CLOSE_BOTTOM_SHEET);
Clipboard.setString(linkDestination || source);
}}
testID='at_mention.bottom_sheet.copy_url'
@@ -130,7 +132,7 @@ const MarkdownImage = ({
destructive={true}
icon='cancel'
onPress={() => {
DeviceEventEmitter.emit(Navigation.NAVIGATION_CLOSE_MODAL);
DeviceEventEmitter.emit(Events.CLOSE_BOTTOM_SHEET);
}}
testID='at_mention.bottom_sheet.cancel'
text={intl.formatMessage({id: 'mobile.post.cancel', defaultMessage: 'Cancel'})}
@@ -139,12 +141,15 @@ const MarkdownImage = ({
);
};
showModalOverCurrentContext('BottomSheet', {
bottomSheet({
closeButtonId: 'close-mardown-image',
renderContent,
snapPoints: [3 * ITEM_HEIGHT, 10],
title: intl.formatMessage({id: 'post.options.title', defaultMessage: 'Options'}),
theme,
});
}
}, [managedConfig]);
}, [managedConfig, intl, theme]);
const handlePreviewImage = useCallback(() => {
openGallerWithMockFile(fileInfo.uri, postId, fileInfo.height, fileInfo.width, fileInfo.id);

View File

@@ -15,11 +15,12 @@ import urlParse from 'url-parse';
import {showPermalink} from '@actions/local/permalink';
import {switchToChannelByName} from '@actions/remote/channel';
import SlideUpPanelItem, {ITEM_HEIGHT} from '@components/slide_up_panel_item';
import {Navigation} from '@constants';
import {Events} from '@constants';
import {MM_TABLES, SYSTEM_IDENTIFIERS} from '@constants/database';
import DeepLinkTypes from '@constants/deep_linking';
import {useServerUrl} from '@context/server';
import {dismissAllModals, popToRoot, showModalOverCurrentContext} from '@screens/navigation';
import {useTheme} from '@context/theme';
import {bottomSheet, dismissAllModals, popToRoot} from '@screens/navigation';
import {errorBadChannel} from '@utils/draft';
import {preventDoubleTap} from '@utils/tap';
import {matchDeepLink, normalizeProtocol, tryOpenURL} from '@utils/url';
@@ -45,6 +46,7 @@ const MarkdownLink = ({children, experimentalNormalizeMarkdownLinks, href, siteU
const intl = useIntl();
const managedConfig = useManagedConfig();
const serverUrl = useServerUrl();
const theme = useTheme();
const {formatMessage} = intl;
@@ -131,7 +133,7 @@ const MarkdownLink = ({children, experimentalNormalizeMarkdownLinks, href, siteU
<SlideUpPanelItem
icon='content-copy'
onPress={() => {
DeviceEventEmitter.emit(Navigation.NAVIGATION_CLOSE_MODAL);
DeviceEventEmitter.emit(Events.CLOSE_BOTTOM_SHEET);
Clipboard.setString(href);
}}
testID='at_mention.bottom_sheet.copy_url'
@@ -141,7 +143,7 @@ const MarkdownLink = ({children, experimentalNormalizeMarkdownLinks, href, siteU
destructive={true}
icon='cancel'
onPress={() => {
DeviceEventEmitter.emit(Navigation.NAVIGATION_CLOSE_MODAL);
DeviceEventEmitter.emit(Events.CLOSE_BOTTOM_SHEET);
}}
testID='at_mention.bottom_sheet.cancel'
text={intl.formatMessage({id: 'mobile.post.cancel', defaultMessage: 'Cancel'})}
@@ -150,12 +152,15 @@ const MarkdownLink = ({children, experimentalNormalizeMarkdownLinks, href, siteU
);
};
showModalOverCurrentContext('BottomSheet', {
bottomSheet({
closeButtonId: 'close-mardown-link',
renderContent,
snapPoints: [3 * ITEM_HEIGHT, 10],
title: intl.formatMessage({id: 'post.options.title', defaultMessage: 'Options'}),
theme,
});
}
}, [managedConfig]);
}, [managedConfig, intl, theme]);
const renderChildren = experimentalNormalizeMarkdownLinks ? parseChildren() : children;