Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MosaicComposable annotation #229

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may need to be moved to another package


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