Line data Source code
1 : part of 'foss_alert.dart';
2 :
3 : /// Visual overrides for a single [FossAlert]. Every field is optional; a null
4 : /// field falls back to the value the variant and theme resolve. Pass one via
5 : /// `style:` to tweak a one-off without changing the theme.
6 : ///
7 : /// ```dart
8 : /// FossAlert(
9 : /// title: const Text('Heads up'),
10 : /// style: const FossAlertStyle(borderRadius: 8),
11 : /// );
12 : /// ```
13 : @immutable
14 : class FossAlertStyle {
15 : /// Creates a set of alert overrides. All fields default to null (inherit).
16 1 : const FossAlertStyle({
17 : this.backgroundColor,
18 : this.borderColor,
19 : this.iconColor,
20 : this.borderRadius,
21 : this.titleStyle,
22 : this.descriptionStyle,
23 : });
24 :
25 : /// Fill of the surface.
26 : final Color? backgroundColor;
27 :
28 : /// Color of the 1px border.
29 : final Color? borderColor;
30 :
31 : /// Color of the leading status glyph.
32 : final Color? iconColor;
33 :
34 : /// Corner radius in logical pixels.
35 : final double? borderRadius;
36 :
37 : /// Style of the [FossAlert.title]. Merged over the token default.
38 : final TextStyle? titleStyle;
39 :
40 : /// Style of the [FossAlert.description]. Merged over the token default.
41 : final TextStyle? descriptionStyle;
42 :
43 : /// Returns a copy with every non-null field of [other] laid over this one.
44 1 : FossAlertStyle merge(FossAlertStyle? other) {
45 : if (other == null) return this;
46 1 : return FossAlertStyle(
47 2 : backgroundColor: other.backgroundColor ?? backgroundColor,
48 1 : borderColor: other.borderColor ?? borderColor,
49 2 : iconColor: other.iconColor ?? iconColor,
50 1 : borderRadius: other.borderRadius ?? borderRadius,
51 2 : titleStyle: other.titleStyle ?? titleStyle,
52 2 : descriptionStyle: other.descriptionStyle ?? descriptionStyle,
53 : );
54 : }
55 : }
|