@@ -23,101 +23,50 @@ export function wrapWithContainer(
2323 }
2424
2525 // ignore for Groups
26- const propBoxDecoration =
26+ const _boxDecoration =
2727 node instanceof nodes . ReflectGroupNode
2828 ? undefined
2929 : makeBoxDecoration ( node ) ;
30+
3031 // if option passed, use option's value
31- const propSize = array . filters . notEmpty ( options ?. size )
32+ const _size = array . filters . notEmpty ( options ?. size )
3233 ? options . size
3334 : convertToSize ( node ) ;
34- console . log ( "propSize" , propSize ) ;
35+ // console.log("propSize", _size );
3536
3637 // todo Image, Gradient & multiple fills
3738
38- let propPadding : flutter . EdgeInsetsGeometry ;
39+ let _padding : flutter . EdgeInsetsGeometry ;
3940 if ( node instanceof nodes . ReflectFrameNode ) {
40- propPadding = makeEdgeInsets ( node ) ;
41+ _padding = makeEdgeInsets ( node ) ;
4142 }
4243
43- if ( propSize || propBoxDecoration ) {
44+ if ( _size || _boxDecoration ) {
4445 // Container is a container if [propSize] or [propBoxDecoration] are set.
4546 // console.log("wrapping with container. child - ", child)
4647 return new flutter . Container ( {
47- width : roundDouble ( propSize . width ) ,
48- height : roundDouble ( propSize . height ) ,
48+ width : roundDouble ( _size . width ) ,
49+ height : roundDouble ( _size . height ) ,
4950 child : child ,
50- padding : propPadding ,
51+ padding : _padding ,
52+ // region : decoration or color
53+ // flutter only either one of two, but not both. providing both will raise error on flutter runtime.
5154 decoration :
52- propBoxDecoration instanceof flutter . BoxDecoration
53- ? propBoxDecoration
55+ _boxDecoration instanceof flutter . BoxDecoration
56+ ? _boxDecoration
5457 : undefined ,
5558 color :
56- propBoxDecoration instanceof flutter . Color
57- ? propBoxDecoration
58- : undefined ,
59+ _boxDecoration instanceof flutter . Color ? _boxDecoration : undefined ,
60+ // endregion : decoration or color
5961 } ) ;
60- } else if ( propPadding ) {
62+ } else if ( _padding ) {
6163 // console.log("wrapping with padding")
6264 return new flutter . Padding ( {
63- padding : propPadding ,
65+ padding : _padding ,
6466 child : child ,
6567 } ) ;
6668 // if there is just a padding, add Padding
6769 } else {
6870 return child ;
6971 }
7072}
71-
72- type GradientDirection = {
73- begin : flutter . AlignmentGeometry ;
74- end : flutter . AlignmentGeometry ;
75- } ;
76-
77- export function gradientDirection ( angle : number ) : GradientDirection {
78- switch (
79- array . nearestValue ( angle , [ - 180 , - 135 , - 90 , - 45 , 0 , 45 , 90 , 135 , 180 ] )
80- ) {
81- case 0 :
82- return {
83- begin : flutter . Alignment . centerLeft ,
84- end : flutter . Alignment . centerRight ,
85- } ;
86- case 45 :
87- return {
88- begin : flutter . Alignment . topLeft ,
89- end : flutter . Alignment . bottomRight ,
90- } ;
91- case 90 :
92- return {
93- begin : flutter . Alignment . topCenter ,
94- end : flutter . Alignment . bottomCenter ,
95- } ;
96- case 135 :
97- return {
98- begin : flutter . Alignment . topRight ,
99- end : flutter . Alignment . bottomLeft ,
100- } ;
101- case - 45 :
102- return {
103- begin : flutter . Alignment . bottomLeft ,
104- end : flutter . Alignment . topRight ,
105- } ;
106- case - 90 :
107- return {
108- begin : flutter . Alignment . bottomCenter ,
109- end : flutter . Alignment . topCenter ,
110- } ;
111- case - 135 :
112- return {
113- begin : flutter . Alignment . bottomRight ,
114- end : flutter . Alignment . topLeft ,
115- } ;
116- default :
117- // when 180 or -180
118- return {
119- begin : flutter . Alignment . centerRight ,
120- end : flutter . Alignment . centerLeft ,
121- } ;
122- }
123- }
0 commit comments