From f3e0d96faa77ef7e1e5a097657298653e4bd887e Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 26 Oct 2024 00:56:20 +0200 Subject: [PATCH] Just remove the lyricist processor as it always caused issues --- app/shared/build.gradle.kts | 45 ++++++++++--------- app/shared/src/commonMain/kotlin/Strings.kt | 38 ++++++++++++++++ .../src/commonMain/kotlin/TonbrettApp.kt | 3 -- .../commonMain/kotlin/components/SearchBar.kt | 2 +- .../kotlin/components/SearchSuggestions.kt | 2 +- .../kotlin/components/SoundContainer.kt | 2 +- .../commonMain/kotlin/components/SoundList.kt | 2 +- .../app/components/SoundRightClickMenu.kt | 2 +- .../tonbrett/app/MobileTonbrettApp.kt | 1 - build.gradle.kts | 2 +- 10 files changed, 67 insertions(+), 32 deletions(-) create mode 100644 app/shared/src/commonMain/kotlin/Strings.kt diff --git a/app/shared/build.gradle.kts b/app/shared/build.gradle.kts index 83e82517..700a49ac 100644 --- a/app/shared/build.gradle.kts +++ b/app/shared/build.gradle.kts @@ -101,7 +101,8 @@ kotlin { } dependencies { - kspCommonMainMetadata(libs.lyricist.processor) + // This is buggy * ios 18 +// kspCommonMainMetadata(libs.lyricist.processor) "desktopMainImplementation"(libs.kord.common) { exclude(group = "io.ktor") } @@ -121,24 +122,24 @@ android { } } -tasks { - afterEvaluate { - val compilationTasks = kotlin.targets.flatMap { - buildList { - if (it.name != "android") { - add("compileKotlin${it.name.replaceFirstChar { it.titlecase() }}") - val sourcesJarName = "${it.name}SourcesJar" - add(sourcesJarName) - } else { - add("compileDebugKotlinAndroid") - add("compileReleaseKotlinAndroid") - } - } - } - for (task in compilationTasks) { - named(task) { - dependsOn("kspCommonMainKotlinMetadata") - } - } - } -} +//tasks { +// afterEvaluate { +// val compilationTasks = kotlin.targets.flatMap { +// buildList { +// if (it.name != "android") { +// add("compileKotlin${it.name.replaceFirstChar { it.titlecase() }}") +// val sourcesJarName = "${it.name}SourcesJar" +// add(sourcesJarName) +// } else { +// add("compileDebugKotlinAndroid") +// add("compileReleaseKotlinAndroid") +// } +// } +// } +// for (task in compilationTasks) { +// named(task) { +// dependsOn("kspCommonMainKotlinMetadata") +// } +// } +// } +//} diff --git a/app/shared/src/commonMain/kotlin/Strings.kt b/app/shared/src/commonMain/kotlin/Strings.kt new file mode 100644 index 00000000..b92485ad --- /dev/null +++ b/app/shared/src/commonMain/kotlin/Strings.kt @@ -0,0 +1,38 @@ +package dev.schlaubi.tonbrett.app + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.ProvidableCompositionLocal +import androidx.compose.runtime.staticCompositionLocalOf +import androidx.compose.ui.text.intl.Locale +import cafe.adriel.lyricist.Lyricist +import cafe.adriel.lyricist.LanguageTag +import cafe.adriel.lyricist.rememberStrings +import cafe.adriel.lyricist.ProvideStrings +import dev.schlaubi.tonbrett.app.strings.DeStrings +import dev.schlaubi.tonbrett.app.strings.EnStrings +import dev.schlaubi.tonbrett.app.strings.Strings + +public val Strings: Map = mapOf( + "de" to DeStrings, + "en" to EnStrings +) + +public val LocalStrings: ProvidableCompositionLocal = + staticCompositionLocalOf { EnStrings } + + + +@Composable +public fun rememberStrings( + defaultLanguageTag: LanguageTag = "en", + currentLanguageTag: LanguageTag = Locale.current.toLanguageTag(), +): Lyricist = + rememberStrings(Strings, defaultLanguageTag, currentLanguageTag) + +@Composable +public fun ProvideStrings( + lyricist: Lyricist = rememberStrings(), + content: @Composable () -> Unit +) { + ProvideStrings(lyricist, LocalStrings, content) +} \ No newline at end of file diff --git a/app/shared/src/commonMain/kotlin/TonbrettApp.kt b/app/shared/src/commonMain/kotlin/TonbrettApp.kt index 94314de8..2276e479 100644 --- a/app/shared/src/commonMain/kotlin/TonbrettApp.kt +++ b/app/shared/src/commonMain/kotlin/TonbrettApp.kt @@ -14,9 +14,6 @@ import androidx.compose.material3.Text import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import cafe.adriel.lyricist.LocalStrings -import cafe.adriel.lyricist.ProvideStrings -import cafe.adriel.lyricist.rememberStrings import dev.schlaubi.tonbrett.app.api.IO import dev.schlaubi.tonbrett.app.api.LocalContext import dev.schlaubi.tonbrett.app.components.ErrorText diff --git a/app/shared/src/commonMain/kotlin/components/SearchBar.kt b/app/shared/src/commonMain/kotlin/components/SearchBar.kt index 66dedb5d..ced09807 100644 --- a/app/shared/src/commonMain/kotlin/components/SearchBar.kt +++ b/app/shared/src/commonMain/kotlin/components/SearchBar.kt @@ -21,8 +21,8 @@ import androidx.compose.ui.draw.rotate import androidx.compose.ui.input.key.* import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.unit.dp -import cafe.adriel.lyricist.LocalStrings import dev.schlaubi.tonbrett.app.ColorScheme +import dev.schlaubi.tonbrett.app.LocalStrings import dev.schlaubi.tonbrett.app.api.IO import dev.schlaubi.tonbrett.app.api.LocalContext import dev.schlaubi.tonbrett.common.SoundGroup diff --git a/app/shared/src/commonMain/kotlin/components/SearchSuggestions.kt b/app/shared/src/commonMain/kotlin/components/SearchSuggestions.kt index 6930158e..19a4c37e 100644 --- a/app/shared/src/commonMain/kotlin/components/SearchSuggestions.kt +++ b/app/shared/src/commonMain/kotlin/components/SearchSuggestions.kt @@ -20,8 +20,8 @@ import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.SpanStyle import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.unit.dp -import cafe.adriel.lyricist.LocalStrings import dev.schlaubi.tonbrett.app.ColorScheme +import dev.schlaubi.tonbrett.app.LocalStrings import dev.schlaubi.tonbrett.app.api.LocalContext import dev.schlaubi.tonbrett.app.util.conditional import kotlinx.coroutines.flow.launchIn diff --git a/app/shared/src/commonMain/kotlin/components/SoundContainer.kt b/app/shared/src/commonMain/kotlin/components/SoundContainer.kt index e83e92cf..5c77f905 100644 --- a/app/shared/src/commonMain/kotlin/components/SoundContainer.kt +++ b/app/shared/src/commonMain/kotlin/components/SoundContainer.kt @@ -58,9 +58,9 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.compose.ui.zIndex -import cafe.adriel.lyricist.LocalStrings import dev.schlaubi.tonbrett.app.ColorScheme import dev.schlaubi.tonbrett.app.ErrorReporter +import dev.schlaubi.tonbrett.app.LocalStrings import dev.schlaubi.tonbrett.app.OptionalWebImage import dev.schlaubi.tonbrett.app.api.IO import dev.schlaubi.tonbrett.app.api.LocalContext diff --git a/app/shared/src/commonMain/kotlin/components/SoundList.kt b/app/shared/src/commonMain/kotlin/components/SoundList.kt index 23a30923..d3fce600 100644 --- a/app/shared/src/commonMain/kotlin/components/SoundList.kt +++ b/app/shared/src/commonMain/kotlin/components/SoundList.kt @@ -10,8 +10,8 @@ import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp -import cafe.adriel.lyricist.LocalStrings import dev.schlaubi.tonbrett.app.ErrorReporter +import dev.schlaubi.tonbrett.app.LocalStrings import dev.schlaubi.tonbrett.app.api.IO import dev.schlaubi.tonbrett.app.api.LocalContext import dev.schlaubi.tonbrett.common.* diff --git a/app/shared/src/desktopMain/kotlin/dev/schlaubi/tonbrett/app/components/SoundRightClickMenu.kt b/app/shared/src/desktopMain/kotlin/dev/schlaubi/tonbrett/app/components/SoundRightClickMenu.kt index 7ac9c3fa..038fe67f 100644 --- a/app/shared/src/desktopMain/kotlin/dev/schlaubi/tonbrett/app/components/SoundRightClickMenu.kt +++ b/app/shared/src/desktopMain/kotlin/dev/schlaubi/tonbrett/app/components/SoundRightClickMenu.kt @@ -3,7 +3,7 @@ package dev.schlaubi.tonbrett.app.components import androidx.compose.foundation.ContextMenuArea import androidx.compose.foundation.ContextMenuItem import androidx.compose.runtime.Composable -import cafe.adriel.lyricist.LocalStrings +import dev.schlaubi.tonbrett.app.LocalStrings import dev.schlaubi.tonbrett.app.api.LocalContext import dev.schlaubi.tonbrett.common.Id import dev.schlaubi.tonbrett.common.Route diff --git a/app/shared/src/mobileMain/kotlin/dev/schlaubi/tonbrett/app/MobileTonbrettApp.kt b/app/shared/src/mobileMain/kotlin/dev/schlaubi/tonbrett/app/MobileTonbrettApp.kt index 6a630677..b35196b5 100644 --- a/app/shared/src/mobileMain/kotlin/dev/schlaubi/tonbrett/app/MobileTonbrettApp.kt +++ b/app/shared/src/mobileMain/kotlin/dev/schlaubi/tonbrett/app/MobileTonbrettApp.kt @@ -15,7 +15,6 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import cafe.adriel.lyricist.LocalStrings import dev.schlaubi.tonbrett.app.api.LocalContext import dev.schlaubi.tonbrett.app.api.MobileAppContext import dev.schlaubi.tonbrett.app.api.getUrl diff --git a/build.gradle.kts b/build.gradle.kts index c8f4b381..abd22b99 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { allprojects { group = "dev.schlaubi.tonbrett" - version = "1.22.6" + version = "1.22.7" repositories { mavenCentral()