mirror of
https://github.com/InsanusMokrassar/KotlinPublicationScriptsBuilder.git
synced 2026-05-20 21:47:18 +00:00
Compare commits
3 Commits
3be0f24eac
...
different_
| Author | SHA1 | Date | |
|---|---|---|---|
| 0770772e7d | |||
| c6b1289f5a | |||
| 788fe49aa4 |
2
.github/workflows/commit-release.yml
vendored
2
.github/workflows/commit-release.yml
vendored
@@ -44,6 +44,6 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
|
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
|
||||||
asset_path: "./desktop/build/compose/jars/kmppscriptbuilder.desktop-linux-x64-${{ env.version }}${{ env.additional_version }}.jar"
|
asset_path: "./core/build/compose/jars/kmppscriptbuilder.desktop-linux-x64-${{ env.version }}${{ env.additional_version }}.jar"
|
||||||
asset_name: KotlinPublicationScriptsBuilder-linux-x64.jar
|
asset_name: KotlinPublicationScriptsBuilder-linux-x64.jar
|
||||||
asset_content_type: application/java-archive
|
asset_content_type: application/java-archive
|
||||||
|
|||||||
@@ -33,13 +33,10 @@ data class MavenPublishingRepository(
|
|||||||
val name: String,
|
val name: String,
|
||||||
val url: String,
|
val url: String,
|
||||||
val credsType: CredentialsType = CredentialsType.UsernameAndPassword(
|
val credsType: CredentialsType = CredentialsType.UsernameAndPassword(
|
||||||
"${name.uppercase()}_USER",
|
CredentialsType.UsernameAndPassword.defaultUsernameProperty(name),
|
||||||
"${name.uppercase()}_PASSWORD"
|
CredentialsType.UsernameAndPassword.defaultPasswordProperty(name),
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
val defaultUsernameProperty = "${name.uppercase()}_USER"
|
|
||||||
val defaultPasswordProperty = "${name.uppercase()}_PASSWORD"
|
|
||||||
val defaultHeaderValueProperty = "${name.uppercase()}_TOKEN"
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
sealed interface CredentialsType {
|
sealed interface CredentialsType {
|
||||||
@@ -53,6 +50,11 @@ data class MavenPublishingRepository(
|
|||||||
val usernameProperty: String,
|
val usernameProperty: String,
|
||||||
val passwordProperty: String
|
val passwordProperty: String
|
||||||
): CredentialsType {
|
): CredentialsType {
|
||||||
|
constructor(baseParameter: String) : this(
|
||||||
|
defaultUsernameProperty(baseParameter),
|
||||||
|
defaultPasswordProperty(baseParameter)
|
||||||
|
)
|
||||||
|
|
||||||
override fun buildCheckPart(): String = "(project.hasProperty('${usernameProperty}') || System.getenv('${usernameProperty}') != null) && (project.hasProperty('${passwordProperty}') || System.getenv('${passwordProperty}') != null)"
|
override fun buildCheckPart(): String = "(project.hasProperty('${usernameProperty}') || System.getenv('${usernameProperty}') != null) && (project.hasProperty('${passwordProperty}') || System.getenv('${passwordProperty}') != null)"
|
||||||
override fun buildCredsPart(): String {
|
override fun buildCredsPart(): String {
|
||||||
return """
|
return """
|
||||||
@@ -62,6 +64,15 @@ return """
|
|||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun defaultUsernameProperty(name: String): String {
|
||||||
|
return "${name.uppercase()}_USER"
|
||||||
|
}
|
||||||
|
fun defaultPasswordProperty(name: String): String {
|
||||||
|
return "${name.uppercase()}_PASSWORD"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@Serializable
|
@Serializable
|
||||||
data class HttpHeaderCredentials(
|
data class HttpHeaderCredentials(
|
||||||
@@ -77,6 +88,12 @@ return """
|
|||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun defaultValueProperty(name: String): String {
|
||||||
|
return "${name.uppercase()}_TOKEN"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun buildCheckPart(): String
|
fun buildCheckPart(): String
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import androidx.compose.runtime.getValue
|
|||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.setValue
|
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.DefaultBox
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.DefaultContentColumn
|
||||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.DefaultDivider
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.DefaultDivider
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -45,7 +45,7 @@ class BuilderView : View() {
|
|||||||
config = it
|
config = it
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultBox {
|
DefaultContentColumn {
|
||||||
projectTypeView.build()
|
projectTypeView.build()
|
||||||
DefaultDivider()
|
DefaultDivider()
|
||||||
licensesView.build()
|
licensesView.build()
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import androidx.compose.runtime.setValue
|
|||||||
import dev.inmo.kmppscriptbuilder.core.models.Developer
|
import dev.inmo.kmppscriptbuilder.core.models.Developer
|
||||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.CommonText
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.CommonText
|
||||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.CommonTextField
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.CommonTextField
|
||||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.DefaultBox
|
|
||||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.DefaultSmallVerticalMargin
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.DefaultSmallVerticalMargin
|
||||||
|
|
||||||
class DeveloperState(
|
class DeveloperState(
|
||||||
|
|||||||
@@ -3,23 +3,32 @@ package dev.inmo.kmppscriptbuilder.core.ui
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import dev.inmo.kmppscriptbuilder.core.models.MavenPublishingRepository
|
import dev.inmo.kmppscriptbuilder.core.models.MavenPublishingRepository
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.ButtonsPanel
|
||||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.CommonText
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.CommonText
|
||||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.CommonTextField
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.CommonTextField
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.DefaultContentColumn
|
||||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.DefaultSmallVerticalMargin
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.DefaultSmallVerticalMargin
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer
|
||||||
|
|
||||||
class RepositoryState(
|
class RepositoryState(
|
||||||
name: String = "",
|
name: String = "",
|
||||||
url: String = ""
|
url: String = "",
|
||||||
|
credsType: MavenPublishingRepository.CredentialsType = MavenPublishingRepository.CredentialsType.UsernameAndPassword(name)
|
||||||
) {
|
) {
|
||||||
var name: String by mutableStateOf(name)
|
var name: String by mutableStateOf(name)
|
||||||
var url: String by mutableStateOf(url)
|
var url: String by mutableStateOf(url)
|
||||||
|
var credsType by mutableStateOf(credsType)
|
||||||
|
|
||||||
fun toRepository() = MavenPublishingRepository(name, url)
|
fun toRepository() = MavenPublishingRepository(name, url, credsType)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun MavenPublishingRepository.toRepositoryState() = RepositoryState(name, url)
|
private fun MavenPublishingRepository.toRepositoryState() = RepositoryState(name, url, credsType)
|
||||||
|
|
||||||
|
expect class RepositoryCredentialTypeDrawer : Drawer<MavenPublishingRepository.CredentialsType>
|
||||||
|
expect fun RepositoryCredentialTypeDrawerWithState(repositoryState: RepositoryState): RepositoryCredentialTypeDrawer
|
||||||
|
|
||||||
class RepositoriesView : ListView<RepositoryState>("Repositories info") {
|
class RepositoriesView : ListView<RepositoryState>("Repositories info") {
|
||||||
var repositories: List<MavenPublishingRepository>
|
var repositories: List<MavenPublishingRepository>
|
||||||
@@ -38,17 +47,96 @@ class RepositoriesView : ListView<RepositoryState>("Repositories info") {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
override fun buildView(item: RepositoryState) {
|
override fun buildView(item: RepositoryState) {
|
||||||
|
val credsTypesDrawer = remember {
|
||||||
|
RepositoryCredentialTypeDrawerWithState(item)
|
||||||
|
}
|
||||||
|
|
||||||
CommonText("Repository name")
|
CommonText("Repository name")
|
||||||
CommonTextField(
|
CommonTextField(
|
||||||
item.name,
|
item.name,
|
||||||
"This name will be used to identify repository in gradle"
|
"This name will be used to identify repository in gradle"
|
||||||
) { item.name = it }
|
) {
|
||||||
|
val previous = item.name
|
||||||
|
item.name = it
|
||||||
|
when (val currentCredsType = item.credsType) {
|
||||||
|
is MavenPublishingRepository.CredentialsType.HttpHeaderCredentials -> {
|
||||||
|
if (MavenPublishingRepository.CredentialsType.HttpHeaderCredentials.defaultValueProperty(previous) == currentCredsType.headerValueProperty) {
|
||||||
|
item.credsType = currentCredsType.copy(
|
||||||
|
headerValueProperty = MavenPublishingRepository.CredentialsType.HttpHeaderCredentials.defaultValueProperty(it)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MavenPublishingRepository.CredentialsType.Nothing -> {}
|
||||||
|
is MavenPublishingRepository.CredentialsType.UsernameAndPassword -> {
|
||||||
|
var current: MavenPublishingRepository.CredentialsType.UsernameAndPassword = currentCredsType
|
||||||
|
if (MavenPublishingRepository.CredentialsType.UsernameAndPassword.defaultUsernameProperty(previous) == currentCredsType.usernameProperty) {
|
||||||
|
current = current.copy(
|
||||||
|
usernameProperty = MavenPublishingRepository.CredentialsType.UsernameAndPassword.defaultUsernameProperty(it)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (MavenPublishingRepository.CredentialsType.UsernameAndPassword.defaultPasswordProperty(previous) == currentCredsType.passwordProperty) {
|
||||||
|
current = current.copy(
|
||||||
|
passwordProperty = MavenPublishingRepository.CredentialsType.UsernameAndPassword.defaultPasswordProperty(it)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
item.credsType = current
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
DefaultSmallVerticalMargin()
|
DefaultSmallVerticalMargin()
|
||||||
CommonText("Repository url")
|
CommonText("Repository url")
|
||||||
CommonTextField(
|
CommonTextField(
|
||||||
item.url,
|
item.url,
|
||||||
"For example: https://repo.maven.apache.org/maven2/"
|
"For example: https://repo.maven.apache.org/maven2/"
|
||||||
) { item.url = it }
|
) { item.url = it }
|
||||||
|
|
||||||
|
ButtonsPanel(
|
||||||
|
"Credentials type",
|
||||||
|
MavenPublishingRepository.CredentialsType.Nothing.takeIf { item.credsType != it } ?: item.credsType,
|
||||||
|
MavenPublishingRepository.CredentialsType.UsernameAndPassword(item.name).takeIf { item.credsType !is MavenPublishingRepository.CredentialsType.UsernameAndPassword } ?: item.credsType,
|
||||||
|
MavenPublishingRepository.CredentialsType.HttpHeaderCredentials(
|
||||||
|
"Authorization",
|
||||||
|
MavenPublishingRepository.CredentialsType.HttpHeaderCredentials.defaultValueProperty(item.name)
|
||||||
|
).takeIf { item.credsType !is MavenPublishingRepository.CredentialsType.HttpHeaderCredentials } ?: item.credsType,
|
||||||
|
) {
|
||||||
|
with(credsTypesDrawer) {
|
||||||
|
with(it) {
|
||||||
|
draw()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DefaultContentColumn {
|
||||||
|
when (val credsType = item.credsType) {
|
||||||
|
is MavenPublishingRepository.CredentialsType.HttpHeaderCredentials -> {
|
||||||
|
CommonText("Header name")
|
||||||
|
CommonTextField(credsType.headerName) {
|
||||||
|
item.credsType = credsType.copy(headerName = it)
|
||||||
|
}
|
||||||
|
DefaultSmallVerticalMargin()
|
||||||
|
|
||||||
|
CommonText("Property name")
|
||||||
|
CommonTextField(credsType.headerValueProperty) {
|
||||||
|
item.credsType = credsType.copy(headerValueProperty = it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MavenPublishingRepository.CredentialsType.Nothing -> {
|
||||||
|
CommonText("No parameters for absence of credentials")
|
||||||
|
}
|
||||||
|
is MavenPublishingRepository.CredentialsType.UsernameAndPassword -> {
|
||||||
|
CommonText("Username property name")
|
||||||
|
CommonTextField(credsType.usernameProperty) {
|
||||||
|
item.credsType = credsType.copy(usernameProperty = it)
|
||||||
|
}
|
||||||
|
DefaultSmallVerticalMargin()
|
||||||
|
|
||||||
|
CommonText("Password property name")
|
||||||
|
CommonTextField(credsType.passwordProperty) {
|
||||||
|
item.credsType = credsType.copy(passwordProperty = it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package dev.inmo.kmppscriptbuilder.core.ui
|
package dev.inmo.kmppscriptbuilder.core.ui
|
||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.DefaultBox
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.DefaultContentColumn
|
||||||
|
|
||||||
abstract class VerticalView(protected val title: String) : View() {
|
abstract class VerticalView(protected val title: String) : View() {
|
||||||
abstract val content: @Composable () -> Unit
|
abstract val content: @Composable () -> Unit
|
||||||
@Composable
|
@Composable
|
||||||
override fun build() {
|
override fun build() {
|
||||||
DefaultBox {
|
DefaultContentColumn {
|
||||||
DrawVertically(title, content)
|
DrawVertically(title, content)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,4 +46,4 @@ expect fun DefaultDivider()
|
|||||||
expect fun DefaultSmallVerticalMargin()
|
expect fun DefaultSmallVerticalMargin()
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
expect fun DefaultBox(block: @Composable () -> Unit)
|
expect fun DefaultContentColumn(block: @Composable () -> Unit)
|
||||||
|
|||||||
@@ -5,17 +5,15 @@ import dev.inmo.jsuikit.elements.DefaultButton
|
|||||||
import dev.inmo.jsuikit.modifiers.UIKitButton
|
import dev.inmo.jsuikit.modifiers.UIKitButton
|
||||||
import dev.inmo.jsuikit.modifiers.UIKitMargin
|
import dev.inmo.jsuikit.modifiers.UIKitMargin
|
||||||
import dev.inmo.jsuikit.modifiers.UIKitUtility
|
import dev.inmo.jsuikit.modifiers.UIKitUtility
|
||||||
import dev.inmo.jsuikit.modifiers.builder
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.DefaultContentColumn
|
||||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.DefaultBox
|
|
||||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer
|
||||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.NoTransform
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.NoTransform
|
||||||
import org.jetbrains.compose.web.dom.Div
|
|
||||||
|
|
||||||
actual class ListViewDrawer<T> : Drawer<ListView<T>> {
|
actual class ListViewDrawer<T> : Drawer<ListView<T>> {
|
||||||
@Composable
|
@Composable
|
||||||
override fun ListView<T>.draw() {
|
override fun ListView<T>.draw() {
|
||||||
itemsList.forEach { item ->
|
itemsList.forEach { item ->
|
||||||
DefaultBox {
|
DefaultContentColumn {
|
||||||
buildView(item)
|
buildView(item)
|
||||||
DefaultButton(removeItemText, UIKitButton.Type.Default, UIKitMargin.Small, UIKitUtility.NoTransform, UIKitUtility.Border.Rounded) {
|
DefaultButton(removeItemText, UIKitButton.Type.Default, UIKitMargin.Small, UIKitUtility.NoTransform, UIKitUtility.Border.Rounded) {
|
||||||
itemsList.remove(item)
|
itemsList.remove(item)
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package dev.inmo.kmppscriptbuilder.core.ui
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import dev.inmo.jsuikit.elements.DefaultButton
|
||||||
|
import dev.inmo.jsuikit.modifiers.UIKitButton
|
||||||
|
import dev.inmo.jsuikit.modifiers.UIKitMargin
|
||||||
|
import dev.inmo.jsuikit.modifiers.UIKitUtility
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.models.MavenPublishingRepository
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.NoTransform
|
||||||
|
|
||||||
|
actual class RepositoryCredentialTypeDrawer(
|
||||||
|
private val state: RepositoryState
|
||||||
|
) : Drawer<MavenPublishingRepository.CredentialsType> {
|
||||||
|
@Composable
|
||||||
|
override fun MavenPublishingRepository.CredentialsType.draw() {
|
||||||
|
val name = when (this@draw) {
|
||||||
|
is MavenPublishingRepository.CredentialsType.HttpHeaderCredentials -> "Headers"
|
||||||
|
MavenPublishingRepository.CredentialsType.Nothing -> "No"
|
||||||
|
is MavenPublishingRepository.CredentialsType.UsernameAndPassword -> "Username and password"
|
||||||
|
}
|
||||||
|
if (state.credsType == this) {
|
||||||
|
DefaultButton(name, UIKitButton.Type.Primary, UIKitButton.Size.Small, UIKitMargin.Small.Horizontal, UIKitUtility.NoTransform, UIKitUtility.Border.Rounded)
|
||||||
|
} else {
|
||||||
|
DefaultButton(name, UIKitButton.Type.Default, UIKitButton.Size.Small, UIKitMargin.Small.Horizontal, UIKitUtility.NoTransform, UIKitUtility.Border.Rounded) {
|
||||||
|
state.credsType = this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
actual fun RepositoryCredentialTypeDrawerWithState(repositoryState: RepositoryState): RepositoryCredentialTypeDrawer = RepositoryCredentialTypeDrawer(repositoryState)
|
||||||
@@ -121,7 +121,7 @@ actual fun DefaultSmallVerticalMargin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
actual fun DefaultBox(block: @Composable () -> Unit) {
|
actual fun DefaultContentColumn(block: @Composable () -> Unit) {
|
||||||
Div(attrsBuilder(UIKitMargin.Small.Horizontal, UIKitMargin.Small.Vertical)) {
|
Div(attrsBuilder(UIKitMargin.Small.Horizontal, UIKitMargin.Small.Vertical)) {
|
||||||
block()
|
block()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package dev.inmo.kmppscriptbuilder.core.ui
|
package dev.inmo.kmppscriptbuilder.core.ui
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Column
|
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material.Button
|
import androidx.compose.material.Button
|
||||||
import androidx.compose.material.OutlinedButton
|
import androidx.compose.material.OutlinedButton
|
||||||
@@ -8,14 +7,14 @@ import androidx.compose.runtime.Composable
|
|||||||
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.ui.utils.CommonText
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.CommonText
|
||||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.DefaultBox
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.DefaultContentColumn
|
||||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer
|
||||||
|
|
||||||
actual class ListViewDrawer<T> : Drawer<ListView<T>> {
|
actual class ListViewDrawer<T> : Drawer<ListView<T>> {
|
||||||
@Composable
|
@Composable
|
||||||
override fun ListView<T>.draw() {
|
override fun ListView<T>.draw() {
|
||||||
itemsList.forEach { item ->
|
itemsList.forEach { item ->
|
||||||
DefaultBox {
|
DefaultContentColumn {
|
||||||
buildView(item)
|
buildView(item)
|
||||||
OutlinedButton({ itemsList.remove(item) }, Modifier.padding(8.dp)) {
|
OutlinedButton({ itemsList.remove(item) }, Modifier.padding(8.dp)) {
|
||||||
CommonText(removeItemText,)
|
CommonText(removeItemText,)
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package dev.inmo.kmppscriptbuilder.core.ui
|
||||||
|
|
||||||
|
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.Modifier
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.models.MavenPublishingRepository
|
||||||
|
import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer
|
||||||
|
|
||||||
|
actual class RepositoryCredentialTypeDrawer(
|
||||||
|
private val state: RepositoryState
|
||||||
|
) : Drawer<MavenPublishingRepository.CredentialsType> {
|
||||||
|
@Composable
|
||||||
|
override fun MavenPublishingRepository.CredentialsType.draw() {
|
||||||
|
val name = when (this@draw) {
|
||||||
|
is MavenPublishingRepository.CredentialsType.HttpHeaderCredentials -> "Headers"
|
||||||
|
MavenPublishingRepository.CredentialsType.Nothing -> "No"
|
||||||
|
is MavenPublishingRepository.CredentialsType.UsernameAndPassword -> "Username and password"
|
||||||
|
}
|
||||||
|
if (state.credsType == this) {
|
||||||
|
Button({}, Modifier.padding(8.dp, 0.dp)) {
|
||||||
|
Text(name)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
OutlinedButton(
|
||||||
|
{
|
||||||
|
state.credsType = this
|
||||||
|
},
|
||||||
|
Modifier.padding(8.dp, 0.dp)
|
||||||
|
) {
|
||||||
|
Text(name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
actual fun RepositoryCredentialTypeDrawerWithState(repositoryState: RepositoryState): RepositoryCredentialTypeDrawer = RepositoryCredentialTypeDrawer(repositoryState)
|
||||||
@@ -87,7 +87,8 @@ actual fun TitleText(text: String) {
|
|||||||
actual fun <T> ButtonsPanel(
|
actual fun <T> ButtonsPanel(
|
||||||
title: String,
|
title: String,
|
||||||
data: Iterable<T>,
|
data: Iterable<T>,
|
||||||
itemDrawer: @Composable (T) -> Unit) {
|
itemDrawer: @Composable (T) -> Unit
|
||||||
|
) {
|
||||||
Row {
|
Row {
|
||||||
Text(title, Modifier.padding(8.dp))
|
Text(title, Modifier.padding(8.dp))
|
||||||
data.forEach { itemDrawer(it) }
|
data.forEach { itemDrawer(it) }
|
||||||
@@ -105,7 +106,7 @@ actual fun DefaultSmallVerticalMargin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
actual fun DefaultBox(block: @Composable () -> Unit) {
|
actual fun DefaultContentColumn(block: @Composable () -> Unit) {
|
||||||
Column(Modifier.padding(8.dp)) {
|
Column(Modifier.padding(8.dp)) {
|
||||||
block()
|
block()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user