import 'package:flutter/material.dart'; import 'scale_theme.dart'; enum ScaleToastKind { info, error, } class ScaleToastTheme { ScaleToastTheme( {required this.primaryColor, required this.backgroundColor, required this.foregroundColor, required this.borderSide, required this.borderRadius, required this.padding, required this.icon, required this.titleTextStyle, required this.descriptionTextStyle}); final Color primaryColor; final Color backgroundColor; final Color foregroundColor; final BorderSide? borderSide; final BorderRadiusGeometry borderRadius; final EdgeInsetsGeometry padding; final Icon icon; final TextStyle titleTextStyle; final TextStyle descriptionTextStyle; } extension ScaleToastThemeExt on ScaleTheme { ScaleToastTheme toastTheme(ScaleToastKind kind) { final toastScaleColor = scheme.scale(ScaleKind.tertiary); final primaryColor = toastScaleColor.calloutText; final borderColor = toastScaleColor.border; final backgroundColor = config.useVisualIndicators ? toastScaleColor.calloutText : toastScaleColor.calloutBackground; final textColor = config.useVisualIndicators ? toastScaleColor.calloutBackground : toastScaleColor.calloutText; final titleColor = config.useVisualIndicators ? toastScaleColor.calloutBackground : toastScaleColor.calloutText; Icon icon; switch (kind) { case ScaleToastKind.info: icon = Icon(Icons.info, size: 32, color: primaryColor); case ScaleToastKind.error: icon = Icon(Icons.dangerous, size: 32, color: primaryColor); } return ScaleToastTheme( primaryColor: primaryColor, backgroundColor: backgroundColor, foregroundColor: textColor, borderSide: (config.useVisualIndicators || config.preferBorders) ? BorderSide(color: borderColor, width: 2) : const BorderSide(color: Colors.transparent, width: 0), borderRadius: BorderRadius.circular(12 * config.borderRadiusScale), padding: const EdgeInsets.all(8), icon: icon, titleTextStyle: textTheme.labelMedium!.copyWith(color: titleColor), descriptionTextStyle: textTheme.labelMedium!.copyWith(color: textColor)); } }