diff --git a/markdown/core/api/core.api b/markdown/core/api/core.api index e732e11cf..82e6953f1 100644 --- a/markdown/core/api/core.api +++ b/markdown/core/api/core.api @@ -444,7 +444,7 @@ public final class org/jetbrains/jewel/markdown/rendering/DefaultInlineMarkdownR public class org/jetbrains/jewel/markdown/rendering/DefaultMarkdownBlockRenderer : org/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer { public static final field $stable I - public fun (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling;Ljava/util/List;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;Lkotlin/jvm/functions/Function1;)V + public fun (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling;Ljava/util/List;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;)V public fun render (Ljava/util/List;Landroidx/compose/runtime/Composer;I)V public fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$BlockQuote;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$BlockQuote;Landroidx/compose/runtime/Composer;I)V public fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$CodeBlock$FencedCodeBlock;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Fenced;Landroidx/compose/runtime/Composer;I)V diff --git a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/DefaultMarkdownBlockRenderer.kt b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/DefaultMarkdownBlockRenderer.kt index aa151e713..96b3853ef 100644 --- a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/DefaultMarkdownBlockRenderer.kt +++ b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/DefaultMarkdownBlockRenderer.kt @@ -77,6 +77,7 @@ public open class DefaultMarkdownBlockRenderer( private val rendererExtensions: List, private val inlineRenderer: InlineMarkdownRenderer, private val onUrlClick: (String) -> Unit, + private val onTextClick: () -> Unit, ) : MarkdownBlockRenderer { @Composable @@ -115,6 +116,7 @@ public open class DefaultMarkdownBlockRenderer( text = renderedContent, textStyle = styling.inlinesStyling.textStyle, color = styling.inlinesStyling.textStyle.color.takeOrElse { LocalContentColor.current }, + onUnhandledClick = onTextClick, ) } @@ -158,6 +160,7 @@ public open class DefaultMarkdownBlockRenderer( text = renderedContent, textStyle = textStyle, color = textStyle.color.takeOrElse { LocalContentColor.current }, + onUnhandledClick = onTextClick, ) if (underlineWidth > 0.dp && underlineColor.isSpecified) { @@ -380,6 +383,7 @@ public open class DefaultMarkdownBlockRenderer( textStyle: TextStyle, modifier: Modifier = Modifier, color: Color = Color.Unspecified, + onUnhandledClick: () -> Unit, ) { var pointerIcon by remember { mutableStateOf(PointerIcon.Default) } @@ -400,8 +404,12 @@ public open class DefaultMarkdownBlockRenderer( } }, ) { offset -> - val span = text.getUrlAnnotations(offset, offset).firstOrNull() ?: return@ClickableText - onUrlClick(span.item.url) + val span = text.getUrlAnnotations(offset, offset).firstOrNull() + if (span != null) { + onUrlClick(span.item.url) + } else { + onUnhandledClick() + } } } diff --git a/markdown/ide-laf-bridge-styling/api/ide-laf-bridge-styling.api b/markdown/ide-laf-bridge-styling/api/ide-laf-bridge-styling.api index 91a91b6c7..4deef211c 100644 --- a/markdown/ide-laf-bridge-styling/api/ide-laf-bridge-styling.api +++ b/markdown/ide-laf-bridge-styling/api/ide-laf-bridge-styling.api @@ -1,6 +1,6 @@ public final class org/jetbrains/jewel/intui/markdown/MarkdownBlockRendererExtensionsKt { - public static final fun create (Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer$Companion;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling;Ljava/util/List;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer; - public static synthetic fun create$default (Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer$Companion;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling;Ljava/util/List;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer; + public static final fun create (Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer$Companion;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling;Ljava/util/List;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer; + public static synthetic fun create$default (Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer$Companion;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling;Ljava/util/List;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer; } public final class org/jetbrains/jewel/intui/markdown/styling/MarkdownBridgeStylingKt { diff --git a/markdown/ide-laf-bridge-styling/src/main/kotlin/org/jetbrains/jewel/intui/markdown/MarkdownBlockRendererExtensions.kt b/markdown/ide-laf-bridge-styling/src/main/kotlin/org/jetbrains/jewel/intui/markdown/MarkdownBlockRendererExtensions.kt index ff1bf487b..d3e7670f2 100644 --- a/markdown/ide-laf-bridge-styling/src/main/kotlin/org/jetbrains/jewel/intui/markdown/MarkdownBlockRendererExtensions.kt +++ b/markdown/ide-laf-bridge-styling/src/main/kotlin/org/jetbrains/jewel/intui/markdown/MarkdownBlockRendererExtensions.kt @@ -12,4 +12,6 @@ public fun MarkdownBlockRenderer.Companion.create( rendererExtensions: List = emptyList(), inlineRenderer: InlineMarkdownRenderer = InlineMarkdownRenderer.default(), onUrlClick: (String) -> Unit = {}, -): MarkdownBlockRenderer = DefaultMarkdownBlockRenderer(styling, rendererExtensions, inlineRenderer, onUrlClick) + onTextClick: () -> Unit = {}, +): MarkdownBlockRenderer = + DefaultMarkdownBlockRenderer(styling, rendererExtensions, inlineRenderer, onUrlClick, onTextClick) diff --git a/markdown/int-ui-standalone-styling/api/int-ui-standalone-styling.api b/markdown/int-ui-standalone-styling/api/int-ui-standalone-styling.api index c70cd0973..6af0bf3c1 100644 --- a/markdown/int-ui-standalone-styling/api/int-ui-standalone-styling.api +++ b/markdown/int-ui-standalone-styling/api/int-ui-standalone-styling.api @@ -1,8 +1,8 @@ public final class org/jetbrains/jewel/intui/markdown/MarkdownBlockRendererExtensionsKt { - public static final fun dark (Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer$Companion;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling;Ljava/util/List;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer; - public static synthetic fun dark$default (Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer$Companion;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling;Ljava/util/List;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer; - public static final fun light (Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer$Companion;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling;Ljava/util/List;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer; - public static synthetic fun light$default (Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer$Companion;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling;Ljava/util/List;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer; + public static final fun dark (Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer$Companion;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling;Ljava/util/List;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer; + public static synthetic fun dark$default (Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer$Companion;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling;Ljava/util/List;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer; + public static final fun light (Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer$Companion;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling;Ljava/util/List;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer; + public static synthetic fun light$default (Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer$Companion;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling;Ljava/util/List;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer; } public final class org/jetbrains/jewel/intui/markdown/styling/MarkdownIntUiStylingKt { diff --git a/markdown/int-ui-standalone-styling/src/main/kotlin/org/jetbrains/jewel/intui/markdown/MarkdownBlockRendererExtensions.kt b/markdown/int-ui-standalone-styling/src/main/kotlin/org/jetbrains/jewel/intui/markdown/MarkdownBlockRendererExtensions.kt index 5400f55f3..89a1326f2 100644 --- a/markdown/int-ui-standalone-styling/src/main/kotlin/org/jetbrains/jewel/intui/markdown/MarkdownBlockRendererExtensions.kt +++ b/markdown/int-ui-standalone-styling/src/main/kotlin/org/jetbrains/jewel/intui/markdown/MarkdownBlockRendererExtensions.kt @@ -13,11 +13,15 @@ public fun MarkdownBlockRenderer.Companion.light( rendererExtensions: List = emptyList(), inlineRenderer: InlineMarkdownRenderer = InlineMarkdownRenderer.default(), onUrlClick: (String) -> Unit = {}, -): MarkdownBlockRenderer = DefaultMarkdownBlockRenderer(styling, rendererExtensions, inlineRenderer, onUrlClick) + onTextClick: () -> Unit = {}, +): MarkdownBlockRenderer = + DefaultMarkdownBlockRenderer(styling, rendererExtensions, inlineRenderer, onUrlClick, onTextClick) public fun MarkdownBlockRenderer.Companion.dark( styling: MarkdownStyling = MarkdownStyling.dark(), rendererExtensions: List = emptyList(), inlineRenderer: InlineMarkdownRenderer = InlineMarkdownRenderer.default(), onUrlClick: (String) -> Unit = {}, -): MarkdownBlockRenderer = DefaultMarkdownBlockRenderer(styling, rendererExtensions, inlineRenderer, onUrlClick) + onTextClick: () -> Unit = {}, +): MarkdownBlockRenderer = + DefaultMarkdownBlockRenderer(styling, rendererExtensions, inlineRenderer, onUrlClick, onTextClick) diff --git a/samples/ide-plugin/src/main/kotlin/org/jetbrains/jewel/samples/ideplugin/MarkdownPreview.kt b/samples/ide-plugin/src/main/kotlin/org/jetbrains/jewel/samples/ideplugin/MarkdownPreview.kt index b2259ed92..2a1cd8027 100644 --- a/samples/ide-plugin/src/main/kotlin/org/jetbrains/jewel/samples/ideplugin/MarkdownPreview.kt +++ b/samples/ide-plugin/src/main/kotlin/org/jetbrains/jewel/samples/ideplugin/MarkdownPreview.kt @@ -33,9 +33,8 @@ internal fun MarkdownPreview(@Language("Markdown") rawMarkdown: String, modifier MarkdownBlockRenderer.create( styling = markdownStyling, inlineRenderer = InlineMarkdownRenderer.default(), - ) { url -> - Desktop.getDesktop().browse(URI.create(url)) - } + onUrlClick = { url -> Desktop.getDesktop().browse(URI.create(url)) }, + ) } SelectionContainer(modifier) { diff --git a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/MarkdownPreview.kt b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/MarkdownPreview.kt index cd729d04a..7670301e4 100644 --- a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/MarkdownPreview.kt +++ b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/MarkdownPreview.kt @@ -71,17 +71,15 @@ internal fun MarkdownPreview( styling = markdownStyling, rendererExtensions = listOf(GitHubAlertRendererExtension(AlertStyling.dark(), markdownStyling)), inlineRenderer = InlineMarkdownRenderer.default(extensions), - ) { url -> - Desktop.getDesktop().browse(URI.create(url)) - } + onUrlClick = { url -> Desktop.getDesktop().browse(URI.create(url)) }, + ) } else { MarkdownBlockRenderer.light( styling = markdownStyling, rendererExtensions = listOf(GitHubAlertRendererExtension(AlertStyling.light(), markdownStyling)), inlineRenderer = InlineMarkdownRenderer.default(extensions), - ) { url -> - Desktop.getDesktop().browse(URI.create(url)) - } + onUrlClick = { url -> Desktop.getDesktop().browse(URI.create(url)) }, + ) } } diff --git a/ui/api/ui.api b/ui/api/ui.api index 7937b85d7..a5f24c312 100644 --- a/ui/api/ui.api +++ b/ui/api/ui.api @@ -134,11 +134,11 @@ public final class org/jetbrains/jewel/ui/component/ButtonState$Companion { public final class org/jetbrains/jewel/ui/component/CheckboxKt { public static final fun Checkbox (ZLkotlin/jvm/functions/Function1;Landroidx/compose/ui/Modifier;ZLorg/jetbrains/jewel/ui/Outline;Landroidx/compose/foundation/interaction/MutableInteractionSource;Lorg/jetbrains/jewel/ui/component/styling/CheckboxColors;Lorg/jetbrains/jewel/ui/component/styling/CheckboxMetrics;Lorg/jetbrains/jewel/ui/component/styling/CheckboxIcons;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/ui/Alignment$Vertical;Landroidx/compose/runtime/Composer;III)V - public static final fun CheckboxRow (Ljava/lang/String;ZLkotlin/jvm/functions/Function1;Landroidx/compose/ui/Modifier;ZLorg/jetbrains/jewel/ui/Outline;Landroidx/compose/foundation/interaction/MutableInteractionSource;Lorg/jetbrains/jewel/ui/component/styling/CheckboxColors;Lorg/jetbrains/jewel/ui/component/styling/CheckboxMetrics;Lorg/jetbrains/jewel/ui/component/styling/CheckboxIcons;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/ui/Alignment$Vertical;Landroidx/compose/runtime/Composer;III)V + public static final fun CheckboxRow (Ljava/lang/String;ZLkotlin/jvm/functions/Function1;Landroidx/compose/ui/Modifier;Landroidx/compose/ui/Modifier;ZLorg/jetbrains/jewel/ui/Outline;Landroidx/compose/foundation/interaction/MutableInteractionSource;Lorg/jetbrains/jewel/ui/component/styling/CheckboxColors;Lorg/jetbrains/jewel/ui/component/styling/CheckboxMetrics;Lorg/jetbrains/jewel/ui/component/styling/CheckboxIcons;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/ui/Alignment$Vertical;Landroidx/compose/runtime/Composer;III)V public static final fun CheckboxRow (ZLkotlin/jvm/functions/Function1;Landroidx/compose/ui/Modifier;ZLorg/jetbrains/jewel/ui/Outline;Landroidx/compose/foundation/interaction/MutableInteractionSource;Lorg/jetbrains/jewel/ui/component/styling/CheckboxColors;Lorg/jetbrains/jewel/ui/component/styling/CheckboxMetrics;Lorg/jetbrains/jewel/ui/component/styling/CheckboxIcons;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/ui/Alignment$Vertical;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;III)V public static final fun TriStateCheckbox (Landroidx/compose/ui/state/ToggleableState;Lkotlin/jvm/functions/Function0;Landroidx/compose/ui/Modifier;ZLorg/jetbrains/jewel/ui/Outline;Landroidx/compose/foundation/interaction/MutableInteractionSource;Lorg/jetbrains/jewel/ui/component/styling/CheckboxColors;Lorg/jetbrains/jewel/ui/component/styling/CheckboxMetrics;Lorg/jetbrains/jewel/ui/component/styling/CheckboxIcons;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/ui/Alignment$Vertical;Landroidx/compose/runtime/Composer;III)V public static final fun TriStateCheckboxRow (Landroidx/compose/ui/state/ToggleableState;Lkotlin/jvm/functions/Function0;Landroidx/compose/ui/Modifier;ZLorg/jetbrains/jewel/ui/Outline;Landroidx/compose/foundation/interaction/MutableInteractionSource;Lorg/jetbrains/jewel/ui/component/styling/CheckboxColors;Lorg/jetbrains/jewel/ui/component/styling/CheckboxMetrics;Lorg/jetbrains/jewel/ui/component/styling/CheckboxIcons;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/ui/Alignment$Vertical;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;III)V - public static final fun TriStateCheckboxRow (Ljava/lang/String;Landroidx/compose/ui/state/ToggleableState;Lkotlin/jvm/functions/Function0;Landroidx/compose/ui/Modifier;ZLorg/jetbrains/jewel/ui/Outline;Landroidx/compose/foundation/interaction/MutableInteractionSource;Lorg/jetbrains/jewel/ui/component/styling/CheckboxColors;Lorg/jetbrains/jewel/ui/component/styling/CheckboxMetrics;Lorg/jetbrains/jewel/ui/component/styling/CheckboxIcons;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/ui/Alignment$Vertical;Landroidx/compose/runtime/Composer;III)V + public static final fun TriStateCheckboxRow (Ljava/lang/String;Landroidx/compose/ui/state/ToggleableState;Lkotlin/jvm/functions/Function0;Landroidx/compose/ui/Modifier;Landroidx/compose/ui/Modifier;ZLorg/jetbrains/jewel/ui/Outline;Landroidx/compose/foundation/interaction/MutableInteractionSource;Lorg/jetbrains/jewel/ui/component/styling/CheckboxColors;Lorg/jetbrains/jewel/ui/component/styling/CheckboxMetrics;Lorg/jetbrains/jewel/ui/component/styling/CheckboxIcons;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/ui/Alignment$Vertical;Landroidx/compose/runtime/Composer;III)V } public final class org/jetbrains/jewel/ui/component/CheckboxState : org/jetbrains/jewel/foundation/state/FocusableComponentState, org/jetbrains/jewel/foundation/state/ToggleableComponentState { diff --git a/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Checkbox.kt b/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Checkbox.kt index eaeaa0ae9..8e4151873 100644 --- a/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Checkbox.kt +++ b/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Checkbox.kt @@ -73,6 +73,7 @@ public fun Checkbox( state = state, onClick = { onCheckedChange.invoke(!checked) }, modifier = modifier, + contentModifier = Modifier, enabled = enabled, outline = outline, interactionSource = interactionSource, @@ -103,6 +104,7 @@ public fun TriStateCheckbox( state = state, onClick = onClick, modifier = modifier, + contentModifier = Modifier, enabled = enabled, outline = outline, interactionSource = interactionSource, @@ -121,6 +123,7 @@ public fun TriStateCheckboxRow( state: ToggleableState, onClick: () -> Unit, modifier: Modifier = Modifier, + textModifier: Modifier = Modifier, enabled: Boolean = true, outline: Outline = Outline.None, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, @@ -134,6 +137,7 @@ public fun TriStateCheckboxRow( state = state, onClick = onClick, modifier = modifier, + contentModifier = textModifier, enabled = enabled, outline = outline, interactionSource = interactionSource, @@ -151,8 +155,9 @@ public fun TriStateCheckboxRow( public fun CheckboxRow( text: String, checked: Boolean, - onCheckedChange: ((Boolean) -> Unit)?, + onCheckedChange: (Boolean) -> Unit, modifier: Modifier = Modifier, + textModifier: Modifier = Modifier, enabled: Boolean = true, outline: Outline = Outline.None, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, @@ -166,8 +171,9 @@ public fun CheckboxRow( CheckboxImpl( state = state, - onClick = { onCheckedChange?.invoke(!checked) }, + onClick = { onCheckedChange(!checked) }, modifier = modifier, + contentModifier = textModifier, enabled = enabled, outline = outline, interactionSource = interactionSource, @@ -184,7 +190,7 @@ public fun CheckboxRow( @Composable public fun CheckboxRow( checked: Boolean, - onCheckedChange: ((Boolean) -> Unit)?, + onCheckedChange: (Boolean) -> Unit, modifier: Modifier = Modifier, enabled: Boolean = true, outline: Outline = Outline.None, @@ -198,8 +204,9 @@ public fun CheckboxRow( ) { CheckboxImpl( state = ToggleableState(checked), - onClick = { onCheckedChange?.invoke(!checked) }, + onClick = { onCheckedChange(!checked) }, modifier = modifier, + contentModifier = Modifier, enabled = enabled, outline = outline, interactionSource = interactionSource, @@ -231,6 +238,7 @@ public fun TriStateCheckboxRow( state = state, onClick = onClick, modifier = modifier, + contentModifier = Modifier, enabled = enabled, outline = outline, interactionSource = interactionSource, @@ -251,6 +259,7 @@ private fun CheckboxImpl( metrics: CheckboxMetrics, icons: CheckboxIcons, modifier: Modifier, + contentModifier: Modifier, enabled: Boolean, outline: Outline, interactionSource: MutableInteractionSource, @@ -315,7 +324,7 @@ private fun CheckboxImpl( val checkboxBoxModifier = Modifier.size(metrics.checkboxSize) if (content == null) { - Box(checkboxBoxModifier, contentAlignment = Alignment.TopStart) { + Box(wrapperModifier.then(checkboxBoxModifier), contentAlignment = Alignment.TopStart) { CheckBoxImage(checkboxPainter) Box(outlineModifier.align(Alignment.Center)) } @@ -335,7 +344,9 @@ private fun CheckboxImpl( LocalTextStyle provides textStyle.copy(color = contentColor.takeOrElse { textStyle.color }), LocalContentColor provides contentColor.takeOrElse { LocalContentColor.current }, ) { - content() + Row(contentModifier) { + content() + } } } }