@@ -9,11 +9,15 @@ class PassiveAppBarTransformer extends NodeWidgetTransformer<AppBarNode> {
99 PassiveAppBarTransformer (super .getNode, super .manager);
1010
1111 @override
12- Widget buildWidget (
12+ PreferredSizeWidget buildWidget (
1313 AppBarNode node,
1414 BuildContext context,
1515 WidgetBuildSettings settings,
1616 ) {
17+ if (settings.buildRawWidget) {
18+ return buildRawAppBar (context, node: node, settings: settings);
19+ }
20+
1721 return PassiveAppBarWidget (
1822 node: node,
1923 settings: settings,
@@ -22,6 +26,71 @@ class PassiveAppBarTransformer extends NodeWidgetTransformer<AppBarNode> {
2226 );
2327 }
2428
29+ PreferredSizeWidget buildRawAppBar (
30+ BuildContext context, {
31+ required AppBarNode node,
32+ WidgetBuildSettings settings = const WidgetBuildSettings (
33+ debugLabel: 'buildPreview' ,
34+ replaceVariablesWithSymbols: true ,
35+ ),
36+ List <VariableData > variablesOverrides = const [],
37+ }) {
38+ final Widget ? leading = node.properties.leading.icon.show &&
39+ ! node.properties.automaticallyImplyLeading
40+ ? retrieveIconWidget (node.properties.leading.icon, null )
41+ : null ;
42+
43+ final Widget ? title = node.properties.title.trim ().isEmpty
44+ ? null
45+ : TextUtils .buildText (
46+ context,
47+ node.properties.title,
48+ textAlignHorizontal: null ,
49+ maxLines: null ,
50+ overflow: null ,
51+ node: node,
52+ variablesOverrides: variablesOverrides,
53+ nullSubstitutionMode: settings.nullSubstitutionMode,
54+ replaceVariablesWithSymbol: settings.replaceVariablesWithSymbols,
55+ );
56+ return AppBar (
57+ centerTitle: node.properties.centerTitle,
58+ leading: leading != null
59+ ? IconButton (
60+ onPressed: () => onTriggerAction.call (
61+ context, node.properties.leading.reactions),
62+ icon: leading,
63+ )
64+ : null ,
65+ titleTextStyle: TextUtils .retrieveTextStyleFromProp (
66+ node.properties.titleStyle,
67+ effects: const [],
68+ ),
69+ backgroundColor: node.properties.backgroundColor.toFlutterColor (),
70+ elevation: node.properties.elevation,
71+ automaticallyImplyLeading: node.properties.leading.icon.show
72+ ? node.properties.automaticallyImplyLeading
73+ : false ,
74+ title: title,
75+ foregroundColor:
76+ node.properties.titleStyle.fills.firstOrNull? .toFlutterColor (),
77+ titleSpacing: node.properties.titleSpacing,
78+ shadowColor: node.properties.shadowColor.toFlutterColor (),
79+ actions: [
80+ for (final item
81+ in node.properties.actions.whereType <IconAppBarActionItem >())
82+ IconButton (
83+ onPressed: () => onTriggerAction.call (context, item.reactions),
84+ // splashRadius: 20,
85+ iconSize: item.icon.size,
86+ tooltip: item.tooltip,
87+ icon: retrieveIconWidget (item.icon, item.icon.size) ??
88+ const SizedBox .shrink (),
89+ ),
90+ ],
91+ );
92+ }
93+
2594 void onTriggerAction (BuildContext context, List <Reaction > reactions) async {
2695 final bool executed = await FunctionsRepository .triggerAction (
2796 context, reactions: reactions, TriggerType .click);
@@ -83,6 +152,8 @@ class PassiveAppBarTransformer extends NodeWidgetTransformer<AppBarNode> {
83152 }
84153}
85154
155+ typedef AppBarBuilder = PreferredSizeWidget Function (BuildContext context);
156+
86157class PassiveAppBarWidget extends StatelessWidget
87158 implements PreferredSizeWidget {
88159 final AppBarNode node;
@@ -97,13 +168,16 @@ class PassiveAppBarWidget extends StatelessWidget
97168 const PassiveAppBarWidget ({
98169 super .key,
99170 required this .node,
100- this .elevation,
101171 required this .settings,
172+ this .elevation,
102173 this .onLeadingPressed,
103174 this .onActionPressed,
104175 this .variablesOverrides = const [],
105176 });
106177
178+ @override
179+ Size get preferredSize => node.outerBoxLocal.size.flutterSize;
180+
107181 @override
108182 Widget build (BuildContext context) {
109183 final Widget ? leading = node.properties.leading.icon.show &&
@@ -164,7 +238,4 @@ class PassiveAppBarWidget extends StatelessWidget
164238 ),
165239 );
166240 }
167-
168- @override
169- Size get preferredSize => node.basicBoxLocal.size.flutterSize;
170241}
0 commit comments