feat: remove output button
This commit is contained in:
parent
379d1b2f2e
commit
50b52ecf58
8 changed files with 150 additions and 54 deletions
|
@ -9,7 +9,6 @@ import xyz.atnrch.wrench.components.center.empty.DefaultDisplay
|
||||||
import xyz.atnrch.wrench.components.center.input.InputEntries
|
import xyz.atnrch.wrench.components.center.input.InputEntries
|
||||||
import xyz.atnrch.wrench.components.center.output.OutputEntries
|
import xyz.atnrch.wrench.components.center.output.OutputEntries
|
||||||
import xyz.atnrch.wrench.watcher.WatcherManager
|
import xyz.atnrch.wrench.watcher.WatcherManager
|
||||||
import java.io.File
|
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
@ -24,7 +23,7 @@ fun WatcherDisplay(
|
||||||
modifier = Modifier.padding(0.dp, 0.dp, 0.dp, 55.dp)
|
modifier = Modifier.padding(0.dp, 0.dp, 0.dp, 55.dp)
|
||||||
) {
|
) {
|
||||||
if (watcherManager.getEntries().isEmpty()) {
|
if (watcherManager.getEntries().isEmpty()) {
|
||||||
watcherManager.addFile(File("/home/aro/IdeaProjects/Wrench/dummy"))
|
//watcherManager.addFile(File("/home/aro/IdeaProjects/Wrench/dummy"))
|
||||||
DefaultDisplay()
|
DefaultDisplay()
|
||||||
} else {
|
} else {
|
||||||
InputEntries(watcherManager, onEntryClick)
|
InputEntries(watcherManager, onEntryClick)
|
||||||
|
|
|
@ -30,6 +30,6 @@ fun WrenchScaffold() {
|
||||||
floatingActionButton = { FloatingButton(watcherManager) },
|
floatingActionButton = { FloatingButton(watcherManager) },
|
||||||
isFloatingActionButtonDocked = true,
|
isFloatingActionButtonDocked = true,
|
||||||
backgroundColor = UIColors.PRIMARY,
|
backgroundColor = UIColors.PRIMARY,
|
||||||
bottomBar = { BottomAppBar(watcherManager, watcher, currentClick, outputs) }
|
bottomBar = { BottomAppBar(watcherManager, watcher, currentClick, outputs) { currentClick = it } }
|
||||||
) { WatcherDisplay(watcherManager, currentClick, outputs) { currentClick = it } }
|
) { WatcherDisplay(watcherManager, currentClick, outputs) { currentClick = it } }
|
||||||
}
|
}
|
|
@ -1,2 +1,64 @@
|
||||||
package xyz.atnrch.wrench.components.bottom
|
package xyz.atnrch.wrench.components.bottom
|
||||||
|
|
||||||
|
import androidx.compose.foundation.BorderStroke
|
||||||
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material.Button
|
||||||
|
import androidx.compose.material.ButtonDefaults
|
||||||
|
import androidx.compose.material.Icon
|
||||||
|
import androidx.compose.material.Text
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.NoteAdd
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.draw.shadow
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import xyz.atnrch.wrench.components.center.showDirectoryPicker
|
||||||
|
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
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun AddOutputButton(
|
||||||
|
watcherManager: WatcherManager,
|
||||||
|
outputs: MutableList<Path>,
|
||||||
|
currentClick: Int
|
||||||
|
) {
|
||||||
|
Button(
|
||||||
|
onClick =
|
||||||
|
{
|
||||||
|
val entry: WatcherEntry? = watcherManager.getFromId(currentClick)
|
||||||
|
showDirectoryPicker({
|
||||||
|
Logger.info("Path: ${it.absolutePath}")
|
||||||
|
entry!!.map.add(it.toPath())
|
||||||
|
outputs.add(it.toPath())
|
||||||
|
}, {
|
||||||
|
Logger.info("No file selected.")
|
||||||
|
})
|
||||||
|
},
|
||||||
|
colors = ButtonDefaults.buttonColors(UIColors.DARK, Color.White),
|
||||||
|
contentPadding = PaddingValues(
|
||||||
|
start = 14.dp,
|
||||||
|
top = 6.dp,
|
||||||
|
end = 14.dp,
|
||||||
|
bottom = 6.dp
|
||||||
|
),
|
||||||
|
shape = RoundedCornerShape(100),
|
||||||
|
border = BorderStroke(2.dp, UIColors.ORANGE),
|
||||||
|
modifier = Modifier.shadow(24.dp, RoundedCornerShape(100), false)
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
Icons.Filled.NoteAdd,
|
||||||
|
tint = UIColors.ORANGE,
|
||||||
|
contentDescription = "Add output",
|
||||||
|
modifier = Modifier.size(22.dp)
|
||||||
|
)
|
||||||
|
Spacer(Modifier.size(ButtonDefaults.IconSpacing))
|
||||||
|
Text("Add output...")
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,12 +13,13 @@ fun BottomAppBar(
|
||||||
watcherManager: WatcherManager,
|
watcherManager: WatcherManager,
|
||||||
watcher: Watcher,
|
watcher: Watcher,
|
||||||
currentClick: Int,
|
currentClick: Int,
|
||||||
outputs: MutableList<Path>
|
outputs: MutableList<Path>,
|
||||||
|
onCurrentClick: (Int) -> Unit
|
||||||
) {
|
) {
|
||||||
androidx.compose.material.BottomAppBar(
|
androidx.compose.material.BottomAppBar(
|
||||||
cutoutShape = MaterialTheme.shapes.small.copy(
|
cutoutShape = MaterialTheme.shapes.small.copy(
|
||||||
CornerSize(percent = 50)
|
CornerSize(percent = 50)
|
||||||
),
|
),
|
||||||
backgroundColor = UIColors.DARK
|
backgroundColor = UIColors.DARK
|
||||||
) { BottomRowNew(watcherManager, watcher, currentClick, outputs) }
|
) { BottomRowNew(watcherManager, watcher, currentClick, outputs, onCurrentClick) }
|
||||||
}
|
}
|
|
@ -1,5 +1,61 @@
|
||||||
package xyz.atnrch.wrench.components.bottom
|
package xyz.atnrch.wrench.components.bottom
|
||||||
|
|
||||||
class RemoveOutputButton(watcherManager: WatcherManager, outputs: MutableList<Path>, currentClick: Int) {
|
import androidx.compose.foundation.BorderStroke
|
||||||
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material.Button
|
||||||
|
import androidx.compose.material.ButtonDefaults
|
||||||
|
import androidx.compose.material.Icon
|
||||||
|
import androidx.compose.material.Text
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.Delete
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.draw.shadow
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import xyz.atnrch.wrench.registery.ACTIVE_COMPOSABLE
|
||||||
|
import xyz.atnrch.wrench.ui.UIColors
|
||||||
|
import xyz.atnrch.wrench.watcher.WatcherEntry
|
||||||
|
import xyz.atnrch.wrench.watcher.WatcherManager
|
||||||
|
import java.nio.file.Path
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun RemoveOutputButton(
|
||||||
|
watcherManager: WatcherManager,
|
||||||
|
outputs: MutableList<Path>,
|
||||||
|
currentClick: Int,
|
||||||
|
onCurrentClick: (Int) -> Unit
|
||||||
|
) {
|
||||||
|
Button(
|
||||||
|
onClick =
|
||||||
|
{
|
||||||
|
val entry: WatcherEntry? = watcherManager.getFromId(currentClick)
|
||||||
|
watcherManager.removeFile(currentClick)
|
||||||
|
outputs.clear()
|
||||||
|
ACTIVE_COMPOSABLE = -1
|
||||||
|
onCurrentClick.invoke(-1)
|
||||||
|
},
|
||||||
|
colors = ButtonDefaults.buttonColors(UIColors.DARK, Color.White),
|
||||||
|
contentPadding = PaddingValues(
|
||||||
|
start = 14.dp,
|
||||||
|
top = 6.dp,
|
||||||
|
end = 14.dp,
|
||||||
|
bottom = 6.dp
|
||||||
|
),
|
||||||
|
shape = RoundedCornerShape(100),
|
||||||
|
border = BorderStroke(2.dp, UIColors.STRESS),
|
||||||
|
modifier = Modifier.shadow(24.dp, RoundedCornerShape(100), false)
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
Icons.Filled.Delete,
|
||||||
|
tint = UIColors.STRESS,
|
||||||
|
contentDescription = "Remove file",
|
||||||
|
modifier = Modifier.size(22.dp)
|
||||||
|
)
|
||||||
|
Spacer(Modifier.size(ButtonDefaults.IconSpacing))
|
||||||
|
Text("Delete input")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,18 +11,14 @@ import androidx.compose.material.ButtonDefaults
|
||||||
import androidx.compose.material.Icon
|
import androidx.compose.material.Icon
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.NoteAdd
|
|
||||||
import androidx.compose.material.icons.filled.Update
|
import androidx.compose.material.icons.filled.Update
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.shadow
|
import androidx.compose.ui.draw.shadow
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import xyz.atnrch.wrench.components.center.showDirectoryPicker
|
|
||||||
import xyz.atnrch.wrench.logger.Logger
|
|
||||||
import xyz.atnrch.wrench.ui.UIColors
|
import xyz.atnrch.wrench.ui.UIColors
|
||||||
import xyz.atnrch.wrench.watcher.Watcher
|
import xyz.atnrch.wrench.watcher.Watcher
|
||||||
import xyz.atnrch.wrench.watcher.WatcherEntry
|
|
||||||
import xyz.atnrch.wrench.watcher.WatcherManager
|
import xyz.atnrch.wrench.watcher.WatcherManager
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
|
|
||||||
|
@ -31,7 +27,8 @@ fun BottomRowNew(
|
||||||
watcherManager: WatcherManager,
|
watcherManager: WatcherManager,
|
||||||
watcher: Watcher,
|
watcher: Watcher,
|
||||||
currentClick: Int,
|
currentClick: Int,
|
||||||
outputs: MutableList<Path>
|
outputs: MutableList<Path>,
|
||||||
|
onCurrentClick: (Int) -> Unit,
|
||||||
) {
|
) {
|
||||||
Spacer(Modifier.width(10.dp))
|
Spacer(Modifier.width(10.dp))
|
||||||
Button(
|
Button(
|
||||||
|
@ -58,37 +55,8 @@ fun BottomRowNew(
|
||||||
}
|
}
|
||||||
if (currentClick != -1) {
|
if (currentClick != -1) {
|
||||||
Spacer(Modifier.width(10.dp))
|
Spacer(Modifier.width(10.dp))
|
||||||
Button(
|
AddOutputButton(watcherManager, outputs, currentClick)
|
||||||
onClick =
|
Spacer(Modifier.width(10.dp))
|
||||||
{
|
RemoveOutputButton(watcherManager, outputs, currentClick, onCurrentClick)
|
||||||
val entry: WatcherEntry? = watcherManager.getFromId(currentClick)
|
|
||||||
showDirectoryPicker({
|
|
||||||
Logger.info("Path: ${it.absolutePath}")
|
|
||||||
entry!!.map.add(it.toPath())
|
|
||||||
outputs.add(it.toPath())
|
|
||||||
}, {
|
|
||||||
Logger.info("No file selected.")
|
|
||||||
})
|
|
||||||
},
|
|
||||||
colors = ButtonDefaults.buttonColors(UIColors.DARK, Color.White),
|
|
||||||
contentPadding = PaddingValues(
|
|
||||||
start = 14.dp,
|
|
||||||
top = 6.dp,
|
|
||||||
end = 14.dp,
|
|
||||||
bottom = 6.dp
|
|
||||||
),
|
|
||||||
shape = RoundedCornerShape(100),
|
|
||||||
border = BorderStroke(2.dp, UIColors.ORANGE),
|
|
||||||
modifier = Modifier.shadow(24.dp, RoundedCornerShape(100), false)
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
Icons.Filled.NoteAdd,
|
|
||||||
tint = UIColors.ORANGE,
|
|
||||||
contentDescription = "Start",
|
|
||||||
modifier = Modifier.size(22.dp)
|
|
||||||
)
|
|
||||||
Spacer(Modifier.size(ButtonDefaults.IconSpacing))
|
|
||||||
Text("Add output...")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,37 +1,43 @@
|
||||||
package xyz.atnrch.wrench.components.center.empty
|
package xyz.atnrch.wrench.components.center.empty
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.material.ButtonDefaults
|
|
||||||
import androidx.compose.material.Icon
|
import androidx.compose.material.Icon
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.rounded.QuestionMark
|
import androidx.compose.material.icons.rounded.FolderOff
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.unit.ExperimentalUnitApi
|
||||||
|
import androidx.compose.ui.unit.TextUnit
|
||||||
|
import androidx.compose.ui.unit.TextUnitType
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
import xyz.atnrch.wrench.ui.Fonts
|
import xyz.atnrch.wrench.ui.Fonts
|
||||||
|
import xyz.atnrch.wrench.ui.UIColors
|
||||||
|
|
||||||
|
@OptIn(ExperimentalUnitApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun DefaultDisplay() {
|
fun DefaultDisplay() {
|
||||||
Box(
|
Box(
|
||||||
contentAlignment = Alignment.Center,
|
contentAlignment = Alignment.Center,
|
||||||
modifier = Modifier.fillMaxWidth().fillMaxHeight()
|
modifier = Modifier.fillMaxWidth().fillMaxHeight()
|
||||||
) {
|
) {
|
||||||
Row(
|
Column (
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalArrangement = Arrangement.SpaceEvenly,
|
||||||
horizontalArrangement = Arrangement.SpaceEvenly
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Rounded.QuestionMark,
|
imageVector = Icons.Rounded.FolderOff,
|
||||||
tint = Color.White,
|
tint = UIColors.ORANGE,
|
||||||
contentDescription = "Open Folder",
|
contentDescription = "Open Folder",
|
||||||
modifier = Modifier.size(ButtonDefaults.IconSize)
|
modifier = Modifier.size(58.dp)
|
||||||
)
|
)
|
||||||
Spacer(Modifier.size(ButtonDefaults.IconSpacing))
|
Spacer(Modifier.height(24.dp))
|
||||||
Text(
|
Text(
|
||||||
text = "Add a file to start...",
|
text = "Add a file to start...",
|
||||||
fontFamily = Fonts.ROBOTO_REGULAR,
|
fontFamily = Fonts.ROBOTO_BOLD,
|
||||||
|
fontSize = TextUnit(20F, TextUnitType.Sp),
|
||||||
color = Color.White
|
color = Color.White
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,10 @@ class WatcherManager(private val entries: MutableMap<Int, WatcherEntry>) {
|
||||||
Logger.info("Tracking new file:\n ID: $currentId\n Name: ${file.name}\n Path: ${file.absolutePath}")
|
Logger.info("Tracking new file:\n ID: $currentId\n Name: ${file.name}\n Path: ${file.absolutePath}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun removeFile(id: Int) {
|
||||||
|
entries.remove(id)
|
||||||
|
}
|
||||||
|
|
||||||
fun getEntries(): MutableMap<Int, WatcherEntry> {
|
fun getEntries(): MutableMap<Int, WatcherEntry> {
|
||||||
return entries
|
return entries
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue