From 7b41366ea6baf3e7ce0ef851f1b453583c267527 Mon Sep 17 00:00:00 2001 From: Michael Leonhard Date: Tue, 9 Jan 2024 20:32:24 -0800 Subject: [PATCH] Support ApplinIos 0.32.0. Remove on_user_error_poll action and make it a parameter of the rpc action. Add `modal` action. Add `aspect_ratio` param to `choose_photo` and `take_photo` actions. --- CHANGELOG.md | 5 +++++ lib/applin.rb | 34 +++++++++++++++++++--------------- lib/applin/rails/version.rb | 2 +- sig/applin.rbs | 15 +++++++++------ 4 files changed, 34 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b1ed86..27b649b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ ## applin Ruby Gem Changes +- v0.7.0 + - Support ApplinIos 0.32.0. + - Remove on_user_error_poll action and make it a parameter of the rpc action. + - Add `modal` action. + - Add `aspect_ratio` param to `choose_photo` and `take_photo` actions. - v0.6.0 - Support ApplinIos v0.25.0. - Add `poll_delay_ms` to checkbox and textfield. diff --git a/lib/applin.rb b/lib/applin.rb index afc14a4..5e6dddc 100644 --- a/lib/applin.rb +++ b/lib/applin.rb @@ -22,48 +22,52 @@ module Applin # Actions ################################################################### - def choose_photo(upload_url:) - "choose_photo:#{upload_url}" + def choose_photo(upload_url:, aspect_ratio: nil) + { typ: "choose_photo", url: upload_url, aspect_ratio: aspect_ratio } end def copy_to_clipboard(text) - "copy_to_clipboard:#{text}" + { typ: "copy_to_clipboard", string_value: text } end def launch_url(url) - "launch_url:#{url}" + { typ: "launch_url", url: url } end def logout - "logout" + { typ: "logout" } end - def on_user_error_poll - "on_user_error_poll" + def modal_button(text:, actions:) + { text: text, actions: actions } + end + + def modal(title:, buttons:, message: nil) + { typ: "modal", title: title, message: message, buttons: buttons } end def poll - "poll" + { typ: "poll" } end def pop - "pop" + { typ: "pop" } end def push(page_key) - "push:#{page_key}" + { typ: "push", page: page_key } end def replace_all(page_key) - "replace_all:#{page_key}" + { typ: "replace_all", page: page_key } end - def rpc(url) - "rpc:#{url}" + def rpc(url:, on_user_error_poll: nil) + { typ: "rpc", url: url, on_user_error_poll: on_user_error_poll } end - def take_photo(upload_url:) - "take_photo:#{upload_url}" + def take_photo(upload_url:, aspect_ratio: nil) + { typ: "take_photo", url: upload_url, aspect_ratio: aspect_ratio } end # Pages ##################################################################### diff --git a/lib/applin/rails/version.rb b/lib/applin/rails/version.rb index c0e6b71..5eac06a 100644 --- a/lib/applin/rails/version.rb +++ b/lib/applin/rails/version.rb @@ -2,6 +2,6 @@ module Applin module Rails - VERSION = "0.6.0" + VERSION = "0.7.0" end end diff --git a/sig/applin.rbs b/sig/applin.rbs index ae5a79f..160f384 100644 --- a/sig/applin.rbs +++ b/sig/applin.rbs @@ -27,7 +27,8 @@ module Applin DISPOSITION_STRETCH: disposition VERSION: String - type action = String + type action = { typ: String } + type modal_button = { text: String, actions: Array[action] } type page = { title: String } type widget = { typ: String } @@ -43,7 +44,7 @@ module Applin poll_delay_ms: Numeric?, ) -> widget - def choose_photo: (upload_url: String) -> action + def choose_photo: (upload_url: String, aspect_ratio: Numeric?) -> action def column: (widgets: Array[widget], align: alignment?, spacing: Numeric?) -> widget @@ -69,6 +70,10 @@ module Applin def logout: -> action + def modal_button: (text: String, actions: Array[action]) -> modal_button + + def modal: (title: String, message: String?, buttons: Array[modal_button]) -> action + def nav_button: (text: String, actions: Array[action], badge_text: String?, photo_url: String?, sub_text: String?) -> widget def nav_page: ( @@ -80,8 +85,6 @@ module Applin poll_seconds: Numeric?, ) { () -> widget } -> page - def on_user_error_poll: -> action - def plain_page: ( title: String?, ephemeral: bool?, @@ -97,13 +100,13 @@ module Applin def replace_all: (String) -> action - def rpc: (String) -> action + def rpc: (url: String, on_user_error_poll: bool?) -> action def scroll: () { () -> widget } -> widget def table: (rows: Array[Array[widget]], spacing: Numeric?) -> widget - def take_photo: (upload_url: String) -> action + def take_photo: (upload_url: String, aspect_ratio: Numeric?) -> action def text: (String) -> widget