mirror of
https://github.com/InsanusMokrassar/KotlinPublicationScriptsBuilder.git
synced 2024-11-14 12:23:56 +00:00
update desktop part
This commit is contained in:
parent
9a95bddf08
commit
26fe225577
@ -6,13 +6,13 @@ const val defaultProjectName = "\${project.name}"
|
||||
const val defaultProjectDescription = "\${project.name}"
|
||||
|
||||
@Serializable
|
||||
sealed class GpgSigning {
|
||||
sealed class GpgSigning(val name: String) {
|
||||
@Serializable
|
||||
object Disabled : GpgSigning()
|
||||
object Disabled : GpgSigning("Disabled")
|
||||
@Serializable
|
||||
object Optional : GpgSigning()
|
||||
object Optional : GpgSigning("Optional")
|
||||
@Serializable
|
||||
object Enabled : GpgSigning()
|
||||
object Enabled : GpgSigning("Enabled")
|
||||
}
|
||||
|
||||
@Serializable
|
||||
|
@ -1,11 +1,13 @@
|
||||
package dev.inmo.kmppscriptbuilder.desktop.views
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.*
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.shadow
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import dev.inmo.kmppscriptbuilder.core.models.Config
|
||||
@ -28,6 +30,34 @@ class BuilderView : View() {
|
||||
saveAvailableState = true
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
private fun createIcon(
|
||||
tooltip: String,
|
||||
resource: String,
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
TooltipArea(
|
||||
tooltip = {
|
||||
Surface(
|
||||
modifier = Modifier.shadow(4.dp),
|
||||
color = MaterialTheme.colors.primarySurface,
|
||||
shape = RoundedCornerShape(4.dp)
|
||||
) {
|
||||
Text(tooltip, modifier = Modifier.padding(10.dp), color = MaterialTheme.colors.onPrimary)
|
||||
}
|
||||
}
|
||||
) {
|
||||
IconButton(onClick) {
|
||||
Image(
|
||||
painter = painterResource(resource),
|
||||
contentDescription = tooltip
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
override fun build() {
|
||||
Box(Modifier.fillMaxSize()) {
|
||||
@ -37,56 +67,28 @@ class BuilderView : View() {
|
||||
CommonText("Kotlin publication scripts builder", Modifier.clickable { println(config) })
|
||||
},
|
||||
actions = {
|
||||
IconButton(
|
||||
{
|
||||
loadConfig()?.also {
|
||||
config = it
|
||||
}
|
||||
}
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource("images/open_file.svg"),
|
||||
contentDescription = "Open file"
|
||||
)
|
||||
}
|
||||
|
||||
if (saveAvailableState) {
|
||||
IconButton(
|
||||
{
|
||||
saveConfig(config)
|
||||
}
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource("images/save_file.svg"),
|
||||
contentDescription = "Save file"
|
||||
)
|
||||
createIcon("Open file", "images/open_file.svg") {
|
||||
loadConfig()?.also {
|
||||
config = it
|
||||
}
|
||||
}
|
||||
|
||||
if (saveAvailableState) {
|
||||
IconButton(
|
||||
{
|
||||
exportGradle(config)
|
||||
}
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource("images/export_gradle.svg"),
|
||||
contentDescription = "Export Gradle script"
|
||||
)
|
||||
createIcon("Save", "images/save_file.svg") {
|
||||
saveConfig(config)
|
||||
}
|
||||
}
|
||||
|
||||
IconButton(
|
||||
{
|
||||
if (saveAs(config)) {
|
||||
saveAvailableState = true
|
||||
}
|
||||
if (saveAvailableState) {
|
||||
createIcon("Export Gradle script", "images/export_gradle.svg") {
|
||||
exportGradle(config)
|
||||
}
|
||||
}
|
||||
|
||||
createIcon("Save as", "images/save_as.svg") {
|
||||
if (saveAs(config)) {
|
||||
saveAvailableState = true
|
||||
}
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource("images/save_as.svg"),
|
||||
contentDescription = "Export Gradle script"
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
@ -1,7 +1,12 @@
|
||||
package dev.inmo.kmppscriptbuilder.desktop.views
|
||||
|
||||
import androidx.compose.foundation.layout.ColumnScope
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.layout.VerticalAlignmentLine
|
||||
import androidx.compose.ui.unit.dp
|
||||
import dev.inmo.kmppscriptbuilder.core.models.*
|
||||
import dev.inmo.kmppscriptbuilder.desktop.utils.*
|
||||
|
||||
@ -45,6 +50,24 @@ class MavenInfoView : VerticalView("Project information") {
|
||||
// developersView.developers = value.developers
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun addGpgSigningButton(gpgSigning: GpgSigning) {
|
||||
if (gpgSignProperty == gpgSigning) {
|
||||
Button({}, Modifier.padding(8.dp)) {
|
||||
Text(gpgSigning.name)
|
||||
}
|
||||
} else {
|
||||
OutlinedButton(
|
||||
{
|
||||
gpgSignProperty = gpgSigning
|
||||
},
|
||||
Modifier.padding(8.dp)
|
||||
) {
|
||||
Text(gpgSigning.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override val content: @Composable ColumnScope.() -> Unit = {
|
||||
CommonTextField(
|
||||
projectNameProperty,
|
||||
@ -63,12 +86,12 @@ class MavenInfoView : VerticalView("Project information") {
|
||||
"Public project VCS URL (with .git)"
|
||||
) { projectVcsUrlProperty = it }
|
||||
|
||||
|
||||
// SwitchWithLabel(
|
||||
// "Include GPG Signing",
|
||||
// includeGpgSignProperty,
|
||||
// placeSwitchAtTheStart = true
|
||||
// ) { includeGpgSignProperty = it }
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Text("Gpg Signing: ")
|
||||
addGpgSigningButton(GpgSigning.Disabled)
|
||||
addGpgSigningButton(GpgSigning.Optional)
|
||||
addGpgSigningButton(GpgSigning.Enabled)
|
||||
}
|
||||
|
||||
SwitchWithLabel(
|
||||
"Include publication to MavenCentral",
|
||||
|
@ -1,33 +1,40 @@
|
||||
package dev.inmo.kmppscriptbuilder.desktop.views
|
||||
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.Switch
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import dev.inmo.kmppscriptbuilder.core.models.*
|
||||
import dev.inmo.kmppscriptbuilder.desktop.utils.VerticalView
|
||||
|
||||
class ProjectTypeView : VerticalView("Project type") {
|
||||
private var projectTypeState by mutableStateOf<Boolean>(false)
|
||||
private val calculatedProjectType: ProjectType
|
||||
get() = if (projectTypeState) JVMProjectType else MultiplatformProjectType
|
||||
var projectType: ProjectType
|
||||
get() = calculatedProjectType
|
||||
set(value) {
|
||||
projectTypeState = value == JVMProjectType
|
||||
var projectType by mutableStateOf<ProjectType>(MultiplatformProjectType)
|
||||
|
||||
@Composable
|
||||
private fun addProjectTypeButton(newProjectType: ProjectType) {
|
||||
if (projectType == newProjectType) {
|
||||
Button({}, Modifier.padding(8.dp)) {
|
||||
Text(newProjectType.name)
|
||||
}
|
||||
} else {
|
||||
OutlinedButton(
|
||||
{
|
||||
projectType = newProjectType
|
||||
},
|
||||
Modifier.padding(8.dp)
|
||||
) {
|
||||
Text(newProjectType.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override val content: @Composable ColumnScope.() -> Unit = {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(5.dp)) {
|
||||
Text("Multiplatform", Modifier.alignByBaseline())
|
||||
Switch(
|
||||
projectTypeState,
|
||||
{ projectTypeState = it },
|
||||
Modifier.padding(4.dp, 0.dp)
|
||||
)
|
||||
Text("JVM", Modifier.alignByBaseline())
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
addProjectTypeButton(MultiplatformProjectType)
|
||||
addProjectTypeButton(JVMProjectType)
|
||||
addProjectTypeButton(JSProjectType)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user