diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 3c3a2e2ba..599b675c4 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -2,8 +2,11 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat plugins{ id("java") - kotlin("jvm") version "1.9.23" - id("org.jetbrains.compose") version "1.7.1" + + kotlin("jvm") version libs.versions.kotlin + alias(libs.plugins.compose.compiler) + alias(libs.plugins.jetbrainsCompose) + alias(libs.plugins.serialization) } group = rootProject.group @@ -28,7 +31,6 @@ sourceSets{ } } - compose.desktop { application { mainClass = "processing.app.ui.Splash" @@ -79,6 +81,8 @@ dependencies { implementation(compose.desktop.currentOs) implementation("io.github.alexzhirkevich:compottie:${compottieVersion}") + + implementation("com.charleskorn.kaml:kaml:0.65.0") } tasks.register("addCore"){ diff --git a/app/src/processing/app/contrib/ui/ContributionManager.kt b/app/src/processing/app/contrib/ui/ContributionManager.kt new file mode 100644 index 000000000..8f91401ee --- /dev/null +++ b/app/src/processing/app/contrib/ui/ContributionManager.kt @@ -0,0 +1,188 @@ +package processing.app.contrib.ui + +import androidx.compose.foundation.* +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.items +import androidx.compose.foundation.lazy.rememberLazyListState +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.input.pointer.PointerIcon +import androidx.compose.ui.input.pointer.pointerHoverIcon +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.LineHeightStyle +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import androidx.compose.ui.window.Window +import androidx.compose.ui.window.application +import com.charleskorn.kaml.Yaml +import com.charleskorn.kaml.YamlConfiguration +import kotlinx.serialization.Serializable +import java.net.URL + + +fun main() = application { + Window(onCloseRequest = ::exitApplication) { + ContributionsManager() + } +} + +enum class Status { + VALID, + BROKEN, + DEPRECATED +} +enum class Type { + library, + mode, + tool, + examples, +} + +@Serializable +data class Author( + val name: String, + val url: String? = null, +) + +@Serializable +data class Contribution( + val id: Int, + val status: Status, + val source: String, + val type: Type, + val name: String? = null, + val categories: List? = emptyList(), + val authors: String? = null, + val authorList: List? = emptyList(), + val url: String? = null, + val sentence: String? = null, + val paragraph: String? = null, + val version: String? = null, + val prettyVersion: String? = null, + val minRevision: Int? = null, + val maxRevision: Int? = null, + val download: String? = null, +) + +@Serializable +data class Contributions( + val contributions: List +) + +@Composable +fun ContributionsManager(){ + val contributions = remember { mutableStateOf(arrayOf()) } + val error = remember { mutableStateOf(null) } + + LaunchedEffect(Unit){ + try { + val url = URL("https://github.com/mingness/processing-contributions-new/raw/refs/heads/main/contributions.yaml") + val connection = url.openConnection() + val inputStream = connection.getInputStream() + val yaml = inputStream.readAllBytes().decodeToString() + // TODO cache in processing folder + + val parser = Yaml( + configuration = YamlConfiguration( + strictMode = false + ) + ) + val result = parser.decodeFromString(Contributions.serializer(), yaml) + + contributions.value = result.contributions + .filter { it.status == Status.VALID } + .map { + // TODO Parse better + val authorList = it.authors?.split(",")?.map { author -> + val parts = author.split("](") + val name = parts[0].removePrefix("[") + val url = parts.getOrNull(1)?.removeSuffix(")") + Author(name, url) + } ?: emptyList() + it.copy(authorList = authorList) + } + .toTypedArray() + } catch (e: Exception){ + error.value = e + } + } + if(error.value != null){ + Text("Error loading contributions: ${error.value}") + return + } + if(contributions.value.isEmpty()){ + Text("Loading contributions...") + return + } + + val contributionsByType = contributions.value.groupBy { it.type } + val types = Type.entries + val selectedType = remember { mutableStateOf(types.first()) } + val contributionsForType = (contributionsByType[selectedType.value] ?: emptyList()) + .sortedBy { it.name } + + val selectedContribution = remember { mutableStateOf(null) } + + Box{ + Column { + Row{ + for(type in types){ + Text(type.name, modifier = Modifier + .background(if(selectedType.value == type) Color.Gray else Color.Transparent) + .clickable { + selectedType.value = type + selectedContribution.value = null + } + .padding(8.dp) + ) + } + Spacer(modifier = Modifier.weight(1f)) + Text("Updates") + } + Box{ + val state = rememberLazyListState() + LazyColumn(state = state) { + item{ + // Table Header + } + items(contributionsForType){ contribution -> + Row(modifier = Modifier + .pointerHoverIcon(PointerIcon.Hand) + .clickable { selectedContribution.value = contribution } + .padding(8.dp) + ) { + Row(modifier = Modifier.weight(1f)){ + Text("status") + } + Row(horizontalArrangement = Arrangement.spacedBy(4.dp), modifier = Modifier.weight(8f)){ + Text(contribution.name ?: "Unnamed", fontWeight = FontWeight.Bold) + Text(contribution.sentence ?: "No description", maxLines = 1, overflow = TextOverflow.Ellipsis) + } + Row(modifier = Modifier.weight(4f)){ + Text(contribution.authorList?.joinToString { it.name } ?: "Unknown") + } + } + } + } + VerticalScrollbar( + modifier = Modifier + .align(Alignment.CenterEnd) + .background(Color.LightGray) + .fillMaxHeight(), + adapter = rememberScrollbarAdapter( + scrollState = state + ) + ) + } + } + + } + +} \ No newline at end of file diff --git a/app/src/processing/app/ui/JVMManager.kt b/app/src/processing/app/ui/JVMManager.kt index 103de7492..eda5b3e5e 100644 --- a/app/src/processing/app/ui/JVMManager.kt +++ b/app/src/processing/app/ui/JVMManager.kt @@ -64,11 +64,11 @@ fun main() = application { fun JDKManager(){ val home = Platform.getJavaHome() val valid = File(home, "bin/java").exists() -// if(valid) return + if(valid) return val color = Theme.getColor("status.notice.bgcolor") val colorText = Theme.getColor("status.notice.fgcolor") - val buttonColor = Theme.getColor("toolbar.button.enabled.field") + val buttonColor = Theme.getColor("toolbar.button.enabled.field") val buttonTextColor = Theme.getColor("toolbar.button.enabled.glyph") val fontFamily = FontFamily( diff --git a/build.gradle.kts b/build.gradle.kts index 97b5ab214..ec5bc3f2f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,2 +1,11 @@ group = "org.processing" -version = "4.4.0" \ No newline at end of file +version = "4.4.0" + +plugins { + kotlin("jvm") version libs.versions.kotlin apply false + alias(libs.plugins.kotlinMultiplatform) apply false + + alias(libs.plugins.compose.compiler) apply false + alias(libs.plugins.jetbrainsCompose) apply false + +} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 000000000..9b6e36d78 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,11 @@ +[versions] +kotlin = "2.0.20" +compose-plugin = "1.7.1" + +[libraries] + +[plugins] +jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" } +kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } +compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } +serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index e5ab17852..31f11a68b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -6,12 +6,6 @@ include( "java" ) -pluginManagement { - plugins { - kotlin("jvm") version "1.9.23" - } -} - buildscript { repositories { mavenCentral()