feat: working button in dialog

This commit is contained in:
aro 2022-11-18 15:00:46 +01:00
parent 9a7e4db074
commit 720a5c76e5
4 changed files with 93 additions and 72 deletions

View file

@ -2,10 +2,7 @@ package xyz.atnrch.wrench.components
import androidx.compose.foundation.clickable
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.*
import androidx.compose.ui.Modifier
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.TextUnit
import androidx.compose.ui.unit.TextUnitType
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import xyz.atnrch.wrench.components.dialog.EntryDialog
import xyz.atnrch.wrench.watcher.WatcherEntry
@OptIn(ExperimentalUnitApi::class)
@ -29,32 +25,17 @@ fun WatcherTextEntry(entry: WatcherEntry) {
fontSize = TextUnit(15F, TextUnitType.Sp)
),
modifier = Modifier.clickable {
if (dialogState) {
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")
}
}
}
}
}
dialogState = true
}
)
if (dialogState) {
EntryDialog(
onCancelClick = {
dialogState = false
println("clicked cancel")
},
onStateChange = { dialogState = it }
)
}
}

View file

@ -1,21 +1,16 @@
package xyz.atnrch.wrench.components
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
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.TextUnit
import androidx.compose.ui.unit.TextUnitType
import androidx.compose.ui.unit.dp
import xyz.atnrch.wrench.components.debug.DummyTextEntry
import xyz.atnrch.wrench.watcher.WatcherManager
@OptIn(ExperimentalUnitApi::class)
@ -24,38 +19,34 @@ fun WatcherDisplay(
watcherManager: WatcherManager
) {
var selectedFile = remember { mutableStateOf("") }
Box(
contentAlignment = Alignment.CenterStart,
modifier = Modifier.fillMaxSize(),
) {
Column(
modifier = Modifier.padding(84.dp)
Column {
Box(
contentAlignment = Alignment.CenterStart,
modifier = Modifier.fillMaxSize(50F).border(BorderStroke(8.dp, Color.Black), RectangleShape),
) {
//.............
// INPUT SIDE
//.............
watcherManager.getEntries().forEach {
Text(
text = "${it.file.absolutePath}",
style = TextStyle(
color = Color.Black,
fontSize = TextUnit(15F, TextUnitType.Sp)
)
)
Column(
modifier = Modifier.padding(24.dp)
) {
//.............
// INPUT SIDE
//.............
watcherManager.getEntries().forEach {
WatcherTextEntry(it)
}
DummyTextEntry()
}
}
Box(
contentAlignment = Alignment.CenterEnd,
modifier = Modifier.fillMaxSize(50F),
) {
Column(
modifier = Modifier.padding(24.dp)
) {
//.............
// OUTPUT SIDE
//.............
}
}
}
Box(
contentAlignment = Alignment.CenterEnd,
modifier = Modifier.fillMaxSize(),
) {
Column(
modifier = Modifier.padding(84.dp)
) {
//.............
// OUTPUT SIDE
//.............
}
}
}

View file

@ -1,2 +1,11 @@
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()))
}

View file

@ -1,2 +1,42 @@
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")
}
}
}
}
}