From 8197cc5f0f9620cb022d6d4a92f1ccee7ea4369e Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Thu, 21 Sep 2023 09:34:20 +0200 Subject: [PATCH] No longer hide entire UI if not connected to VC --- app/desktop/build.gradle.kts | 3 +- .../kotlin/components/SoundContainer.kt | 13 +++++-- .../commonMain/kotlin/components/SoundList.kt | 38 ++++++++----------- .../commonMain/kotlin/strings/DeStrings.kt | 3 +- .../commonMain/kotlin/strings/EnStrings.kt | 3 +- .../src/commonMain/kotlin/strings/Strings.kt | 3 +- build.gradle.kts | 2 +- 7 files changed, 34 insertions(+), 31 deletions(-) diff --git a/app/desktop/build.gradle.kts b/app/desktop/build.gradle.kts index 15c4ab6..9ba6bd1 100644 --- a/app/desktop/build.gradle.kts +++ b/app/desktop/build.gradle.kts @@ -1,4 +1,5 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat +import org.jetbrains.compose.internal.utils.localPropertiesFile import org.jetbrains.kotlin.org.jline.utils.OSUtils plugins { @@ -22,7 +23,7 @@ kotlin { } named("jvmMain") { - if (OSUtils.IS_WINDOWS) { + if (OSUtils.IS_WINDOWS && System.getenv("GITHUB_REF") != null) { dependsOn(windowsMain) } else { dependsOn(nonWindowsMain) diff --git a/app/shared/src/commonMain/kotlin/components/SoundContainer.kt b/app/shared/src/commonMain/kotlin/components/SoundContainer.kt index 6156025..1033549 100644 --- a/app/shared/src/commonMain/kotlin/components/SoundContainer.kt +++ b/app/shared/src/commonMain/kotlin/components/SoundContainer.kt @@ -24,6 +24,7 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.shadow import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.em import androidx.compose.ui.unit.sp import androidx.compose.ui.zIndex import dev.schlaubi.tonbrett.app.ColorScheme @@ -45,9 +46,10 @@ fun SoundContainer( sounds: List, errorReporter: ErrorReporter, playingSound: Id?, - disabled: Boolean, + unavailableFor: String?, soundUpdater: SoundUpdater ) { + val disabled = unavailableFor != null Column { SearchBarScope(soundUpdater) { LazyVerticalGrid(GridCells.Adaptive(160.dp), Modifier.canClearFocus().fillMaxHeight()) { @@ -56,13 +58,16 @@ fun SoundContainer( } } - if (disabled) { + if (unavailableFor != null) { Box( modifier = Modifier - .fillMaxSize() + .fillMaxWidth() + .padding(vertical = 5.dp) .background(ColorScheme.disabled.copy(alpha = .4f)) .zIndex(1f) - ) {} + ) { + Text(unavailableFor, textAlign = TextAlign.Center, modifier = Modifier.fillMaxWidth(), fontSize = 25.sp) + } } } } diff --git a/app/shared/src/commonMain/kotlin/components/SoundList.kt b/app/shared/src/commonMain/kotlin/components/SoundList.kt index b6e59d5..1c4e8ea 100644 --- a/app/shared/src/commonMain/kotlin/components/SoundList.kt +++ b/app/shared/src/commonMain/kotlin/components/SoundList.kt @@ -1,7 +1,6 @@ package dev.schlaubi.tonbrett.app.components import androidx.compose.animation.AnimatedContent -import androidx.compose.animation.ExperimentalAnimationApi import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.fillMaxWidth @@ -15,7 +14,6 @@ import cafe.adriel.lyricist.LocalStrings import dev.schlaubi.tonbrett.app.ErrorReporter import dev.schlaubi.tonbrett.app.api.IO import dev.schlaubi.tonbrett.app.api.LocalContext -import dev.schlaubi.tonbrett.app.util.canClearFocus import dev.schlaubi.tonbrett.common.* import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.launchIn @@ -100,9 +98,7 @@ fun SoundList(errorReporter: ErrorReporter, voiceState: User.VoiceState?) { if (loading) { LaunchedEffect(Unit) { withContext(Dispatchers.IO) { - if (voiceState?.channelMismatch == false) { - sounds = api.getSounds() - } + sounds = api.getSounds() loading = false } } @@ -110,24 +106,22 @@ fun SoundList(errorReporter: ErrorReporter, voiceState: User.VoiceState?) { NonListBlock { CircularProgressIndicator() } - } - - Column { - val renderingSounds = !loading && !channelMismatch && !offline - AnimatedContent(renderingSounds) { render -> - if (render) { - SoundContainer(sounds, errorReporter, playingSound, !available) { - sounds = it - } - } - } - - NonListBlock(Modifier.canClearFocus()) { + } else { + Column { val strings = LocalStrings.current - when { - offline -> ErrorText(strings.offline) - channelMismatch -> ErrorText(strings.wrongChannelExplainer) - !loading && sounds.isEmpty() -> ErrorText(strings.noSounds) + val availabilityReason = when { + offline -> strings.offline + channelMismatch -> strings.wrongChannelExplainer + !loading && sounds.isEmpty() -> strings.noSounds + !available -> strings.playerBusy + else -> null + } + AnimatedContent(!loading) { render -> + if (render) { + SoundContainer(sounds, errorReporter, playingSound, availabilityReason) { + sounds = it + } + } } } } diff --git a/app/shared/src/commonMain/kotlin/strings/DeStrings.kt b/app/shared/src/commonMain/kotlin/strings/DeStrings.kt index a54e992..16b5204 100644 --- a/app/shared/src/commonMain/kotlin/strings/DeStrings.kt +++ b/app/shared/src/commonMain/kotlin/strings/DeStrings.kt @@ -29,5 +29,6 @@ val DeStrings = Strings( update = "Aktualisieren", appCrash = "Die App ist abgestürzt", unknownError = "Es ist ein unerwarteter Fehler aufgetreten", - copyUrl = "Audio-URL kopieren" + copyUrl = "Audio-URL kopieren", + playerBusy = "Jemand anders spielt gerade einen Ton ab" ) diff --git a/app/shared/src/commonMain/kotlin/strings/EnStrings.kt b/app/shared/src/commonMain/kotlin/strings/EnStrings.kt index 0cc6410..1617e25 100644 --- a/app/shared/src/commonMain/kotlin/strings/EnStrings.kt +++ b/app/shared/src/commonMain/kotlin/strings/EnStrings.kt @@ -29,5 +29,6 @@ val EnStrings = Strings( update = "Update", appCrash = "The App crashed", unknownError = "An unknown error occurred", - copyUrl = "Copy Audio-URL" + copyUrl = "Copy Audio-URL", + playerBusy = "Someone else is currently playing a sound" ) diff --git a/app/shared/src/commonMain/kotlin/strings/Strings.kt b/app/shared/src/commonMain/kotlin/strings/Strings.kt index 7b8d3b5..0c75e11 100644 --- a/app/shared/src/commonMain/kotlin/strings/Strings.kt +++ b/app/shared/src/commonMain/kotlin/strings/Strings.kt @@ -26,5 +26,6 @@ data class Strings( val appCrash: String, val needsUpdate: String, val unknownError: String, - val copyUrl: String + val copyUrl: String, + val playerBusy: String ) diff --git a/build.gradle.kts b/build.gradle.kts index 29b3cfb..27f4c2f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,7 +10,7 @@ plugins { allprojects { group = "dev.schlaubi.tonbrett" - version = "1.12.25" + version = "1.13.0" repositories { mavenCentral()