diff --git a/README.md b/README.md index 4518531..ae0f3af 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,11 @@ The type of script is determined by the line (meta tag) at the beginning of the # Changelog +### 5.3.0 + +* Added `prefs:show_dialog` method +* Added support for SVG icons to the Rich UI API + ### 5.2.3 * Added `on_load()` callback @@ -139,7 +144,8 @@ The `ui:show_chart()` function takes a string as its third argument to format th * `number` - an ordinary number with group separation; * `float` - the same, but with two decimal places; * `date` - date in day.month format; -* `time` - time in hours:minutes format. +* `time` - time in hours:minutes format; +* `none` - disable. ### Clicks @@ -671,6 +677,8 @@ end The `new_key` will be present in the table even after the AIO Launcher has been restrated. +The `show_dialog()` method automatically creates a window of current settings from fields defined in prefs. The window will display all fields with a text key and a value of one of three types: string, number, or boolean. All other fields of different types will be omittedi. Fields whose names start with an underscore will also be omitted. Script will be reloaded on settings save. + ## Animation and real time updates _Available only in widget scripts._ diff --git a/README_RICH_UI.md b/README_RICH_UI.md index be22686..58b3c8a 100644 --- a/README_RICH_UI.md +++ b/README_RICH_UI.md @@ -72,7 +72,7 @@ Third way: display icon in the button: {"button", "Text with icon: %%fa:microphone%%"} ``` -The second method also allows displaying icons of applications and contacts. How to do this is shown in the example [samples/rich-ui-sample.lua]. +The second method also allows displaying icons of applications and contacts. How to do this is shown in the example [rich-ui-sample.lua](samples/rich-ui-sample.lua). You can also use the `icon` element to display your own icons in SVG format. Example: [svg-sample.lua](samples/svg-sample.lua). By the way, if you want the button to stretch across the entire width of the screen, you can use the expand argument: diff --git a/samples/prefs-widget3.lua b/samples/prefs-widget3.lua new file mode 100644 index 0000000..99e304a --- /dev/null +++ b/samples/prefs-widget3.lua @@ -0,0 +1,31 @@ +--[[ +This example shows how to use the prefs module +to display a settings dialog automatically generated on the screen. +]] + +prefs = require("prefs") + +function on_load() + -- Initialize settings with default values + prefs.text_field_1 = "Test" + prefs.text_field_2 = "Test #2" + prefs.numeric_field = 123 + prefs.boolean_field = false + prefs._hidden_field = "Hidden" +end + +function on_resume() + ui:show_toast("On resume called") + ui:show_text("Click to edit preferencies") +end + +function on_click() + --[[ + The `show_dialog()` method automatically creates a window of current settings from fields defined in prefs. + The window will display all fields with a text key and a value of one of three types: string, number, or boolean. + All other fields of different types will be omittedi. + Fields whose names start with an underscore will also be omitted. + Script will be reloaded on settings save. + ]] + prefs:show_dialog() +end diff --git a/samples/svg-sample.lua b/samples/svg-sample.lua new file mode 100644 index 0000000..bb62ecc --- /dev/null +++ b/samples/svg-sample.lua @@ -0,0 +1,12 @@ +local icon = [[ + + + + +]] + +function on_resume() + gui{ + {"icon", "svg:"..icon, {size = 100}}, + }.render() +end