mirror of
https://github.com/InsanusMokrassar/KotlinPublicationScriptsBuilder.git
synced 2026-04-03 23:02:21 +00:00
complete restyling
This commit is contained in:
@@ -5,6 +5,7 @@ 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.DefaultBox
|
||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.DefaultDivider
|
||||
|
||||
@Composable
|
||||
@@ -44,10 +45,12 @@ class BuilderView : View() {
|
||||
config = it
|
||||
}
|
||||
|
||||
projectTypeView.build()
|
||||
DefaultDivider()
|
||||
licensesView.build()
|
||||
DefaultDivider()
|
||||
mavenInfoView.build()
|
||||
DefaultBox {
|
||||
projectTypeView.build()
|
||||
DefaultDivider()
|
||||
licensesView.build()
|
||||
DefaultDivider()
|
||||
mavenInfoView.build()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@ package dev.inmo.kmppscriptbuilder.core.ui
|
||||
|
||||
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.Developer
|
||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.CommonText
|
||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.CommonTextField
|
||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.DefaultBox
|
||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.DefaultSmallVerticalMargin
|
||||
|
||||
class DeveloperState(
|
||||
id: String = "",
|
||||
@@ -38,17 +40,19 @@ class DevelopersView : ListView<DeveloperState>("Developers info") {
|
||||
override fun createItem(): DeveloperState = DeveloperState()
|
||||
@Composable
|
||||
override fun buildView(item: DeveloperState) {
|
||||
CommonText("Developer username")
|
||||
CommonTextField(
|
||||
item.id,
|
||||
"Developer username",
|
||||
) { item.id = it }
|
||||
DefaultSmallVerticalMargin()
|
||||
CommonText("Developer name")
|
||||
CommonTextField(
|
||||
item.name,
|
||||
"Developer name",
|
||||
) { item.name = it }
|
||||
DefaultSmallVerticalMargin()
|
||||
CommonText("Developer E-Mail")
|
||||
CommonTextField(
|
||||
item.eMail,
|
||||
"Developer E-Mail",
|
||||
) { item.eMail = it }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,18 +5,19 @@ import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateListOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
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.CommonText
|
||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.CommonTextField
|
||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.DefaultSmallVerticalMargin
|
||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer
|
||||
import io.ktor.client.HttpClient
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
internal class LicenseState(
|
||||
class LicenseState(
|
||||
id: String = "",
|
||||
title: String = "",
|
||||
url: String? = null
|
||||
@@ -32,13 +33,12 @@ internal fun License.toLicenseState() = LicenseState(id, title, url)
|
||||
|
||||
expect object LicensesDrawer : Drawer<LicensesView>
|
||||
|
||||
class LicensesView: VerticalView("Licenses") {
|
||||
internal var licensesListState = mutableStateListOf<LicenseState>()
|
||||
class LicensesView : ListView<LicenseState>("Licenses") {
|
||||
var licenses: List<License>
|
||||
get() = licensesListState.map { it.toLicense() }
|
||||
get() = itemsList.map { it.toLicense() }
|
||||
set(value) {
|
||||
licensesListState.clear()
|
||||
licensesListState.addAll(value.map { it.toLicenseState() })
|
||||
itemsList.clear()
|
||||
itemsList.addAll(value.map { it.toLicenseState() })
|
||||
}
|
||||
internal val availableLicensesState = mutableStateListOf<License>()
|
||||
internal var licenseSearchFilter by mutableStateOf("")
|
||||
@@ -50,6 +50,9 @@ class LicensesView: VerticalView("Licenses") {
|
||||
}
|
||||
}
|
||||
|
||||
override val addItemText: String
|
||||
get() = "Add empty license"
|
||||
|
||||
init {
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
val client = HttpClient()
|
||||
@@ -58,6 +61,27 @@ class LicensesView: VerticalView("Licenses") {
|
||||
}
|
||||
}
|
||||
|
||||
override fun createItem(): LicenseState = LicenseState()
|
||||
|
||||
@Composable
|
||||
override fun buildView(item: LicenseState) {
|
||||
CommonText("License ID")
|
||||
CommonTextField(
|
||||
item.id,
|
||||
"Short name like \"Apache-2.0\"",
|
||||
) { item.id = it }
|
||||
CommonText("License title")
|
||||
CommonTextField(
|
||||
item.title,
|
||||
"Official title of license (like \"Apache Software License 2.0\")",
|
||||
) { item.title = it }
|
||||
CommonText("License URL")
|
||||
CommonTextField(
|
||||
item.url ?: "",
|
||||
"Link to your LICENSE file OR official license file (like \"https://opensource.org/licenses/Apache-2.0\")",
|
||||
) { item.url = it }
|
||||
}
|
||||
|
||||
override val content: @Composable () -> Unit = {
|
||||
CommonTextField(
|
||||
licenseSearchFilter,
|
||||
@@ -68,7 +92,12 @@ class LicensesView: VerticalView("Licenses") {
|
||||
) { filterText ->
|
||||
licenseSearchFilter = filterText
|
||||
}
|
||||
DefaultSmallVerticalMargin()
|
||||
|
||||
with(LicensesDrawer) { draw() }
|
||||
|
||||
DefaultSmallVerticalMargin()
|
||||
|
||||
super.content()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@ import dev.inmo.kmppscriptbuilder.core.models.SonatypeRepository
|
||||
import dev.inmo.kmppscriptbuilder.core.models.defaultProjectDescription
|
||||
import dev.inmo.kmppscriptbuilder.core.models.defaultProjectName
|
||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.ButtonsPanel
|
||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.CommonText
|
||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.CommonTextField
|
||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.DefaultSmallVerticalMargin
|
||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer
|
||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.SwitchWithLabel
|
||||
|
||||
@@ -56,21 +58,28 @@ class MavenInfoView : VerticalView("Project information") {
|
||||
private val gpgSigningDrawer = GpgSigningOptionDrawerWithView(this)
|
||||
|
||||
override val content: @Composable () -> Unit = {
|
||||
CommonText("Public project name")
|
||||
CommonTextField(
|
||||
projectNameProperty,
|
||||
"Public project name",
|
||||
"\${project.name}",
|
||||
) { projectNameProperty = it }
|
||||
DefaultSmallVerticalMargin()
|
||||
CommonText("Public project description")
|
||||
CommonTextField(
|
||||
projectDescriptionProperty,
|
||||
"Public project description",
|
||||
"\${project.name}",
|
||||
) { projectDescriptionProperty = it }
|
||||
DefaultSmallVerticalMargin()
|
||||
CommonText("Public project URL")
|
||||
CommonTextField(
|
||||
projectUrlProperty,
|
||||
"Public project URL",
|
||||
"Type url to github or other source with readme",
|
||||
) { projectUrlProperty = it }
|
||||
DefaultSmallVerticalMargin()
|
||||
CommonText("Public project VCS URL (with .git)")
|
||||
CommonTextField(
|
||||
projectVcsUrlProperty,
|
||||
"Public project VCS URL (with .git)",
|
||||
"Type url to github .git file"
|
||||
) { projectVcsUrlProperty = it }
|
||||
|
||||
ButtonsPanel(
|
||||
|
||||
@@ -9,6 +9,7 @@ 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.ButtonsPanel
|
||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.DefaultSmallVerticalMargin
|
||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer
|
||||
|
||||
expect class ProjectTypeDrawer : Drawer<ProjectType>
|
||||
|
||||
@@ -2,12 +2,12 @@ package dev.inmo.kmppscriptbuilder.core.ui
|
||||
|
||||
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.MavenPublishingRepository
|
||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.CommonText
|
||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.CommonTextField
|
||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.Drawer
|
||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.DefaultSmallVerticalMargin
|
||||
|
||||
class RepositoryState(
|
||||
name: String = "",
|
||||
@@ -38,13 +38,16 @@ class RepositoriesView : ListView<RepositoryState>("Repositories info") {
|
||||
|
||||
@Composable
|
||||
override fun buildView(item: RepositoryState) {
|
||||
CommonText("Repository name")
|
||||
CommonTextField(
|
||||
item.name,
|
||||
"Repository name",
|
||||
"This name will be used to identify repository in gradle"
|
||||
) { item.name = it }
|
||||
DefaultSmallVerticalMargin()
|
||||
CommonText("Repository url")
|
||||
CommonTextField(
|
||||
item.url,
|
||||
"Repository url",
|
||||
"For example: https://repo.maven.apache.org/maven2/"
|
||||
) { item.url = it }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package dev.inmo.kmppscriptbuilder.core.ui
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import dev.inmo.kmppscriptbuilder.core.ui.utils.DefaultBox
|
||||
|
||||
abstract class VerticalView(protected val title: String) : View() {
|
||||
abstract val content: @Composable () -> Unit
|
||||
@Composable
|
||||
override fun build() {
|
||||
DrawVertically(title, content)
|
||||
DefaultBox {
|
||||
DrawVertically(title, content)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ expect fun CommonText(text: String, onClick: (() -> Unit)? = null)
|
||||
@Composable
|
||||
expect fun CommonTextField(
|
||||
presetText: String,
|
||||
hint: String,
|
||||
hint: String? = null,
|
||||
onFocusChanged: (Boolean) -> Unit = {},
|
||||
onChange: (String) -> Unit
|
||||
)
|
||||
@@ -41,3 +41,9 @@ fun <T> ButtonsPanel(
|
||||
|
||||
@Composable
|
||||
expect fun DefaultDivider()
|
||||
|
||||
@Composable
|
||||
expect fun DefaultSmallVerticalMargin()
|
||||
|
||||
@Composable
|
||||
expect fun DefaultBox(block: @Composable () -> Unit)
|
||||
|
||||
Reference in New Issue
Block a user