Line data Source code
1 : part of 'foss_tabs.dart';
2 :
3 : /// Visual overrides for a single [FossTabs]. Every field is optional; a null
4 : /// field falls back to the value the theme resolves for the chosen variant.
5 : /// Pass one via `style:` to tweak a one-off without changing the theme for
6 : /// every other tab set.
7 : ///
8 : /// The tab and bar radii stay token-driven; retheme [FossRadii] to change
9 : /// them globally.
10 : ///
11 : /// A segmented set with a green active pill:
12 : ///
13 : /// ```dart
14 : /// FossTabs<String>(
15 : /// tabs: tabs,
16 : /// style: const FossTabsStyle(indicatorColor: Color(0xFF10B981)),
17 : /// );
18 : /// ```
19 : @immutable
20 : class FossTabsStyle {
21 : /// Creates a set of tab overrides. All fields default to null (inherit).
22 1 : const FossTabsStyle({
23 : this.barColor,
24 : this.indicatorColor,
25 : this.indicatorShadow,
26 : this.hoverColor,
27 : this.activeForeground,
28 : this.inactiveForeground,
29 : this.labelStyle,
30 : });
31 :
32 : /// Fill of the segmented strip bar. Unused by the underline variant.
33 : final Color? barColor;
34 :
35 : /// Fill of the active indicator: the segmented pill, or the underline bar.
36 : final Color? indicatorColor;
37 :
38 : /// Shadow layers under the segmented pill; empty for none.
39 : final List<BoxShadow>? indicatorShadow;
40 :
41 : /// Background tint of a hovered underline tab.
42 : final Color? hoverColor;
43 :
44 : /// Label color of the active tab.
45 : final Color? activeForeground;
46 :
47 : /// Label color of inactive tabs.
48 : final Color? inactiveForeground;
49 :
50 : /// Text style of every tab label. Color is applied per state.
51 : final TextStyle? labelStyle;
52 :
53 : /// Returns a copy with every non-null field of [other] laid over this one.
54 : ///
55 : /// ```dart
56 : /// const base = FossTabsStyle(barColor: Color(0xFFEEEEEE));
57 : /// const override = FossTabsStyle(indicatorColor: Color(0xFF10B981));
58 : /// base.merge(override); // barColor kept, indicatorColor added
59 : /// ```
60 1 : FossTabsStyle merge(FossTabsStyle? other) {
61 : if (other == null) return this;
62 1 : return FossTabsStyle(
63 2 : barColor: other.barColor ?? barColor,
64 2 : indicatorColor: other.indicatorColor ?? indicatorColor,
65 2 : indicatorShadow: other.indicatorShadow ?? indicatorShadow,
66 2 : hoverColor: other.hoverColor ?? hoverColor,
67 1 : activeForeground: other.activeForeground ?? activeForeground,
68 2 : inactiveForeground: other.inactiveForeground ?? inactiveForeground,
69 2 : labelStyle: other.labelStyle ?? labelStyle,
70 : );
71 : }
72 : }
|