@@ -14,6 +14,8 @@ import {
1414 handle_flutter_case_no_size_stack_children ,
1515} from "../case-handling" ;
1616import { rd } from "../_utils" ;
17+ import assert from "assert" ;
18+ import { WrappingContainer } from "@designto/token/tokens" ;
1719
1820export function buildFlutterWidgetFromTokens (
1921 widget : core . DefaultStyleWidget
@@ -33,6 +35,8 @@ function compose(
3335 widget : core . DefaultStyleWidget ,
3436 context : { is_root : boolean }
3537) {
38+ assert ( widget , "input widget is required" ) ;
39+
3640 const handleChildren = (
3741 children : core . DefaultStyleWidget [ ]
3842 ) : flutter . Widget [ ] => {
@@ -55,6 +59,9 @@ function compose(
5559 ..._remove_width_height_if_root_wh ,
5660 } ;
5761
62+ // const _key = keyFromWidget(widget);
63+ let thisFlutterWidget : flutter . Widget ;
64+
5865 const flex_props = ( f : core . Flex ) => {
5966 return {
6067 mainAxisAlignment : rendering . mainAxisAlignment ( f . mainAxisAlignment ) ,
@@ -63,9 +70,7 @@ function compose(
6370 verticalDirection : painting . verticalDirection ( f . verticalDirection ) ,
6471 } ;
6572 } ;
66- // const _key = keyFromWidget(widget);
6773
68- let thisFlutterWidget : flutter . Widget ;
6974 if ( widget instanceof core . Column ) {
7075 const children = compose_item_spacing_children ( widget . children , {
7176 itemspacing : widget . itemSpacing ,
@@ -106,13 +111,15 @@ function compose(
106111 } ) ;
107112 } else if ( widget instanceof core . Flex ) {
108113 // FIXME: FLEX not supported yet.
109- // thisFlutterWidget = new flutter.Flex({
110- // // direction: widget.direction,
111- // // ...widget,
112- // // ...default_props_for_layout,
113- // children: handleChildren(widget.children),
114- // // key: _key,
115- // });
114+ thisFlutterWidget = new flutter . Flex ( {
115+ ...widget ,
116+ ...default_props_for_layout ,
117+ ...flex_props ( widget ) ,
118+ clipBehavior : null ,
119+ direction : painting . axis ( widget . direction ) ,
120+ children : handleChildren ( widget . children ) ,
121+ // key: _key,
122+ } ) ;
116123 } else if ( widget instanceof core . Stack ) {
117124 const _remove_overflow_if_root_overflow = {
118125 clipBehavior : context . is_root
@@ -163,30 +170,30 @@ function compose(
163170 }
164171 // -------------------------------------
165172 }
173+ } else if ( widget instanceof core . SizedBox ) {
174+ //
175+ } else if ( widget instanceof core . OverflowBox ) {
176+ //
166177 } else if ( widget instanceof core . Opacity ) {
167178 thisFlutterWidget = new flutter . Opacity ( {
168179 opacity : widget . opacity ,
169180 child : handleChild ( widget . child ) ,
170181 } ) ;
182+ } else if ( widget instanceof core . Blurred ) {
183+ // FIXME: blur flutter control
184+ // const isBlurVisibile = widget.blur.visible;
185+ // if (isBlurVisibile) {
186+ // if (widget.blur.type === "LAYER_BLUR") {
187+ // } else if (widget.blur.type === "BACKGROUND_BLUR") {
188+ // }
189+ // }
171190 } else if ( widget instanceof core . Rotation ) {
172191 thisFlutterWidget = flutter . Transform . rotate ( {
173192 angle : widget . rotation ,
174193 child : handleChild ( widget . child ) ,
175194 } ) ;
176195 }
177196
178- // FIXME: blur flutter control
179- // else if (widget instanceof core.Blurred) {
180- // const isBlurVisibile = widget.blur.visible;
181- // if (isBlurVisibile) {
182-
183- // if (widget.blur.type === "LAYER_BLUR") {
184-
185- // } else if (widget.blur.type === "BACKGROUND_BLUR") {
186- // }
187- // }
188- // }
189-
190197 // ----- region clip path ------
191198 else if ( widget instanceof core . ClipRRect ) {
192199 // FIXME: flutter clip rrect support is not ready.
@@ -253,6 +260,41 @@ function compose(
253260 }
254261 }
255262
263+ // #region component widgets
264+ // button
265+ else if ( widget instanceof core . ButtonStyleButton ) {
266+ // TODO: widget.icon - not supported
267+ // thisFlutterWidget = compose_unwrapped_button(_key, widget);
268+ }
269+ // textfield
270+ else if ( widget instanceof core . TextField ) {
271+ // thisFlutterWidget = compose_unwrapped_text_input(_key, widget);
272+ } else if ( widget instanceof core . Slider ) {
273+ // thisFlutterWidget = compose_unwrapped_slider(_key, widget);
274+ }
275+ // wrapping container
276+ else if ( widget instanceof WrappingContainer ) {
277+ // #region
278+ // mergable widgets for web
279+ // if (widget.child instanceof core.TextField) {
280+ // thisFlutterWidget = compose_unwrapped_text_input(
281+ // _key,
282+ // widget.child,
283+ // widget
284+ // );
285+ // } else if (widget.child instanceof core.ButtonStyleButton) {
286+ // thisFlutterWidget = compose_unwrapped_button(_key, widget.child, widget);
287+ // } else if (widget.child instanceof core.Slider) {
288+ // thisFlutterWidget = compose_unwrapped_slider(_key, widget.child, widget);
289+ // } else {
290+ // throw new Error(
291+ // `Unsupported widget type: ${widget.child.constructor.name}`
292+ // );
293+ // }
294+ // #endregion
295+ }
296+ // #endregion
297+
256298 // execution order matters - some above widgets inherits from Container, this shall be handled at the last.
257299 else if ( widget instanceof core . Container ) {
258300 // flutter cannot set both shape circle & border radius.
0 commit comments