Skip to content

Commit

Permalink
deps: update dependency org.jetbrains.compose to v1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sschuberth committed Nov 7, 2024
1 parent 371960a commit b98e907
Show file tree
Hide file tree
Showing 58 changed files with 168 additions and 162 deletions.
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ repositories {
}

dependencies {
implementation(compose.components.resources)
implementation(compose.desktop.currentOs)
implementation(compose.materialIconsExtended)
implementation(libs.bundles.ort)
implementation(libs.bundles.richtext)
implementation(libs.dataTableMaterial)
Expand Down
7 changes: 7 additions & 0 deletions detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ formatting:
active: false
MaximumLineLength:
active: false
NoWildcardImports:
active: false

naming:
FunctionNaming:
Expand All @@ -42,6 +44,11 @@ style:
UnusedPrivateMember:
active: true
ignoreAnnotated: ['Preview']
WildcardImport:
excludeImports:
- 'androidx.compose.material.icons.automirrored.filled.*'
- 'androidx.compose.material.icons.filled.*'
- 'org.ossreviewtoolkit.workbench.ort_workbench.generated.resources.*'

ORT:
OrtImportOrder:
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
detektPlugin = "1.23.7"
composePlugin = "1.6.11"
composePlugin = "1.7.0"
kotlinPlugin = "2.0.21"
versionsPlugin = "0.51.0"

Expand Down
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
15 changes: 12 additions & 3 deletions src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
package org.ossreviewtoolkit.workbench

import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.res.loadImageBitmap
import androidx.compose.ui.res.useResource
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.WindowState
import androidx.compose.ui.window.singleWindowApplication

import java.net.URI

import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.decodeToImageBitmap

import org.ossreviewtoolkit.workbench.ort_workbench.generated.resources.Res
import org.ossreviewtoolkit.workbench.ui.App
import org.ossreviewtoolkit.workbench.ui.WorkbenchController

@OptIn(ExperimentalResourceApi::class)
fun main() {
val workbenchController = WorkbenchController()

// See https://github.com/JetBrains/compose-multiplatform/issues/2369.
val iconBytes = URI.create(Res.getUri("drawable/app-icon/icon.png")).toURL().readBytes()
val icon = BitmapPainter(iconBytes.decodeToImageBitmap())

singleWindowApplication(
title = "ORT Workbench",
state = WindowState(
size = DpSize(1440.dp, 810.dp)
),
icon = BitmapPainter(useResource("app-icon/icon.png", ::loadImageBitmap))
icon = icon
) {
App(workbenchController)
}
Expand Down
9 changes: 4 additions & 5 deletions src/main/kotlin/composables/Expandable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource

import org.ossreviewtoolkit.workbench.utils.MaterialIcon

@Composable
fun Expandable(
Expand All @@ -35,8 +34,8 @@ fun Expandable(
onClick = { expanded.targetState = !expanded.currentState },
modifier = Modifier.align(Alignment.Top)
) {
val resource = (if (expanded.currentState) MaterialIcon.EXPAND_LESS else MaterialIcon.EXPAND_MORE).resource
Icon(painterResource(resource), "expand")
val image = if (expanded.currentState) Icons.Default.ExpandLess else Icons.Default.ExpandMore
Icon(image, "expand")
}
}

Expand Down
13 changes: 6 additions & 7 deletions src/main/kotlin/composables/ExpandableText.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,21 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.material.Icon
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

import com.halilibo.richtext.markdown.Markdown
import com.halilibo.richtext.ui.material.RichText

import org.ossreviewtoolkit.workbench.utils.MaterialIcon

@Composable
fun ExpandableText(text: String, unexpandedHeight: Dp = 20.dp, fontFamily: FontFamily? = null) {
var expanded by rememberSaveable { mutableStateOf(false) }
Expand All @@ -31,8 +30,8 @@ fun ExpandableText(text: String, unexpandedHeight: Dp = 20.dp, fontFamily: FontF
Row(modifier = modifier.animateContentSize()) {
Text(text, modifier = Modifier.weight(1f), fontFamily = fontFamily)

val resource = (if (expanded) MaterialIcon.EXPAND_LESS else MaterialIcon.EXPAND_MORE).resource
Icon(painterResource(resource), "expand", modifier = Modifier.clickable { expanded = !expanded })
val image = if (expanded) Icons.Default.ExpandLess else Icons.Default.ExpandMore
Icon(image, "expand", modifier = Modifier.clickable { expanded = !expanded })
}
}

Expand All @@ -46,7 +45,7 @@ fun ExpandableMarkdown(text: String, unexpandedHeight: Dp = 20.dp) {
Markdown(text)
}

val resource = (if (expanded) MaterialIcon.EXPAND_LESS else MaterialIcon.EXPAND_MORE).resource
Icon(painterResource(resource), "expand", modifier = Modifier.clickable { expanded = !expanded })
val image = if (expanded) Icons.Default.ExpandLess else Icons.Default.ExpandMore
Icon(image, "expand", modifier = Modifier.clickable { expanded = !expanded })
}
}
11 changes: 5 additions & 6 deletions src/main/kotlin/composables/FilterTextField.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,26 @@ import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.TextField
import androidx.compose.material.TextFieldDefaults
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.dp

import org.ossreviewtoolkit.workbench.utils.MaterialIcon

@Composable
fun FilterTextField(
filterText: String,
label: String = "Filter",
icon: MaterialIcon = MaterialIcon.FILTER,
image: ImageVector = Icons.Default.Filter,
modifier: Modifier = Modifier,
onFilterChange: (String) -> Unit
) {
val filterIcon = painterResource(icon.resource)
var localFilterText by remember(filterText) { mutableStateOf(filterText) }

TextField(
Expand All @@ -40,7 +39,7 @@ fun FilterTextField(
},
placeholder = { Text(label) },
singleLine = true,
leadingIcon = { Icon(filterIcon, label) },
leadingIcon = { Icon(image, label) },
shape = RoundedCornerShape(10.dp),
colors = TextFieldDefaults.textFieldColors(
focusedIndicatorColor = Color.Transparent,
Expand Down
8 changes: 4 additions & 4 deletions src/main/kotlin/composables/IconText.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.foundation.layout.Row
import androidx.compose.material.Icon
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.scale
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.res.painterResource

import org.ossreviewtoolkit.workbench.utils.MaterialIcon
import androidx.compose.ui.graphics.vector.rememberVectorPainter

private const val ICON_SCALE = 0.6f

Expand All @@ -36,7 +36,7 @@ fun IconText(
private fun IconTextPreview() {
Preview {
IconText(
icon = painterResource(MaterialIcon.BUG_REPORT.resource),
icon = rememberVectorPainter(Icons.Default.BugReport),
text = "Issues"
)
}
Expand Down
11 changes: 6 additions & 5 deletions src/main/kotlin/composables/Link.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ import androidx.compose.material.Icon
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.unit.dp

import java.io.File

import org.ossreviewtoolkit.workbench.utils.MaterialIcon
import org.ossreviewtoolkit.workbench.utils.browseDirectory
import org.ossreviewtoolkit.workbench.utils.editFile
import org.ossreviewtoolkit.workbench.utils.openUrlInBrowser
Expand Down Expand Up @@ -75,21 +76,21 @@ private fun LinkPreview() {

@Composable
fun BrowseDirectoryLink(text: String, file: File) {
Link(text, tooltip = file.path, icon = painterResource(MaterialIcon.OPEN_IN_NEW.resource)) {
Link(text, tooltip = file.path, icon = rememberVectorPainter(Icons.AutoMirrored.Default.OpenInNew)) {
browseDirectory(file)
}
}

@Composable
fun EditFileLink(text: String, file: File) {
Link(text, tooltip = file.path, icon = painterResource(MaterialIcon.OPEN_IN_NEW.resource)) {
Link(text, tooltip = file.path, icon = rememberVectorPainter(Icons.AutoMirrored.Default.OpenInNew)) {
editFile(file)
}
}

@Composable
fun WebLink(text: String, url: String) {
Link(text, tooltip = url, icon = painterResource(MaterialIcon.OPEN_IN_NEW.resource)) {
Link(text, tooltip = url, icon = rememberVectorPainter(Icons.AutoMirrored.Default.OpenInNew)) {
openUrlInBrowser(url)
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/main/kotlin/composables/ListScreenAppBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp

import org.ossreviewtoolkit.workbench.utils.MaterialIcon

@Composable
fun ListScreenAppBar(
filterText: String,
Expand All @@ -27,7 +26,7 @@ fun ListScreenAppBar(

IconButton(onClick = onToggleFilter) {
Icon(
painterResource(MaterialIcon.FILTER_LIST.resource),
Icons.Default.FilterList,
contentDescription = "Filter",
modifier = Modifier.size(32.dp)
)
Expand Down
12 changes: 6 additions & 6 deletions src/main/kotlin/composables/SeverityIcon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.size
import androidx.compose.material.Icon
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

Expand All @@ -15,14 +16,13 @@ import org.ossreviewtoolkit.workbench.theme.Error
import org.ossreviewtoolkit.workbench.theme.Hint
import org.ossreviewtoolkit.workbench.theme.LightGray
import org.ossreviewtoolkit.workbench.theme.Warning
import org.ossreviewtoolkit.workbench.utils.MaterialIcon

@Composable
fun SeverityIcon(severity: Severity, resolved: Boolean = false, size: Dp = 24.dp) {
val icon = when (severity) {
Severity.HINT -> MaterialIcon.INFO
Severity.WARNING -> MaterialIcon.WARNING
Severity.ERROR -> MaterialIcon.ERROR
Severity.HINT -> Icons.Default.Info
Severity.WARNING -> Icons.Default.Warning
Severity.ERROR -> Icons.Default.Error
}

val tint = if (resolved) {
Expand All @@ -36,7 +36,7 @@ fun SeverityIcon(severity: Severity, resolved: Boolean = false, size: Dp = 24.dp
}

Icon(
painterResource(icon.resource),
icon,
contentDescription = severity.name,
tint = tint,
modifier = Modifier.size(size)
Expand Down
16 changes: 9 additions & 7 deletions src/main/kotlin/composables/tree/Tree.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,25 @@ import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.Icon
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.input.key.Key
import androidx.compose.ui.input.key.KeyEvent
import androidx.compose.ui.input.key.KeyEventType
import androidx.compose.ui.input.key.key
import androidx.compose.ui.input.key.onKeyEvent
import androidx.compose.ui.input.key.type
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

import org.ossreviewtoolkit.workbench.composables.Preview
import org.ossreviewtoolkit.workbench.utils.MaterialIcon

@Composable
fun <VALUE> Tree(
Expand All @@ -37,8 +39,8 @@ fun <VALUE> Tree(
startExpanded: Boolean = false,
listState: LazyListState = rememberLazyListState(),
indentation: Dp = 5.dp,
expandIcon: MaterialIcon = MaterialIcon.CHEVRON_RIGHT,
expandedIcon: MaterialIcon = MaterialIcon.EXPAND_MORE,
expandIcon: ImageVector = Icons.Default.ChevronRight,
expandedIcon: ImageVector = Icons.Default.ExpandMore,
iconSize: Dp = 12.dp,
itemContent: @Composable (item: TreeItem<VALUE>, isSelected: Boolean) -> Unit = { item, isSelected ->
DefaultItemContent(item, isSelected)
Expand All @@ -62,8 +64,8 @@ fun <VALUE> Tree(
state: TreeState<VALUE>,
listState: LazyListState = rememberLazyListState(),
indentation: Dp = 5.dp,
expandIcon: MaterialIcon = MaterialIcon.CHEVRON_RIGHT,
expandedIcon: MaterialIcon = MaterialIcon.EXPAND_MORE,
expandIcon: ImageVector = Icons.Default.ChevronRight,
expandedIcon: ImageVector = Icons.Default.ExpandMore,
iconSize: Dp = 12.dp,
itemContent: @Composable (item: TreeItem<VALUE>, isSelected: Boolean) -> Unit = { item, isSelected ->
DefaultItemContent(item, isSelected)
Expand Down Expand Up @@ -127,7 +129,7 @@ fun <VALUE> Tree(

if (icon != null) {
Icon(
painter = painterResource(icon.resource),
painter = rememberVectorPainter(icon),
contentDescription = null,
modifier = Modifier.size(iconSize).clickable { state.toggleExpanded(item) }
)
Expand Down
Loading

0 comments on commit b98e907

Please sign in to comment.