From dbe565319d9edd4016b7bdd97923e475095a13c7 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Thu, 5 Jan 2023 09:51:51 +0200 Subject: [PATCH] BottomSheet migration to react-native-bottom-sheet (#6907) * BottomSheet migration to react-native-bottom-sheet * Use correct scroll view for announcement bottom sheet * ux review * Fix post options bottom sheet snap point * feedback review --- NOTICE.txt | 22 -- .../announcement_banner.tsx | 16 +- .../expanded_announcement_banner.tsx | 10 +- .../channel_actions/channel_actions.tsx | 4 +- .../markdown/at_mention/at_mention.tsx | 7 +- .../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 +- .../camera_quick_action/index.tsx | 3 +- .../post_priority_action/index.tsx | 9 +- .../post_list/post/body/failed/index.tsx | 6 +- .../post_priority_picker/index.tsx | 2 + app/components/team_list/index.tsx | 37 +++- app/components/user_avatars_stack/index.tsx | 10 +- .../user_avatars_stack/users_list/index.tsx | 16 +- app/constants/reaction_picker.ts | 2 + app/constants/view.ts | 7 +- .../calls/screens/call_screen/call_screen.tsx | 6 +- app/screens/bottom_sheet/button.tsx | 102 ++++++--- app/screens/bottom_sheet/content.tsx | 25 +-- app/screens/bottom_sheet/index.tsx | 205 +++++++++--------- app/screens/bottom_sheet/indicator.tsx | 2 +- .../browse_channels/channel_dropdown.tsx | 6 +- app/screens/channel/header/header.tsx | 14 +- .../channel/header/quick_actions/index.tsx | 12 +- .../components/profile_image_picker.tsx | 6 +- .../options/user_presence/index.tsx | 2 +- .../categories_list/header/header.tsx | 6 +- .../home/channel_list/servers/index.tsx | 30 ++- .../servers_list/add_server_button.tsx | 32 +++ .../servers/servers_list/index.tsx | 16 +- ...slideup.tsx => bottom_sheet_team_list.tsx} | 3 +- .../results/file_options/mobile_options.tsx | 3 +- app/screens/home/search/results/header.tsx | 3 +- app/screens/home/search/team_picker_icon.tsx | 30 ++- app/screens/navigation.ts | 6 +- app/screens/post_options/post_options.tsx | 57 +++-- app/screens/reactions/reactions.tsx | 6 +- app/screens/reactions/reactors_list/index.tsx | 15 +- app/screens/thread_options/thread_options.tsx | 4 +- app/screens/user_profile/user_profile.tsx | 68 +++--- app/utils/helpers.ts | 11 +- app/utils/team_list/index.ts | 32 --- package-lock.json | 63 ++++-- package.json | 2 +- types/components/bottom_sheet.d.ts | 4 + 47 files changed, 547 insertions(+), 399 deletions(-) create mode 100644 app/screens/home/channel_list/servers/servers_list/add_server_button.tsx rename app/screens/home/search/{select_team_slideup.tsx => bottom_sheet_team_list.tsx} (88%) delete mode 100644 app/utils/team_list/index.ts create mode 100644 types/components/bottom_sheet.d.ts diff --git a/NOTICE.txt b/NOTICE.txt index 8453b77d5..c4a1b9f94 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -2962,28 +2962,6 @@ IN THE SOFTWARE. """ ---- - -## reanimated-bottom-sheet - -This product contains a modified version of 'reanimated-bottom-sheet' by Michał Osadnik. - -Highly configurable component imitating native bottom sheet behavior, with fully native 60 FPS animations! - -* HOMEPAGE: - * https://github.com/osdnk/react-native-reanimated-bottom-sheet - -* LICENSE: MIT - -Copyright 2019 – present Michał Osadnik - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - --- ## semver diff --git a/app/components/announcement_banner/announcement_banner.tsx b/app/components/announcement_banner/announcement_banner.tsx index 4008b5c86..08f4bcd17 100644 --- a/app/components/announcement_banner/announcement_banner.tsx +++ b/app/components/announcement_banner/announcement_banner.tsx @@ -9,6 +9,7 @@ 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'; @@ -17,6 +18,7 @@ import {ANNOUNCEMENT_BAR_HEIGHT} from '@constants/view'; import {useServerUrl} from '@context/server'; import {useTheme} from '@context/theme'; import {bottomSheet} from '@screens/navigation'; +import {bottomSheetSnapPoint} from '@utils/helpers'; import {getMarkdownTextStyles} from '@utils/markdown'; import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme'; import {typography} from '@utils/typography'; @@ -82,6 +84,7 @@ 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); @@ -100,19 +103,20 @@ const AnnouncementBanner = ({ defaultMessage: 'Announcement', }); - let snapPoint = SNAP_POINT_WITHOUT_DISMISS; - if (allowDismissal) { - snapPoint += DISMISS_BUTTON_HEIGHT; - } + const snapPoint = bottomSheetSnapPoint( + 1, + SNAP_POINT_WITHOUT_DISMISS + (allowDismissal ? DISMISS_BUTTON_HEIGHT : 0), + bottom, + ); bottomSheet({ closeButtonId: CLOSE_BUTTON_ID, title, renderContent, - snapPoints: [snapPoint, 10], + snapPoints: [1, snapPoint], theme, }); - }, [theme.sidebarHeaderTextColor, intl.locale, renderContent, allowDismissal]); + }, [theme.sidebarHeaderTextColor, intl.locale, renderContent, allowDismissal, bottom]); const handleDismiss = useCallback(() => { dismissAnnouncement(serverUrl, bannerText); diff --git a/app/components/announcement_banner/expanded_announcement_banner.tsx b/app/components/announcement_banner/expanded_announcement_banner.tsx index 22de72d02..a34938b3c 100644 --- a/app/components/announcement_banner/expanded_announcement_banner.tsx +++ b/app/components/announcement_banner/expanded_announcement_banner.tsx @@ -1,11 +1,11 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. +import {BottomSheetScrollView} from '@gorhom/bottom-sheet'; import React, {useCallback, useMemo} from 'react'; import {useIntl} from 'react-intl'; -import {Text, View} from 'react-native'; +import {ScrollView, Text, View} from 'react-native'; import Button from 'react-native-button'; -import {ScrollView} from 'react-native-gesture-handler'; import {useSafeAreaInsets} from 'react-native-safe-area-context'; import {dismissAnnouncement} from '@actions/local/systems'; @@ -84,6 +84,8 @@ const ExpandedAnnouncementBanner = ({ return [style.container, {marginBottom: insets.bottom + 10}]; }, [style, insets.bottom]); + const Scroll = useMemo(() => (isTablet ? ScrollView : BottomSheetScrollView), [isTablet]); + return ( {!isTablet && ( @@ -94,7 +96,7 @@ const ExpandedAnnouncementBanner = ({ })} )} - - +