More helpers/DRY

This commit is contained in:
downthecrop 2025-10-24 18:43:16 -07:00
parent 573e579643
commit 47e545cbc7
17 changed files with 264 additions and 289 deletions

View file

@ -4,13 +4,13 @@ import KondoKit.Helpers
import KondoKit.components.*
import KondoKit.ViewConstants
import KondoKit.views.ViewLayoutHelpers.createSearchFieldSection
import KondoKit.setFixedSize
import KondoKit.pluginmanager.GitLabPlugin
import KondoKit.pluginmanager.GitLabPluginFetcher
import KondoKit.pluginmanager.PluginDownloadManager
import KondoKit.pluginmanager.PluginProperties
import KondoKit.pluginmanager.PluginInfoWithStatus
import KondoKit.Helpers.showToast
import KondoKit.plugin.Companion.TITLE_BAR_COLOR
import KondoKit.plugin.Companion.TOOLTIP_BACKGROUND
import KondoKit.plugin.Companion.VIEW_BACKGROUND_COLOR
import KondoKit.plugin.Companion.WIDGET_COLOR
@ -304,17 +304,10 @@ object ReflectiveEditorView : View {
}
// Edit button (only show if plugin has exposed attributes)
val editButton = if (exposedFields.isNotEmpty()) {
val button = JButton("Edit")
button.background = TITLE_BAR_COLOR
button.foreground = secondaryColor
button.font = ViewConstants.FONT_RUNESCAPE_SMALL_14
button.addActionListener {
val editButton = exposedFields.takeIf { it.isNotEmpty() }?.let {
UiStyler.button(text = "Edit") {
showPluginDetails(pluginInfo, plugin)
}
button
} else {
null
}
// Plugin toggle switch (iOS style) - skip for KondoKit since it should always be on
@ -324,8 +317,7 @@ object ReflectiveEditorView : View {
// Create a placeholder component that takes the same space but is invisible
val placeholder = JPanel()
placeholder.background = WIDGET_COLOR
placeholder.preferredSize = ViewConstants.TOGGLE_PLACEHOLDER_SIZE
placeholder.maximumSize = ViewConstants.TOGGLE_PLACEHOLDER_SIZE
placeholder.setFixedSize(ViewConstants.TOGGLE_PLACEHOLDER_SIZE)
placeholder.isVisible = false
placeholder
}
@ -417,10 +409,7 @@ object ReflectiveEditorView : View {
nameLabel.font = ViewConstants.FONT_RUNESCAPE_SMALL_PLAIN_16
// Action button based on plugin status
val actionButton = JButton()
actionButton.background = TITLE_BAR_COLOR
actionButton.foreground = secondaryColor
actionButton.font = ViewConstants.FONT_RUNESCAPE_SMALL_14
val actionButton = UiStyler.button()
// Progress bar for downloads
val progressBar = JProgressBar(0, 100)