Line data Source code
1 : part of 'foss_drawer.dart';
2 :
3 : /// Visual overrides for a single [FossDrawer]. 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 drawer.
6 : ///
7 : /// ```dart
8 : /// FossDrawer(
9 : /// title: const Text('Tinted'),
10 : /// style: FossDrawerStyle(backgroundColor: const Color(0xFF101014)),
11 : /// );
12 : /// ```
13 : @immutable
14 : class FossDrawerStyle {
15 : /// Creates a set of drawer overrides. All fields default to null (inherit).
16 1 : const FossDrawerStyle({
17 : this.backgroundColor,
18 : this.borderColor,
19 : this.borderRadius,
20 : this.shadows,
21 : this.titleStyle,
22 : this.descriptionStyle,
23 : });
24 :
25 : /// Fill of the drawer surface.
26 : final Color? backgroundColor;
27 :
28 : /// Color of the 1px surface border.
29 : final Color? borderColor;
30 :
31 : /// Radius of the exposed corners in logical pixels.
32 : final double? borderRadius;
33 :
34 : /// Drop shadow layers under the surface; empty for none.
35 : final List<BoxShadow>? shadows;
36 :
37 : /// Style of the [FossDrawer.title]. Merged over the token default.
38 : final TextStyle? titleStyle;
39 :
40 : /// Style of the [FossDrawer.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 : FossDrawerStyle merge(FossDrawerStyle? other) {
45 : if (other == null) return this;
46 1 : return FossDrawerStyle(
47 2 : backgroundColor: other.backgroundColor ?? backgroundColor,
48 1 : borderColor: other.borderColor ?? borderColor,
49 1 : borderRadius: other.borderRadius ?? borderRadius,
50 2 : shadows: other.shadows ?? shadows,
51 2 : titleStyle: other.titleStyle ?? titleStyle,
52 2 : descriptionStyle: other.descriptionStyle ?? descriptionStyle,
53 : );
54 : }
55 : }
|