import { type TextStyle, type ViewStyle, StyleSheet } from "react-native"; import type { ToastDynamicStyleType, ToastTypeConstantType, ToastTypes, ToastType } from "./type"; import type { Mutable } from "../../types"; export const TOAST_TYPE_STYLES: Record< ToastType, { containerColor: keyof NCoreUIKit.ContainerContentColors; subTitleColor: keyof NCoreUIKit.TextContentColors; actionColor: keyof NCoreUIKit.TextContentColors; titleColor: keyof NCoreUIKit.TextContentColors; iconColor: keyof NCoreUIKit.IconContentColors; } > = { success: { subTitleColor: "successLow", containerColor: "success", actionColor: "success", titleColor: "success", iconColor: "success" }, warning: { subTitleColor: "warningLow", containerColor: "warning", actionColor: "warning", titleColor: "warning", iconColor: "warning" }, danger: { subTitleColor: "dangerLow", containerColor: "danger", actionColor: "danger", titleColor: "danger", iconColor: "danger" }, info: { subTitleColor: "infoLow", containerColor: "info", actionColor: "info", titleColor: "info", iconColor: "info" }, primary: { actionColor: "onPrimary", iconColor: "emphasized", containerColor: "mid", subTitleColor: "low", titleColor: "mid" }, neutral: { containerColor: "mid", subTitleColor: "low", actionColor: "mid", titleColor: "mid", iconColor: "mid" } }; export const getToastType = ({ type }: ToastTypeConstantType): ToastTypes => { const currentType = TOAST_TYPE_STYLES[type]; return currentType; }; const stylesheet = StyleSheet.create({ contentContainer: { justifyContent: "center", alignItems: "flex-start", flexDirection: "column", flexShrink: 1 }, iconContainer: { justifyContent: "center", alignItems: "center" }, container: { position: "absolute", alignSelf: "center", zIndex: 99998 }, containerObject: { flexDirection: "row", alignItems: "center" }, title: { textAlign: "left" }, subTitle: { textAlign: "left" } }); export const useStyles = ({ safeAreaBottom, currentType, radiuses, subTitle, colors, spaces }: ToastDynamicStyleType) => { const styles = { container: { backgroundColor: colors.content.container[currentType.containerColor], bottom: safeAreaBottom + 100, borderRadius: radiuses.full } as Mutable, containerObject: { paddingHorizontal: spaces.spacingLg, paddingVertical: spaces.spacingMd } as Mutable, action: { paddingBottom: spaces.spacingSm, paddingRight: spaces.spacingSm, paddingLeft: spaces.spacingMd, paddingTop: spaces.spacingSm, marginLeft: spaces.spacingMd } as Mutable, iconContainer: { paddingRight: spaces.spacingSm, marginRight: spaces.spacingSm } as Mutable, subTitle: { marginTop: spaces.spacingXs } as Mutable, contentContainer: { } as Mutable, title: { } as Mutable }; if(subTitle) { styles.container.borderRadius = radiuses.lg; } return styles; }; export default stylesheet;