Line data Source code
1 : // ThemeExtension has no home outside material.dart on the supported SDKs.
2 : // ignore: deprecated_member_use
3 : import 'package:flutter/material.dart' show ThemeExtension;
4 : import 'package:flutter/widgets.dart';
5 : import 'package:fossui/src/theme/lerp_encoders.dart';
6 : import 'package:theme_tailor_annotation/theme_tailor_annotation.dart';
7 :
8 : part 'foss_shadows.tailor.dart';
9 :
10 : /// Layered drop shadows per elevation step. Each is a baked `List<BoxShadow>`
11 : /// (black at low alpha); [none] is an empty list. Resolved at author time, no
12 : /// shadow math at runtime.
13 : ///
14 : /// ```dart
15 : /// const s = FossShadows.standard;
16 : /// DecoratedBox(decoration: BoxDecoration(boxShadow: s.md));
17 : /// ```
18 : @TailorMixin(
19 : themeGetter: ThemeGetter.none,
20 : encoders: [BoxShadowListLerpEncoder()],
21 : )
22 : class FossShadows extends ThemeExtension<FossShadows>
23 : with _$FossShadowsTailorMixin {
24 : /// Creates a shadow scale. Prefer [standard] unless retheming.
25 5 : const FossShadows({
26 : required this.xs,
27 : required this.sm,
28 : required this.md,
29 : required this.lg,
30 : });
31 :
32 : /// Subtle lift: controls, chips.
33 : @override
34 : final List<BoxShadow> xs;
35 :
36 : /// Small elevation: raised buttons.
37 : @override
38 : final List<BoxShadow> sm;
39 :
40 : /// Medium elevation: cards.
41 : @override
42 : final List<BoxShadow> md;
43 :
44 : /// Large elevation: popovers, sheets, dialogs.
45 : @override
46 : final List<BoxShadow> lg;
47 :
48 : /// No shadow.
49 : static const none = <BoxShadow>[];
50 :
51 : /// The default shadow scale.
52 : static const standard = FossShadows(
53 : xs: [
54 : BoxShadow(color: Color(0x0D000000), offset: Offset(0, 1), blurRadius: 2),
55 : ],
56 : sm: [
57 : BoxShadow(color: Color(0x0F000000), offset: Offset(0, 1), blurRadius: 2),
58 : BoxShadow(color: Color(0x1A000000), offset: Offset(0, 1), blurRadius: 3),
59 : ],
60 : md: [
61 : BoxShadow(
62 : color: Color(0x0F000000),
63 : offset: Offset(0, 2),
64 : blurRadius: 4,
65 : spreadRadius: -1,
66 : ),
67 : BoxShadow(
68 : color: Color(0x1A000000),
69 : offset: Offset(0, 4),
70 : blurRadius: 6,
71 : spreadRadius: -1,
72 : ),
73 : ],
74 : lg: [
75 : BoxShadow(
76 : color: Color(0x0D000000),
77 : offset: Offset(0, 4),
78 : blurRadius: 6,
79 : spreadRadius: -2,
80 : ),
81 : BoxShadow(
82 : color: Color(0x1A000000),
83 : offset: Offset(0, 10),
84 : blurRadius: 15,
85 : spreadRadius: -3,
86 : ),
87 : ],
88 : );
89 : }
|