Skip to content

Commit

Permalink
No longer hide entire UI if not connected to VC
Browse files Browse the repository at this point in the history
  • Loading branch information
DRSchlaubi committed Sep 21, 2023
1 parent 0854d0e commit 8197cc5
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 31 deletions.
3 changes: 2 additions & 1 deletion app/desktop/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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)
Expand Down
13 changes: 9 additions & 4 deletions app/shared/src/commonMain/kotlin/components/SoundContainer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,9 +46,10 @@ fun SoundContainer(
sounds: List<Sound>,
errorReporter: ErrorReporter,
playingSound: Id<Sound>?,
disabled: Boolean,
unavailableFor: String?,
soundUpdater: SoundUpdater
) {
val disabled = unavailableFor != null
Column {
SearchBarScope(soundUpdater) {
LazyVerticalGrid(GridCells.Adaptive(160.dp), Modifier.canClearFocus().fillMaxHeight()) {
Expand All @@ -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)
}
}
}
}
Expand Down
38 changes: 16 additions & 22 deletions app/shared/src/commonMain/kotlin/components/SoundList.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -100,34 +98,30 @@ 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
}
}

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
}
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/shared/src/commonMain/kotlin/strings/DeStrings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
3 changes: 2 additions & 1 deletion app/shared/src/commonMain/kotlin/strings/EnStrings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
3 changes: 2 additions & 1 deletion app/shared/src/commonMain/kotlin/strings/Strings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {

allprojects {
group = "dev.schlaubi.tonbrett"
version = "1.12.25"
version = "1.13.0"

repositories {
mavenCentral()
Expand Down

0 comments on commit 8197cc5

Please sign in to comment.