71 lines
2.5 KiB
TypeScript
71 lines
2.5 KiB
TypeScript
// Metro module 10187 (f10188).
|
|
import { useRef } from "react";
|
|
import { Image as Image2, View } from "react-native";
|
|
import { UPLOAD_MEDIUM_SIZE } from "../../Constants";
|
|
import { createStyles } from "../../design/components/Styles/native/createStyles";
|
|
import UploadUtils from "../../utils/native/UploadUtils";
|
|
import GuildIcon, { GuildIconSizes } from "../../modules/guild/native/GuildIcon";
|
|
import { makeSource } from "../../utils/AvatarUtils";
|
|
import Module10188 from "../../_bundle/Module10188";
|
|
import { PressableOpacity } from "../../design/void/Pressables/native/Pressables";
|
|
import { intl, t } from "../../intl/index.native";
|
|
const useStyles = createStyles({
|
|
uploadIcon: {
|
|
position: "absolute",
|
|
right: -7,
|
|
top: -7
|
|
},
|
|
avatar: {
|
|
height: 64,
|
|
width: 64,
|
|
borderRadius: 32
|
|
}
|
|
});
|
|
export default function IconUploader(props) {
|
|
const { disabled = false, makeURL = (a0) => {}, type = "avatar" } = props;
|
|
let ref;
|
|
const { name, icon, onUpload, style, iconStyle, onChangeIconPress } = props;
|
|
ref = void 0;
|
|
let _handleChangeIcon2 = function _handleChangeIcon() {
|
|
const r9 = async () => {
|
|
let c30203_1;
|
|
let c31523_0;
|
|
L18: {
|
|
c30203_1 = void 0;
|
|
c31523_0 = void 0;
|
|
if (onChangeIconPress != null) {
|
|
onChangeIconPress();
|
|
}
|
|
if (ref.current) {
|
|
break L18;
|
|
}
|
|
ref.current = true;
|
|
c31523_0 = (await UploadUtils.openImagePicker({
|
|
size: UPLOAD_MEDIUM_SIZE
|
|
})).base64;
|
|
if (c31523_0 != null) {
|
|
if (onUpload != null) {
|
|
onUpload(c31523_0);
|
|
}
|
|
}
|
|
ref.current = false;
|
|
return void 0;
|
|
}
|
|
};
|
|
_handleChangeIcon2 = r9;
|
|
return r9.apply(this, arguments);
|
|
};
|
|
const styles = useStyles();
|
|
ref = useRef(false);
|
|
const icon2 = icon != null ? /^data:/.test(icon) ? icon : makeURL(icon) : makeURL(icon);
|
|
const r64 = <>
|
|
{type === "guild" ? icon == null && name == null ? void 0 : <GuildIcon style={iconStyle} icon={icon2} value={name} size={GuildIconSizes.XLARGE} animate /> : <Image2 style={[styles.avatar, iconStyle]} source={makeSource(icon2)} />}
|
|
{disabled ? null : <Image2 style={styles.uploadIcon} source={Module10188} />}
|
|
</>;
|
|
return disabled ? r64 : <View style={style}>
|
|
<PressableOpacity accessibilityRole="button" accessibilityLabel={intl.string(t["MsUY/S"])} onPress={function handleChangeIcon() {
|
|
return _handleChangeIcon2.apply(this, arguments);
|
|
}}>{r64}</PressableOpacity>
|
|
</View>;
|
|
};
|