mirror of
https://github.com/InsanusMokrassar/KotlinPublicationScriptsBuilder.git
synced 2024-11-24 11:08:52 +00:00
temporal progress
This commit is contained in:
parent
70baa30127
commit
53a76c7a73
@ -1,6 +1,9 @@
|
|||||||
package dev.inmo.kmppscriptbuilder.core.ui
|
package dev.inmo.kmppscriptbuilder.core.ui
|
||||||
|
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import dev.inmo.kmppscriptbuilder.core.models.Config
|
import dev.inmo.kmppscriptbuilder.core.models.Config
|
||||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package dev.inmo.kmppscriptbuilder.core.ui
|
package dev.inmo.kmppscriptbuilder.core.ui
|
||||||
|
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateListOf
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import dev.inmo.kmppscriptbuilder.core.models.Developer
|
import dev.inmo.kmppscriptbuilder.core.models.Developer
|
||||||
import dev.inmo.kmppscriptbuilder.desktop.utils.CommonTextField
|
|
||||||
|
|
||||||
class DeveloperState(
|
class DeveloperState(
|
||||||
id: String = "",
|
id: String = "",
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
package dev.inmo.kmppscriptbuilder.core.ui
|
package dev.inmo.kmppscriptbuilder.core.ui
|
||||||
|
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateListOf
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import dev.inmo.kmppscriptbuilder.core.models.License
|
import dev.inmo.kmppscriptbuilder.core.models.License
|
||||||
import dev.inmo.kmppscriptbuilder.core.models.getLicenses
|
import dev.inmo.kmppscriptbuilder.core.models.getLicenses
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
private class LicenseState(
|
internal class LicenseState(
|
||||||
id: String = "",
|
id: String = "",
|
||||||
title: String = "",
|
title: String = "",
|
||||||
url: String? = null
|
url: String? = null
|
||||||
@ -18,19 +25,21 @@ private class LicenseState(
|
|||||||
fun toLicense() = License(id, title, url)
|
fun toLicense() = License(id, title, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun License.toLicenseState() = LicenseState(id, title, url)
|
internal fun License.toLicenseState() = LicenseState(id, title, url)
|
||||||
|
|
||||||
|
expect object LicensesDrawer : Drawer<LicensesView>
|
||||||
|
|
||||||
class LicensesView: VerticalView("Licenses") {
|
class LicensesView: VerticalView("Licenses") {
|
||||||
private var licensesListState = mutableStateListOf<LicenseState>()
|
internal var licensesListState = mutableStateListOf<LicenseState>()
|
||||||
var licenses: List<License>
|
var licenses: List<License>
|
||||||
get() = licensesListState.map { it.toLicense() }
|
get() = licensesListState.map { it.toLicense() }
|
||||||
set(value) {
|
set(value) {
|
||||||
licensesListState.clear()
|
licensesListState.clear()
|
||||||
licensesListState.addAll(value.map { it.toLicenseState() })
|
licensesListState.addAll(value.map { it.toLicenseState() })
|
||||||
}
|
}
|
||||||
private val availableLicensesState = mutableStateListOf<License>()
|
internal val availableLicensesState = mutableStateListOf<License>()
|
||||||
private val licensesOffersToShow = mutableStateListOf<License>()
|
internal val licensesOffersToShow = mutableStateListOf<License>()
|
||||||
private var licenseSearchFilter by mutableStateOf("")
|
internal var licenseSearchFilter by mutableStateOf("")
|
||||||
|
|
||||||
init {
|
init {
|
||||||
CoroutineScope(Dispatchers.Default).launch {
|
CoroutineScope(Dispatchers.Default).launch {
|
||||||
@ -40,49 +49,7 @@ class LicensesView: VerticalView("Licenses") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override val content: @Composable ColumnScope.() -> Unit = {
|
override val content: @Composable () -> Unit = {
|
||||||
CommonTextField(licenseSearchFilter, "Search filter") { filterText ->
|
with(LicensesDrawer) { draw() }
|
||||||
licenseSearchFilter = filterText
|
|
||||||
licensesOffersToShow.clear()
|
|
||||||
if (licenseSearchFilter.isNotEmpty()) {
|
|
||||||
licensesOffersToShow.addAll(
|
|
||||||
availableLicensesState.filter { filterText.all { symbol -> symbol.lowercaseChar() in it.title } }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Column {
|
|
||||||
licensesOffersToShow.forEach {
|
|
||||||
Column(Modifier.padding(16.dp, 8.dp, 8.dp, 8.dp)) {
|
|
||||||
CommonText(it.title, Modifier.clickable {
|
|
||||||
licensesListState.add(it.toLicenseState())
|
|
||||||
licenseSearchFilter = ""
|
|
||||||
licensesOffersToShow.clear()
|
|
||||||
})
|
|
||||||
Divider()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Button({ licensesListState.add(LicenseState()) }, Modifier.padding(8.dp)) {
|
|
||||||
CommonText("Add empty license")
|
|
||||||
}
|
|
||||||
licensesListState.forEach { license ->
|
|
||||||
Column(Modifier.padding(8.dp)) {
|
|
||||||
CommonTextField(
|
|
||||||
license.id,
|
|
||||||
"License ID"
|
|
||||||
) { license.id = it }
|
|
||||||
CommonTextField(
|
|
||||||
license.title,
|
|
||||||
"License title"
|
|
||||||
) { license.title = it }
|
|
||||||
CommonTextField(
|
|
||||||
license.url ?: "",
|
|
||||||
"License URL"
|
|
||||||
) { license.url = it }
|
|
||||||
Button({ licensesListState.remove(license) }, Modifier.padding(8.dp)) {
|
|
||||||
CommonText("Remove")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer
|
|||||||
|
|
||||||
expect class ListViewDrawer<T>() : Drawer<ListView<T>>
|
expect class ListViewDrawer<T>() : Drawer<ListView<T>>
|
||||||
|
|
||||||
abstract class ListView<T>(protected val title: String) : View() {
|
abstract class ListView<T>(title: String) : VerticalView(title) {
|
||||||
internal val itemsList = mutableStateListOf<T>()
|
internal val itemsList = mutableStateListOf<T>()
|
||||||
|
|
||||||
internal open val addItemText: String = "Add"
|
internal open val addItemText: String = "Add"
|
||||||
@ -18,9 +18,9 @@ abstract class ListView<T>(protected val title: String) : View() {
|
|||||||
|
|
||||||
protected val drawer = ListViewDrawer<T>()
|
protected val drawer = ListViewDrawer<T>()
|
||||||
|
|
||||||
override fun build() {
|
override val content: () -> Unit = {
|
||||||
DrawVertically(title) {
|
with(drawer) {
|
||||||
with(drawer) { draw() }
|
draw()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,20 @@
|
|||||||
package dev.inmo.kmppscriptbuilder.core.ui
|
package dev.inmo.kmppscriptbuilder.core.ui
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.*
|
|
||||||
import androidx.compose.material.*
|
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Alignment
|
import dev.inmo.kmppscriptbuilder.core.models.GpgSigning
|
||||||
import androidx.compose.ui.Modifier
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer
|
||||||
import androidx.compose.ui.layout.VerticalAlignmentLine
|
|
||||||
import androidx.compose.ui.unit.dp
|
expect object MavenInfoDrawer : Drawer<MavenInfoView>
|
||||||
import dev.inmo.kmppscriptbuilder.core.models.*
|
|
||||||
import dev.inmo.kmppscriptbuilder.desktop.utils.*
|
|
||||||
|
|
||||||
class MavenInfoView : VerticalView("Project information") {
|
class MavenInfoView : VerticalView("Project information") {
|
||||||
private var projectNameProperty by mutableStateOf("")
|
internal var projectNameProperty by mutableStateOf("")
|
||||||
private var projectDescriptionProperty by mutableStateOf("")
|
internal var projectDescriptionProperty by mutableStateOf("")
|
||||||
private var projectUrlProperty by mutableStateOf("")
|
internal var projectUrlProperty by mutableStateOf("")
|
||||||
private var projectVcsUrlProperty by mutableStateOf("")
|
internal var projectVcsUrlProperty by mutableStateOf("")
|
||||||
private var gpgSignProperty by mutableStateOf<GpgSigning>(GpgSigning.Disabled)
|
internal var gpgSignProperty by mutableStateOf<GpgSigning>(GpgSigning.Disabled)
|
||||||
private var publishToMavenCentralProperty by mutableStateOf(false)
|
internal var publishToMavenCentralProperty by mutableStateOf(false)
|
||||||
private val developersView = DevelopersView()
|
internal val developersView = DevelopersView()
|
||||||
private val repositoriesView = RepositoriesView()
|
internal val repositoriesView = RepositoriesView()
|
||||||
|
|
||||||
var mavenConfig: MavenConfig
|
var mavenConfig: MavenConfig
|
||||||
get() = MavenConfig(
|
get() = MavenConfig(
|
||||||
@ -50,55 +46,7 @@ class MavenInfoView : VerticalView("Project information") {
|
|||||||
// developersView.developers = value.developers
|
// developersView.developers = value.developers
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
override val content: @Composable () -> Unit = {
|
||||||
private fun addGpgSigningButton(gpgSigning: GpgSigning) {
|
with (MavenInfoDrawer) { draw() }
|
||||||
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,
|
|
||||||
"Public project name"
|
|
||||||
) { projectNameProperty = it }
|
|
||||||
CommonTextField(
|
|
||||||
projectDescriptionProperty,
|
|
||||||
"Public project description"
|
|
||||||
) { projectDescriptionProperty = it }
|
|
||||||
CommonTextField(
|
|
||||||
projectUrlProperty,
|
|
||||||
"Public project URL"
|
|
||||||
) { projectUrlProperty = it }
|
|
||||||
CommonTextField(
|
|
||||||
projectVcsUrlProperty,
|
|
||||||
"Public project VCS URL (with .git)"
|
|
||||||
) { projectVcsUrlProperty = it }
|
|
||||||
|
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
|
||||||
Text("Gpg Signing: ")
|
|
||||||
addGpgSigningButton(GpgSigning.Disabled)
|
|
||||||
addGpgSigningButton(GpgSigning.Optional)
|
|
||||||
addGpgSigningButton(GpgSigning.Enabled)
|
|
||||||
}
|
|
||||||
|
|
||||||
SwitchWithLabel(
|
|
||||||
"Include publication to MavenCentral",
|
|
||||||
publishToMavenCentralProperty,
|
|
||||||
placeSwitchAtTheStart = true
|
|
||||||
) { publishToMavenCentralProperty = it }
|
|
||||||
developersView.init()
|
|
||||||
repositoriesView.init()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,40 +1,19 @@
|
|||||||
package dev.inmo.kmppscriptbuilder.core.ui
|
package dev.inmo.kmppscriptbuilder.core.ui
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.material.*
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import dev.inmo.kmppscriptbuilder.core.models.MultiplatformProjectType
|
||||||
import androidx.compose.ui.unit.dp
|
import dev.inmo.kmppscriptbuilder.core.models.ProjectType
|
||||||
import dev.inmo.kmppscriptbuilder.core.models.*
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer
|
||||||
import dev.inmo.kmppscriptbuilder.desktop.utils.VerticalView
|
|
||||||
|
expect object ProjectTypeDrawer : Drawer<ProjectTypeView>
|
||||||
|
|
||||||
class ProjectTypeView : VerticalView("Project type") {
|
class ProjectTypeView : VerticalView("Project type") {
|
||||||
var projectType by mutableStateOf<ProjectType>(MultiplatformProjectType)
|
var projectType by mutableStateOf<ProjectType>(MultiplatformProjectType)
|
||||||
|
|
||||||
@Composable
|
override val content: @Composable () -> Unit = {
|
||||||
private fun addProjectTypeButton(newProjectType: ProjectType) {
|
with(ProjectTypeDrawer) { draw() }
|
||||||
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(verticalAlignment = Alignment.CenterVertically) {
|
|
||||||
addProjectTypeButton(MultiplatformProjectType)
|
|
||||||
addProjectTypeButton(JVMProjectType)
|
|
||||||
addProjectTypeButton(JSProjectType)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
package dev.inmo.kmppscriptbuilder.core.ui
|
package dev.inmo.kmppscriptbuilder.core.ui
|
||||||
|
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import dev.inmo.kmppscriptbuilder.core.models.MavenPublishingRepository
|
import dev.inmo.kmppscriptbuilder.core.models.MavenPublishingRepository
|
||||||
import dev.inmo.kmppscriptbuilder.desktop.utils.CommonTextField
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer
|
||||||
|
|
||||||
class RepositoryState(
|
class RepositoryState(
|
||||||
name: String = "",
|
name: String = "",
|
||||||
@ -16,6 +19,8 @@ class RepositoryState(
|
|||||||
|
|
||||||
private fun MavenPublishingRepository.toRepositoryState() = RepositoryState(name, url)
|
private fun MavenPublishingRepository.toRepositoryState() = RepositoryState(name, url)
|
||||||
|
|
||||||
|
expect object RepositoryStateDrawer : Drawer<RepositoryState>
|
||||||
|
|
||||||
class RepositoriesView : ListView<RepositoryState>("Repositories info") {
|
class RepositoriesView : ListView<RepositoryState>("Repositories info") {
|
||||||
var repositories: List<MavenPublishingRepository>
|
var repositories: List<MavenPublishingRepository>
|
||||||
get() = itemsList.map { it.toRepository() }
|
get() = itemsList.map { it.toRepository() }
|
||||||
@ -30,16 +35,10 @@ class RepositoriesView : ListView<RepositoryState>("Repositories info") {
|
|||||||
override val removeItemText: String = "Remove repository"
|
override val removeItemText: String = "Remove repository"
|
||||||
|
|
||||||
override fun createItem(): RepositoryState = RepositoryState()
|
override fun createItem(): RepositoryState = RepositoryState()
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
override fun buildView(item: RepositoryState) {
|
override fun buildView(item: RepositoryState) {
|
||||||
CommonTextField(
|
with(RepositoryStateDrawer) { with(item) { draw() } }
|
||||||
item.name,
|
|
||||||
"Repository name"
|
|
||||||
) { item.name = it }
|
|
||||||
CommonTextField(
|
|
||||||
item.url,
|
|
||||||
"Repository url"
|
|
||||||
) { item.url = it }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
package dev.inmo.kmppscriptbuilder.core.ui
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
|
||||||
|
abstract class VerticalView(protected val title: String) : View() {
|
||||||
|
abstract val content: @Composable () -> Unit
|
||||||
|
@Composable
|
||||||
|
override fun build() {
|
||||||
|
DrawVertically(title, content)
|
||||||
|
}
|
||||||
|
}
|
@ -6,7 +6,7 @@ import androidx.compose.runtime.Composable
|
|||||||
expect fun TitleText(text: String)
|
expect fun TitleText(text: String)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
expect fun CommonText(text: String)
|
expect fun CommonText(text: String, onClick: (() -> Unit)? = null)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
expect fun CommonTextField(presetText: String, hint: String, onChange: (String) -> Unit)
|
expect fun CommonTextField(presetText: String, hint: String, onChange: (String) -> Unit)
|
||||||
|
@ -0,0 +1,59 @@
|
|||||||
|
package dev.inmo.kmppscriptbuilder.core.ui
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.material.Button
|
||||||
|
import androidx.compose.material.Divider
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.CommonText
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.CommonTextField
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer
|
||||||
|
|
||||||
|
actual object LicensesDrawer : Drawer<LicensesView> {
|
||||||
|
override fun LicensesView.draw() {
|
||||||
|
CommonTextField(licenseSearchFilter, "Search filter") { filterText ->
|
||||||
|
licenseSearchFilter = filterText
|
||||||
|
licensesOffersToShow.clear()
|
||||||
|
if (licenseSearchFilter.isNotEmpty()) {
|
||||||
|
licensesOffersToShow.addAll(
|
||||||
|
availableLicensesState.filter { filterText.all { symbol -> symbol.lowercaseChar() in it.title } }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Column {
|
||||||
|
licensesOffersToShow.forEach {
|
||||||
|
Column(Modifier.padding(16.dp, 8.dp, 8.dp, 8.dp)) {
|
||||||
|
CommonText(it.title) {
|
||||||
|
licensesListState.add(it.toLicenseState())
|
||||||
|
licenseSearchFilter = ""
|
||||||
|
licensesOffersToShow.clear()
|
||||||
|
}
|
||||||
|
Divider()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Button({ licensesListState.add(LicenseState()) }, Modifier.padding(8.dp)) {
|
||||||
|
CommonText("Add empty license",)
|
||||||
|
}
|
||||||
|
licensesListState.forEach { license ->
|
||||||
|
Column(Modifier.padding(8.dp)) {
|
||||||
|
CommonTextField(
|
||||||
|
license.id,
|
||||||
|
"License ID"
|
||||||
|
) { license.id = it }
|
||||||
|
CommonTextField(
|
||||||
|
license.title,
|
||||||
|
"License title"
|
||||||
|
) { license.title = it }
|
||||||
|
CommonTextField(
|
||||||
|
license.url ?: "",
|
||||||
|
"License URL"
|
||||||
|
) { license.url = it }
|
||||||
|
Button({ licensesListState.remove(license) }, Modifier.padding(8.dp)) {
|
||||||
|
CommonText("Remove",)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -11,13 +11,13 @@ import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer
|
|||||||
actual class ListViewDrawer<T> : Drawer<ListView<T>> {
|
actual class ListViewDrawer<T> : Drawer<ListView<T>> {
|
||||||
override fun ListView<T>.draw() {
|
override fun ListView<T>.draw() {
|
||||||
Button({ itemsList.add(createItem()) }) {
|
Button({ itemsList.add(createItem()) }) {
|
||||||
CommonText(addItemText)
|
CommonText(addItemText,)
|
||||||
}
|
}
|
||||||
itemsList.forEach { item ->
|
itemsList.forEach { item ->
|
||||||
Column(Modifier.padding(8.dp)) {
|
Column(Modifier.padding(8.dp)) {
|
||||||
buildView(item)
|
buildView(item)
|
||||||
Button({ itemsList.remove(item) }, Modifier.padding(8.dp)) {
|
Button({ itemsList.remove(item) }, Modifier.padding(8.dp)) {
|
||||||
CommonText(removeItemText)
|
CommonText(removeItemText,)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
package dev.inmo.kmppscriptbuilder.core.ui
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.material.Button
|
||||||
|
import androidx.compose.material.OutlinedButton
|
||||||
|
import androidx.compose.material.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.models.GpgSigning
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.CommonTextField
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.SwitchWithLabel
|
||||||
|
|
||||||
|
actual object MavenInfoDrawer : Drawer<MavenInfoView> {
|
||||||
|
@Composable
|
||||||
|
private fun MavenInfoView.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 fun MavenInfoView.draw() {
|
||||||
|
CommonTextField(
|
||||||
|
projectNameProperty,
|
||||||
|
"Public project name"
|
||||||
|
) { projectNameProperty = it }
|
||||||
|
CommonTextField(
|
||||||
|
projectDescriptionProperty,
|
||||||
|
"Public project description"
|
||||||
|
) { projectDescriptionProperty = it }
|
||||||
|
CommonTextField(
|
||||||
|
projectUrlProperty,
|
||||||
|
"Public project URL"
|
||||||
|
) { projectUrlProperty = it }
|
||||||
|
CommonTextField(
|
||||||
|
projectVcsUrlProperty,
|
||||||
|
"Public project VCS URL (with .git)"
|
||||||
|
) { projectVcsUrlProperty = it }
|
||||||
|
|
||||||
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
|
Text("Gpg Signing: ")
|
||||||
|
addGpgSigningButton(GpgSigning.Disabled)
|
||||||
|
addGpgSigningButton(GpgSigning.Optional)
|
||||||
|
addGpgSigningButton(GpgSigning.Enabled)
|
||||||
|
}
|
||||||
|
|
||||||
|
SwitchWithLabel(
|
||||||
|
"Include publication to MavenCentral",
|
||||||
|
publishToMavenCentralProperty,
|
||||||
|
placeSwitchAtTheStart = true
|
||||||
|
) { publishToMavenCentralProperty = it }
|
||||||
|
developersView.init()
|
||||||
|
repositoriesView.init()
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package dev.inmo.kmppscriptbuilder.core.ui
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.material.Button
|
||||||
|
import androidx.compose.material.OutlinedButton
|
||||||
|
import androidx.compose.material.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.models.JSProjectType
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.models.JVMProjectType
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.models.MultiplatformProjectType
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.models.ProjectType
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer
|
||||||
|
|
||||||
|
actual object ProjectTypeDrawer : Drawer<ProjectTypeView> {
|
||||||
|
@Composable
|
||||||
|
private fun ProjectTypeView.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 fun ProjectTypeView.draw() {
|
||||||
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
|
addProjectTypeButton(MultiplatformProjectType)
|
||||||
|
addProjectTypeButton(JVMProjectType)
|
||||||
|
addProjectTypeButton(JSProjectType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package dev.inmo.kmppscriptbuilder.core.ui
|
||||||
|
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.CommonTextField
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer
|
||||||
|
|
||||||
|
actual object RepositoryStateDrawer : Drawer<RepositoriesView> {
|
||||||
|
override fun RepositoriesView.draw() {
|
||||||
|
CommonTextField(
|
||||||
|
item.name,
|
||||||
|
"Repository name"
|
||||||
|
) { item.name = it }
|
||||||
|
CommonTextField(
|
||||||
|
item.url,
|
||||||
|
"Repository url"
|
||||||
|
) { item.url = it }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -37,7 +37,7 @@ actual fun SwitchWithLabel(
|
|||||||
switchCreator()
|
switchCreator()
|
||||||
}
|
}
|
||||||
Box(Modifier.fillMaxWidth().align(Alignment.CenterVertically).clickable { }) {
|
Box(Modifier.fillMaxWidth().align(Alignment.CenterVertically).clickable { }) {
|
||||||
CommonText(label)
|
CommonText(label,)
|
||||||
}
|
}
|
||||||
if (!placeSwitchAtTheStart) {
|
if (!placeSwitchAtTheStart) {
|
||||||
switchCreator()
|
switchCreator()
|
||||||
@ -53,14 +53,14 @@ actual fun CommonTextField(presetText: String, hint: String, onChange: (String)
|
|||||||
Modifier.fillMaxWidth(),
|
Modifier.fillMaxWidth(),
|
||||||
singleLine = true,
|
singleLine = true,
|
||||||
label = {
|
label = {
|
||||||
CommonText(hint)
|
CommonText(hint,)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
actual fun CommonText(text: String) {
|
actual fun CommonText(text: String, onClick: (() -> Unit)?) {
|
||||||
Text(text)
|
Text(text, modifier = Modifier.run { onClick ?.let { clickable(onClick = it) } ?: this })
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
Loading…
Reference in New Issue
Block a user