diff --git a/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/BuilderView.kt b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/BuilderView.kt index 5c1259f..e12e309 100644 --- a/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/BuilderView.kt +++ b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/BuilderView.kt @@ -1,6 +1,9 @@ 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.ui.utils.Drawer diff --git a/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/DevelopersView.kt b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/DevelopersView.kt index b22b7a3..924eb1e 100644 --- a/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/DevelopersView.kt +++ b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/DevelopersView.kt @@ -1,8 +1,10 @@ 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.desktop.utils.CommonTextField class DeveloperState( id: String = "", diff --git a/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/LicensesView.kt b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/LicensesView.kt index 72677f4..4322ab1 100644 --- a/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/LicensesView.kt +++ b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/LicensesView.kt @@ -1,12 +1,19 @@ 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.getLicenses +import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer 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 = "", title: String = "", url: String? = null @@ -18,19 +25,21 @@ private class LicenseState( 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 class LicensesView: VerticalView("Licenses") { - private var licensesListState = mutableStateListOf() + internal var licensesListState = mutableStateListOf() var licenses: List get() = licensesListState.map { it.toLicense() } set(value) { licensesListState.clear() licensesListState.addAll(value.map { it.toLicenseState() }) } - private val availableLicensesState = mutableStateListOf() - private val licensesOffersToShow = mutableStateListOf() - private var licenseSearchFilter by mutableStateOf("") + internal val availableLicensesState = mutableStateListOf() + internal val licensesOffersToShow = mutableStateListOf() + internal var licenseSearchFilter by mutableStateOf("") init { CoroutineScope(Dispatchers.Default).launch { @@ -40,49 +49,7 @@ class LicensesView: VerticalView("Licenses") { } } - override val content: @Composable ColumnScope.() -> Unit = { - 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, 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") - } - } - } + override val content: @Composable () -> Unit = { + with(LicensesDrawer) { draw() } } } diff --git a/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ListView.kt b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ListView.kt index f1aa590..467fe5c 100644 --- a/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ListView.kt +++ b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ListView.kt @@ -6,7 +6,7 @@ import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer expect class ListViewDrawer() : Drawer> -abstract class ListView(protected val title: String) : View() { +abstract class ListView(title: String) : VerticalView(title) { internal val itemsList = mutableStateListOf() internal open val addItemText: String = "Add" @@ -18,9 +18,9 @@ abstract class ListView(protected val title: String) : View() { protected val drawer = ListViewDrawer() - override fun build() { - DrawVertically(title) { - with(drawer) { draw() } + override val content: () -> Unit = { + with(drawer) { + draw() } } } diff --git a/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/MavenInfoView.kt b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/MavenInfoView.kt index d1626d8..7fc7d8b 100644 --- a/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/MavenInfoView.kt +++ b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/MavenInfoView.kt @@ -1,24 +1,20 @@ package dev.inmo.kmppscriptbuilder.core.ui -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.* +import dev.inmo.kmppscriptbuilder.core.models.GpgSigning +import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer + +expect object MavenInfoDrawer : Drawer class MavenInfoView : VerticalView("Project information") { - private var projectNameProperty by mutableStateOf("") - private var projectDescriptionProperty by mutableStateOf("") - private var projectUrlProperty by mutableStateOf("") - private var projectVcsUrlProperty by mutableStateOf("") - private var gpgSignProperty by mutableStateOf(GpgSigning.Disabled) - private var publishToMavenCentralProperty by mutableStateOf(false) - private val developersView = DevelopersView() - private val repositoriesView = RepositoriesView() + internal var projectNameProperty by mutableStateOf("") + internal var projectDescriptionProperty by mutableStateOf("") + internal var projectUrlProperty by mutableStateOf("") + internal var projectVcsUrlProperty by mutableStateOf("") + internal var gpgSignProperty by mutableStateOf(GpgSigning.Disabled) + internal var publishToMavenCentralProperty by mutableStateOf(false) + internal val developersView = DevelopersView() + internal val repositoriesView = RepositoriesView() var mavenConfig: MavenConfig get() = MavenConfig( @@ -50,55 +46,7 @@ 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, - "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() + override val content: @Composable () -> Unit = { + with (MavenInfoDrawer) { draw() } } } diff --git a/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ProjectTypeView.kt b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ProjectTypeView.kt index a35c2e9..06db987 100644 --- a/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ProjectTypeView.kt +++ b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ProjectTypeView.kt @@ -1,40 +1,19 @@ package dev.inmo.kmppscriptbuilder.core.ui -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.unit.dp -import dev.inmo.kmppscriptbuilder.core.models.* -import dev.inmo.kmppscriptbuilder.desktop.utils.VerticalView +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.MultiplatformProjectType +import dev.inmo.kmppscriptbuilder.core.models.ProjectType +import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer + +expect object ProjectTypeDrawer : Drawer class ProjectTypeView : VerticalView("Project type") { var projectType by mutableStateOf(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(verticalAlignment = Alignment.CenterVertically) { - addProjectTypeButton(MultiplatformProjectType) - addProjectTypeButton(JVMProjectType) - addProjectTypeButton(JSProjectType) - } + override val content: @Composable () -> Unit = { + with(ProjectTypeDrawer) { draw() } } } diff --git a/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/RepositoriesView.kt b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/RepositoriesView.kt index e022ee7..15c8b8f 100644 --- a/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/RepositoriesView.kt +++ b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/RepositoriesView.kt @@ -1,8 +1,11 @@ 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.desktop.utils.CommonTextField +import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer class RepositoryState( name: String = "", @@ -16,6 +19,8 @@ class RepositoryState( private fun MavenPublishingRepository.toRepositoryState() = RepositoryState(name, url) +expect object RepositoryStateDrawer : Drawer + class RepositoriesView : ListView("Repositories info") { var repositories: List get() = itemsList.map { it.toRepository() } @@ -30,16 +35,10 @@ class RepositoriesView : ListView("Repositories info") { override val removeItemText: String = "Remove repository" override fun createItem(): RepositoryState = RepositoryState() + @Composable override fun buildView(item: RepositoryState) { - CommonTextField( - item.name, - "Repository name" - ) { item.name = it } - CommonTextField( - item.url, - "Repository url" - ) { item.url = it } + with(RepositoryStateDrawer) { with(item) { draw() } } } } diff --git a/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/VerticalView.kt b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/VerticalView.kt new file mode 100644 index 0000000..bf380ce --- /dev/null +++ b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/VerticalView.kt @@ -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) + } +} diff --git a/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/utils/UIElements.kt b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/utils/UIElements.kt index ff0fc83..51d8032 100644 --- a/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/utils/UIElements.kt +++ b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/utils/UIElements.kt @@ -6,7 +6,7 @@ import androidx.compose.runtime.Composable expect fun TitleText(text: String) @Composable -expect fun CommonText(text: String) +expect fun CommonText(text: String, onClick: (() -> Unit)? = null) @Composable expect fun CommonTextField(presetText: String, hint: String, onChange: (String) -> Unit) diff --git a/core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/LicensesDrawer.kt b/core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/LicensesDrawer.kt new file mode 100644 index 0000000..30a7226 --- /dev/null +++ b/core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/LicensesDrawer.kt @@ -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 { + 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",) + } + } + } + } +} diff --git a/core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ListViewDrawer.kt b/core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ListViewDrawer.kt index c62f426..e827984 100644 --- a/core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ListViewDrawer.kt +++ b/core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ListViewDrawer.kt @@ -11,13 +11,13 @@ import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer actual class ListViewDrawer : Drawer> { override fun ListView.draw() { Button({ itemsList.add(createItem()) }) { - CommonText(addItemText) + CommonText(addItemText,) } itemsList.forEach { item -> Column(Modifier.padding(8.dp)) { buildView(item) Button({ itemsList.remove(item) }, Modifier.padding(8.dp)) { - CommonText(removeItemText) + CommonText(removeItemText,) } } } diff --git a/core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/MavenInfoDrawer.kt b/core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/MavenInfoDrawer.kt new file mode 100644 index 0000000..c7c0474 --- /dev/null +++ b/core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/MavenInfoDrawer.kt @@ -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 { + @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() + } +} diff --git a/core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ProjectTypeDrawer.kt b/core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ProjectTypeDrawer.kt new file mode 100644 index 0000000..553ca17 --- /dev/null +++ b/core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/ProjectTypeDrawer.kt @@ -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 { + @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) + } + } +} diff --git a/core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/RepositoryStateDrawer.kt b/core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/RepositoryStateDrawer.kt new file mode 100644 index 0000000..9db1901 --- /dev/null +++ b/core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/RepositoryStateDrawer.kt @@ -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 { + override fun RepositoriesView.draw() { + CommonTextField( + item.name, + "Repository name" + ) { item.name = it } + CommonTextField( + item.url, + "Repository url" + ) { item.url = it } + } + +} diff --git a/core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/utils/ActualUIElements.kt b/core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/utils/ActualUIElements.kt index e9bc427..0f98bc2 100644 --- a/core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/utils/ActualUIElements.kt +++ b/core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/ui/utils/ActualUIElements.kt @@ -37,7 +37,7 @@ actual fun SwitchWithLabel( switchCreator() } Box(Modifier.fillMaxWidth().align(Alignment.CenterVertically).clickable { }) { - CommonText(label) + CommonText(label,) } if (!placeSwitchAtTheStart) { switchCreator() @@ -53,14 +53,14 @@ actual fun CommonTextField(presetText: String, hint: String, onChange: (String) Modifier.fillMaxWidth(), singleLine = true, label = { - CommonText(hint) + CommonText(hint,) } ) } @Composable -actual fun CommonText(text: String) { - Text(text) +actual fun CommonText(text: String, onClick: (() -> Unit)?) { + Text(text, modifier = Modifier.run { onClick ?.let { clickable(onClick = it) } ?: this }) } @Composable