Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3343931
D9274.id31383.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D9274.id31383.diff
View Options
diff --git a/native/bottom-sheet/bottom-sheet.react.js b/native/bottom-sheet/bottom-sheet.react.js
--- a/native/bottom-sheet/bottom-sheet.react.js
+++ b/native/bottom-sheet/bottom-sheet.react.js
@@ -1,10 +1,12 @@
// @flow
import { BottomSheetModal } from '@gorhom/bottom-sheet';
+import invariant from 'invariant';
import * as React from 'react';
import BottomSheetBackdrop from './bottom-sheet-backdrop.react.js';
import BottomSheetHandle from './bottom-sheet-handle.react.js';
+import { BottomSheetContext } from './bottom-sheet-provider.react.js';
import { useStyles } from '../themes/colors.js';
type Props = {
@@ -20,7 +22,12 @@
const styles = useStyles(unboundStyles);
- const snapPoints = React.useMemo(() => ['25%', '50%'], []);
+ const bottomSheetContext = React.useContext(BottomSheetContext);
+ invariant(bottomSheetContext, 'bottomSheetContext should be set');
+
+ const { contentHeight } = bottomSheetContext;
+
+ const snapPoints = React.useMemo(() => [contentHeight], [contentHeight]);
return (
<BottomSheetModal
diff --git a/native/user-profile/user-profile-relationship-button.react.js b/native/user-profile/user-profile-relationship-button.react.js
--- a/native/user-profile/user-profile-relationship-button.react.js
+++ b/native/user-profile/user-profile-relationship-button.react.js
@@ -5,6 +5,7 @@
import { View, Text } from 'react-native';
import { useRelationshipPrompt } from 'lib/hooks/relationship-prompt.js';
+import type { SetState } from 'lib/types/hook-types.js';
import { userRelationshipStatus } from 'lib/types/relationship-types.js';
import type { ThreadInfo } from 'lib/types/thread-types.js';
import type { UserInfo } from 'lib/types/user-types';
@@ -20,10 +21,15 @@
type Props = {
+threadInfo: ThreadInfo,
+pendingPersonalThreadUserInfo?: UserInfo,
+ +setUserProfileRelationshipButtonHeight: SetState<number>,
};
function UserProfileRelationshipButton(props: Props): React.Node {
- const { threadInfo, pendingPersonalThreadUserInfo } = props;
+ const {
+ threadInfo,
+ pendingPersonalThreadUserInfo,
+ setUserProfileRelationshipButtonHeight,
+ } = props;
const {
otherUserInfo,
@@ -46,6 +52,24 @@
const showWithdrawFriendRequestButton =
otherUserInfo?.relationshipStatus === userRelationshipStatus.REQUEST_SENT;
+ React.useLayoutEffect(() => {
+ if (showNothing) {
+ setUserProfileRelationshipButtonHeight(0);
+ } else if (showIncomingFriendRequestButtons) {
+ const incomingFriendRequestButtonsContainerHeight = 88;
+ setUserProfileRelationshipButtonHeight(
+ incomingFriendRequestButtonsContainerHeight,
+ );
+ } else {
+ const relationshipButtonHeight = 54;
+ setUserProfileRelationshipButtonHeight(relationshipButtonHeight);
+ }
+ }, [
+ setUserProfileRelationshipButtonHeight,
+ showIncomingFriendRequestButtons,
+ showNothing,
+ ]);
+
const styles = useStyles(unboundStyles);
const colors = useColors();
diff --git a/native/user-profile/user-profile.react.js b/native/user-profile/user-profile.react.js
--- a/native/user-profile/user-profile.react.js
+++ b/native/user-profile/user-profile.react.js
@@ -1,8 +1,10 @@
// @flow
import Clipboard from '@react-native-clipboard/clipboard';
+import invariant from 'invariant';
import * as React from 'react';
import { View, Text, TouchableOpacity } from 'react-native';
+import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { useUserProfileThreadInfo } from 'lib/shared/thread-utils.js';
import { stringForUserExplicit } from 'lib/shared/user-utils.js';
@@ -13,6 +15,7 @@
import UserProfileMessageButton from './user-profile-message-button.react.js';
import UserProfileRelationshipButton from './user-profile-relationship-button.react.js';
import UserAvatar from '../avatars/user-avatar.react.js';
+import { BottomSheetContext } from '../bottom-sheet/bottom-sheet-provider.react.js';
import SingleLine from '../components/single-line.react.js';
import SWMansionIcon from '../components/swmansion-icon.react.js';
import { useStyles } from '../themes/colors.js';
@@ -35,6 +38,44 @@
const [usernameCopied, setUsernameCopied] = React.useState<boolean>(false);
+ const [
+ userProfileRelationshipButtonHeight,
+ setUserProfileRelationshipButtonHeight,
+ ] = React.useState<number>(0);
+
+ const bottomSheetContext = React.useContext(BottomSheetContext);
+ invariant(bottomSheetContext, 'bottomSheetContext should be set');
+
+ const { setContentHeight } = bottomSheetContext;
+
+ const insets = useSafeAreaInsets();
+ const bottomInset = insets.bottom;
+
+ React.useLayoutEffect(() => {
+ const userInfoContainerHeight = 90;
+ const bottomPadding = 40;
+
+ let height = bottomInset + userInfoContainerHeight + bottomPadding;
+
+ if (userProfileThreadInfo) {
+ const menuButtonHeight = 24;
+ height += menuButtonHeight;
+ }
+
+ if (userProfileThreadInfo && !userBlockIsActive) {
+ const messageButtonHeight = 54;
+ height += messageButtonHeight + userProfileRelationshipButtonHeight;
+ }
+
+ setContentHeight(height);
+ }, [
+ bottomInset,
+ setContentHeight,
+ userBlockIsActive,
+ userProfileRelationshipButtonHeight,
+ userProfileThreadInfo,
+ ]);
+
const styles = useStyles(unboundStyles);
const onPressCopyUsername = React.useCallback(async () => {
@@ -99,6 +140,9 @@
<UserProfileRelationshipButton
threadInfo={threadInfo}
pendingPersonalThreadUserInfo={pendingPersonalThreadUserInfo}
+ setUserProfileRelationshipButtonHeight={
+ setUserProfileRelationshipButtonHeight
+ }
/>
);
}, [userBlockIsActive, userProfileThreadInfo]);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 4:14 AM (17 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2568103
Default Alt Text
D9274.id31383.diff (5 KB)
Attached To
Mode
D9274: [native] make bottomsheet snap point dynamic
Attached
Detach File
Event Timeline
Log In to Comment