Page MenuHomePhabricator

D7502.diff
No OneTemporary

D7502.diff

diff --git a/native/avatars/edit-avatar-badge.react.js b/native/avatars/edit-avatar-badge.react.js
new file mode 100644
--- /dev/null
+++ b/native/avatars/edit-avatar-badge.react.js
@@ -0,0 +1,43 @@
+// @flow
+
+import * as React from 'react';
+import { View } from 'react-native';
+
+import SWMansionIcon from '../components/swmansion-icon.react.js';
+import { useColors, useStyles } from '../themes/colors.js';
+
+function EditAvatarBadge(): React.Node {
+ const colors = useColors();
+ const styles = useStyles(unboundStyles);
+
+ return (
+ <View style={styles.editAvatarIconContainer}>
+ <SWMansionIcon
+ name="edit-2"
+ size={16}
+ style={styles.editAvatarIcon}
+ color={colors.floatingButtonLabel}
+ />
+ </View>
+ );
+}
+
+const unboundStyles = {
+ editAvatarIconContainer: {
+ position: 'absolute',
+ bottom: 0,
+ right: 0,
+ borderWidth: 2,
+ borderColor: 'panelForeground',
+ borderRadius: 18,
+ width: 36,
+ height: 36,
+ backgroundColor: 'purpleButton',
+ justifyContent: 'center',
+ },
+ editAvatarIcon: {
+ textAlign: 'center',
+ },
+};
+
+export default EditAvatarBadge;
diff --git a/native/avatars/edit-thread-avatar.react.js b/native/avatars/edit-thread-avatar.react.js
--- a/native/avatars/edit-thread-avatar.react.js
+++ b/native/avatars/edit-thread-avatar.react.js
@@ -2,12 +2,13 @@
import { useActionSheet } from '@expo/react-native-action-sheet';
import * as React from 'react';
-import { View, TouchableOpacity, Platform } from 'react-native';
+import { TouchableOpacity, Platform } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { useSelectAndUploadFromGallery } from './avatar-hooks.js';
+import EditAvatarBadge from './edit-avatar-badge.react.js';
import SWMansionIcon from '../components/swmansion-icon.react.js';
-import { useColors, useStyles } from '../themes/colors.js';
+import { useStyles } from '../themes/colors.js';
type Props = {
+children: React.Node,
@@ -18,7 +19,6 @@
const { onPressEmojiAvatarFlow, children, disabled } = props;
const { showActionSheetWithOptions } = useActionSheet();
- const colors = useColors();
const styles = useStyles(unboundStyles);
const selectAndUploadFromGallery = useSelectAndUploadFromGallery();
@@ -105,27 +105,10 @@
);
}, [editAvatarOptions, insets.bottom, showActionSheetWithOptions]);
- const editBadge = React.useMemo(() => {
- if (disabled) {
- return null;
- }
-
- return (
- <View style={styles.editAvatarIconContainer}>
- <SWMansionIcon
- name="edit-2"
- size={16}
- style={styles.editAvatarIcon}
- color={colors.floatingButtonLabel}
- />
- </View>
- );
- }, [
- colors.floatingButtonLabel,
- disabled,
- styles.editAvatarIcon,
- styles.editAvatarIconContainer,
- ]);
+ let editBadge;
+ if (!disabled) {
+ editBadge = <EditAvatarBadge />;
+ }
return (
<TouchableOpacity onPress={onPressEditAvatar} disabled={disabled}>
@@ -136,21 +119,6 @@
}
const unboundStyles = {
- editAvatarIconContainer: {
- position: 'absolute',
- bottom: 0,
- right: 0,
- borderWidth: 2,
- borderColor: 'panelForeground',
- borderRadius: 18,
- width: 36,
- height: 36,
- backgroundColor: 'purpleButton',
- justifyContent: 'center',
- },
- editAvatarIcon: {
- textAlign: 'center',
- },
bottomSheetIcon: {
color: '#000000',
},
diff --git a/native/avatars/edit-user-avatar.react.js b/native/avatars/edit-user-avatar.react.js
--- a/native/avatars/edit-user-avatar.react.js
+++ b/native/avatars/edit-user-avatar.react.js
@@ -2,12 +2,13 @@
import { useActionSheet } from '@expo/react-native-action-sheet';
import * as React from 'react';
-import { View, TouchableOpacity, Platform } from 'react-native';
+import { TouchableOpacity, Platform } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { useSelectAndUploadFromGallery } from './avatar-hooks.js';
+import EditAvatarBadge from './edit-avatar-badge.react.js';
import SWMansionIcon from '../components/swmansion-icon.react.js';
-import { useColors, useStyles } from '../themes/colors.js';
+import { useStyles } from '../themes/colors.js';
type Props = {
+children: React.Node,
@@ -18,7 +19,6 @@
const { onPressEmojiAvatarFlow, children, disabled } = props;
const { showActionSheetWithOptions } = useActionSheet();
- const colors = useColors();
const styles = useStyles(unboundStyles);
const selectAndUploadFromGallery = useSelectAndUploadFromGallery();
@@ -105,27 +105,10 @@
);
}, [editAvatarOptions, insets.bottom, showActionSheetWithOptions]);
- const editBadge = React.useMemo(() => {
- if (disabled) {
- return null;
- }
-
- return (
- <View style={styles.editAvatarIconContainer}>
- <SWMansionIcon
- name="edit-2"
- size={16}
- style={styles.editAvatarIcon}
- color={colors.floatingButtonLabel}
- />
- </View>
- );
- }, [
- colors.floatingButtonLabel,
- disabled,
- styles.editAvatarIcon,
- styles.editAvatarIconContainer,
- ]);
+ let editBadge;
+ if (!disabled) {
+ editBadge = <EditAvatarBadge />;
+ }
return (
<TouchableOpacity onPress={onPressEditAvatar} disabled={disabled}>
@@ -136,21 +119,6 @@
}
const unboundStyles = {
- editAvatarIconContainer: {
- position: 'absolute',
- bottom: 0,
- right: 0,
- borderWidth: 2,
- borderColor: 'panelForeground',
- borderRadius: 18,
- width: 36,
- height: 36,
- backgroundColor: 'purpleButton',
- justifyContent: 'center',
- },
- editAvatarIcon: {
- textAlign: 'center',
- },
bottomSheetIcon: {
color: '#000000',
},

File Metadata

Mime Type
text/plain
Expires
Mon, Oct 7, 3:45 PM (22 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2255167
Default Alt Text
D7502.diff (5 KB)

Event Timeline