diff --git a/buildSrc/src/main/kotlin/Config.kt b/buildSrc/src/main/kotlin/Config.kt index 7776f9d..83feaf5 100644 --- a/buildSrc/src/main/kotlin/Config.kt +++ b/buildSrc/src/main/kotlin/Config.kt @@ -18,7 +18,7 @@ object Config { const val majorRelease = 1 const val minorRelease = 4 - const val patch = 2 + const val patch = 3 const val postfix = "" const val versionName = "$majorRelease.$minorRelease.$patch$postfix" @@ -47,7 +47,6 @@ object Config { val jvmCompilerArgs = buildList { addAll(compilerArgs) add("-Xjvm-default=all") // enable all jvm optimizations - add("-Xcontext-receivers") add("-Xstring-concat=inline") addAll(optIns.map { "-opt-in=$it" }) } diff --git a/compose/src/commonMain/kotlin/pro/respawn/kmmutils/compose/lazy/PagerEffects.kt b/compose/src/commonMain/kotlin/pro/respawn/kmmutils/compose/lazy/PagerEffects.kt index f39dc85..270bafb 100644 --- a/compose/src/commonMain/kotlin/pro/respawn/kmmutils/compose/lazy/PagerEffects.kt +++ b/compose/src/commonMain/kotlin/pro/respawn/kmmutils/compose/lazy/PagerEffects.kt @@ -39,12 +39,10 @@ public fun Modifier.scalePagerEffect( // Calculate the absolute offset for the current page from the // scroll position. We use the absolute value which allows us to mirror // any effects for both directions - val pageOffset = state.offsetForPage(index) - lerp( start = ScaleFactor(scaleFactor, scaleFactor), stop = ScaleFactor(1f, 1f), - fraction = 1f - pageOffset.coerceIn(0f, 1f) + fraction = 1f - state.offsetForPage(index).coerceIn(0f, 1f) ).also { scale -> scaleX = scale.scaleX scaleY = scale.scaleY diff --git a/compose/src/commonMain/kotlin/pro/respawn/kmmutils/compose/lazy/PagerExt.kt b/compose/src/commonMain/kotlin/pro/respawn/kmmutils/compose/lazy/PagerExt.kt index 38c8acd..df3aecb 100644 --- a/compose/src/commonMain/kotlin/pro/respawn/kmmutils/compose/lazy/PagerExt.kt +++ b/compose/src/commonMain/kotlin/pro/respawn/kmmutils/compose/lazy/PagerExt.kt @@ -1,13 +1,11 @@ package pro.respawn.kmmutils.compose.lazy -import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.pager.PagerState /** * Same behavior as [LazyListState.firstVisibleItemIndex]. */ -@OptIn(ExperimentalFoundationApi::class) public inline val PagerState.firstVisiblePage: Int get() = when { currentPageOffsetFraction >= 0 -> currentPage @@ -17,6 +15,5 @@ public inline val PagerState.firstVisiblePage: Int /** * Same behavior as [LazyListState.firstVisibleItemScrollOffset]. */ -@OptIn(ExperimentalFoundationApi::class) public inline val PagerState.firstVisiblePageOffsetFraction: Float - get() = getOffsetFractionForPage(firstVisiblePage.coerceIn(0..pageCount)) + get() = getOffsetDistanceInPages(firstVisiblePage.coerceIn(0..pageCount)) diff --git a/compose/src/commonMain/kotlin/pro/respawn/kmmutils/compose/lazy/PagesPerScreen.kt b/compose/src/commonMain/kotlin/pro/respawn/kmmutils/compose/lazy/PagesPerScreen.kt index 933e5db..3295b8c 100644 --- a/compose/src/commonMain/kotlin/pro/respawn/kmmutils/compose/lazy/PagesPerScreen.kt +++ b/compose/src/commonMain/kotlin/pro/respawn/kmmutils/compose/lazy/PagesPerScreen.kt @@ -1,6 +1,5 @@ package pro.respawn.kmmutils.compose.lazy -import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.pager.PageSize import androidx.compose.ui.unit.Density @@ -8,7 +7,6 @@ import androidx.compose.ui.unit.Density * Defines a [PageSize] that shows [amount] pages on the screen at all times. The size of pages will be changed * to always show [amount] pages. */ -@OptIn(ExperimentalFoundationApi::class) public class PagesPerScreen( public val amount: Int ) : PageSize { diff --git a/compose/src/commonMain/kotlin/pro/respawn/kmmutils/compose/modifier/Clickable.kt b/compose/src/commonMain/kotlin/pro/respawn/kmmutils/compose/modifier/Clickable.kt index b458bde..46d6901 100644 --- a/compose/src/commonMain/kotlin/pro/respawn/kmmutils/compose/modifier/Clickable.kt +++ b/compose/src/commonMain/kotlin/pro/respawn/kmmutils/compose/modifier/Clickable.kt @@ -1,17 +1,24 @@ package pro.respawn.kmmutils.compose.modifier -// TODO: Waiting for compose update +import androidx.compose.foundation.clickable +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.ui.Modifier +import androidx.compose.ui.semantics.Role -// public fun Modifier.noIndicationClickable( -// enabled: Boolean = true, -// onClickLabel: String? = null, -// role: Role? = null, -// onClick: () -> Unit, -// ): Modifier = clickable( -// interactionSource = null, -// indication = null, -// enabled = enabled, -// onClickLabel = onClickLabel, -// role = role, -// onClick = onClick -// ) +/** + * Add a clickable modifier that has no indication (no ripple) + */ +public fun Modifier.noIndicationClickable( + enabled: Boolean = true, + onClickLabel: String? = null, + role: Role? = null, + interactionSource: MutableInteractionSource? = null, + onClick: () -> Unit, +): Modifier = clickable( + interactionSource = interactionSource, + indication = null, + enabled = enabled, + onClickLabel = onClickLabel, + role = role, + onClick = onClick +) diff --git a/compose/src/commonMain/kotlin/pro/respawn/kmmutils/compose/resources/ResourcesExt.kt b/compose/src/commonMain/kotlin/pro/respawn/kmmutils/compose/resources/ResourcesExt.kt index 2cb7894..ae568eb 100644 --- a/compose/src/commonMain/kotlin/pro/respawn/kmmutils/compose/resources/ResourcesExt.kt +++ b/compose/src/commonMain/kotlin/pro/respawn/kmmutils/compose/resources/ResourcesExt.kt @@ -5,7 +5,12 @@ import androidx.compose.runtime.NonSkippableComposable import androidx.compose.ui.graphics.ImageBitmap import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.text.font.Font +import androidx.compose.ui.text.font.FontStyle +import androidx.compose.ui.text.font.FontWeight import org.jetbrains.compose.resources.DrawableResource +import org.jetbrains.compose.resources.Font +import org.jetbrains.compose.resources.FontResource import org.jetbrains.compose.resources.PluralStringResource import org.jetbrains.compose.resources.StringArrayResource import org.jetbrains.compose.resources.StringResource @@ -52,3 +57,10 @@ public fun Text.string(): String = when (this) { public fun String.text(): Text.Dynamic = Text.Dynamic(this) public fun StringResource.text(vararg args: Any): Text.Resource = Text.Resource(this, args = args) + +@Composable +@NonSkippableComposable +public fun FontResource.font( + weight: FontWeight = FontWeight.Normal, + style: FontStyle = FontStyle.Normal +): Font = Font(this, weight, style) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e85c5d0..8d6c39c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,34 +1,33 @@ [versions] androidx-activity = "1.9.1" androidx-core = "1.13.1" -compose = "1.6.10" +compose = "1.7.0-alpha02" composeDetektPlugin = "1.3.0" coroutines = "1.9.0-RC" datetime = "0.6.0" dependencyAnalysisPlugin = "1.32.0" detekt = "1.23.6" -detektFormattingPlugin = "1.23.6" dokka = "1.9.20" -gradleAndroid = "8.6.0-beta02" +gradleAndroid = "8.6.0-rc01" gradleDoctorPlugin = "0.10.0" junit = "4.13.2" kotest = "5.9.1" # @pin -kotlin = "2.0.0" +kotlin = "2.0.10" kotlinx-atomicfu = "0.25.0" lifecycle = "2.8.0" +maven-publish-plugin = "0.29.0" turbine = "1.1.0" versionCatalogUpdatePlugin = "0.8.4" -maven-publish-plugin = "0.29.0" [libraries] android-gradle = { module = "com.android.tools.build:gradle", version.ref = "gradleAndroid" } androidx-activity = { module = "androidx.activity:activity-ktx", version.ref = "androidx-activity" } androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" } androidx-core = { module = "androidx.core:core-ktx", version.ref = "androidx-core" } -androidx-lifecycle-viewmodel = "androidx.lifecycle:lifecycle-viewmodel-compose-android:2.8.4" +androidx-lifecycle-viewmodel = { module = "androidx.lifecycle:lifecycle-viewmodel-compose-android", version.ref = "lifecycle" } detekt-compose = { module = "ru.kode:detekt-rules-compose", version.ref = "composeDetektPlugin" } -detekt-formatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detektFormattingPlugin" } +detekt-formatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detekt" } detekt-gradle = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detekt" } detekt-libraries = { module = "io.gitlab.arturbosch.detekt:detekt-rules-libraries", version.ref = "detekt" } dokka-android = { module = "org.jetbrains.dokka:android-documentation-plugin", version.ref = "dokka" } @@ -68,6 +67,6 @@ dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } gradleDoctor = { id = "com.osacky.doctor", version.ref = "gradleDoctorPlugin" } kotest = { id = "io.kotest.multiplatform", version.ref = "kotest" } kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } +maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "maven-publish-plugin" } serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } version-catalog-update = { id = "nl.littlerobots.version-catalog-update", version.ref = "versionCatalogUpdatePlugin" } -maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "maven-publish-plugin" }