feat: move to official button
This commit is contained in:
parent
44bf996d3c
commit
6d02a62319
3 changed files with 58 additions and 18 deletions
|
@ -6,5 +6,6 @@ class WrenchColors {
|
||||||
companion object {
|
companion object {
|
||||||
val PRIMARY = Color(0xFF424242)
|
val PRIMARY = Color(0xFF424242)
|
||||||
val LIGHT = Color(0xFF6D6D6D)
|
val LIGHT = Color(0xFF6D6D6D)
|
||||||
|
val STRESS = Color(0xFFF44336)
|
||||||
}
|
}
|
||||||
}
|
}
|
19
src/main/kotlin/xyz/atnrch/wrench/components/FilePicker.kt
Normal file
19
src/main/kotlin/xyz/atnrch/wrench/components/FilePicker.kt
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
package xyz.atnrch.wrench.components
|
||||||
|
|
||||||
|
import androidx.compose.ui.awt.ComposeWindow
|
||||||
|
import java.io.File
|
||||||
|
import javax.swing.JFileChooser
|
||||||
|
|
||||||
|
fun FilePicker(
|
||||||
|
onResult: (file: File) -> Unit,
|
||||||
|
onNoResult: () -> Unit
|
||||||
|
) {
|
||||||
|
val filePicker = JFileChooser(System.getProperty("user.home")).apply {
|
||||||
|
fileSelectionMode = JFileChooser.FILES_ONLY
|
||||||
|
dialogTitle = "Select a file"
|
||||||
|
approveButtonText = "Confirm"
|
||||||
|
approveButtonToolTipText = "Select source file"
|
||||||
|
}
|
||||||
|
filePicker.showOpenDialog(ComposeWindow())
|
||||||
|
if (filePicker.selectedFile != null) onResult.invoke(filePicker.selectedFile) else onNoResult.invoke()
|
||||||
|
}
|
|
@ -4,20 +4,24 @@ import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.shape.CornerSize
|
import androidx.compose.foundation.shape.CornerSize
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.*
|
import androidx.compose.material.*
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Add
|
import androidx.compose.material.icons.filled.Add
|
||||||
import androidx.compose.material.icons.filled.Close
|
import androidx.compose.material.icons.filled.Close
|
||||||
import androidx.compose.material.icons.filled.PlayArrow
|
import androidx.compose.material.icons.filled.PlayArrow
|
||||||
|
import androidx.compose.material.icons.filled.Settings
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.awt.ComposeWindow
|
import androidx.compose.ui.draw.shadow
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.graphics.RectangleShape
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import xyz.atnrch.wrench.colors.WrenchColors
|
import xyz.atnrch.wrench.colors.WrenchColors
|
||||||
|
import xyz.atnrch.wrench.components.FilePicker
|
||||||
import xyz.atnrch.wrench.components.WrenchFileManagerInput
|
import xyz.atnrch.wrench.components.WrenchFileManagerInput
|
||||||
import xyz.atnrch.wrench.components.WrenchFileManagerOutput
|
import xyz.atnrch.wrench.components.WrenchFileManagerOutput
|
||||||
import javax.swing.JFileChooser
|
import xyz.atnrch.wrench.logger.Logger
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun WrenchScaffold(
|
fun WrenchScaffold(
|
||||||
|
@ -29,38 +33,49 @@ fun WrenchScaffold(
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
|
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
backgroundColor = WrenchColors.PRIMARY,
|
backgroundColor = WrenchColors.PRIMARY,
|
||||||
contentColor = Color.White,
|
contentColor = Color.White,
|
||||||
elevation = 16.dp,
|
elevation = 16.dp,
|
||||||
title = { Text("Wrench") },
|
title = { Text("Wrench") },
|
||||||
actions = {
|
actions = {
|
||||||
|
//.............
|
||||||
|
// Debug Button
|
||||||
|
//.............
|
||||||
Button(
|
Button(
|
||||||
onClick = {
|
{ Logger.debug("Empty.") },
|
||||||
val fileChooser = JFileChooser(System.getProperty("user.home")).apply {
|
colors = ButtonDefaults.buttonColors(WrenchColors.STRESS, Color.White),
|
||||||
fileSelectionMode = JFileChooser.FILES_ONLY
|
shape = RectangleShape
|
||||||
dialogTitle = "Select a file"
|
|
||||||
approveButtonText = "Select"
|
|
||||||
approveButtonToolTipText = "Select current directory as save destination"
|
|
||||||
}
|
|
||||||
fileChooser.showOpenDialog(ComposeWindow())
|
|
||||||
val result = fileChooser.selectedFile
|
|
||||||
println(result)
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
Text("DEBUG")
|
Icon(
|
||||||
|
Icons.Filled.Settings,
|
||||||
|
tint = Color.White,
|
||||||
|
contentDescription = "Debug Settings",
|
||||||
|
modifier = Modifier.size(18.dp)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
Spacer(Modifier.width(10.dp))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
floatingActionButton = {
|
floatingActionButton = {
|
||||||
|
//.............
|
||||||
|
// ADD BUTTON (FLOATING)
|
||||||
|
//.............
|
||||||
FloatingActionButton(
|
FloatingActionButton(
|
||||||
onClick = { /* ... */ },
|
onClick = {
|
||||||
backgroundColor = WrenchColors.LIGHT
|
FilePicker({
|
||||||
|
Logger.info("Path: ${it.absolutePath}")
|
||||||
|
}, {
|
||||||
|
Logger.info("No file selected.")
|
||||||
|
})
|
||||||
|
},
|
||||||
|
backgroundColor = WrenchColors.LIGHT,
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
Icons.Filled.Add,
|
Icons.Filled.Add,
|
||||||
tint = Color.White,
|
tint = Color.White,
|
||||||
contentDescription = "Start",
|
contentDescription = "Add file...",
|
||||||
modifier = Modifier.size(28.dp)
|
modifier = Modifier.size(28.dp)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -73,6 +88,9 @@ fun WrenchScaffold(
|
||||||
),
|
),
|
||||||
backgroundColor = WrenchColors.PRIMARY
|
backgroundColor = WrenchColors.PRIMARY
|
||||||
) {
|
) {
|
||||||
|
//.............
|
||||||
|
// START BUTTON
|
||||||
|
//.............
|
||||||
Spacer(Modifier.width(5.dp))
|
Spacer(Modifier.width(5.dp))
|
||||||
Button(
|
Button(
|
||||||
{
|
{
|
||||||
|
@ -85,7 +103,9 @@ fun WrenchScaffold(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
colors = ButtonDefaults.buttonColors(WrenchColors.LIGHT, Color.White),
|
colors = ButtonDefaults.buttonColors(WrenchColors.LIGHT, Color.White),
|
||||||
contentPadding = ButtonDefaults.ContentPadding
|
contentPadding = ButtonDefaults.ContentPadding,
|
||||||
|
shape = RoundedCornerShape(100),
|
||||||
|
modifier = Modifier.shadow(15.dp, RoundedCornerShape(100), false)
|
||||||
) {
|
) {
|
||||||
if (status) Icon(
|
if (status) Icon(
|
||||||
Icons.Filled.Close,
|
Icons.Filled.Close,
|
||||||
|
|
Reference in a new issue