• k

    karandeep singh

    2 years ago
    can @Compose annotated functions return values in newer apis now?
    k
    Timo Drick
    +2
    13 replies
    Copy to Clipboard
  • bohregard

    bohregard

    2 years ago
    What's the reason this works:
    val context = ContextAmbient.current
    Card(modifier = Modifier.padding(8.dp) + Modifier.fillMaxWidth()) {
            Button(onClick = {
                Log.d(TAG, "Test")
                Toast.makeText(context, "Toast me bro", Toast.LENGTH_SHORT)
                    .show()
            }) {
                Text(text = "Test")
            }
        }
    }
    but this doesn't
    Card(modifier = Modifier.padding(8.dp) + Modifier.fillMaxWidth()) {
            Button(onClick = {
                Log.d(TAG, "Test")
                Toast.makeText(ContextAmbient.current, "Toast me bro", Toast.LENGTH_SHORT)
                    .show()
            }) {
                Text(text = "Test")
            }
        }
    }
    bohregard
    Adam Powell
    2 replies
    Copy to Clipboard
  • manueldidonna

    manueldidonna

    2 years ago
    I've made thit list with compose. Are these performances normal/expected? Gist: https://gist.github.com/manueldidonna/1eef3017a4ff4e42865641482ea78817
    manueldidonna
    l
    +2
    22 replies
    Copy to Clipboard
  • d

    dagomni

    2 years ago
    I guess until you implement support for Kotlin 1.4 it won't work, but I have to ask Is there any way to make Compose work with 1.4? 😛 I get this error, related to IR
    java.lang.NoSuchMethodError: org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl.<init>(IILkotlin/jvm/functions/Function1;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
    d
    l
    +1
    6 replies
    Copy to Clipboard
  • Gabriel Feo

    Gabriel Feo

    2 years ago
    Will this actually compile with the import to the platform Activity extension, or is it a tooling error?
    Gabriel Feo
    l
    +1
    7 replies
    Copy to Clipboard
  • Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    2 years ago
    Question about
    AdapterList
    performance: with
    RecyclerView
    , when using
    DiffUtil
    to calculate list changes, it’s recommended to run the diff calculation on a background thread since it can be slow. This makes it tricky to use with declarative programming, because state updates to the list don’t synchronously get propagated down the tree (e.g.
    EditText
    in an item view causes a new list to be emitted with new text, but that text doesn’t get bound to the actual view until a few main loop iterations later, which causes state to get out of sync when typing fast). What implications does this have for
    AdapterList
    in Compose? Add/remove item animations can be done at the per-item level, which seems straightforward enough. But if the list is re-ordered, or items are inserted anywhere other than the end of the list, does
    AdapterList
    preserve composable state/groups by keying on the list items (i.e. using key/Pivotal machinery)? If it does, does it process those changes more efficiently than
    DiffUtil
    ? Does this question not even make sense in the Compose world?
    Zach Klippenstein (he/him) [MOD]
    v
    +2
    12 replies
    Copy to Clipboard
  • bohregard

    bohregard

    2 years ago
    Is there known issues with the preview in Dev10 in the latest canary android studio? I'm getting this error in every method that has a preview annotation:
    java.lang.NoClassDefFoundError: Could not initialize class kotlinx.coroutines.Dispatchers   at androidx.ui.core.WrappedComposition$setContent$1.invoke(Wrapper.kt:267)   at androidx.ui.core.WrappedComposition$setContent$1.invoke(Wrapper.kt:-1)   at androidx.compose.internal.RestartableFunction.invoke(RestartableFunction.kt:131)   at androidx.compose.internal.RestartableFunction.invoke(RestartableFunction.kt:-1)   at androidx.compose.ComposerKt.invokeComposable(Composer.kt:2106)   at androidx.compose.Recomposer.recompose$compose_runtime_release(Recomposer.kt:67)   at androidx.compose.CompositionImpl.setContent(Composition.kt:120)   at androidx.ui.core.WrappedComposition.setContent(Wrapper.kt:266)   at androidx.ui.core.WrappedComposition$setContent$2.invoke(Wrapper.kt:277)   at androidx.ui.core.WrappedComposition$setContent$2.invoke(Wrapper.kt:-1)   at androidx.ui.core.SavedStateDelegate.stopWaitingForStateRestoration(SavedStateDelegate.kt:84)   at androidx.ui.core.AndroidComposeView.onMeasure_Original(AndroidOwner.kt:455)   at androidx.ui.core.AndroidComposeView.onMeasure(AndroidOwner.kt:-1)   at android.view.View.measure_Original(View.java:24552)   at android.view.View_Delegate.measure(View_Delegate.java:80)   at android.view.View.measure(View.java:24516)   at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6828)   at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)   at android.view.View.measure_Original(View.java:24552)   at android.view.View_Delegate.measure(View_Delegate.java:80)   at android.view.View.measure(View.java:24516)   at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6828)   at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)   at android.view.View.measure_Original(View.java:24552)   at android.view.View_Delegate.measure(View_Delegate.java:80)   at android.view.View.measure(View.java:24516)   at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:735)   at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:481)   at android.view.View.measure_Original(View.java:24552)   at android.view.View_Delegate.measure(View_Delegate.java:80)   at android.view.View.measure(View.java:24516)   at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6828)   at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)   at android.view.View.measure_Original(View.java:24552)   at android.view.View_Delegate.measure(View_Delegate.java:80)   at android.view.View.measure(View.java:24516) Copy stack to clipboard   Tip: Try to refresh the layout.
    bohregard
    ian.shaun.thomas
    +1
    6 replies
    Copy to Clipboard
  • Karthick

    Karthick

    2 years ago
    why compose uses sp, dp, instead of raw number just like flutter...🤔
    Karthick
    Brian Gardner
    +3
    15 replies
    Copy to Clipboard
  • s

    Sam Woodall

    2 years ago
    Hey, does anyone happen to know why onTap is called when I tap the red box here? but not the green box?
    setContent {
        Stack(Modifier.fillMaxSize()) {
            Box(backgroundColor = Color.Green, modifier = Modifier.tapGestureFilter(onTap = { ... }).preferredSize(200.dp).offset(200.dp, 200.dp))
            Box(backgroundColor = Color.Red, modifier = Modifier.preferredSize(100.dp))
        }
    }
    s
    l
    2 replies
    Copy to Clipboard
  • k

    Kazemihabib1996

    2 years ago
    I'm trying the saveLayer and blendMode (I'm using this for the first time I've never used that before even in the previous android UIToolkit). So I followed this tutorial that's originally written for flutter https://stackoverflow.com/a/59650400/4146943 and I ended up with this code in jetpack compose
    @Composable
    fun testBlending2(modifier: Modifier = Modifier) {
    
        val paint = remember { Paint() }
    
    
        Canvas(modifier = modifier, onCanvas = {
            save()
            val rect = Rect(0f, 0f, 100f, 100f)
            drawRect(rect, paint.apply { color = Color.Red })
            saveLayer(Rect.fromLTWH(0f, 0f, size.width.value, size.height.value), paint.apply { BlendMode.multiply })
    
            drawRect(
                    rect.shift(Offset(20f, 20f)),
                    paint.apply { color = Color.Blue }
            )
            restore()
            restore()
        })
    }
    It's supposed to be but it just produces this image:

    https://i.stack.imgur.com/q3In0.png

    What am I doing wrong?
    k
    r
    27 replies
    Copy to Clipboard