-
Notifications
You must be signed in to change notification settings - Fork 201
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
🔧 By upgrading the version of Compose Multiplatform itself and the accompanying dependencies, we have addressed the issue of fling scrolling not working on iOS in Compose Multiplatform. #984
🔧 By upgrading the version of Compose Multiplatform itself and the accompanying dependencies, we have addressed the issue of fling scrolling not working on iOS in Compose Multiplatform. #984
Conversation
…companying dependencies, we have addressed the issue of fling scrolling not working on iOS in Compose Multiplatform. https://github.com/JetBrains/compose-multiplatform/releases/tag/v1.7.0-alpha02
What is PreviewContextConfigurationEffect...?🤔 |
I think we can have Composable function something like this.
And I think we should invoke it here. |
@takahirom package io.github.droidkaigi.confsched.testing
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.platform.LocalInspectionMode
@Composable
fun ProvideAndroidContextToComposeResource(content: @Composable () -> Unit) {
CompositionLocalProvider(LocalInspectionMode provides true) {
content()
}
} fun setContent(content: @Composable () -> Unit) {
val repositoryProvider = EntryPoints.get(
composeTestRule.activity.application,
RepositoryProviderEntryPoint::class.java,
)
.getRepositoryProvider()
composeTestRule.setContent {
repositoryProvider.Provide {
ProvideAndroidContextToComposeResource {
content()
}
}
}
} override fun test(preview: ComposablePreview<JvmAnnotationInfo>) {
captureRoboImage("${preview.methodName}.png") {
println(preview.methodName)
ProvideAndroidContextToComposeResource {
preview()
}
}
} |
I think we need to do it something like this. I think we also need to invoke override fun test(preview: ComposablePreview<JvmAnnotationInfo>) {
captureRoboImage("${preview.methodName}.png") {
println(preview.methodName)
ProvideAndroidContextToComposeResource()
preview()
}
} |
@takahirom package io.github.droidkaigi.confsched.model
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.platform.LocalInspectionMode
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.PreviewContextConfigurationEffect
@OptIn(ExperimentalResourceApi::class)
@Composable
fun ProvideAndroidContextToComposeResource() {
CompositionLocalProvider(LocalInspectionMode provides true) {
PreviewContextConfigurationEffect()
}
}
fun setContent(content: @Composable () -> Unit) {
val repositoryProvider = EntryPoints.get(
composeTestRule.activity.application,
RepositoryProviderEntryPoint::class.java,
)
.getRepositoryProvider()
composeTestRule.setContent {
repositoryProvider.Provide {
ProvideAndroidContextToComposeResource()
content()
}
}
} override fun test(preview: ComposablePreview<JvmAnnotationInfo>) {
captureRoboImage("${preview.methodName}.png") {
println(preview.methodName)
ProvideAndroidContextToComposeResource()
preview()
}
} |
Thanks. Could you remove this and try again? I think we need |
@takahirom However, it seems that the following errors are still occurring in KaigiAppTest.kt, etc. 🤔
|
KaigiAppTest desn't use the setContent and we can't insert the Android context. Do you have any idea to do this? We might have to have another activity to setting the context before the test. |
@takahirom It seems that the following issues have been addressed.
However, there seems to be a problem with the test for the profile card at the end. 🤔 package io.github.droidkaigi.confsched.model
import android.os.Build
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.ProvidedValue
@Composable
inline fun KaigiAppCompositionLocalProvider(
locals:ProvidedValue<*>,
crossinline content: @Composable () -> Unit,
) {
CompositionLocalProvider(
locals,
) {
if ("robolectric" == Build.FINGERPRINT) {
ProvideAndroidContextToComposeResource()
}
content()
}
}
KaigiAppCompositionLocalProvider(
locals = LocalClock provides clockProvider.clock(),
) {
repositoryProvider.Provide {
KaigiApp(
windowSize = windowSize,
fontFamily = fontFamily,
displayFeatures = displayFeatures,
)
}
}
|
Although I think there is some room for improvement in the KaigiAppCompositionLocalProvider, I believe it is good to have it in production with Line 5 in bab8c00
|
@takahirom |
I'm fine with having |
@takahirom |
…dified to be used.
…the test would not pass. DroidKaigi#984 (comment)
…dified to use KaigiAppCompositionLocalProvider.
@takahirom
This part has already been set in Android/KmpRoborazziPlugin, so there should be no need to add anything in this update, right? Lines 30 to 31 in bab8c00
Line 27 in bab8c00
|
Yes, I think we need to create an issue in the Robolectric repository. But for now, how about using a try-catch block for toBitmap and adding a FIXME comment? |
…hat the test would pass. DroidKaigi#984 (comment)
I'll merge this PR and release version 1.3 today. Thank you for addressing many kinds of issues. |
Sorry for asking so many questions throughout the day.🙇♂️ |
Issue
Overview (Required)
Links
Movie (Optional)
before.mov
after.mov