Skip to content

Commit

Permalink
Merge pull request #21 from respawn-app/1.4.3
Browse files Browse the repository at this point in the history
1.4.3
  • Loading branch information
Nek-12 authored Aug 8, 2024
2 parents 48717d0 + b0c31cf commit 72a0900
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 33 deletions.
3 changes: 1 addition & 2 deletions buildSrc/src/main/kotlin/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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" })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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))
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package pro.respawn.kmmutils.compose.lazy

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.pager.PageSize
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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
15 changes: 7 additions & 8 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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" }
Expand Down Expand Up @@ -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" }

0 comments on commit 72a0900

Please sign in to comment.