refactor: cleaner display code

This commit is contained in:
aro 2023-01-13 11:45:11 +01:00
parent 1791010676
commit be5039b386

View file

@ -13,6 +13,7 @@ import androidx.compose.ui.unit.ExperimentalUnitApi
import androidx.compose.ui.unit.TextUnit import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.TextUnitType import androidx.compose.ui.unit.TextUnitType
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import xyz.atnrch.wrench.gui.style.Fonts
import xyz.atnrch.wrench.gui.style.UIColors import xyz.atnrch.wrench.gui.style.UIColors
import xyz.atnrch.wrench.watcher.WatcherEntry import xyz.atnrch.wrench.watcher.WatcherEntry
import xyz.atnrch.wrench.watcher.WatcherManager import xyz.atnrch.wrench.watcher.WatcherManager
@ -35,30 +36,24 @@ fun OutputEntries(
) { ) {
OutputTopText() OutputTopText()
Column( Column(
verticalArrangement = Arrangement.spacedBy(15.dp) verticalArrangement = Arrangement.spacedBy(15.dp),
horizontalAlignment = Alignment.CenterHorizontally
) { ) {
val entry: WatcherEntry? = watcherManager.getFromId(currentClick) val entry: WatcherEntry? = watcherManager.getFromId(currentClick)
if (entry != null) { if (entry != null) {
outputs.clear() outputs.clear()
outputs.addAll(entry.outputs) outputs.addAll(entry.outputs)
Box( if (outputs.isEmpty()) Text(
contentAlignment = Alignment.Center
) {
Column(
verticalArrangement = Arrangement.SpaceEvenly,
horizontalAlignment = Alignment.CenterHorizontally
) {
if (outputs.isEmpty()) {
Text(
text = "This file does not have any output location.", text = "This file does not have any output location.",
fontSize = TextUnit(17F, TextUnitType.Sp), fontSize = TextUnit(17F, TextUnitType.Sp),
fontFamily = Fonts.ROBOTO_BOLD,
color = Color.White color = Color.White
) ) else outputs.forEach {
} else {
outputs.forEach {
Text( Text(
text = it.pathString, text = it.pathString,
fontSize = TextUnit(17F, TextUnitType.Sp),
fontFamily = Fonts.ROBOTO_REGULAR,
color = Color.White color = Color.White
) )
} }
@ -66,6 +61,3 @@ fun OutputEntries(
} }
} }
} }
}
}
}