Skip to content

Commit d703732

Browse files
authored
patch: More theme tokens (#31)
* Added new theme tokens * wip
1 parent f853b18 commit d703732

File tree

2 files changed

+97
-7
lines changed

2 files changed

+97
-7
lines changed

lib/src/ui/theme/preprocessor.dart

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ final class ThemePreprocessor {
2929
"Align" ||
3030
"BackdropFilter" ||
3131
"ColoredBox" ||
32-
"ConstrainedBoxAttributes" ||
32+
"ConstrainedBox" ||
3333
"DecoratedBox" ||
3434
"Expanded" ||
3535
"FittedBox" ||
@@ -44,7 +44,8 @@ final class ThemePreprocessor {
4444
"RotatedBox" ||
4545
"Stack" ||
4646
"Wrap" ||
47-
"Transform" =>
47+
"Transform" ||
48+
"Card" =>
4849
AnimatedPropOwnerThemeToken(
4950
themeData,
5051
widgetType,
@@ -53,19 +54,28 @@ final class ThemePreprocessor {
5354
themeData,
5455
widgetType,
5556
),
57+
"GestureDetector" || "InkWell" => ExcludeGestureCallbacksThemeToken(
58+
themeData,
59+
widgetType,
60+
),
61+
"AppBar" || "Scaffold" => ExcludeChildThemeToken(
62+
themeData,
63+
widgetType,
64+
),
65+
"GridView" || "ListView" => DynamicChildHolderThemeToken(
66+
themeData,
67+
widgetType,
68+
),
5669
"ElevatedButton" ||
5770
"Center" ||
58-
"IgnorePointerAttributes" ||
71+
"IgnorePointer" ||
5972
"RepaintBoundary" ||
6073
"SingleChildScrollView" =>
6174
DefaultThemeToken(
6275
themeData,
6376
widgetType,
6477
),
65-
"CheckboxAttributes" ||
66-
"Switch" ||
67-
"TextField" =>
68-
AttendedWidgetThemeToken(
78+
"Checkbox" || "Switch" || "TextField" => AttendedWidgetThemeToken(
6979
themeData,
7080
widgetType,
7181
),

lib/src/ui/theme/theme_token.dart

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ const _attendedWidgetExcludedFields = {
77
"value",
88
};
99

10+
const _subviewsExcludedFields = {
11+
"leading",
12+
"title",
13+
"actions",
14+
"bottom",
15+
"flexibleSpace",
16+
"body",
17+
"appBar",
18+
"bottomNavigationBar",
19+
"floatingActionButton",
20+
"bottomSheet",
21+
"persistentFooterButtons"
22+
};
23+
1024
/// An abstract class representing a token for a theme in the application.
1125
///
1226
/// [ThemeToken] is used to encapsulate theme-related data for widgets,
@@ -187,3 +201,69 @@ final class SliderThemeToken extends ThemeToken {
187201
"Slider",
188202
);
189203
}
204+
205+
final class ExcludeGestureCallbacksThemeToken extends ThemeToken {
206+
const ExcludeGestureCallbacksThemeToken(
207+
Map<String, dynamic> data,
208+
String type,
209+
) : super(
210+
const {
211+
..._animatedOwnerExcludedFields,
212+
"onTap",
213+
"onTapDown",
214+
"onTapUp",
215+
"onTapCancel",
216+
"onDoubleTap",
217+
"onDoubleTapDown",
218+
"onDoubleTapCancel",
219+
"onLongPressDown",
220+
"onLongPressCancel",
221+
"onLongPress",
222+
"onLongPressStart",
223+
"onLongPressMoveUpdate",
224+
"onLongPressUp",
225+
"onLongPressEnd",
226+
"onPanStart",
227+
"onPanDown",
228+
"onPanUpdate",
229+
"onPanEnd",
230+
"onPanCancel",
231+
"onSecondaryTapDown",
232+
"onSecondaryTapCancel",
233+
"onSecondaryTap",
234+
"onSecondaryTapUp",
235+
},
236+
data,
237+
type,
238+
);
239+
}
240+
241+
final class ExcludeChildThemeToken extends ThemeToken {
242+
const ExcludeChildThemeToken(
243+
Map<String, dynamic> data,
244+
String type,
245+
) : super(
246+
const {
247+
..._animatedOwnerExcludedFields,
248+
..._subviewsExcludedFields,
249+
},
250+
data,
251+
type,
252+
);
253+
}
254+
255+
final class DynamicChildHolderThemeToken extends ThemeToken {
256+
const DynamicChildHolderThemeToken(
257+
Map<String, dynamic> data,
258+
String type,
259+
) : super(
260+
const {
261+
"childObjects",
262+
"constructor",
263+
"type",
264+
"restorationId",
265+
},
266+
data,
267+
type,
268+
);
269+
}

0 commit comments

Comments
 (0)