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

🔧 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

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import androidx.activity.enableEdgeToEdge
import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi
import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.getValue
import androidx.compose.runtime.produceState
import androidx.compose.runtime.remember
Expand All @@ -22,6 +21,7 @@ import androidx.window.layout.WindowInfoTracker
import dagger.hilt.android.AndroidEntryPoint
import io.github.droidkaigi.confsched.data.di.RepositoryProvider
import io.github.droidkaigi.confsched.designsystem.theme.dotGothic16FontFamily
import io.github.droidkaigi.confsched.droidkaigiui.KaigiAppCompositionLocalProvider
import io.github.droidkaigi.confsched.droidkaigiui.compositionlocal.LocalClock
import io.github.droidkaigi.confsched.model.FontFamily.DotGothic16Regular
import io.github.droidkaigi.confsched.model.FontFamily.SystemDefault
Expand Down Expand Up @@ -90,8 +90,10 @@ class MainActivity : ComponentActivity() {
}
}

CompositionLocalProvider(
LocalClock provides clockProvider.clock(),
KaigiAppCompositionLocalProvider(
locals = arrayOf(
LocalClock provides clockProvider.clock(),
),
) {
repositoryProvider.Provide {
KaigiApp(
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ allprojects {
resolutionStrategy {
// When the fixed version is released, remove this block
// https://issuetracker.google.com/issues/341880461
force("androidx.compose.foundation:foundation:1.6.8")
force("androidx.compose.foundation:foundation:1.8.0-alpha01")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.github.droidkaigi.confsched.droidkaigiui

import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.ProvidedValue

@Composable
inline fun KaigiAppCompositionLocalProvider(
vararg locals: ProvidedValue<*>,
crossinline content: @Composable () -> Unit,
) {
CompositionLocalProvider(*locals) {
if (isTest()) {
ProvideAndroidContextToComposeResource()
}
content()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.github.droidkaigi.confsched.droidkaigiui

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()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import androidx.compose.material.icons.filled.Favorite
import androidx.compose.material.icons.filled.Info
import androidx.compose.material.icons.filled.Person
import androidx.compose.material.icons.outlined.FavoriteBorder
import androidx.compose.material.ripple.rememberRipple
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.ripple
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
Expand Down Expand Up @@ -107,7 +107,7 @@ fun TimetableItemCard(
)
.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = rememberRipple(color = LocalRoomTheme.current.primaryColor),
indication = ripple(color = LocalRoomTheme.current.primaryColor),
onClick = dropUnlessResumed { onTimetableItemClick(timetableItem) },
),
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.github.takahirom.roborazzi.ComposePreviewTester.Options
import com.github.takahirom.roborazzi.ComposePreviewTester.Options.JUnit4TestLifecycleOptions
import com.github.takahirom.roborazzi.ExperimentalRoborazziApi
import com.github.takahirom.roborazzi.captureRoboImage
import io.github.droidkaigi.confsched.droidkaigiui.ProvideAndroidContextToComposeResource
import io.github.droidkaigi.confsched.testing.rules.CoilRule
import sergio.sastre.composable.preview.scanner.core.preview.ComposablePreview
import sergio.sastre.composable.preview.scanner.jvm.JvmAnnotationInfo
Expand All @@ -28,6 +29,7 @@ class DroidKaigiKmpPreviewTester : ComposePreviewTester<JvmAnnotationInfo> {
override fun test(preview: ComposablePreview<JvmAnnotationInfo>) {
captureRoboImage("${preview.methodName}.png") {
println(preview.methodName)
ProvideAndroidContextToComposeResource()
preview()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import dagger.hilt.EntryPoints
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import io.github.droidkaigi.confsched.data.di.RepositoryProvider
import io.github.droidkaigi.confsched.droidkaigiui.ProvideAndroidContextToComposeResource
import io.github.droidkaigi.confsched.testing.HiltTestActivity
import org.junit.rules.RuleChain
import org.junit.rules.TestRule
Expand Down Expand Up @@ -141,6 +142,7 @@ class RobotTestRule(
.getRepositoryProvider()
composeTestRule.setContent {
repositoryProvider.Provide {
ProvideAndroidContextToComposeResource()
content()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.dp
import co.touchlab.kermit.Logger
import coil3.compose.AsyncImagePainter
import com.preat.peekaboo.image.picker.toImageBitmap
import io.github.droidkaigi.confsched.droidkaigiui.compositionlocal.LocalClock
import io.github.droidkaigi.confsched.model.generateColoredImageBase64
import io.github.droidkaigi.confsched.profilecard.ProfileCardUiState.Card
import io.github.droidkaigi.confsched.profilecard.decodeBase64Bytes
import kotlinx.coroutines.flow.first

@Composable
Expand All @@ -44,7 +47,17 @@ internal fun BackgroundCapturableCardBack(
}
qrCodeImagePainter.state.first { it is AsyncImagePainter.State.Success }
Logger.d { "BackgroundCapturableCardBack: onCaptured" }
onCaptured(graphicsLayer.toImageBitmap())
try {
// FIXME In the tests currently implemented, an IllegalArgumentException is thrown when SkiaGraphicsLayer.toImageBitmap is executed.
// FIXME https://github.com/DroidKaigi/conference-app-2024/pull/984#issuecomment-2335126855
onCaptured(graphicsLayer.toImageBitmap())
} catch (e: IllegalArgumentException) {
val workAroundImageBitmap = generateColoredImageBase64()
.decodeBase64Bytes()
.toImageBitmap()
onCaptured(workAroundImageBitmap)
Logger.e("In the tests currently implemented, an IllegalArgumentException is thrown when SkiaGraphicsLayer.toImageBitmap is executed.", e)
}
}

Box(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.dp
import co.touchlab.kermit.Logger
import coil3.compose.AsyncImagePainter
import com.preat.peekaboo.image.picker.toImageBitmap
import io.github.droidkaigi.confsched.droidkaigiui.compositionlocal.LocalClock
import io.github.droidkaigi.confsched.model.generateColoredImageBase64
import io.github.droidkaigi.confsched.profilecard.ProfileCardUiState.Card
import io.github.droidkaigi.confsched.profilecard.decodeBase64Bytes
import kotlinx.coroutines.flow.first

@Composable
Expand All @@ -42,7 +45,17 @@ internal fun BackgroundCapturableCardFront(
}
profileImagePainter.state.first { it is AsyncImagePainter.State.Success }
Logger.d { "BackgroundCapturableCardFront: onCaptured" }
onCaptured(graphicsLayer.toImageBitmap())
try {
// FIXME In the tests currently implemented, an IllegalArgumentException is thrown when SkiaGraphicsLayer.toImageBitmap is executed.
// FIXME https://github.com/DroidKaigi/conference-app-2024/pull/984#issuecomment-2335126855
onCaptured(graphicsLayer.toImageBitmap())
} catch (e: IllegalArgumentException) {
val workAroundImageBitmap = generateColoredImageBase64()
.decodeBase64Bytes()
.toImageBitmap()
onCaptured(workAroundImageBitmap)
Logger.e("In the tests currently implemented, an IllegalArgumentException is thrown when SkiaGraphicsLayer.toImageBitmap is executed.", e)
}
}

Box(
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ kotlin = "2.0.10"

androidxCore = "1.13.1"
androidDesugarJdkLibs = "2.0.4"
compose = "2024.06.00"
composeMultiplatform = "1.6.11"
compose = "2024.09.00"
composeMultiplatform = "1.7.0-alpha02"
rin = "0.1.0"
composeInvestigator = "1.5.10-0.2.1"
composeMaterial3 = "1.2.1"
composeMaterial3 = "1.3.0"
composeHiltNavigation = "1.2.0"
androidxLifecycle = "2.8.4"
androidxActivity = "1.9.1"
Expand Down
Loading