@@ -39,7 +39,7 @@ const getStrokeAlignment = (node: SceneNode): "inside" | "center" | "outside" =>
3939 * @param node - The scene node with stroke properties
4040 * @returns Compose border modifier string
4141 */
42- export const composeBorder = ( node : SceneNode ) : string => {
42+ export const composeBorder = ( node : SceneNode , shape ?: string | null ) : string => {
4343 if ( ! ( "strokes" in node ) ) {
4444 return "" ;
4545 }
@@ -62,7 +62,7 @@ export const composeBorder = (node: SceneNode): string => {
6262 return "" ;
6363 }
6464
65- return generateBorderModifier ( stroke . all , strokeFill , strokeAlignment ) ;
65+ return generateBorderModifier ( stroke . all , strokeFill , strokeAlignment , shape ) ;
6666 } else {
6767 // Handle non-uniform borders
6868 // Compose doesn't have direct support for different border widths per side
@@ -80,7 +80,7 @@ export const composeBorder = (node: SceneNode): string => {
8080
8181 // For now, use uniform border with max width
8282 // TODO: Consider using Canvas or custom drawing for true non-uniform borders
83- return generateBorderModifier ( maxWidth , strokeFill , strokeAlignment ) ;
83+ return generateBorderModifier ( maxWidth , strokeFill , strokeAlignment , shape ) ;
8484 }
8585} ;
8686
@@ -90,7 +90,8 @@ export const composeBorder = (node: SceneNode): string => {
9090const generateBorderModifier = (
9191 width : number ,
9292 fill : Paint ,
93- alignment : "inside" | "center" | "outside"
93+ alignment : "inside" | "center" | "outside" ,
94+ shape ?: string | null
9495) : string => {
9596 const widthDp = `${ numberToFixedString ( width ) } .dp` ;
9697
@@ -109,11 +110,12 @@ const generateBorderModifier = (
109110 // For alignment, we note that Compose doesn't have built-in stroke alignment
110111 // All borders are essentially "inside" by default
111112 // For outside borders, we might need custom drawing or padding adjustments
113+ const shapeParam = shape ? `, shape = ${ shape } ` : "" ;
112114 if ( alignment === "outside" ) {
113115 // Add comment about limitation
114- return `. border(width = ${ widthDp } , color = ${ colorValue } ) // Note: Compose borders are always inside` ;
116+ return `border(width = ${ widthDp } , color = ${ colorValue } ${ shapeParam } ) // Note: Compose borders are always inside` ;
115117 } else {
116- return `. border(width = ${ widthDp } , color = ${ colorValue } )` ;
118+ return `border(width = ${ widthDp } , color = ${ colorValue } ${ shapeParam } )` ;
117119 }
118120 } else if ( fill . type === "GRADIENT_LINEAR" ) {
119121 // Convert gradient to Compose Brush
@@ -133,13 +135,14 @@ const generateBorderModifier = (
133135 } ) . join ( ", " ) ;
134136
135137 const brush = `Brush.linearGradient(
136- colorStops = arrayOf (${ stops } )
138+ listOf (${ stops } )
137139 )` ;
138140
141+ const shapeParam = shape ? `, shape = ${ shape } ` : "" ;
139142 if ( alignment === "outside" ) {
140- return `. border(width = ${ widthDp } , brush = ${ brush } ) // Note: Compose borders are always inside` ;
143+ return `border(width = ${ widthDp } , brush = ${ brush } ${ shapeParam } ) // Note: Compose borders are always inside` ;
141144 } else {
142- return `. border(width = ${ widthDp } , brush = ${ brush } )` ;
145+ return `border(width = ${ widthDp } , brush = ${ brush } ${ shapeParam } )` ;
143146 }
144147 } else if ( fill . type === "GRADIENT_RADIAL" ) {
145148 // Convert radial gradient to Compose Brush
@@ -159,13 +162,14 @@ const generateBorderModifier = (
159162 } ) . join ( ", " ) ;
160163
161164 const brush = `Brush.radialGradient(
162- colorStops = arrayOf (${ stops } )
165+ listOf (${ stops } )
163166 )` ;
164167
168+ const shapeParam = shape ? `, shape = ${ shape } ` : "" ;
165169 if ( alignment === "outside" ) {
166- return `. border(width = ${ widthDp } , brush = ${ brush } ) // Note: Compose borders are always inside` ;
170+ return `border(width = ${ widthDp } , brush = ${ brush } ${ shapeParam } ) // Note: Compose borders are always inside` ;
167171 } else {
168- return `. border(width = ${ widthDp } , brush = ${ brush } )` ;
172+ return `border(width = ${ widthDp } , brush = ${ brush } ${ shapeParam } )` ;
169173 }
170174 }
171175
0 commit comments