This commit is contained in:
Insality
2025-10-27 22:25:13 +02:00
parent 1601d6d56e
commit 1b2cdabd8b
2 changed files with 62 additions and 94 deletions

View File

@@ -28,38 +28,6 @@ local function handle_install(item, install_folder, on_success, on_error)
end end
---Show installation status dialog
---@param success boolean - Whether installation was successful
---@param message string - Status message
local function show_install_status(success, message)
local dialog_component = editor.ui.component(function()
return editor.ui.dialog({
title = success and "Installation Successful" or "Installation Failed",
content = editor.ui.vertical({
spacing = editor.ui.SPACING.MEDIUM,
padding = editor.ui.PADDING.MEDIUM,
children = {
editor.ui.label({
text = message,
color = success and editor.ui.COLOR.TEXT or editor.ui.COLOR.ERROR,
alignment = editor.ui.ALIGNMENT.LEFT
})
}
}),
buttons = {
editor.ui.dialog_button({
text = "OK",
default = true
})
}
})
end)
editor.ui.show_dialog(dialog_component({}))
end
---Open the asset store dialog ---Open the asset store dialog
function M.open_asset_store(store_url) function M.open_asset_store(store_url)
print("Opening Druid Asset Store from:", store_url) print("Opening Druid Asset Store from:", store_url)
@@ -86,11 +54,9 @@ function M.open_asset_store(store_url)
handle_install(item, install_folder, handle_install(item, install_folder,
function(message) function(message)
set_install_status("Success: " .. message) set_install_status("Success: " .. message)
show_install_status(true, message)
end, end,
function(message) function(message)
set_install_status("Error: " .. message) set_install_status("Error: " .. message)
show_install_status(false, message)
end end
) )
end end

View File

@@ -163,25 +163,7 @@ function M.create_widget_item(item, is_installed, on_install)
deps_text = "Depends: " .. table.concat(item.depends, ", ") deps_text = "Depends: " .. table.concat(item.depends, ", ")
end end
return editor.ui.horizontal({ local widget_details_children = {
spacing = editor.ui.SPACING.NONE,
padding = editor.ui.PADDING.SMALL,
children = {
editor.ui.separator({
orientation = editor.ui.ORIENTATION.HORIZONTAL,
}),
-- Widget icon placeholder
editor.ui.label({
text = "📦",
color = editor.ui.COLOR.HINT
}),
-- Widget details
editor.ui.vertical({
spacing = editor.ui.SPACING.SMALL,
grow = true,
children = {
-- Title and author
editor.ui.horizontal({ editor.ui.horizontal({
spacing = editor.ui.SPACING.SMALL, spacing = editor.ui.SPACING.SMALL,
children = { children = {
@@ -205,29 +187,52 @@ function M.create_widget_item(item, is_installed, on_install)
}), }),
-- Description -- Description
editor.ui.label({ editor.ui.paragraph({
text = item.description or "No description available", text = item.description or "No description available",
color = editor.ui.COLOR.TEXT color = editor.ui.COLOR.TEXT
}), }),
}
-- Tags if tags_text ~= "" then
tags_text ~= "" and editor.ui.label({ table.insert(widget_details_children, editor.ui.label({
text = tags_text, text = tags_text,
color = editor.ui.COLOR.HINT color = editor.ui.COLOR.HINT
}) or nil, }))
end
-- Dependencies if deps_text ~= "" then
deps_text ~= "" and editor.ui.label({ table.insert(widget_details_children, editor.ui.label({
text = deps_text, text = deps_text,
color = editor.ui.COLOR.HINT color = editor.ui.COLOR.HINT
}) or nil, }))
end
-- Installation status if is_installed then
is_installed and editor.ui.label({ table.insert(widget_details_children, editor.ui.label({
text = "✓ Already installed", text = "✓ Already installed",
color = editor.ui.COLOR.WARNING
}))
end
table.insert(widget_details_children, editor.ui.separator({
orientation = editor.ui.ORIENTATION.HORIZONTAL,
}))
return editor.ui.horizontal({
spacing = editor.ui.SPACING.NONE,
padding = editor.ui.PADDING.SMALL,
children = {
-- Widget icon placeholder
editor.ui.label({
text = "📦",
color = editor.ui.COLOR.HINT color = editor.ui.COLOR.HINT
}) or nil }),
}
-- Widget details
editor.ui.vertical({
spacing = editor.ui.SPACING.SMALL,
grow = true,
children = widget_details_children
}), }),
-- Action buttons -- Action buttons
@@ -235,10 +240,9 @@ function M.create_widget_item(item, is_installed, on_install)
spacing = editor.ui.SPACING.MEDIUM, spacing = editor.ui.SPACING.MEDIUM,
children = { children = {
editor.ui.button({ editor.ui.button({
text = "Install", text = "Install",
on_pressed = on_install, on_pressed = on_install,
enabled = is_installed == false enabled = not is_installed
}), }),
editor.ui.button({ editor.ui.button({
text = "API", text = "API",
@@ -260,14 +264,12 @@ function M.create_widget_list(items, on_install)
local widget_items = {} local widget_items = {}
local install_folder = installer.get_install_folder() local install_folder = installer.get_install_folder()
for index = 1, 9 do
for _, item in ipairs(items) do for _, item in ipairs(items) do
local is_installed = installer.is_widget_installed(item, install_folder) local is_installed = installer.is_widget_installed(item, install_folder)
table.insert(widget_items, M.create_widget_item(item, is_installed, table.insert(widget_items, M.create_widget_item(item, is_installed,
function() on_install(item) end function() on_install(item) end
)) ))
end end
end
return editor.ui.scroll({ return editor.ui.scroll({
content = editor.ui.vertical({ content = editor.ui.vertical({