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

1.4.4 #22

Merged
merged 7 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .idea/runConfigurations/kmmutils__dokkaHtml_.xml

This file was deleted.

This file was deleted.

6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import nl.littlerobots.vcu.plugin.versionCatalogUpdate
import nl.littlerobots.vcu.plugin.versionSelector
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradleSubplugin
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeFeatureFlag.Companion.OptimizeNonSkippingGroups
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension
Expand Down Expand Up @@ -37,6 +38,7 @@ buildscript {
allprojects {
group = Config.artifactId
version = Config.versionName

tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
jvmTarget.set(Config.jvmTarget)
Expand Down Expand Up @@ -77,9 +79,7 @@ subprojects {
}
plugins.withType<ComposeCompilerGradleSubplugin>().configureEach {
the<ComposeCompilerGradlePluginExtension>().apply {
enableIntrinsicRemember = true
enableNonSkippingGroupOptimization = true
enableStrongSkippingMode = true
featureFlags.addAll(OptimizeNonSkippingGroups)
stabilityConfigurationFile = rootProject.layout.projectDirectory.file("stability_definitions.txt")
if (properties["enableComposeCompilerReports"] == "true") {
val metricsDir = layout.buildDirectory.dir("compose_metrics")
Expand Down
6 changes: 3 additions & 3 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 = 3
const val patch = 4
const val postfix = ""
const val versionName = "$majorRelease.$minorRelease.$patch$postfix"

Expand All @@ -42,12 +42,12 @@ object Config {
"kotlin.contracts.ExperimentalContracts"
)
val compilerArgs = listOf(
"-Xbackend-threads=0", // parallel IR compilation
"-Xconsistent-data-class-copy-visibility",
)
val jvmCompilerArgs = buildList {
addAll(compilerArgs)
add("-Xjvm-default=all") // enable all jvm optimizations
add("-Xstring-concat=inline")
add("-Xbackend-threads=0") // parallel IR compilation
addAll(optIns.map { "-opt-in=$it" })
}

Expand Down
8 changes: 6 additions & 2 deletions buildSrc/src/main/kotlin/ConfigureMultiplatform.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import org.gradle.api.Project
import org.gradle.kotlin.dsl.getValue
import org.gradle.kotlin.dsl.getting
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinHierarchyBuilder
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

@OptIn(ExperimentalWasmDsl::class, ExperimentalKotlinGradlePluginApi::class)
fun Project.configureMultiplatform(
Expand All @@ -29,6 +29,11 @@ fun Project.configureMultiplatform(
applyDefaultHierarchyTemplate(configure)
withSourcesJar(true)

compilerOptions {
freeCompilerArgs.addAll(Config.compilerArgs)
optIn.addAll(Config.optIns)
}

if (linux) {
linuxX64()
linuxArm64()
Expand Down Expand Up @@ -91,7 +96,6 @@ fun Project.configureMultiplatform(
all {
languageSettings {
progressiveMode = true
Config.optIns.forEach { optIn(it) }
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ kotlin {
api(compose.components.resources)

api(libs.lifecycle.runtime)
api(libs.lifecycle.compose)
implementation(libs.compose.window.size)
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.animationGraphics)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shadow
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.LinkAnnotation
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontFamily
Expand Down Expand Up @@ -129,12 +130,15 @@ public fun String.shadow(
*/
public fun String.font(fontFamily: FontFamily): AnnotatedString = annotate(SpanStyle(fontFamily = fontFamily))

// TODO: Waiting for compose update

// public fun String.clickable(onClick: () -> Unit): AnnotatedString = annotate {
// pushLink(LinkAnnotation.Clickable("clickable") { onClick() })
// pushStyle(SpanStyle(textDecoration = TextDecoration.Underline))
// append(this@clickable)
// pop()
// pop()
// }
/**
* Makes this string clickable. When clicked, the [onClick] lambda is invoked
*
* @return the [AnnotatedString] created
*/
public fun String.clickable(onClick: () -> Unit): AnnotatedString = annotate {
pushLink(LinkAnnotation.Clickable("clickable") { onClick() })
pushStyle(SpanStyle(textDecoration = TextDecoration.Underline))
append(this@clickable)
pop()
pop()
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.compose.LocalLifecycleOwner

/**
* Registers a new lifecycle observer for the lifetime of the composition of this function, then clears it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public inline fun <reified T : Any> TypeCrossfade(
@PublishedApi
internal fun <T> Transition<T>.Crossfade(
modifier: Modifier = Modifier,
contentAlignment: Alignment,
contentAlignment: Alignment = Alignment.Center,
animationSpec: FiniteAnimationSpec<Float> = tween(),
contentKey: (targetState: T) -> Any? = { it },
content: @Composable BoxScope.(targetState: T) -> Unit
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("TooManyFunctions")

package pro.respawn.kmmutils.compose.resources

import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -39,7 +41,10 @@ public fun StringArrayResource.strings(): List<String> = stringArrayResource(thi

@Composable
@NonSkippableComposable
public fun StringResource.string(vararg args: Any): String = stringResource(this, formatArgs = args)
public fun StringResource.string(
vararg args: Any,
trim: Boolean = true
): String = stringResource(this, formatArgs = args).let { if (trim) it.trim() else it }

@Composable
@NonSkippableComposable
Expand All @@ -64,3 +69,8 @@ public fun FontResource.font(
weight: FontWeight = FontWeight.Normal,
style: FontStyle = FontStyle.Normal
): Font = Font(this, weight, style)

public suspend fun StringResource.getString(
vararg args: Any,
trim: Boolean = true
): String = org.jetbrains.compose.resources.getString(this, formatArgs = args).let { if (trim) it.trim() else it }
Loading
Loading