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}"
|
const val defaultProjectDescription = "\${project.name}"
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
sealed class GpgSigning {
|
sealed class GpgSigning(val name: String) {
|
||||||
@Serializable
|
@Serializable
|
||||||
object Disabled : GpgSigning()
|
object Disabled : GpgSigning("Disabled")
|
||||||
@Serializable
|
@Serializable
|
||||||
object Optional : GpgSigning()
|
object Optional : GpgSigning("Optional")
|
||||||
@Serializable
|
@Serializable
|
||||||
object Enabled : GpgSigning()
|
object Enabled : GpgSigning("Enabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package dev.inmo.kmppscriptbuilder.desktop.views
|
package dev.inmo.kmppscriptbuilder.desktop.views
|
||||||
|
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.*
|
||||||
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.*
|
import androidx.compose.material.*
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Modifier
|
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.res.painterResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import dev.inmo.kmppscriptbuilder.core.models.Config
|
import dev.inmo.kmppscriptbuilder.core.models.Config
|
||||||
@ -28,6 +30,34 @@ class BuilderView : View() {
|
|||||||
saveAvailableState = true
|
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
|
@Composable
|
||||||
override fun build() {
|
override fun build() {
|
||||||
Box(Modifier.fillMaxSize()) {
|
Box(Modifier.fillMaxSize()) {
|
||||||
@ -37,56 +67,28 @@ class BuilderView : View() {
|
|||||||
CommonText("Kotlin publication scripts builder", Modifier.clickable { println(config) })
|
CommonText("Kotlin publication scripts builder", Modifier.clickable { println(config) })
|
||||||
},
|
},
|
||||||
actions = {
|
actions = {
|
||||||
IconButton(
|
createIcon("Open file", "images/open_file.svg") {
|
||||||
{
|
loadConfig()?.also {
|
||||||
loadConfig()?.also {
|
config = it
|
||||||
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"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (saveAvailableState) {
|
if (saveAvailableState) {
|
||||||
IconButton(
|
createIcon("Save", "images/save_file.svg") {
|
||||||
{
|
saveConfig(config)
|
||||||
exportGradle(config)
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
Image(
|
|
||||||
painter = painterResource("images/export_gradle.svg"),
|
|
||||||
contentDescription = "Export Gradle script"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IconButton(
|
if (saveAvailableState) {
|
||||||
{
|
createIcon("Export Gradle script", "images/export_gradle.svg") {
|
||||||
if (saveAs(config)) {
|
exportGradle(config)
|
||||||
saveAvailableState = true
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
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.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.core.models.*
|
||||||
import dev.inmo.kmppscriptbuilder.desktop.utils.*
|
import dev.inmo.kmppscriptbuilder.desktop.utils.*
|
||||||
|
|
||||||
@ -45,6 +50,24 @@ class MavenInfoView : VerticalView("Project information") {
|
|||||||
// developersView.developers = value.developers
|
// 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 = {
|
override val content: @Composable ColumnScope.() -> Unit = {
|
||||||
CommonTextField(
|
CommonTextField(
|
||||||
projectNameProperty,
|
projectNameProperty,
|
||||||
@ -63,12 +86,12 @@ class MavenInfoView : VerticalView("Project information") {
|
|||||||
"Public project VCS URL (with .git)"
|
"Public project VCS URL (with .git)"
|
||||||
) { projectVcsUrlProperty = it }
|
) { projectVcsUrlProperty = it }
|
||||||
|
|
||||||
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
// SwitchWithLabel(
|
Text("Gpg Signing: ")
|
||||||
// "Include GPG Signing",
|
addGpgSigningButton(GpgSigning.Disabled)
|
||||||
// includeGpgSignProperty,
|
addGpgSigningButton(GpgSigning.Optional)
|
||||||
// placeSwitchAtTheStart = true
|
addGpgSigningButton(GpgSigning.Enabled)
|
||||||
// ) { includeGpgSignProperty = it }
|
}
|
||||||
|
|
||||||
SwitchWithLabel(
|
SwitchWithLabel(
|
||||||
"Include publication to MavenCentral",
|
"Include publication to MavenCentral",
|
||||||
|
@ -1,33 +1,40 @@
|
|||||||
package dev.inmo.kmppscriptbuilder.desktop.views
|
package dev.inmo.kmppscriptbuilder.desktop.views
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.material.Switch
|
import androidx.compose.material.*
|
||||||
import androidx.compose.material.Text
|
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import dev.inmo.kmppscriptbuilder.core.models.*
|
import dev.inmo.kmppscriptbuilder.core.models.*
|
||||||
import dev.inmo.kmppscriptbuilder.desktop.utils.VerticalView
|
import dev.inmo.kmppscriptbuilder.desktop.utils.VerticalView
|
||||||
|
|
||||||
class ProjectTypeView : VerticalView("Project type") {
|
class ProjectTypeView : VerticalView("Project type") {
|
||||||
private var projectTypeState by mutableStateOf<Boolean>(false)
|
var projectType by mutableStateOf<ProjectType>(MultiplatformProjectType)
|
||||||
private val calculatedProjectType: ProjectType
|
|
||||||
get() = if (projectTypeState) JVMProjectType else MultiplatformProjectType
|
@Composable
|
||||||
var projectType: ProjectType
|
private fun addProjectTypeButton(newProjectType: ProjectType) {
|
||||||
get() = calculatedProjectType
|
if (projectType == newProjectType) {
|
||||||
set(value) {
|
Button({}, Modifier.padding(8.dp)) {
|
||||||
projectTypeState = value == JVMProjectType
|
Text(newProjectType.name)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
OutlinedButton(
|
||||||
|
{
|
||||||
|
projectType = newProjectType
|
||||||
|
},
|
||||||
|
Modifier.padding(8.dp)
|
||||||
|
) {
|
||||||
|
Text(newProjectType.name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override val content: @Composable ColumnScope.() -> Unit = {
|
override val content: @Composable ColumnScope.() -> Unit = {
|
||||||
Row(horizontalArrangement = Arrangement.spacedBy(5.dp)) {
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
Text("Multiplatform", Modifier.alignByBaseline())
|
addProjectTypeButton(MultiplatformProjectType)
|
||||||
Switch(
|
addProjectTypeButton(JVMProjectType)
|
||||||
projectTypeState,
|
addProjectTypeButton(JSProjectType)
|
||||||
{ projectTypeState = it },
|
|
||||||
Modifier.padding(4.dp, 0.dp)
|
|
||||||
)
|
|
||||||
Text("JVM", Modifier.alignByBaseline())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user