feat: outputs displayed (i hate compose this framework is not ready at all)
This commit is contained in:
parent
b77de56091
commit
3008a2a5ef
7 changed files with 46 additions and 51 deletions
|
@ -1,6 +1,5 @@
|
|||
package xyz.atnrch.wrench.components
|
||||
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
|
@ -19,7 +18,6 @@ fun WatcherDisplay(
|
|||
watcherManager: WatcherManager
|
||||
) {
|
||||
var currentClick by remember { mutableStateOf(-1) }
|
||||
val interactionSource = remember { MutableInteractionSource() }
|
||||
|
||||
Row {
|
||||
if (watcherManager.getEntries().isEmpty()) {
|
||||
|
@ -31,7 +29,7 @@ fun WatcherDisplay(
|
|||
Text("Add a file to start...")
|
||||
}
|
||||
} else {
|
||||
InputEntries(watcherManager, interactionSource) { currentClick = it }
|
||||
InputEntries(watcherManager) { currentClick = it }
|
||||
OutputEntries(watcherManager, currentClick)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@ import xyz.atnrch.wrench.watcher.WatcherManager
|
|||
@Composable
|
||||
fun WrenchScaffold() {
|
||||
val entries: MutableMap<Int, WatcherEntry> = remember { mutableStateMapOf() }
|
||||
val watcher = remember { Watcher(entries) }
|
||||
val watcherManager = remember { WatcherManager(entries) }
|
||||
val watcher = remember { Watcher(watcherManager) }
|
||||
var buttonState by remember { mutableStateOf(false) }
|
||||
|
||||
Scaffold(
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package xyz.atnrch.wrench.components.center
|
||||
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.runtime.Composable
|
||||
import xyz.atnrch.wrench.registery.RegisterComposable
|
||||
import xyz.atnrch.wrench.watcher.WatcherEntry
|
||||
|
@ -10,7 +9,6 @@ import java.io.File
|
|||
@Composable
|
||||
fun DummyTextEntry(
|
||||
watcherManager: WatcherManager,
|
||||
interactionSource: MutableInteractionSource,
|
||||
onEntrySelected: (id: Int) -> Unit
|
||||
) {
|
||||
val id = 0
|
||||
|
@ -19,8 +17,7 @@ fun DummyTextEntry(
|
|||
id,
|
||||
WatcherEntry(File("/home/aro/IdeaProjects/Wrench/dummy"), arrayListOf()),
|
||||
watcherManager,
|
||||
onEntrySelected,
|
||||
interactionSource
|
||||
onEntrySelected
|
||||
)
|
||||
}
|
||||
}
|
|
@ -2,7 +2,6 @@ package xyz.atnrch.wrench.components.center
|
|||
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.PointerMatcher
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.onClick
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.*
|
||||
|
@ -25,13 +24,12 @@ fun WatcherTextEntry(
|
|||
id: Int,
|
||||
entry: WatcherEntry,
|
||||
watcherManager: WatcherManager,
|
||||
onEntrySelected: (id: Int) -> Unit,
|
||||
interactionSource: MutableInteractionSource,
|
||||
onEntrySelected: (id: Int) -> Unit
|
||||
) {
|
||||
var dialogState by remember { mutableStateOf(false) }
|
||||
|
||||
Text(
|
||||
text = "${entry.file.absolutePath}",
|
||||
text = entry.file.absolutePath,
|
||||
style = TextStyle(
|
||||
color = if(ACTIVE_COMPOSABLE == id) Color.Red else Color.Black,
|
||||
fontSize = TextUnit(15F, TextUnitType.Sp),
|
||||
|
@ -40,7 +38,6 @@ fun WatcherTextEntry(
|
|||
modifier = Modifier
|
||||
.onClick(
|
||||
matcher = PointerMatcher.mouse(PointerButton.Primary),
|
||||
interactionSource = interactionSource,
|
||||
onClick = {
|
||||
println("Active composable ID was $ACTIVE_COMPOSABLE")
|
||||
ACTIVE_COMPOSABLE = id
|
||||
|
|
|
@ -2,7 +2,6 @@ package xyz.atnrch.wrench.components.center.input
|
|||
|
||||
import androidx.compose.foundation.BorderStroke
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
|
@ -17,7 +16,6 @@ import xyz.atnrch.wrench.watcher.WatcherManager
|
|||
@Composable
|
||||
fun InputEntries(
|
||||
watcherManager: WatcherManager,
|
||||
interactionSource: MutableInteractionSource,
|
||||
onEntryClick: (id: Int) -> Unit
|
||||
) {
|
||||
Box(
|
||||
|
@ -38,8 +36,7 @@ fun InputEntries(
|
|||
it.key,
|
||||
it.value,
|
||||
watcherManager,
|
||||
onEntryClick,
|
||||
interactionSource
|
||||
onEntryClick
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ import androidx.compose.material.Text
|
|||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.PostAdd
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.mutableStateListOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
@ -19,6 +21,7 @@ import xyz.atnrch.wrench.logger.Logger
|
|||
import xyz.atnrch.wrench.ui.UIColors
|
||||
import xyz.atnrch.wrench.watcher.WatcherEntry
|
||||
import xyz.atnrch.wrench.watcher.WatcherManager
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.pathString
|
||||
|
||||
@Composable
|
||||
|
@ -26,6 +29,8 @@ fun OutputEntries(
|
|||
watcherManager: WatcherManager,
|
||||
currentSelectedInputId: Int
|
||||
) {
|
||||
val outputs: MutableList<Path> = remember { mutableStateListOf() }
|
||||
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = Modifier
|
||||
|
@ -40,7 +45,9 @@ fun OutputEntries(
|
|||
) {
|
||||
val entry: WatcherEntry? = watcherManager.getFromId(currentSelectedInputId)
|
||||
if (entry != null) {
|
||||
if (entry.map.isEmpty()) {
|
||||
outputs.clear()
|
||||
outputs.addAll(entry.map)
|
||||
|
||||
Box(
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
|
@ -48,19 +55,20 @@ fun OutputEntries(
|
|||
verticalArrangement = Arrangement.SpaceEvenly,
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
if (entry.map.isEmpty()) {
|
||||
Text("No output")
|
||||
if (outputs.isEmpty()) {
|
||||
Text("No outputs.")
|
||||
} else {
|
||||
entry.map.forEach {
|
||||
outputs.forEach {
|
||||
Text(it.pathString)
|
||||
}
|
||||
}
|
||||
Spacer(Modifier.height(28.dp))
|
||||
Spacer(Modifier.height(24.dp))
|
||||
Button(
|
||||
onClick = {
|
||||
showDirectoryPicker({
|
||||
Logger.info("Path: ${it.absolutePath}")
|
||||
entry.map.add(it.toPath())
|
||||
outputs.add(it.toPath())
|
||||
}, {
|
||||
Logger.info("No file selected.")
|
||||
})
|
||||
|
@ -78,5 +86,4 @@ fun OutputEntries(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import xyz.atnrch.wrench.logger.Logger
|
|||
import java.nio.file.Files
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class Watcher(private val entries: MutableMap<Int, WatcherEntry>) {
|
||||
class Watcher(private val watcherManager: WatcherManager) {
|
||||
companion object {
|
||||
var WATCHING = false
|
||||
}
|
||||
|
@ -21,8 +21,7 @@ class Watcher(private val entries: MutableMap<Int, WatcherEntry>) {
|
|||
Logger.info("Started Watcher.")
|
||||
while (WATCHING) {
|
||||
delay(TimeUnit.SECONDS.toMillis(5))
|
||||
val manager = WatcherManager(entries)
|
||||
for (entry: WatcherEntry in manager.getEntries().values) {
|
||||
for (entry: WatcherEntry in watcherManager.getEntries().values) {
|
||||
entry.map.forEach {
|
||||
Files.copy(entry.file.toPath(), it.toAbsolutePath())
|
||||
}
|
||||
|
|
Reference in a new issue