Line data Source code
1 : part of 'foss_popover.dart';
2 :
3 : /// Visual overrides for a single [FossPopover] surface. Every field is
4 : /// optional; a null field falls back to the value the theme resolves. Pass one
5 : /// via `style:` to tweak a one-off without retheming every other popover.
6 : ///
7 : /// Carries the surface knobs so a taller child can widen the corner and
8 : /// tighten the padding, the way a calendar surface does.
9 : ///
10 : /// ```dart
11 : /// FossPopover(
12 : /// style: FossPopoverStyle(
13 : /// borderRadius: 14,
14 : /// padding: const EdgeInsets.all(8),
15 : /// ),
16 : /// builder: (context) => const Calendar(),
17 : /// child: const FossButton(child: Text('Pick a date')),
18 : /// );
19 : /// ```
20 : @immutable
21 : class FossPopoverStyle {
22 : /// Creates a set of surface overrides. All fields default to null (inherit).
23 1 : const FossPopoverStyle({
24 : this.backgroundColor,
25 : this.borderColor,
26 : this.foregroundColor,
27 : this.borderRadius,
28 : this.padding,
29 : this.shadows,
30 : });
31 :
32 : /// Fill of the surface.
33 : final Color? backgroundColor;
34 :
35 : /// Color of the 1px surface border.
36 : final Color? borderColor;
37 :
38 : /// Default text color of the content.
39 : final Color? foregroundColor;
40 :
41 : /// Corner radius of the surface.
42 : final double? borderRadius;
43 :
44 : /// Padding around the content.
45 : final EdgeInsetsGeometry? padding;
46 :
47 : /// Drop shadow of the surface.
48 : final List<BoxShadow>? shadows;
49 :
50 : /// Returns a copy with every non-null field of [other] laid over this one.
51 1 : FossPopoverStyle merge(FossPopoverStyle? other) {
52 : if (other == null) return this;
53 1 : return FossPopoverStyle(
54 2 : backgroundColor: other.backgroundColor ?? backgroundColor,
55 2 : borderColor: other.borderColor ?? borderColor,
56 2 : foregroundColor: other.foregroundColor ?? foregroundColor,
57 1 : borderRadius: other.borderRadius ?? borderRadius,
58 2 : padding: other.padding ?? padding,
59 2 : shadows: other.shadows ?? shadows,
60 : );
61 : }
62 : }
|