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;

View File

@@ -8,7 +8,7 @@ import {CameraOptions} from 'react-native-image-picker';
import CompassIcon from '@components/compass_icon';
import FormattedText from '@components/formatted_text';
import TouchableWithFeedback from '@components/touchable_with_feedback';
import {Navigation} from '@constants';
import {Events} from '@constants';
import {useTheme} from '@context/theme';
import {useIsTablet} from '@hooks/device';
import {makeStyleSheetFromTheme} from '@utils/theme';
@@ -65,7 +65,7 @@ const CameraType = ({onPress}: Props) => {
};
onPress(options);
DeviceEventEmitter.emit(Navigation.NAVIGATION_CLOSE_MODAL);
DeviceEventEmitter.emit(Events.CLOSE_BOTTOM_SHEET);
};
const onVideo = () => {
@@ -76,7 +76,7 @@ const CameraType = ({onPress}: Props) => {
};
onPress(options);
DeviceEventEmitter.emit(Navigation.NAVIGATION_CLOSE_MODAL);
DeviceEventEmitter.emit(Events.CLOSE_BOTTOM_SHEET);
};
return (

View File

@@ -9,9 +9,9 @@ import {removePost} from '@actions/local/post';
import CompassIcon from '@components/compass_icon';
import SlideUpPanelItem, {ITEM_HEIGHT} from '@components/slide_up_panel_item';
import TouchableWithFeedback from '@components/touchable_with_feedback';
import Navigation from '@constants/navigation';
import {Events} from '@constants';
import {useServerUrl} from '@context/server';
import {showModalOverCurrentContext} from '@screens/navigation';
import {bottomSheet} from '@screens/navigation';
import type PostModel from '@typings/database/models/servers/post';
@@ -46,7 +46,7 @@ const Failed = ({post, theme}: FailedProps) => {
<SlideUpPanelItem
icon='send-outline'
onPress={() => {
DeviceEventEmitter.emit(Navigation.NAVIGATION_CLOSE_MODAL);
DeviceEventEmitter.emit(Events.CLOSE_BOTTOM_SHEET);
retryPost(serverUrl, post);
}}
testID='post.failed.retry'
@@ -56,7 +56,7 @@ const Failed = ({post, theme}: FailedProps) => {
destructive={true}
icon='close-circle-outline'
onPress={() => {
DeviceEventEmitter.emit(Navigation.NAVIGATION_CLOSE_MODAL);
DeviceEventEmitter.emit(Events.CLOSE_BOTTOM_SHEET);
removePost(serverUrl, post);
}}
testID='post.failed.delete'
@@ -66,9 +66,12 @@ const Failed = ({post, theme}: FailedProps) => {
);
};
showModalOverCurrentContext('BottomSheet', {
bottomSheet({
closeButtonId: 'close-post-failed',
renderContent,
snapPoints: [3 * ITEM_HEIGHT, 10],
title: intl.formatMessage({id: 'post.options.title', defaultMessage: 'Options'}),
theme,
});
}, []);

View File

@@ -5,7 +5,7 @@ import React, {useCallback} from 'react';
import {useIntl} from 'react-intl';
import {DeviceEventEmitter} from 'react-native';
import {Navigation} from '@constants';
import {Events} from '@constants';
import BottomSheetContent from '@screens/bottom_sheet/content';
import TeamList from './team_list';
@@ -23,7 +23,7 @@ export default function AddTeamSlideUp({otherTeams, canCreateTeams, showTitle =
const onPressCreate = useCallback(() => {
//TODO Create team screen
DeviceEventEmitter.emit(Navigation.NAVIGATION_CLOSE_MODAL);
DeviceEventEmitter.emit(Events.CLOSE_BOTTOM_SHEET);
}, []);
return (

View File

@@ -7,7 +7,7 @@ import {DeviceEventEmitter, Text, View} from 'react-native';
import {addUserToTeam} from '@actions/remote/team';
import TeamIcon from '@components/team_sidebar/team_list/team_item/team_icon';
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 {makeStyleSheetFromTheme} from '@utils/theme';
@@ -25,7 +25,7 @@ export default function TeamListItem({team, currentUserId}: Props) {
const serverUrl = useServerUrl();
const onPress = useCallback(async () => {
await addUserToTeam(serverUrl, team.id, currentUserId);
DeviceEventEmitter.emit(Navigation.NAVIGATION_CLOSE_MODAL);
DeviceEventEmitter.emit(Events.CLOSE_BOTTOM_SHEET);
}, []);
return (

View File

@@ -6,6 +6,7 @@ import keyMirror from '@utils/key_mirror';
export default keyMirror({
ACCOUNT_SELECT_TABLET_VIEW: null,
CHANNEL_DELETED: null,
CLOSE_BOTTOM_SHEET: null,
CONFIG_CHANGED: null,
LEAVE_CHANNEL: null,
LEAVE_TEAM: null,

View File

@@ -5,7 +5,6 @@ import keyMirror from '@utils/key_mirror';
const Navigation = keyMirror({
NAVIGATE_TO_TAB: null,
NAVIGATION_CLOSE_MODAL: null,
NAVIGATION_HOME: null,
NAVIGATION_SHOW_OVERLAY: null,
NAVIGATION_DISMISS_AND_POP_TO_ROOT: null,

View File

@@ -8,7 +8,7 @@ import {Navigation as RNN} from 'react-native-navigation';
import Animated from 'react-native-reanimated';
import RNBottomSheet from 'reanimated-bottom-sheet';
import {Navigation, Screens} from '@constants';
import {Events, Screens} from '@constants';
import {useTheme} from '@context/theme';
import {useIsTablet} from '@hooks/device';
import {dismissModal} from '@screens/navigation';
@@ -32,7 +32,7 @@ const BottomSheet = ({closeButtonId, initialSnapIndex = 0, renderContent, snapPo
const lastSnap = snapPoints.length - 1;
useEffect(() => {
const listener = DeviceEventEmitter.addListener(Navigation.NAVIGATION_CLOSE_MODAL, () => {
const listener = DeviceEventEmitter.addListener(Events.CLOSE_BOTTOM_SHEET, () => {
if (sheetRef.current) {
sheetRef.current.snapTo(lastSnap);
} else {

View File

@@ -6,7 +6,7 @@ import {useIntl} from 'react-intl';
import {DeviceEventEmitter} from 'react-native';
import SlideUpPanelItem from '@components/slide_up_panel_item';
import NavigationConstants from '@constants/navigation';
import {Events} from '@constants';
import {useTheme} from '@context/theme';
import {useIsTablet} from '@hooks/device';
import BottomSheetContent from '@screens/bottom_sheet/content';
@@ -49,17 +49,17 @@ export default function DropdownSlideup({
};
const handlePublicPress = useCallback(() => {
DeviceEventEmitter.emit(NavigationConstants.NAVIGATION_CLOSE_MODAL);
DeviceEventEmitter.emit(Events.CLOSE_BOTTOM_SHEET);
onPress(PUBLIC);
}, [onPress]);
const handleArchivedPress = useCallback(() => {
DeviceEventEmitter.emit(NavigationConstants.NAVIGATION_CLOSE_MODAL);
DeviceEventEmitter.emit(Events.CLOSE_BOTTOM_SHEET);
onPress(ARCHIVED);
}, [onPress]);
const handleSharedPress = useCallback(() => {
DeviceEventEmitter.emit(NavigationConstants.NAVIGATION_CLOSE_MODAL);
DeviceEventEmitter.emit(Events.CLOSE_BOTTOM_SHEET);
onPress(SHARED);
}, [onPress]);

View File

@@ -6,7 +6,7 @@ import {DeviceEventEmitter, Platform, View} from 'react-native';
import {Client} from '@client/rest';
import ProfileImage from '@components/profile_picture';
import {Navigation} from '@constants';
import {Events} from '@constants';
import {ACCOUNT_OUTLINE_IMAGE} from '@constants/profile';
import {useServerUrl} from '@context/server';
import {useTheme} from '@context/theme';
@@ -81,7 +81,7 @@ const EditProfilePicture = ({user, onUpdateProfilePicture}: ChangeProfilePicture
setPictureUrl(pUrl);
onUpdateProfilePicture({isRemoved, localPath});
DeviceEventEmitter.emit(Navigation.NAVIGATION_CLOSE_MODAL);
DeviceEventEmitter.emit(Events.CLOSE_BOTTOM_SHEET);
}, [onUpdateProfilePicture]);
const pictureSource = useMemo(() => {

View File

@@ -10,7 +10,7 @@ import DrawerItem from '@components/drawer_item';
import SlideUpPanelItem, {ITEM_HEIGHT} from '@components/slide_up_panel_item';
import StatusLabel from '@components/status_label';
import UserStatusIndicator from '@components/user_status';
import {Navigation} from '@constants';
import {Events} from '@constants';
import General from '@constants/general';
import {useServerUrl} from '@context/server';
import {bottomSheet, dismissModal} from '@screens/navigation';
@@ -111,7 +111,7 @@ const UserStatus = ({currentUser, style, theme}: Props) => {
}
updateStatus(status);
DeviceEventEmitter.emit(Navigation.NAVIGATION_CLOSE_MODAL);
DeviceEventEmitter.emit(Events.CLOSE_BOTTOM_SHEET);
return null;
}, []);

View File

@@ -9,7 +9,7 @@ import Swipeable from 'react-native-gesture-handler/Swipeable';
import CompassIcon from '@components/compass_icon';
import ServerIcon from '@components/server_icon';
import {Events, Navigation} from '@constants';
import {Events} from '@constants';
import {useTheme} from '@context/theme';
import {subscribeServerUnreadAndMentions} from '@database/subscription/unreads';
import WebsocketManager from '@init/websocket_manager';
@@ -141,7 +141,7 @@ const ServerItem = ({isActive, server}: Props) => {
if (isActive) {
// eslint-disable-next-line no-console
console.log('ACTIVE SERVER', server.displayName);
DeviceEventEmitter.emit(Navigation.NAVIGATION_CLOSE_MODAL);
DeviceEventEmitter.emit(Events.CLOSE_BOTTOM_SHEET);
return;
}

View File

@@ -9,7 +9,7 @@ import DocumentPicker, {DocumentPickerResponse} from 'react-native-document-pick
import {Asset, CameraOptions, ImageLibraryOptions, ImagePickerResponse, launchCamera, launchImageLibrary} from 'react-native-image-picker';
import Permissions, {AndroidPermission, IOSPermission} from 'react-native-permissions';
import {Navigation} from '@constants';
import {Events} from '@constants';
import {extractFileInfo, lookupMimeType} from '@utils/file';
const ShareExtension = NativeModules.MattermostShare;
@@ -101,7 +101,7 @@ export default class FilePickerUtil {
const out = await extractFileInfo(files);
if (out.length > 0) {
DeviceEventEmitter.emit(Navigation.NAVIGATION_CLOSE_MODAL);
DeviceEventEmitter.emit(Events.CLOSE_BOTTOM_SHEET);
this.uploadFiles(out);
}
};

View File

@@ -25,6 +25,15 @@
"apps.error.responses.unknown_type": "App response type not supported. Response type: {type}.",
"apps.error.unknown": "Unknown error occurred.",
"archivedChannelMessage": "You are viewing an **archived channel**. New messages cannot be posted.",
"browse_channels.archivedChannels": "Archived Channels",
"browse_channels.dropdownTitle": "Show",
"browse_channels.noMore": "No more channels to join",
"browse_channels.publicChannels": "Public Channels",
"browse_channels.sharedChannels": "Shared Channels",
"browse_channels.showArchivedChannels": "Show: Archived Channels",
"browse_channels.showPublicChannels": "Show: Public Channels",
"browse_channels.showSharedChannels": "Show: Shared Channels",
"browse_channels.title": "More Channels",
"camera_type.photo.option": "Capture Photo",
"camera_type.title": "Choose an action",
"camera_type.video.option": "Record Video",
@@ -179,7 +188,10 @@
"mobile.components.select_server_view.msg_description": "A Server is your team's communication hub which is accessed through a unique URL",
"mobile.components.select_server_view.msg_welcome": "Welcome",
"mobile.components.select_server_view.proceed": "Proceed",
"mobile.create_channel": "Create",
"mobile.create_channel.public": "New Public Channel",
"mobile.create_post.read_only": "This channel is read-only.",
"mobile.custom_list.no_results": "No Results",
"mobile.custom_status.choose_emoji": "Choose an emoji",
"mobile.custom_status.clear_after": "Clear After",
"mobile.custom_status.clear_after.title": "Clear Custom Status After",
@@ -359,6 +371,7 @@
"post_info.guest": "GUEST",
"post_info.system": "System",
"post_message_view.edited": "(edited)",
"post.options.title": "Options",
"posts_view.newMsg": "New Messages",
"screen.mentions.subtitle": "Messages you've been mentioned in",
"screen.mentions.title": "Recent Mentions",