* feature edit profile screen * minor refactoring * Apply suggestions from code review Co-authored-by: Elias Nahum <nahumhbl@gmail.com> * ts fixes * revert floatingTextInput label This reverts commit a778e1f76191aea7c1a18d60a23ffbd6d3dec0eb. * code clean up * Apply suggestions from code review Co-authored-by: Elias Nahum <nahumhbl@gmail.com> * code fix * code fix * Adding preventDoubleTap * rename id to fieldKey * Update edit_profile.tsx * wip * navigating through fields; partly done * navigating through fields - partly done * navigating through fields; partly done * completed field navigation * added theme into dependency array * code clean up * revert conditions for disabling fields * Added colorFilters prop to Loading component * Completed loading feature on Edit Profile screen * code clean up * Add profile_error * renamed valid_mime_types to valid_image_mime_types * added props isDisabled to email field * refactored next field logic * fix * fix * code clean up * code clean up * Updated ESLINT hook rules to warning instead of disabled * code fix * code fix * new line within your_profile component * added memo for Field component * added canSave to dependency array * update loading component - color filter * Update app/screens/edit_profile/edit_profile.tsx Co-authored-by: Elias Nahum <nahumhbl@gmail.com> * dependency fix * fix to fetch my latest status * fix to remove unnecessary user id for local action updateLocalUser * prevents bouncing for iOS * code revert * Adding textInputStyle and animatedTextStyle to FloatingTextInput component * correction after dev session * adding changes as per new ux * Update edit_profile.tsx * corrections after ux review * ux review * ux review * code clean up * Adding userProfileFields into useMemo * Add enableSaveButton to dependency of submitUser * Added react-native-image-picker * fix picker util * Added action for setDefaultProfileImage * account outline on remove picture * Update edit_profile.tsx * fix image picker * style fix * fix image picker * removed unused types * mmjstool issue with integrity checksum * perform camera permission check for Android * fix to pull latest status * updated ChangeProfilePicture to EditProfilePciture * removed integrity key for mmjstool in package-lock.json * corrections from pr review * bumping react-native-image-picker to v4.7.1 * pod install * update to hooks dependency * fix profile picture component * added event emitter from edit_profile_picture * made hitslop a constant * code clean up * uploadProfilePicture as a remote action * else if profileImage removed * removed check on isBot * update renderProfilePicture dependencies * extractFileInfo with try catch * updated snappoints * Revert "updated snappoints" This reverts commit 6d16d480a168755fc80e5bc80569ad3ba561f73b. * profile picture size * refactored renderProfilePicture into its own component * change to if else * platform select for hasPermissions * unneeded comment removed * else if on prefix in edit profile picture * track has update user info now * moved image_picker under edit_screen and increased actionSheets item height * added preventDoubleTap for imagePicker * multiple uploads * switch the conditions * added alert box as requested by Marina * Revert "added alert box as requested by Marina" This reverts commit 20735c17a87b40995e05eb4318c138c1adcc6c8c. * Apply suggestions from code review Co-authored-by: Elias Nahum <nahumhbl@gmail.com> * removed userInfos constant * added useMemo for certain components on profile_picture * converting account-outline into a constant * added panelItem component * adding return instead of making the function return * eslint fix * update i18n desc Co-authored-by: Elias Nahum <nahumhbl@gmail.com> * hasPictureUrl transferred to file utils * removing excess mediaType prop * add USER_PROFILE_PICTURE_SIZE into constant/profile * relocate hasPictureUrl method * relocate hasPictureUrl * rename ImagePicker to ProfileImagePicker * removing isDestructive property from panelTypes. * update sectionLimit for attachFileFromPhotoGallery * Change animation for showModalOverCurrentContext to a quick alpha on iOS * re-create PickerUtil if intl changes * Combine styles in edit_profile_picture component * Split profile image component into smaller components * useCallback for showFileAttachmentOptions * split comment into multiple lines * edit_profile group refs * remove unnecessary casting * add new line to file.d.ts * remove extra space for utils/index.d.ts * allowMultiSelection for attachFilesFromFiles, default is false * Split edit profile screen into smaller components Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
80 lines
2.1 KiB
TypeScript
80 lines
2.1 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import React, {useMemo} from 'react';
|
|
import FastImage, {Source} from 'react-native-fast-image';
|
|
|
|
import CompassIcon from '@components/compass_icon';
|
|
import {ACCOUNT_OUTLINE_IMAGE} from '@constants/profile';
|
|
import {useServerUrl} from '@context/server';
|
|
import {useTheme} from '@context/theme';
|
|
import NetworkManager from '@init/network_manager';
|
|
import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme';
|
|
|
|
import type {Client} from '@client/rest';
|
|
import type UserModel from '@typings/database/models/servers/user';
|
|
|
|
type Props = {
|
|
author?: UserModel;
|
|
iconSize?: number;
|
|
size: number;
|
|
source?: Source | string;
|
|
};
|
|
|
|
const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => {
|
|
return {
|
|
icon: {
|
|
color: changeOpacity(theme.centerChannelColor, 0.48),
|
|
},
|
|
};
|
|
});
|
|
|
|
const Image = ({author, iconSize, size, source}: Props) => {
|
|
const theme = useTheme();
|
|
const serverUrl = useServerUrl();
|
|
const style = getStyleSheet(theme);
|
|
const fIStyle = useMemo(() => ({
|
|
borderRadius: size / 2,
|
|
height: size,
|
|
width: size,
|
|
}), [size]);
|
|
|
|
if (typeof source === 'string') {
|
|
return (
|
|
<CompassIcon
|
|
name={source}
|
|
size={iconSize || size}
|
|
style={style.icon}
|
|
/>
|
|
);
|
|
}
|
|
|
|
let client: Client | undefined;
|
|
|
|
try {
|
|
client = NetworkManager.getClient(serverUrl);
|
|
} catch {
|
|
// handle below that the client is not set
|
|
}
|
|
|
|
if (author && client) {
|
|
const pictureUrl = client.getProfilePictureUrl(author.id, author.lastPictureUpdate);
|
|
const imgSource = source ?? {uri: `${serverUrl}${pictureUrl}`};
|
|
return (
|
|
<FastImage
|
|
key={pictureUrl}
|
|
style={fIStyle}
|
|
source={imgSource as Source}
|
|
/>
|
|
);
|
|
}
|
|
return (
|
|
<CompassIcon
|
|
name={ACCOUNT_OUTLINE_IMAGE}
|
|
size={iconSize || size}
|
|
style={style.icon}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default Image;
|