@@ -207,6 +207,7 @@ internal val LocalButtonStyle = compositionLocalOf { "automatic" }
207207internal val LocalPickerStyle = compositionLocalOf { " automatic" }
208208internal val LocalToggleStyle = compositionLocalOf { " automatic" }
209209internal val LocalTextFieldStyle = compositionLocalOf { " automatic" }
210+ internal val LocalLabelStyle = compositionLocalOf { " automatic" }
210211
211212// / Interprets a Swift-evaluated node tree into Material 3 composables.
212213// /
@@ -242,6 +243,7 @@ internal fun RenderChild(node: ViewNode) {
242243 var pickerStyle = LocalPickerStyle .current
243244 var toggleStyle = LocalToggleStyle .current
244245 var textFieldStyle = LocalTextFieldStyle .current
246+ var labelStyle = LocalLabelStyle .current
245247 for (m in node.modifiers) {
246248 when (m.kind) {
247249 " font" -> {
@@ -260,6 +262,7 @@ internal fun RenderChild(node: ViewNode) {
260262 " pickerStyle" -> m.args.string(" style" )?.let { pickerStyle = it }
261263 " toggleStyle" -> m.args.string(" style" )?.let { toggleStyle = it }
262264 " textFieldStyle" -> m.args.string(" style" )?.let { textFieldStyle = it }
265+ " labelStyle" -> m.args.string(" style" )?.let { labelStyle = it }
263266 }
264267 }
265268
@@ -274,6 +277,7 @@ internal fun RenderChild(node: ViewNode) {
274277 LocalPickerStyle provides pickerStyle,
275278 LocalToggleStyle provides toggleStyle,
276279 LocalTextFieldStyle provides textFieldStyle,
280+ LocalLabelStyle provides labelStyle,
277281 ) { RenderResolved (node) }
278282}
279283
@@ -343,6 +347,8 @@ private fun RenderResolved(node: ViewNode) {
343347 }
344348 }
345349
350+ " Label" -> RenderLabel (node)
351+
346352 " Link" -> RenderLink (node)
347353
348354 " GeometryReader" -> RenderGeometryReader (node)
@@ -601,6 +607,24 @@ private fun RenderLink(node: ViewNode) {
601607 }
602608}
603609
610+ // children are [icon, title]; the inherited label style may drop either half.
611+ @Composable
612+ private fun RenderLabel (node : ViewNode ) {
613+ val icon = node.children.getOrNull(0 )
614+ val title = node.children.getOrNull(1 )
615+ val style = LocalLabelStyle .current
616+ val showIcon = style != " titleOnly"
617+ val showTitle = style != " iconOnly"
618+ Row (
619+ verticalAlignment = Alignment .CenterVertically ,
620+ horizontalArrangement = Arrangement .spacedBy(6 .dp),
621+ modifier = node.composeModifiers(),
622+ ) {
623+ if (showIcon) icon?.let { RenderChild (it) }
624+ if (showTitle) title?.let { RenderChild (it) }
625+ }
626+ }
627+
604628private fun ViewNode.isPresentation (): Boolean =
605629 type == " Sheet" || type == " Alert" || type == " ConfirmationDialog" || type == " ToolbarItem"
606630
@@ -1548,7 +1572,7 @@ private val KNOWN_MODIFIER_KINDS = setOf(
15481572 " transition" , " focused" , " longPress" , " drag" , " contentMode" , " progressViewStyle" ,
15491573 " buttonStyle" , " pickerStyle" , " toggleStyle" , " textFieldStyle" ,
15501574 " accessibilityLabel" , " accessibilityValue" , " accessibilityHidden" ,
1551- " accessibilityAddTraits" , " accessibilityIdentifier" ,
1575+ " accessibilityAddTraits" , " accessibilityIdentifier" , " labelStyle " ,
15521576)
15531577
15541578// Folds a frame entry: fixed size, fill (maxWidth/Height .infinity), bounded
0 commit comments