feat: working button in dialog
This commit is contained in:
parent
9a7e4db074
commit
720a5c76e5
4 changed files with 93 additions and 72 deletions
|
@ -2,10 +2,7 @@ package xyz.atnrch.wrench.components
|
||||||
|
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
||||||
import androidx.compose.material.Card
|
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
import androidx.compose.material.TextButton
|
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
@ -13,8 +10,7 @@ import androidx.compose.ui.text.TextStyle
|
||||||
import androidx.compose.ui.unit.ExperimentalUnitApi
|
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 xyz.atnrch.wrench.components.dialog.EntryDialog
|
||||||
import androidx.compose.ui.window.Dialog
|
|
||||||
import xyz.atnrch.wrench.watcher.WatcherEntry
|
import xyz.atnrch.wrench.watcher.WatcherEntry
|
||||||
|
|
||||||
@OptIn(ExperimentalUnitApi::class)
|
@OptIn(ExperimentalUnitApi::class)
|
||||||
|
@ -29,32 +25,17 @@ fun WatcherTextEntry(entry: WatcherEntry) {
|
||||||
fontSize = TextUnit(15F, TextUnitType.Sp)
|
fontSize = TextUnit(15F, TextUnitType.Sp)
|
||||||
),
|
),
|
||||||
modifier = Modifier.clickable {
|
modifier = Modifier.clickable {
|
||||||
if (dialogState) {
|
dialogState = true
|
||||||
Dialog(
|
|
||||||
onCloseRequest = { dialogState = false },
|
|
||||||
resizable = false,
|
|
||||||
) {
|
|
||||||
Card(
|
|
||||||
elevation = 8.dp,
|
|
||||||
shape = RoundedCornerShape(12.dp)
|
|
||||||
) {
|
|
||||||
// Buttons
|
|
||||||
Row(
|
|
||||||
horizontalArrangement = Arrangement.End,
|
|
||||||
modifier = Modifier.fillMaxWidth()
|
|
||||||
) {
|
|
||||||
|
|
||||||
TextButton(onClick = {}) {
|
|
||||||
Text(text = "Cancel")
|
|
||||||
}
|
|
||||||
Spacer(modifier = Modifier.width(4.dp))
|
|
||||||
TextButton(onClick = {}) {
|
|
||||||
Text(text = "OK")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (dialogState) {
|
||||||
|
EntryDialog(
|
||||||
|
onCancelClick = {
|
||||||
|
dialogState = false
|
||||||
|
println("clicked cancel")
|
||||||
|
},
|
||||||
|
onStateChange = { dialogState = it }
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,21 +1,16 @@
|
||||||
package xyz.atnrch.wrench.components
|
package xyz.atnrch.wrench.components
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.BorderStroke
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.border
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.material.Text
|
|
||||||
import androidx.compose.runtime.Composable
|
|
||||||
import androidx.compose.runtime.mutableStateOf
|
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
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.text.TextStyle
|
import androidx.compose.ui.graphics.RectangleShape
|
||||||
import androidx.compose.ui.unit.ExperimentalUnitApi
|
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 androidx.compose.ui.unit.dp
|
||||||
|
import xyz.atnrch.wrench.components.debug.DummyTextEntry
|
||||||
import xyz.atnrch.wrench.watcher.WatcherManager
|
import xyz.atnrch.wrench.watcher.WatcherManager
|
||||||
|
|
||||||
@OptIn(ExperimentalUnitApi::class)
|
@OptIn(ExperimentalUnitApi::class)
|
||||||
|
@ -24,34 +19,29 @@ fun WatcherDisplay(
|
||||||
watcherManager: WatcherManager
|
watcherManager: WatcherManager
|
||||||
) {
|
) {
|
||||||
var selectedFile = remember { mutableStateOf("") }
|
var selectedFile = remember { mutableStateOf("") }
|
||||||
|
Column {
|
||||||
Box(
|
Box(
|
||||||
contentAlignment = Alignment.CenterStart,
|
contentAlignment = Alignment.CenterStart,
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(50F).border(BorderStroke(8.dp, Color.Black), RectangleShape),
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.padding(84.dp)
|
modifier = Modifier.padding(24.dp)
|
||||||
) {
|
) {
|
||||||
//.............
|
//.............
|
||||||
// INPUT SIDE
|
// INPUT SIDE
|
||||||
//.............
|
//.............
|
||||||
watcherManager.getEntries().forEach {
|
watcherManager.getEntries().forEach {
|
||||||
Text(
|
WatcherTextEntry(it)
|
||||||
text = "${it.file.absolutePath}",
|
|
||||||
style = TextStyle(
|
|
||||||
color = Color.Black,
|
|
||||||
fontSize = TextUnit(15F, TextUnitType.Sp)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
DummyTextEntry()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Box(
|
Box(
|
||||||
contentAlignment = Alignment.CenterEnd,
|
contentAlignment = Alignment.CenterEnd,
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(50F),
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.padding(84.dp)
|
modifier = Modifier.padding(24.dp)
|
||||||
) {
|
) {
|
||||||
//.............
|
//.............
|
||||||
// OUTPUT SIDE
|
// OUTPUT SIDE
|
||||||
|
@ -59,3 +49,4 @@ fun WatcherDisplay(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,2 +1,11 @@
|
||||||
package xyz.atnrch.wrench.components.debug
|
package xyz.atnrch.wrench.components.debug
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import xyz.atnrch.wrench.components.WatcherTextEntry
|
||||||
|
import xyz.atnrch.wrench.watcher.WatcherEntry
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun DummyTextEntry() {
|
||||||
|
WatcherTextEntry(WatcherEntry(File("/home/aro/IdeaProjects/Wrench/dummy"), arrayListOf()))
|
||||||
|
}
|
|
@ -1,2 +1,42 @@
|
||||||
package xyz.atnrch.wrench.components.dialog
|
package xyz.atnrch.wrench.components.dialog
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.*
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material.Card
|
||||||
|
import androidx.compose.material.Text
|
||||||
|
import androidx.compose.material.TextButton
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.window.Dialog
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun EntryDialog(
|
||||||
|
onCancelClick: () -> Unit,
|
||||||
|
onStateChange: (state: Boolean) -> Unit
|
||||||
|
) {
|
||||||
|
Dialog(
|
||||||
|
onCloseRequest = { onStateChange(false) },
|
||||||
|
resizable = false,
|
||||||
|
) {
|
||||||
|
Card(
|
||||||
|
elevation = 8.dp,
|
||||||
|
shape = RoundedCornerShape(12.dp)
|
||||||
|
) {
|
||||||
|
// Buttons
|
||||||
|
Row(
|
||||||
|
horizontalArrangement = Arrangement.End,
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
) {
|
||||||
|
|
||||||
|
TextButton(onClick = onCancelClick) {
|
||||||
|
Text(text = "Cancel")
|
||||||
|
}
|
||||||
|
Spacer(modifier = Modifier.width(4.dp))
|
||||||
|
TextButton(onClick = {}) {
|
||||||
|
Text(text = "OK")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in a new issue