Line data Source code
1 : part of 'foss_dialog.dart';
2 :
3 : /// Visual overrides for a single [FossDialog]. Every field is optional; a null
4 : /// field falls back to the value the theme resolves. Pass one via `style:` to
5 : /// tweak a one-off without changing the theme for every other dialog.
6 : ///
7 : /// ```dart
8 : /// FossDialog(
9 : /// title: const Text('Wide'),
10 : /// style: const FossDialogStyle(maxWidth: 640),
11 : /// );
12 : /// ```
13 : @immutable
14 : class FossDialogStyle {
15 : /// Creates a set of dialog overrides. All fields default to null (inherit).
16 2 : const FossDialogStyle({
17 : this.backgroundColor,
18 : this.borderColor,
19 : this.borderRadius,
20 : this.maxWidth,
21 : this.shadows,
22 : this.titleStyle,
23 : this.descriptionStyle,
24 : });
25 :
26 : /// Fill of the dialog surface.
27 : final Color? backgroundColor;
28 :
29 : /// Color of the 1px surface border.
30 : final Color? borderColor;
31 :
32 : /// Corner radius of the surface in logical pixels.
33 : final double? borderRadius;
34 :
35 : /// Maximum width of the centered card in logical pixels.
36 : final double? maxWidth;
37 :
38 : /// Drop shadow layers under the surface; empty for none.
39 : final List<BoxShadow>? shadows;
40 :
41 : /// Style of the [FossDialog.title]. Merged over the token default.
42 : final TextStyle? titleStyle;
43 :
44 : /// Style of the [FossDialog.description]. Merged over the token default.
45 : final TextStyle? descriptionStyle;
46 :
47 : /// Returns a copy with every non-null field of [other] laid over this one.
48 1 : FossDialogStyle merge(FossDialogStyle? other) {
49 : if (other == null) return this;
50 1 : return FossDialogStyle(
51 2 : backgroundColor: other.backgroundColor ?? backgroundColor,
52 2 : borderColor: other.borderColor ?? borderColor,
53 2 : borderRadius: other.borderRadius ?? borderRadius,
54 1 : maxWidth: other.maxWidth ?? maxWidth,
55 1 : shadows: other.shadows ?? shadows,
56 2 : titleStyle: other.titleStyle ?? titleStyle,
57 2 : descriptionStyle: other.descriptionStyle ?? descriptionStyle,
58 : );
59 : }
60 : }
|