diff --git a/native/avatars/edit-user-avatar.react.js b/native/avatars/edit-user-avatar.react.js
index 7d1ae7f48..4d6707ecb 100644
--- a/native/avatars/edit-user-avatar.react.js
+++ b/native/avatars/edit-user-avatar.react.js
@@ -1,50 +1,77 @@
// @flow
import * as React from 'react';
-import { TouchableOpacity } from 'react-native';
+import { ActivityIndicator, TouchableOpacity, View } from 'react-native';
import {
useRemoveUserAvatar,
useSelectFromGalleryAndUpdateUserAvatar,
useShowAvatarActionSheet,
} from './avatar-hooks.js';
import EditAvatarBadge from './edit-avatar-badge.react.js';
import UserAvatar from './user-avatar.react.js';
+import { useStyles } from '../themes/colors.js';
type Props = {
+userID: ?string,
+onPressEmojiAvatarFlow: () => mixed,
+disabled?: boolean,
};
function EditUserAvatar(props: Props): React.Node {
+ const styles = useStyles(unboundStyles);
const { userID, onPressEmojiAvatarFlow, disabled } = props;
- const [selectFromGalleryAndUpdateUserAvatar] =
+ const [selectFromGalleryAndUpdateUserAvatar, isGalleryAvatarUpdateLoading] =
useSelectFromGalleryAndUpdateUserAvatar();
- const [removeUserAvatar] = useRemoveUserAvatar();
+ const [removeUserAvatar, isRemoveAvatarUpdateLoading] = useRemoveUserAvatar();
+
+ const isAvatarUpdateInProgress =
+ isGalleryAvatarUpdateLoading || isRemoveAvatarUpdateLoading;
const actionSheetConfig = React.useMemo(
() => [
{ id: 'emoji', onPress: onPressEmojiAvatarFlow },
{ id: 'image', onPress: selectFromGalleryAndUpdateUserAvatar },
{ id: 'remove', onPress: removeUserAvatar },
],
[
onPressEmojiAvatarFlow,
removeUserAvatar,
selectFromGalleryAndUpdateUserAvatar,
],
);
const showAvatarActionSheet = useShowAvatarActionSheet(actionSheetConfig);
+ let spinner;
+ if (isAvatarUpdateInProgress) {
+ spinner = (
+
+
+
+ );
+ }
+
return (
+ {spinner}
{!disabled ? : null}
);
}
+const unboundStyles = {
+ spinnerContainer: {
+ position: 'absolute',
+ alignItems: 'center',
+ justifyContent: 'center',
+ top: 0,
+ bottom: 0,
+ left: 0,
+ right: 0,
+ },
+};
+
export default EditUserAvatar;