From 7cb2ee75b364c8073a0d84039d7067c2ec593781 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Fri, 29 Nov 2024 12:50:09 +0800 Subject: [PATCH] Fix bottomSheet bottom insets (#8331) * Fix bottomSheet bottom insets * fix search team picker on android * ux review * fix footer padding for message priority modal on iPad --- .../announcement_banner/announcement_banner.tsx | 5 +---- .../channel_bookmarks/add_bookmark.tsx | 15 +++++++++------ .../channel_bookmark/channel_bookmark.tsx | 6 ++---- .../channel_bookmarks/channel_bookmarks.tsx | 5 +++-- .../file_options/mobile_options.tsx | 5 +---- app/components/files_search/file_results.tsx | 1 - .../markdown/at_mention/at_mention.tsx | 6 ++---- .../markdown/markdown_code_block/index.tsx | 6 ++---- .../markdown/markdown_image/index.tsx | 6 ++---- .../markdown/markdown_latex_block/index.tsx | 6 ++---- .../markdown/markdown_link/markdown_link.tsx | 6 ++---- .../quick_actions/camera_quick_action/index.tsx | 6 ++---- .../post_priority_action/index.tsx | 2 +- .../body/acknowledgements/acknowledgements.tsx | 10 ++++++---- .../users_list/user_list_item.tsx | 2 +- .../post_list/post/body/failed/index.tsx | 6 ++---- .../post_list/post/body/reactions/reactions.tsx | 2 +- app/components/post_list/post/footer/footer.tsx | 2 +- app/components/selected_users/index.tsx | 15 +++++++-------- app/components/team_list/index.tsx | 1 + app/components/user_avatars_stack/index.tsx | 14 +++++++++----- app/components/user_list/index.tsx | 6 +++--- .../calls/components/audio_device_button.tsx | 4 +--- app/products/calls/hooks.ts | 4 ++-- .../calls/screens/call_screen/call_screen.tsx | 8 +++----- .../screens/host_controls/host_controls.tsx | 8 +++----- .../participants_list/participants_list.tsx | 5 +---- app/screens/bottom_sheet/button.tsx | 2 +- app/screens/bottom_sheet/index.tsx | 5 +++++ .../browse_channels/channel_dropdown.tsx | 4 +--- .../intro/direct_channel/member/member.tsx | 2 +- app/screens/channel/header/bookmarks.tsx | 2 +- app/screens/channel/header/header.tsx | 12 +++++++----- .../components/bookmark_detail.tsx | 2 +- app/screens/channel_files/header.tsx | 5 +---- app/screens/channel_info/extra/extra.tsx | 14 +++----------- .../title/public_private/public_private.tsx | 12 ++---------- .../create_direct_message.tsx | 13 ++++++------- app/screens/custom_status/custom_status.tsx | 2 +- .../components/profile_image_picker.tsx | 6 ++---- .../emoji_picker/picker/footer/index.tsx | 4 ++-- .../components/options/user_presence/index.tsx | 6 ++---- .../categories_list/header/header.tsx | 6 ++---- app/screens/home/channel_list/servers/index.tsx | 6 ++---- app/screens/home/search/results/header.tsx | 5 +---- app/screens/home/search/team_picker_icon.tsx | 6 ++---- .../manage_channel_members.tsx | 2 +- app/screens/post_options/post_options.tsx | 6 ++---- .../post_options/reaction_bar/reaction_bar.tsx | 2 +- app/screens/post_priority_picker/footer.tsx | 4 ++-- .../post_priority_picker.tsx | 16 +++++++--------- app/screens/thread_options/thread_options.tsx | 4 +--- app/screens/user_profile/user_profile.tsx | 12 +++++++----- app/utils/helpers.test.ts | 5 ++--- app/utils/helpers.ts | 5 ++--- patches/@gorhom+bottom-sheet+4.6.4.patch | 17 +++++++++++++++++ 56 files changed, 155 insertions(+), 194 deletions(-) create mode 100644 patches/@gorhom+bottom-sheet+4.6.4.patch diff --git a/app/components/announcement_banner/announcement_banner.tsx b/app/components/announcement_banner/announcement_banner.tsx index 70fbd87bc..242a803a6 100644 --- a/app/components/announcement_banner/announcement_banner.tsx +++ b/app/components/announcement_banner/announcement_banner.tsx @@ -9,7 +9,6 @@ import { View, } from 'react-native'; import Animated, {useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated'; -import {useSafeAreaInsets} from 'react-native-safe-area-context'; import {dismissAnnouncement} from '@actions/local/systems'; import CompassIcon from '@components/compass_icon'; @@ -85,7 +84,6 @@ const AnnouncementBanner = ({ const intl = useIntl(); const serverUrl = useServerUrl(); const height = useSharedValue(0); - const {bottom} = useSafeAreaInsets(); const theme = useTheme(); const [visible, setVisible] = useState(false); const style = getStyle(theme); @@ -107,7 +105,6 @@ const AnnouncementBanner = ({ const snapPoint = bottomSheetSnapPoint( 1, SNAP_POINT_WITHOUT_DISMISS + (allowDismissal ? DISMISS_BUTTON_HEIGHT : 0), - bottom, ); bottomSheet({ @@ -117,7 +114,7 @@ const AnnouncementBanner = ({ snapPoints: [1, snapPoint], theme, }); - }, [theme.sidebarHeaderTextColor, intl.locale, renderContent, allowDismissal, bottom]); + }, [theme.sidebarHeaderTextColor, intl.locale, renderContent, allowDismissal]); const handleDismiss = useCallback(() => { dismissAnnouncement(serverUrl, bannerText); diff --git a/app/components/channel_bookmarks/add_bookmark.tsx b/app/components/channel_bookmarks/add_bookmark.tsx index 2a71f4a68..32bc92957 100644 --- a/app/components/channel_bookmarks/add_bookmark.tsx +++ b/app/components/channel_bookmarks/add_bookmark.tsx @@ -3,14 +3,13 @@ import React, {useCallback} from 'react'; import {useIntl} from 'react-intl'; -import {Alert, View, type Insets} from 'react-native'; -import {useSafeAreaInsets} from 'react-native-safe-area-context'; +import {Alert, Platform, View, type Insets} from 'react-native'; import Button from '@components/button'; import {ITEM_HEIGHT} from '@components/option_item'; import {Screens} from '@constants'; import {useTheme} from '@context/theme'; -import {TITLE_HEIGHT} from '@screens/bottom_sheet'; +import {BOTTOM_SHEET_ANDROID_OFFSET, TITLE_HEIGHT} from '@screens/bottom_sheet'; import {bottomSheet, showModal} from '@screens/navigation'; import {bottomSheetSnapPoint} from '@utils/helpers'; import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme'; @@ -81,7 +80,6 @@ const getStyleSheet = makeStyleSheetFromTheme((theme) => ({ const AddBookmark = ({bookmarksCount, channelId, currentUserId, canUploadFiles, showLarge}: Props) => { const theme = useTheme(); const {formatMessage} = useIntl(); - const {bottom} = useSafeAreaInsets(); const styles = getStyleSheet(theme); const onPress = useCallback(() => { @@ -126,14 +124,19 @@ const AddBookmark = ({bookmarksCount, channelId, currentUserId, canUploadFiles, /> ); + let height = bottomSheetSnapPoint(1, (2 * ITEM_HEIGHT)) + TITLE_HEIGHT; + if (Platform.OS === 'android') { + height += BOTTOM_SHEET_ANDROID_OFFSET; + } + bottomSheet({ title: formatMessage({id: 'channel_info.add_bookmark', defaultMessage: 'Add a bookmark'}), renderContent, - snapPoints: [1, bottomSheetSnapPoint(1, (2 * ITEM_HEIGHT), bottom) + TITLE_HEIGHT], + snapPoints: [1, height], theme, closeButtonId: 'close-channel-quick-actions', }); - }, [bottom, bookmarksCount, canUploadFiles, currentUserId, channelId, theme]); + }, [bookmarksCount, canUploadFiles, formatMessage, theme, channelId, currentUserId]); const button = (