Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3366817
D9377.id31696.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D9377.id31696.diff
View Options
diff --git a/native/user-profile/user-profile-avatar.react.js b/native/user-profile/user-profile-avatar.react.js
new file mode 100644
--- /dev/null
+++ b/native/user-profile/user-profile-avatar.react.js
@@ -0,0 +1,72 @@
+// @flow
+
+import { useNavigation, useRoute } from '@react-navigation/native';
+import invariant from 'invariant';
+import * as React from 'react';
+import { View, TouchableOpacity } from 'react-native';
+
+import { userProfileUserInfoContainerHeight } from './user-profile-constants.js';
+import UserAvatar from '../avatars/user-avatar.react.js';
+import { OverlayContext } from '../navigation/overlay-context.js';
+import { UserProfileAvatarModalRouteName } from '../navigation/route-names.js';
+
+const onAvatarLayout = () => {};
+
+type Props = {
+ userID: ?string,
+};
+
+function UserProfileAvatar(props: Props): React.Node {
+ const { userID } = props;
+
+ const { navigate } = useNavigation();
+ const route = useRoute();
+
+ const overlayContext = React.useContext(OverlayContext);
+
+ const avatarRef = React.useRef();
+
+ const onPressAvatar = React.useCallback(() => {
+ invariant(overlayContext, 'UserProfileAvatar should have OverlayContext');
+ overlayContext.setScrollBlockingModalStatus('open');
+
+ const currentAvatarRef = avatarRef.current;
+ if (!currentAvatarRef) {
+ return;
+ }
+
+ currentAvatarRef.measure((x, y, width, height, pageX, pageY) => {
+ const coordinates = {
+ x: pageX,
+ y: pageY,
+ width,
+ height,
+ };
+
+ const verticalBounds = {
+ height: userProfileUserInfoContainerHeight,
+ y: pageY,
+ };
+
+ navigate<'UserProfileAvatarModal'>({
+ name: UserProfileAvatarModalRouteName,
+ params: {
+ presentedFrom: route.key,
+ initialCoordinates: coordinates,
+ verticalBounds,
+ userID,
+ },
+ });
+ });
+ }, [navigate, overlayContext, route.key, userID]);
+
+ return (
+ <TouchableOpacity onPress={onPressAvatar}>
+ <View ref={avatarRef} onLayout={onAvatarLayout}>
+ <UserAvatar size="L" userID={userID} />
+ </View>
+ </TouchableOpacity>
+ );
+}
+
+export default UserProfileAvatar;
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
@@ -12,6 +12,7 @@
import type { UserInfo } from 'lib/types/user-types';
import sleep from 'lib/utils/sleep.js';
+import UserProfileAvatar from './user-profile-avatar.react.js';
import {
userProfileUserInfoContainerHeight,
userProfileBottomPadding,
@@ -20,7 +21,6 @@
} from './user-profile-constants.js';
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';
@@ -160,7 +160,7 @@
<View style={styles.container}>
<SWMansionIcon name="menu-vertical" size={24} style={styles.moreIcon} />
<View style={styles.userInfoContainer}>
- <UserAvatar size="L" userID={userInfo?.id} />
+ <UserProfileAvatar userID={userInfo?.id} />
<View style={styles.usernameContainer}>
<SingleLine style={styles.usernameText}>{usernameText}</SingleLine>
{copyUsernameButton}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 12:37 PM (21 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2584729
Default Alt Text
D9377.id31696.diff (3 KB)
Attached To
Mode
D9377: [native] introduce UserProfileAvatar
Attached
Detach File
Event Timeline
Log In to Comment