Line data Source code
1 : part of 'foss_tooltip.dart';
2 :
3 : /// Visual overrides for a single [FossTooltip]. 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 tooltip.
6 : ///
7 : /// ```dart
8 : /// FossTooltip(
9 : /// message: 'Copy link',
10 : /// style: const FossTooltipStyle(borderRadius: 12),
11 : /// child: FossButton(child: Text('Copy')),
12 : /// );
13 : /// ```
14 : @immutable
15 : class FossTooltipStyle {
16 : /// Creates a set of tooltip overrides. All fields default to null (inherit).
17 1 : const FossTooltipStyle({
18 : this.backgroundColor,
19 : this.borderColor,
20 : this.foregroundColor,
21 : this.borderRadius,
22 : this.shadows,
23 : this.textStyle,
24 : });
25 :
26 : /// Fill of the popup surface.
27 : final Color? backgroundColor;
28 :
29 : /// Color of the 1px popup border.
30 : final Color? borderColor;
31 :
32 : /// Color of the message text.
33 : final Color? foregroundColor;
34 :
35 : /// Corner radius of the popup surface.
36 : final double? borderRadius;
37 :
38 : /// Drop shadow of the popup surface.
39 : final List<BoxShadow>? shadows;
40 :
41 : /// Style of the message text. Merged over the token default.
42 : final TextStyle? textStyle;
43 :
44 : /// Returns a copy with every non-null field of [other] laid over this one.
45 1 : FossTooltipStyle merge(FossTooltipStyle? other) {
46 : if (other == null) return this;
47 1 : return FossTooltipStyle(
48 2 : backgroundColor: other.backgroundColor ?? backgroundColor,
49 2 : borderColor: other.borderColor ?? borderColor,
50 1 : foregroundColor: other.foregroundColor ?? foregroundColor,
51 1 : borderRadius: other.borderRadius ?? borderRadius,
52 2 : shadows: other.shadows ?? shadows,
53 2 : textStyle: other.textStyle ?? textStyle,
54 : );
55 : }
56 : }
|