From 4904a0050afc9c2958e849a1086d76f15b9e35b9 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 29 Apr 2025 06:59:41 +0800 Subject: [PATCH] Add ui:show_image() --- README.md | 4 +++- samples/image_sample.lua | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 samples/image_sample.lua diff --git a/README.md b/README.md index 824be97..9fb3bcd 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ The type of script is determined by the line (meta tag) at the beginning of the ### 5.7.0 +* Added `ui:show_image(uri)` method * Many changes in the `notify` module ### 5.6.1 @@ -138,6 +139,7 @@ _AIO Launcher also offers a way to create more complex UIs: [instructions](READM * `ui:show_buttons(names, [colors])` - displays a list of buttons, the first argument is a table of strings, the second is an optional argument, a table of colors in the format #XXXXXX; * `ui:show_progress_bar(text, current_value, max_value, [color])` - shows the progress bar; * `ui:show_chart(points, [format], [title], [show_grid], [folded_string], [copyright])` - shows the chart, points - table of coordinate tables, format - data format (see below), title - chart name, show\_grid - grid display flag, folded\_string - string for the folded state (otherwise the name will be shown), copyright - string displayed in the lower right corner; +* `ui:show_image(uri)` - show image by URL; * `ui:show_toast(string)` - shows informational message in Android style; * `ui:default_title()` - returns the standard widget title (set in the `name` metadata); * `ui:set_title()` - changes the title of the widget, should be called before the data display function (empty line - reset to the standard title); @@ -710,7 +712,7 @@ Notification table format: `actions` - table notifications actions with fields: `id`, `title`, `have_input` (_available from: 4.1.5_); ``` -Keep in mind that the AIO Launcher also request current notifications every time you return to the launcher, which means that all scripts will also get the `on_notifications_updated() callback called`. +Keep in mind that the AIO Launcher also request current notifications every time you return to the launcher, which means that all scripts will also get the `on_notifications_updated()` callback called. ## Files diff --git a/samples/image_sample.lua b/samples/image_sample.lua new file mode 100644 index 0000000..29b9185 --- /dev/null +++ b/samples/image_sample.lua @@ -0,0 +1,18 @@ +local height = 0 + +function on_load() + show_image() +end + +function on_click() + if height == 0 then + height = 100 + else + height = 0 + end + show_image() +end + +function show_image() + ui:show_image("https://dummyimage.com/600x400/000/fff", height) +end