Skip to content

Commit

Permalink
Add MosaicComposable annotation (#229)
Browse files Browse the repository at this point in the history
The annotation is used to mark Mosaic Compose functions that cannot be used in other Compose code or for other compositions.
  • Loading branch information
EpicDima authored Oct 15, 2023
1 parent 959e78d commit a4dc9ed
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ internal sealed class NoContentMeasureScope {
}

@Composable
@MosaicComposable
internal fun Layout(
modifiers: Modifier = Modifier,
debugInfo: () -> String = { "Layout()" },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.jakewharton.mosaic.ui

import androidx.compose.runtime.ComposableTargetMarker

/**
* An annotation that can be used to mark an composable function as being expected to be use in a
* composable function that is also marked or inferred to be marked as a [MosaicComposable].
*
* Using this annotation explicitly is rarely necessary as the Compose compiler plugin will infer
* the necessary equivalent annotations automatically. See
* [androidx.compose.runtime.ComposableTarget] for details.
*/
@Retention(AnnotationRetention.BINARY)
@ComposableTargetMarker(description = "Mosaic Composable")
@Target(
AnnotationTarget.FUNCTION,
AnnotationTarget.PROPERTY_GETTER,
AnnotationTarget.TYPE,
AnnotationTarget.TYPE_PARAMETER,
)
public annotation class MosaicComposable
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import com.jakewharton.mosaic.layout.MosaicNode
import com.jakewharton.mosaic.modifier.Modifier

@Composable
@MosaicComposable
internal inline fun Node(
content: @Composable () -> Unit = {},
content: @Composable @MosaicComposable () -> Unit = {},
modifiers: Modifier,
measurePolicy: MeasurePolicy,
debugPolicy: DebugPolicy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.jakewharton.mosaic.text.TextLayout
import kotlin.jvm.JvmName

@Composable
@MosaicComposable
public fun Text(
value: String,
modifier: Modifier = Modifier,
Expand Down

0 comments on commit a4dc9ed

Please sign in to comment.