Add: - ervice/api-client/api-portofolio.ts - creens/Portofolio/BoxPortofolioView.tsx - screens/Portofolio/ButtonCreatePortofolio.tsx - create dan show ### No Issue
66 lines
1.3 KiB
TypeScript
66 lines
1.3 KiB
TypeScript
import API_STRORAGE from "@/constants/base-url-api-strorage";
|
|
import DUMMY_IMAGE from "@/constants/dummy-image-value";
|
|
import { Href, router } from "expo-router";
|
|
import { TouchableOpacity } from "react-native";
|
|
import { Avatar } from "react-native-paper";
|
|
|
|
type Size = "base" | "sm" | "md" | "lg" | "xl";
|
|
|
|
const sizeMap = {
|
|
base: 40,
|
|
sm: 60,
|
|
md: 80,
|
|
lg: 100,
|
|
xl: 120,
|
|
};
|
|
|
|
interface AvatarCompProps {
|
|
fileId?: string;
|
|
fileIdDefault?: string;
|
|
size: Size;
|
|
onPress?: () => void | any;
|
|
href?: Href | undefined | any;
|
|
}
|
|
|
|
export default function AvatarComp({
|
|
fileId,
|
|
fileIdDefault,
|
|
size,
|
|
onPress,
|
|
href = `/(application)/(image)/preview-image/${fileId}`,
|
|
}: AvatarCompProps) {
|
|
const dimension = sizeMap[size];
|
|
|
|
const avatarImage = () => {
|
|
return (
|
|
<Avatar.Image
|
|
size={dimension}
|
|
source={
|
|
fileId
|
|
? { uri: API_STRORAGE.GET({ fileId }) }
|
|
: fileIdDefault
|
|
? fileIdDefault
|
|
: DUMMY_IMAGE.avatar
|
|
}
|
|
/>
|
|
);
|
|
};
|
|
|
|
return (
|
|
<>
|
|
{onPress || href ? (
|
|
<TouchableOpacity
|
|
activeOpacity={0.9}
|
|
onPress={
|
|
href && fileId ? () => router.navigate(href as any) : onPress
|
|
}
|
|
>
|
|
{avatarImage()}
|
|
</TouchableOpacity>
|
|
) : (
|
|
avatarImage()
|
|
)}
|
|
</>
|
|
);
|
|
}
|