|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | +import 'package:freezed_annotation/freezed_annotation.dart'; |
| 3 | +import 'package:stac/src/utils/color_utils.dart'; |
| 4 | +import 'package:stac/src/parsers/widgets/stac_shape_border/stac_shape_border.dart'; |
| 5 | +import 'package:stac/src/parsers/widgets/stac_text_style/stac_text_style.dart'; |
| 6 | +import 'package:stac/src/parsers/widgets/stac_edge_insets/stac_edge_insets.dart'; |
| 7 | + |
| 8 | +part 'stac_snack_bar_theme_data.freezed.dart'; |
| 9 | +part 'stac_snack_bar_theme_data.g.dart'; |
| 10 | + |
| 11 | +@freezed |
| 12 | +abstract class StacSnackBarThemeData with _$StacSnackBarThemeData { |
| 13 | + const factory StacSnackBarThemeData({ |
| 14 | + SnackBarBehavior? behavior, |
| 15 | + String? backgroundColor, |
| 16 | + double? elevation, |
| 17 | + StacShapeBorder? shape, |
| 18 | + double? width, |
| 19 | + StacTextStyle? contentTextStyle, |
| 20 | + String? actionTextColor, |
| 21 | + String? disabledActionTextColor, |
| 22 | + StacEdgeInsets? insetPadding, |
| 23 | + DismissDirection? dismissDirection, |
| 24 | + bool? showCloseIcon, |
| 25 | + String? closeIconColor, |
| 26 | + double? actionOverflowThreshold, |
| 27 | + String? actionBackgroundColor, |
| 28 | + String? disabledActionBackgroundColor, |
| 29 | + }) = _StacSnackBarThemeData; |
| 30 | + |
| 31 | + factory StacSnackBarThemeData.fromJson(Map<String, dynamic> json) => |
| 32 | + _$StacSnackBarThemeDataFromJson(json); |
| 33 | +} |
| 34 | + |
| 35 | +extension StacSnackBarThemeDataParser on StacSnackBarThemeData { |
| 36 | + SnackBarThemeData? parse(BuildContext context) { |
| 37 | + return SnackBarThemeData( |
| 38 | + behavior: behavior, |
| 39 | + backgroundColor: backgroundColor?.toColor(context), |
| 40 | + elevation: elevation, |
| 41 | + shape: shape?.parse(context), |
| 42 | + width: width, |
| 43 | + contentTextStyle: contentTextStyle?.parse(context), |
| 44 | + actionTextColor: actionTextColor?.toColor(context), |
| 45 | + disabledActionTextColor: disabledActionTextColor?.toColor(context), |
| 46 | + insetPadding: insetPadding?.parse, |
| 47 | + dismissDirection: dismissDirection, |
| 48 | + showCloseIcon: showCloseIcon, |
| 49 | + closeIconColor: closeIconColor?.toColor(context), |
| 50 | + actionOverflowThreshold: actionOverflowThreshold, |
| 51 | + actionBackgroundColor: actionBackgroundColor?.toColor(context), |
| 52 | + disabledActionBackgroundColor: |
| 53 | + disabledActionBackgroundColor?.toColor(context), |
| 54 | + ); |
| 55 | + } |
| 56 | +} |
0 commit comments