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 ( + + + + ); +} + +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 ( - - - - ); - }, [ - colors.floatingButtonLabel, - disabled, - styles.editAvatarIcon, - styles.editAvatarIconContainer, - ]); + let editBadge; + if (!disabled) { + editBadge = ; + } return ( @@ -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 ( - - - - ); - }, [ - colors.floatingButtonLabel, - disabled, - styles.editAvatarIcon, - styles.editAvatarIconContainer, - ]); + let editBadge; + if (!disabled) { + editBadge = ; + } return ( @@ -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', },