|
@@ -1,4 +1,5 @@
|
|
|
import {
|
|
import {
|
|
|
|
|
+ type ImageStyle,
|
|
|
type ViewStyle,
|
|
type ViewStyle,
|
|
|
StyleSheet
|
|
StyleSheet
|
|
|
} from "react-native";
|
|
} from "react-native";
|
|
@@ -14,80 +15,150 @@ import type {
|
|
|
} from "../../types";
|
|
} from "../../types";
|
|
|
|
|
|
|
|
export const AVATAR_SIZES: Record<AvatarSizeType, AvatarMeasuresKeys> = {
|
|
export const AVATAR_SIZES: Record<AvatarSizeType, AvatarMeasuresKeys> = {
|
|
|
- xSmall: {
|
|
|
|
|
- paddingHorizontal: "spacingXs",
|
|
|
|
|
- paddingVertical: "spacingXs",
|
|
|
|
|
|
|
+ xxSmall: {
|
|
|
fontSize: "labelSmallSize",
|
|
fontSize: "labelSmallSize",
|
|
|
- iconSize: 14
|
|
|
|
|
|
|
+ statusIndicatorSize: 8,
|
|
|
|
|
+ iconSize: 14,
|
|
|
|
|
+ size: 24
|
|
|
},
|
|
},
|
|
|
- small: {
|
|
|
|
|
- paddingHorizontal: "spacingSm",
|
|
|
|
|
- paddingVertical: "spacingSm",
|
|
|
|
|
|
|
+ xSmall: {
|
|
|
fontSize: "labelMediumSize",
|
|
fontSize: "labelMediumSize",
|
|
|
- iconSize: 18
|
|
|
|
|
|
|
+ statusIndicatorSize: 10,
|
|
|
|
|
+ iconSize: 18,
|
|
|
|
|
+ size: 32
|
|
|
},
|
|
},
|
|
|
- medium: {
|
|
|
|
|
- paddingHorizontal: "spacingMd",
|
|
|
|
|
- paddingVertical: "spacingMd",
|
|
|
|
|
|
|
+ small: {
|
|
|
fontSize: "labelLargeSize",
|
|
fontSize: "labelLargeSize",
|
|
|
- iconSize: 22
|
|
|
|
|
|
|
+ statusIndicatorSize: 12,
|
|
|
|
|
+ iconSize: 22,
|
|
|
|
|
+ size: 40
|
|
|
},
|
|
},
|
|
|
- large: {
|
|
|
|
|
- paddingHorizontal: "spacingLg",
|
|
|
|
|
- paddingVertical: "spacingLg",
|
|
|
|
|
|
|
+ medium: {
|
|
|
fontSize: "bodyLargeSize",
|
|
fontSize: "bodyLargeSize",
|
|
|
- iconSize: 26
|
|
|
|
|
|
|
+ statusIndicatorSize: 14,
|
|
|
|
|
+ iconSize: 26,
|
|
|
|
|
+ size: 48
|
|
|
},
|
|
},
|
|
|
- xLarge: {
|
|
|
|
|
- paddingHorizontal: "spacingXl",
|
|
|
|
|
|
|
+ large: {
|
|
|
fontSize: "headlineSmallSize",
|
|
fontSize: "headlineSmallSize",
|
|
|
- paddingVertical: "spacingXl",
|
|
|
|
|
- iconSize: 32
|
|
|
|
|
|
|
+ statusIndicatorSize: 16,
|
|
|
|
|
+ iconSize: 32,
|
|
|
|
|
+ size: 64
|
|
|
|
|
+ },
|
|
|
|
|
+ xLarge: {
|
|
|
|
|
+ fontSize: "headlineMediumSize",
|
|
|
|
|
+ statusIndicatorSize: 20,
|
|
|
|
|
+ iconSize: 40,
|
|
|
|
|
+ size: 80
|
|
|
|
|
+ },
|
|
|
|
|
+ xxLarge: {
|
|
|
|
|
+ fontSize: "displaySmallSize",
|
|
|
|
|
+ statusIndicatorSize: 28,
|
|
|
|
|
+ iconSize: 60,
|
|
|
|
|
+ size: 120
|
|
|
|
|
+ },
|
|
|
|
|
+ xxxLarge: {
|
|
|
|
|
+ fontSize: "displayMediumSize",
|
|
|
|
|
+ statusIndicatorSize: 32,
|
|
|
|
|
+ iconSize: 76,
|
|
|
|
|
+ size: 150
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
export const getAvatarSize = ({
|
|
export const getAvatarSize = ({
|
|
|
- spaces,
|
|
|
|
|
size
|
|
size
|
|
|
}: AvatarSizeConstantType): AvatarMeasures => {
|
|
}: AvatarSizeConstantType): AvatarMeasures => {
|
|
|
const currentSize = AVATAR_SIZES[size];
|
|
const currentSize = AVATAR_SIZES[size];
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
- paddingHorizontal: spaces[currentSize.paddingHorizontal],
|
|
|
|
|
- paddingVertical: spaces[currentSize.paddingVertical],
|
|
|
|
|
|
|
+ statusIndicatorSize: currentSize.statusIndicatorSize,
|
|
|
fontSize: currentSize.fontSize,
|
|
fontSize: currentSize.fontSize,
|
|
|
- iconSize: currentSize.iconSize
|
|
|
|
|
|
|
+ iconSize: currentSize.iconSize,
|
|
|
|
|
+ size: currentSize.size
|
|
|
};
|
|
};
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const stylesheet = StyleSheet.create({
|
|
const stylesheet = StyleSheet.create({
|
|
|
container: {
|
|
container: {
|
|
|
- overflow: "hidden"
|
|
|
|
|
|
|
+ position: "relative",
|
|
|
|
|
+ display: "flex"
|
|
|
|
|
+ },
|
|
|
|
|
+ image: {
|
|
|
|
|
+ objectFit: "cover"
|
|
|
|
|
+ },
|
|
|
|
|
+ icon: {
|
|
|
|
|
+ },
|
|
|
|
|
+ statusIndicator: {
|
|
|
|
|
+ position: "absolute",
|
|
|
|
|
+ bottom: 0,
|
|
|
|
|
+ right: 0
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
export const useStyles = ({
|
|
export const useStyles = ({
|
|
|
|
|
+ isShowStatusIndicatorSplicer,
|
|
|
|
|
+ avatarBackgroundColor,
|
|
|
|
|
+ statusIndicatorType,
|
|
|
backgroundColor,
|
|
backgroundColor,
|
|
|
borderColor,
|
|
borderColor,
|
|
|
currentSize,
|
|
currentSize,
|
|
|
- iconColor,
|
|
|
|
|
- radiuses,
|
|
|
|
|
|
|
+ isDisabled,
|
|
|
|
|
+ isLoading,
|
|
|
imageUrl,
|
|
imageUrl,
|
|
|
|
|
+ borders,
|
|
|
colors,
|
|
colors,
|
|
|
- spaces,
|
|
|
|
|
image,
|
|
image,
|
|
|
title
|
|
title
|
|
|
}: AvatarDynamicStyleType) => {
|
|
}: AvatarDynamicStyleType) => {
|
|
|
const styles = {
|
|
const styles = {
|
|
|
container: {
|
|
container: {
|
|
|
- backgroundColor: backgroundColor === "transparent" ? "transparent" : colors.content.container[backgroundColor],
|
|
|
|
|
- borderRadius: radiuses.full,
|
|
|
|
|
- padding: spaces.spacingMd
|
|
|
|
|
|
|
+ backgroundColor: backgroundColor ? backgroundColor === "transparent" ? "transparent" : colors.content.container[backgroundColor] : colors.content.container.subtle,
|
|
|
|
|
+ borderColor: borderColor ? borderColor : "transparent",
|
|
|
|
|
+ borderRadius: currentSize.size / 2,
|
|
|
|
|
+ height: currentSize.size,
|
|
|
|
|
+ width: currentSize.size
|
|
|
|
|
+ } as Mutable<ViewStyle>,
|
|
|
|
|
+ image: {
|
|
|
|
|
+ height: currentSize.size,
|
|
|
|
|
+ width: currentSize.size
|
|
|
|
|
+ } as Mutable<ImageStyle>,
|
|
|
|
|
+ icon: {
|
|
|
|
|
+ } as Mutable<ViewStyle>,
|
|
|
|
|
+ statusIndicator: {
|
|
|
|
|
+ borderColor: colors.content.container[avatarBackgroundColor],
|
|
|
|
|
+ backgroundColor: colors.content.icon[statusIndicatorType],
|
|
|
|
|
+ borderRadius: currentSize.statusIndicatorSize / 2,
|
|
|
|
|
+ height: currentSize.statusIndicatorSize,
|
|
|
|
|
+ width: currentSize.statusIndicatorSize
|
|
|
} as Mutable<ViewStyle>
|
|
} as Mutable<ViewStyle>
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
if(!title && !image && !imageUrl && !backgroundColor) {
|
|
if(!title && !image && !imageUrl && !backgroundColor) {
|
|
|
styles.container.backgroundColor = colors.content.container.subtle;
|
|
styles.container.backgroundColor = colors.content.container.subtle;
|
|
|
|
|
+
|
|
|
|
|
+ styles.container.justifyContent = "center";
|
|
|
|
|
+ styles.container.alignItems = "center";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(title) {
|
|
|
|
|
+ styles.container.backgroundColor = colors.content.container.primary;
|
|
|
|
|
+
|
|
|
|
|
+ styles.container.justifyContent = "center";
|
|
|
|
|
+ styles.container.alignItems = "center";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(isShowStatusIndicatorSplicer) {
|
|
|
|
|
+ const multiplier = currentSize.statusIndicatorSize / 14;
|
|
|
|
|
+
|
|
|
|
|
+ styles.statusIndicator.borderWidth = borders.subtract * multiplier;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(isDisabled) {
|
|
|
|
|
+ styles.container.opacity = 0.33;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(isLoading) {
|
|
|
|
|
+ styles.container.opacity = 0.33;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return styles;
|
|
return styles;
|