| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- import {
- type TextStyle,
- type ViewStyle,
- StyleSheet
- } from "react-native";
- import {
- type NotificationIndicatorDynamicStyleType,
- type NotificationIndicatorTypeConstantType,
- type NotificationIndicatorTypes,
- type NotificationIndicatorType
- } from "./type";
- import type {
- Mutable
- } from "../../types";
- export const NOTIFICATION_INDICATOR_TYPE_STYLES: Record<
- NotificationIndicatorType,
- {
- containerColor: keyof NCoreUIKit.ContainerContentColors;
- subTitleColor: keyof NCoreUIKit.TextContentColors;
- titleColor: keyof NCoreUIKit.TextContentColors;
- }
- > = {
- primary: {
- containerColor: "emphasized",
- titleColor: "emphasized",
- subTitleColor: "low"
- },
- danger: {
- subTitleColor: "dangerLow",
- containerColor: "danger",
- titleColor: "danger"
- },
- success: {
- subTitleColor: "successLow",
- containerColor: "success",
- titleColor: "success"
- },
- warning: {
- subTitleColor: "warningLow",
- containerColor: "warning",
- titleColor: "warning"
- },
- info: {
- subTitleColor: "infoLow",
- containerColor: "info",
- titleColor: "info"
- },
- neutral: {
- containerColor: "mid",
- subTitleColor: "low",
- titleColor: "mid"
- }
- };
- export const getNotificationIndicatorType = ({
- type
- }: NotificationIndicatorTypeConstantType): NotificationIndicatorTypes => {
- const currentType = NOTIFICATION_INDICATOR_TYPE_STYLES[type];
- return currentType;
- };
- const stylesheet = StyleSheet.create({
- container: {
- backgroundColor: "transparent",
- borderColor: "transparent",
- position: "relative"
- },
- indicatorContainer: {
- borderStyle: "solid",
- position: "absolute",
- minHeight: 18,
- minWidth: 18
- },
- titleContainer: {
- position: "relative"
- },
- title: {
- },
- loading: {
- },
- overlay: {
- position: "absolute",
- display: "none",
- zIndex: 999,
- bottom: 0,
- right: 0,
- left: 0,
- top: 0
- }
- });
- export const useStyles = ({
- floorBackgroundColor,
- spreadBehaviour,
- currentType,
- isDisabled,
- isLoading,
- radiuses,
- borders,
- colors,
- spaces,
- type
- }: NotificationIndicatorDynamicStyleType) => {
- const styleType = type === "danger" ? "error" : type;
- const styles = {
- container: {
- padding: spaces.spacingSm,
- alignSelf: "auto"
- } as Mutable<ViewStyle>,
- indicatorContainer: {
- backgroundColor: colors.content.container[currentType.containerColor],
- borderColor: colors.content.container[floorBackgroundColor],
- paddingHorizontal: spaces.spacingSm,
- paddingVertical: spaces.spacingXs,
- borderWidth: borders.subtract,
- borderRadius: radiuses.full
- } as Mutable<ViewStyle>,
- titleContainer: {
- } as Mutable<ViewStyle>,
- title: {
- } as Mutable<TextStyle>,
- loading: {
- } as Mutable<ViewStyle>,
- overlay: {
- } as Mutable<ViewStyle>
- };
- if (spreadBehaviour === "baseline") {
- styles.container.alignSelf = spreadBehaviour;
- styles.container.width = "auto";
- } else if (spreadBehaviour === "stretch") {
- styles.container.alignSelf = spreadBehaviour;
- styles.container.justifyContent = "center";
- styles.container.flexShrink = 1;
- styles.container.width = "100%";
- }
- if (isLoading) {
- styles.overlay.backgroundColor = colors.system.state.overlay.disabled[styleType];
- styles.overlay.display = "flex";
- }
- if (isDisabled) {
- styles.overlay.backgroundColor = colors.system.state.overlay.disabled[styleType];
- styles.overlay.display = "flex";
- }
- return styles;
- };
- export default stylesheet;
|