import { type FC } from "react"; import { View } from "react-native"; import type INotificationIndicatorProps from "./type"; import stylesheet, { getNotificationIndicatorType, useStyles } from "./stylesheet"; import { NCoreUIKitTheme } from "../../core/hooks"; import type ITextProps from "../text/type"; import Loading from "../loading"; import Text from "../text"; const NotificationIndicator: FC = ({ floorBackgroundColor = "default", titleVariant = "labelSmallSize", spreadBehaviour = "baseline", isDisabled = false, type = "neutral", customTheme, titleStyle, isLoading, location, children, title, style, ...props }) => { const { typography, radiuses, borders, colors, spaces } = NCoreUIKitTheme.useContext(customTheme); const currentType = getNotificationIndicatorType({ type }); const { indicatorContainer: indicatorContainerDynamicStyle, titleContainer: titleContainerDynamicStyle, container: containerDynamicStyle, loading: loadingDynamicStyle, overlay: overlayDynamicStyle, title: titleDynamicStyle } = useStyles({ floorBackgroundColor, spreadBehaviour, currentType, isDisabled, isLoading, radiuses, borders, colors, spaces, type }); const titleProps: ITextProps = { color: currentType.titleColor, variant: titleVariant }; const fontSize = typography[titleProps.variant as keyof NCoreUIKit.Typography].fontSize; let baseLocation = location ? location : { bottom: undefined, left: undefined, right: 0, top: 2 }; if(!location && title) { baseLocation = { right: -fontSize / String(title).length, top: -fontSize / 2, bottom: undefined, left: undefined }; } if (isDisabled || isLoading) { const stateType = type === "danger" ? "error" : type; titleProps.customColor = colors.system.state.content.disabled[stateType]; } const renderTitle = () => { if (!title) { return null; } return {title} {renderOverlay()} ; }; const renderIndicatorContainer = () => { if (isLoading) { return ; } return {renderTitle()} ; }; const renderOverlay = () => { return ; }; return {children} {renderIndicatorContainer()} ; }; export default NotificationIndicator;