From 90988df698c16feeb952596903aab8e4b945167b Mon Sep 17 00:00:00 2001 From: Carson Katri Date: Tue, 8 Aug 2023 09:15:46 -0400 Subject: [PATCH 01/13] Add binding name configuration to FormState --- .../Views/Controls and Indicators/Pickers/Picker.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sources/LiveViewNative/Views/Controls and Indicators/Pickers/Picker.swift b/Sources/LiveViewNative/Views/Controls and Indicators/Pickers/Picker.swift index 646be0e59..201fbf60d 100644 --- a/Sources/LiveViewNative/Views/Controls and Indicators/Pickers/Picker.swift +++ b/Sources/LiveViewNative/Views/Controls and Indicators/Pickers/Picker.swift @@ -27,6 +27,9 @@ import SwiftUI /// ## Attributes /// - ``selection`` /// +/// ## Attributes +/// - ``selection`` +/// /// ## Children /// - `content` /// - `label` From c5197c9d3b739cf34ff8ae56574bffc2f58c1779 Mon Sep 17 00:00:00 2001 From: May Matyi Date: Wed, 9 Aug 2023 08:37:58 -0700 Subject: [PATCH 02/13] Fix invalid condition for disconnect --- Sources/LiveViewNative/Coordinators/LiveViewCoordinator.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/LiveViewNative/Coordinators/LiveViewCoordinator.swift b/Sources/LiveViewNative/Coordinators/LiveViewCoordinator.swift index b66ded662..fc7e8d12e 100644 --- a/Sources/LiveViewNative/Coordinators/LiveViewCoordinator.swift +++ b/Sources/LiveViewNative/Coordinators/LiveViewCoordinator.swift @@ -299,7 +299,7 @@ public class LiveViewCoordinator: ObservableObject { func disconnect() async { if let channel, - !channel.isClosed + channel.isClosed { await withCheckedContinuation { continuation in channel.leave() From ab4fd9a36570a04f3137561113e647ff2d59e0fc Mon Sep 17 00:00:00 2001 From: May Matyi Date: Wed, 9 Aug 2023 14:06:55 -0700 Subject: [PATCH 03/13] Updates for live_view_native_platform 0.0.8-rc.0 --- lib/live_view_native_swift_ui.ex | 7 +- .../drawing_and_graphics/corner_radius.ex | 4 +- .../text_input_and_output/kerning.ex | 6 +- .../multiline_text_alignment.ex | 11 +- lib/live_view_native_swift_ui/platform.ex | 126 +----------------- .../types/transition.ex | 4 +- mix.exs | 4 +- mix.lock | 6 +- 8 files changed, 30 insertions(+), 138 deletions(-) diff --git a/lib/live_view_native_swift_ui.ex b/lib/live_view_native_swift_ui.ex index 3aa021be6..13379a813 100644 --- a/lib/live_view_native_swift_ui.ex +++ b/lib/live_view_native_swift_ui.ex @@ -1,3 +1,8 @@ defmodule LiveViewNativeSwiftUi do - use LiveViewNativePlatform.Platform + use LiveViewNativePlatform + + def platforms, + do: [ + LiveViewNativeSwiftUi.Platform + ] end diff --git a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/corner_radius.ex b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/corner_radius.ex index 26681dc59..ee68cabd7 100644 --- a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/corner_radius.ex +++ b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/corner_radius.ex @@ -2,7 +2,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.CornerRadius do use LiveViewNativePlatform.Modifier modifier_schema "corner_radius" do - field :radius, :float - field :antialiased, :boolean, default: true + field(:radius, :float) + field(:antialiased, :boolean, default: true) end end diff --git a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/kerning.ex b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/kerning.ex index 1ece78e81..ce3779e23 100644 --- a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/kerning.ex +++ b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/kerning.ex @@ -2,7 +2,9 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Kerning do use LiveViewNativePlatform.Modifier modifier_schema "kerning" do - field :kerning, :float + field(:kerning, :float) end -end + def params(kerning) when is_number(kerning), do: [kerning: kerning] + def params(params), do: params +end diff --git a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/multiline_text_alignment.ex b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/multiline_text_alignment.ex index fd09299ca..cdc46bc33 100644 --- a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/multiline_text_alignment.ex +++ b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/multiline_text_alignment.ex @@ -2,11 +2,16 @@ defmodule LiveViewNativeSwiftUi.Modifiers.MultilineTextAlignment do use LiveViewNativePlatform.Modifier modifier_schema "multiline_text_alignment" do - field :alignment, Ecto.Enum, values: ~w( + field(:alignment, Ecto.Enum, values: ~w( center leading trailing - )a + )a) end -end + def params(alignment) + when is_atom(alignment) and not is_boolean(alignment) and not is_nil(alignment), + do: [alignment: alignment] + + def params(params), do: params +end diff --git a/lib/live_view_native_swift_ui/platform.ex b/lib/live_view_native_swift_ui/platform.ex index fc7023157..4834f0534 100644 --- a/lib/live_view_native_swift_ui/platform.ex +++ b/lib/live_view_native_swift_ui/platform.ex @@ -1,11 +1,4 @@ defmodule LiveViewNativeSwiftUi.Platform do - import LiveViewNativePlatform.Utils, - only: [ - check_dependency!: 1, - check_platform!: 2, - run_command!: 3 - ] - defstruct [ :app_name, :os_name, @@ -15,128 +8,15 @@ defmodule LiveViewNativeSwiftUi.Platform do custom_modifiers: [] ] - defimpl LiveViewNativePlatform do + defimpl LiveViewNativePlatform.Kit do require Logger - def context(struct) do - LiveViewNativePlatform.Context.define(:swiftui, + def compile(struct) do + LiveViewNativePlatform.Env.define(:swiftui, custom_modifiers: struct.custom_modifiers, render_macro: :sigil_SWIFTUI, otp_app: :live_view_native_swift_ui ) end - - def start_simulator(struct, opts \\ []) do - %{ - app_name: app_name, - simulator_opts: %{ - bundle_name: bundle_name, - default_simulator_device: default_simulator_device, - default_simulator_os: default_simulator_os, - default_simulator_os_version: default_simulator_os_version, - project_path: project_path, - xcode_path: xcode_path - } - } = struct - - # Raises if either `xcrun` or `xcodebuild` are missing from the current system PATH. - # These are requirements to run the Simulator - check_dependency!("xcrun") - check_dependency!("xcodebuild") - - # Raises if `LiveViewNativeSwiftUi.Platform` isn't configured to support Simulator. - check_platform!(struct, %{ - app_name: [:must_be_string], - bundle_name: [:must_be_string], - project_path: [:must_be_string, :must_point_to_directory] - }) - - # Get Simulator options from arguments, falling back to the `LiveViewNativeSwiftUi.Platform` - # configuration or defaults. - simulator_device = Keyword.get(opts, :device, default_simulator_device) - simulator_os = Keyword.get(opts, :os, default_simulator_os) - simulator_os_version = Keyword.get(opts, :os_version, default_simulator_os_version) - - # Get the Simulator device information using the result of `xcrun simctl list --json devices available` - Logger.info("Checking for available devices.") - - %{"devices" => devices} = - run_command!("xcrun", ["simctl", "list", "--json", "devices", "available"], format: :json) - - devices_for_os = - Map.get( - devices, - "com.apple.CoreSimulator.SimRuntime.#{simulator_os}-#{simulator_os_version}", - [] - ) - - device_info = Enum.find(devices_for_os, &(&1["name"] == simulator_device)) - - # Run the app in the specified Simulator if it exists. - case device_info do - %{"udid" => udid} -> - # Setup a build path - live_view_native_priv_dir = :code.priv_dir(:live_view_native) - platform_builds_path = Path.join(live_view_native_priv_dir, "platform_builds") - File.mkdir(platform_builds_path) - build_path = Path.join(platform_builds_path, "#{app_name}.#{udid}") - File.mkdir(build_path) - - # Build a project bundle for the Simulator - Logger.info( - "Building #{app_name}.app for #{simulator_device} (#{simulator_os} #{simulator_os_version})..." - ) - - run_command!( - "xcrun", - [ - "xcodebuild", - "-scheme", - app_name, - "-project", - Path.expand(project_path), - "-configuration", - "Debug", - "-destination", - "id=#{udid}", - "-derivedDataPath", - build_path - ], - [] - ) - - # Run the Simulator - Logger.info( - "Running simulator for #{simulator_device} (#{simulator_os} #{simulator_os_version})..." - ) - - simulator_path = - Path.join( - xcode_path, - "Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator" - ) - - run_command!(simulator_path, ["-CurrentDeviceUDID", udid], []) - - # Install the project bundle in the Simulator and launch it - Logger.info("Running #{app_name}.app in simulator...") - - run_command!( - "xcrun", - [ - "simctl", - "install", - udid, - "#{build_path}/Build/Products/Debug-iphonesimulator/#{app_name}.app" - ], - [] - ) - - run_command!("xcrun", ["simctl", "launch", udid, bundle_name], []) - - device_info -> - raise "Missing or invalid Simulator device: #{device_info}" - end - end end end diff --git a/lib/live_view_native_swift_ui/types/transition.ex b/lib/live_view_native_swift_ui/types/transition.ex index 9104eeb73..b6519236f 100644 --- a/lib/live_view_native_swift_ui/types/transition.ex +++ b/lib/live_view_native_swift_ui/types/transition.ex @@ -22,8 +22,8 @@ defmodule LiveViewNativeSwiftUi.Types.Transition do def cast({ :modifier, [ - active: %LiveViewNativePlatform.Context{ modifiers: active }, - identity: %LiveViewNativePlatform.Context{ modifiers: identity } + active: %LiveViewNativePlatform.Env{ modifiers: active }, + identity: %LiveViewNativePlatform.Env{ modifiers: identity } ] }) do {:ok, %__MODULE__{ diff --git a/mix.exs b/mix.exs index 7e601a9bc..24b6f9fb0 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule LiveViewNativeSwiftUi.MixProject do def project do [ app: :live_view_native_swift_ui, - version: "0.0.9", + version: "0.0.10-rc.1", elixir: "~> 1.15", description: "LiveView Native platform for SwiftUI", package: package(), @@ -25,7 +25,7 @@ defmodule LiveViewNativeSwiftUi.MixProject do [ {:jason, "~> 1.2"}, {:ex_doc, ">= 0.0.0", only: :dev, runtime: false}, - {:live_view_native_platform, "~> 0.0.7"} + {:live_view_native_platform, "~> 0.0.8-rc.0"} ] end diff --git a/mix.lock b/mix.lock index 00cd7521f..8c5758fda 100644 --- a/mix.lock +++ b/mix.lock @@ -1,10 +1,10 @@ %{ "decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"}, "earmark_parser": {:hex, :earmark_parser, "1.4.32", "fa739a0ecfa34493de19426681b23f6814573faee95dfd4b4aafe15a7b5b32c6", [:mix], [], "hexpm", "b8b0dd77d60373e77a3d7e8afa598f325e49e8663a51bcc2b88ef41838cca755"}, - "ecto": {:hex, :ecto, "3.10.2", "6b887160281a61aa16843e47735b8a266caa437f80588c3ab80a8a960e6abe37", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "6a895778f0d7648a4b34b486af59a1c8009041fbdf2b17f1ac215eb829c60235"}, + "ecto": {:hex, :ecto, "3.10.3", "eb2ae2eecd210b4eb8bece1217b297ad4ff824b4384c0e3fdd28aaf96edd6135", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "44bec74e2364d491d70f7e42cd0d690922659d329f6465e89feb8a34e8cd3433"}, "ex_doc": {:hex, :ex_doc, "0.29.4", "6257ecbb20c7396b1fe5accd55b7b0d23f44b6aa18017b415cb4c2b91d997729", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "2c6699a737ae46cb61e4ed012af931b57b699643b24dabe2400a8168414bc4f5"}, - "jason": {:hex, :jason, "1.4.0", "e855647bc964a44e2f67df589ccf49105ae039d4179db7f6271dfd3843dc27e6", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "79a3791085b2a0f743ca04cec0f7be26443738779d09302e01318f97bdb82121"}, - "live_view_native_platform": {:hex, :live_view_native_platform, "0.0.7-rc.1", "d5906306a512d28de8413e0e22825373e4dcfff1788fa4851ceaf826757e533e", [:mix], [{:ecto, "~> 3.8", [hex: :ecto, repo: "hexpm", optional: false]}, {:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}], "hexpm", "e80f863cf0758673d437e550855c6a18c721580ec059678635d86cc706407a83"}, + "jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"}, + "live_view_native_platform": {:hex, :live_view_native_platform, "0.0.8-rc.0", "1a04c949b10ec37692c21e83a985e01c86738dc45880a029909e36e7afcb4610", [:mix], [{:ecto, "~> 3.8", [hex: :ecto, repo: "hexpm", optional: false]}, {:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}], "hexpm", "a884414dbdd60211e9636d652a4b89a7bdeca0900d6662455130c35bd5144aea"}, "makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"}, "makeup_elixir": {:hex, :makeup_elixir, "0.16.1", "cc9e3ca312f1cfeccc572b37a09980287e243648108384b97ff2b76e505c3555", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "e127a341ad1b209bd80f7bd1620a15693a9908ed780c3b763bccf7d200c767c6"}, "makeup_erlang": {:hex, :makeup_erlang, "0.1.2", "ad87296a092a46e03b7e9b0be7631ddcf64c790fa68a9ef5323b6cbb36affc72", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f3f5a1ca93ce6e092d92b6d9c049bcda58a3b617a8d888f8e7231c85630e8108"}, From c4498cefbd031a5e097ad022a30cef4bf580565f Mon Sep 17 00:00:00 2001 From: May Matyi Date: Tue, 22 Aug 2023 09:47:34 -0700 Subject: [PATCH 04/13] Add more modifier constructors --- .../modifiers/text_input_and_output/line_spacing.ex | 4 +++- .../modifiers/text_input_and_output/tracking.ex | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/line_spacing.ex b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/line_spacing.ex index 79f823d97..b86966a72 100644 --- a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/line_spacing.ex +++ b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/line_spacing.ex @@ -4,5 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.LineSpacing do modifier_schema "line_spacing" do field :line_spacing, :float end -end + def params(line_spacing) when is_number(line_spacing), do: [line_spacing: line_spacing] + def params(params), do: params +end diff --git a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/tracking.ex b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/tracking.ex index c6c116d97..94ad3bd9e 100644 --- a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/tracking.ex +++ b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/tracking.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Tracking do modifier_schema "tracking" do field :tracking, :float end + + def params(tracking) when is_number(tracking), do: [tracking: tracking] + def params(params), do: params end From f9b70253c5886ebb06e94a435b1b9c41e59c4245 Mon Sep 17 00:00:00 2001 From: May Matyi Date: Tue, 22 Aug 2023 09:47:50 -0700 Subject: [PATCH 05/13] Update tutorial config example --- util/tutorial_repo_base/lvn_tutorial_backend/config/dev.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/tutorial_repo_base/lvn_tutorial_backend/config/dev.exs b/util/tutorial_repo_base/lvn_tutorial_backend/config/dev.exs index 14637ec17..6c42eba06 100644 --- a/util/tutorial_repo_base/lvn_tutorial_backend/config/dev.exs +++ b/util/tutorial_repo_base/lvn_tutorial_backend/config/dev.exs @@ -46,7 +46,7 @@ config :lvn_tutorial, LvnTutorialWeb.Endpoint, live_reload: [ patterns: [ ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$", - ~r"lib/lvn_tutorial_web/(controllers|live|components)/.*(ex|heex)$" + ~r"lib/lvn_tutorial_web/(controllers|live|components|modclasses)/.*(ex|heex)$" ] ] From dc861c161bbd735e103a9b1fbedf81244f46944c Mon Sep 17 00:00:00 2001 From: May Matyi Date: Tue, 22 Aug 2023 09:47:57 -0700 Subject: [PATCH 06/13] Bump package version --- mix.exs | 2 +- mix.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mix.exs b/mix.exs index 24b6f9fb0..62ec6ff61 100644 --- a/mix.exs +++ b/mix.exs @@ -25,7 +25,7 @@ defmodule LiveViewNativeSwiftUi.MixProject do [ {:jason, "~> 1.2"}, {:ex_doc, ">= 0.0.0", only: :dev, runtime: false}, - {:live_view_native_platform, "~> 0.0.8-rc.0"} + {:live_view_native_platform, "~> 0.0.8-rc.1"} ] end diff --git a/mix.lock b/mix.lock index 8c5758fda..1aece467f 100644 --- a/mix.lock +++ b/mix.lock @@ -1,14 +1,14 @@ %{ "decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.32", "fa739a0ecfa34493de19426681b23f6814573faee95dfd4b4aafe15a7b5b32c6", [:mix], [], "hexpm", "b8b0dd77d60373e77a3d7e8afa598f325e49e8663a51bcc2b88ef41838cca755"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.33", "3c3fd9673bb5dcc9edc28dd90f50c87ce506d1f71b70e3de69aa8154bc695d44", [:mix], [], "hexpm", "2d526833729b59b9fdb85785078697c72ac5e5066350663e5be6a1182da61b8f"}, "ecto": {:hex, :ecto, "3.10.3", "eb2ae2eecd210b4eb8bece1217b297ad4ff824b4384c0e3fdd28aaf96edd6135", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "44bec74e2364d491d70f7e42cd0d690922659d329f6465e89feb8a34e8cd3433"}, - "ex_doc": {:hex, :ex_doc, "0.29.4", "6257ecbb20c7396b1fe5accd55b7b0d23f44b6aa18017b415cb4c2b91d997729", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "2c6699a737ae46cb61e4ed012af931b57b699643b24dabe2400a8168414bc4f5"}, + "ex_doc": {:hex, :ex_doc, "0.30.5", "aa6da96a5c23389d7dc7c381eba862710e108cee9cfdc629b7ec021313900e9e", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "88a1e115dcb91cefeef7e22df4a6ebbe4634fbf98b38adcbc25c9607d6d9d8e6"}, "jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"}, - "live_view_native_platform": {:hex, :live_view_native_platform, "0.0.8-rc.0", "1a04c949b10ec37692c21e83a985e01c86738dc45880a029909e36e7afcb4610", [:mix], [{:ecto, "~> 3.8", [hex: :ecto, repo: "hexpm", optional: false]}, {:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}], "hexpm", "a884414dbdd60211e9636d652a4b89a7bdeca0900d6662455130c35bd5144aea"}, + "live_view_native_platform": {:hex, :live_view_native_platform, "0.0.8-rc.1", "29776d9f951f410b7110d70d8543114e592a1787fc95071be39fec09322fecef", [:mix], [{:ecto, "~> 3.8", [hex: :ecto, repo: "hexpm", optional: false]}, {:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}], "hexpm", "a261ce09e9bb20acd8faa4853be465cf9a4756d701df7d5b0564be10f4ffbe51"}, "makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"}, "makeup_elixir": {:hex, :makeup_elixir, "0.16.1", "cc9e3ca312f1cfeccc572b37a09980287e243648108384b97ff2b76e505c3555", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "e127a341ad1b209bd80f7bd1620a15693a9908ed780c3b763bccf7d200c767c6"}, "makeup_erlang": {:hex, :makeup_erlang, "0.1.2", "ad87296a092a46e03b7e9b0be7631ddcf64c790fa68a9ef5323b6cbb36affc72", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f3f5a1ca93ce6e092d92b6d9c049bcda58a3b617a8d888f8e7231c85630e8108"}, "nimble_parsec": {:hex, :nimble_parsec, "1.3.1", "2c54013ecf170e249e9291ed0a62e5832f70a476c61da16f6aac6dca0189f2af", [:mix], [], "hexpm", "2682e3c0b2eb58d90c6375fc0cc30bc7be06f365bf72608804fb9cffa5e1b167"}, - "phoenix_html": {:hex, :phoenix_html, "3.3.1", "4788757e804a30baac6b3fc9695bf5562465dd3f1da8eb8460ad5b404d9a2178", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "bed1906edd4906a15fd7b412b85b05e521e1f67c9a85418c55999277e553d0d3"}, + "phoenix_html": {:hex, :phoenix_html, "3.3.2", "d6ce982c6d8247d2fc0defe625255c721fb8d5f1942c5ac051f6177bffa5973f", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "44adaf8e667c1c20fb9d284b6b0fa8dc7946ce29e81ce621860aa7e96de9a11d"}, "telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"}, } From 96fbf71c7a81b25de0590dcc225e4d8d39b9e1a5 Mon Sep 17 00:00:00 2001 From: Carson Katri Date: Tue, 22 Aug 2023 14:49:14 -0400 Subject: [PATCH 07/13] Add params for animation -> menus_and_commands --- .../RenameActionModifier.swift | 22 +++++-------------- .../MaskModifier.swift | 10 ++++----- .../OnDeleteCommandModifier.swift | 8 +++---- .../OnHoverModifier.swift | 8 +++---- .../OnMoveCommandModifier.swift | 16 +++++++------- ...fier.swift => MenuIndicatorModifier.swift} | 11 +++++----- .../animation/matched_geometry_effect.ex | 10 +++++++++ .../button_border_shape.ex | 3 +++ .../modifiers/documents/rename_action.ex | 14 ++++++++++-- .../modifiers/drag_and_drop/draggable.ex | 4 ++++ .../drag_and_drop/drop_destination.ex | 2 +- .../drawing_and_graphics/background_style.ex | 9 ++++++++ .../drawing_and_graphics/blend_mode.ex | 4 ++++ .../modifiers/drawing_and_graphics/border.ex | 10 +++++++++ .../drawing_and_graphics/brightness.ex | 3 +++ .../drawing_and_graphics/clip_shape.ex | 10 +++++++++ .../drawing_and_graphics/color_multiply.ex | 9 ++++++++ .../drawing_and_graphics/contrast.ex | 3 +++ .../drawing_and_graphics/corner_radius.ex | 4 ++++ .../drawing_and_graphics/grayscale.ex | 3 +++ .../drawing_and_graphics/hue_rotation.ex | 9 ++++++++ .../modifiers/drawing_and_graphics/mask.ex | 2 +- .../drawing_and_graphics/projection_effect.ex | 9 ++++++++ .../rotation_3d_effect.ex | 10 +++++++++ .../drawing_and_graphics/rotation_effect.ex | 10 +++++++++ .../drawing_and_graphics/saturation.ex | 3 +++ .../modifiers/drawing_and_graphics/tint.ex | 9 ++++++++ .../drawing_and_graphics/transform_effect.ex | 9 ++++++++ .../modifiers/focus/focus_scope.ex | 9 ++++++++ .../modifiers/focus/focusable.ex | 3 +++ .../modifiers/focus/prefers_default_focus.ex | 3 +++ .../gestures/defers_system_gestures.ex | 3 +++ .../modifiers/gestures/gesture.ex | 6 ++++- .../modifiers/images/antialiased.ex | 3 +++ .../modifiers/images/interpolation.ex | 3 +++ .../modifiers/images/rendering_mode.ex | 3 +++ .../modifiers/images/symbol_rendering_mode.ex | 3 +++ .../modifiers/images/symbol_variant.ex | 9 ++++++++ .../input_events/allows_hit_testing.ex | 3 +++ .../digital_crown_accessory_visibility.ex | 3 +++ .../modifiers/input_events/hover_effect.ex | 3 +++ .../input_events/on_delete_command.ex | 4 ++-- .../modifiers/input_events/on_hover.ex | 4 ++-- .../modifiers/input_events/on_move_command.ex | 2 +- .../modifiers/input_events/on_submit.ex | 12 +++++++++- .../modifiers/input_events/submit_scope.ex | 3 +++ .../layout_adjustments/coordinate_space.ex | 3 +++ .../layout_adjustments/ignores_safe_area.ex | 4 +++- .../modifiers/lists/badge.ex | 11 ++++++++++ .../modifiers/lists/delete_disabled.ex | 3 +++ .../modifiers/lists/disclosure_group_style.ex | 3 +++ .../modifiers/lists/header_prominence.ex | 5 ++++- .../modifiers/lists/list_item_tint.ex | 9 ++++++++ .../modifiers/lists/list_row_background.ex | 9 ++++++++ .../modifiers/lists/list_row_insets.ex | 9 ++++++++ .../modifiers/lists/list_row_separator.ex | 6 ++++- .../lists/list_row_separator_tint.ex | 10 +++++++++ .../modifiers/lists/list_section_separator.ex | 4 ++++ .../lists/list_section_separator_tint.ex | 10 +++++++++ .../modifiers/lists/list_style.ex | 3 +++ .../modifiers/lists/move_disabled.ex | 3 +++ .../modifiers/lists/refreshable.ex | 2 +- .../menu_action_dismiss_behavior.ex | 3 +++ .../menu_indicator_visibility.ex | 5 ++++- .../menus_and_commands/menu_order.ex | 3 +++ .../menus_and_commands/menu_style.ex | 3 +++ .../keyboard_shortcut.ex | 2 +- .../modifiers/view_fundamentals/on_appear.ex | 4 ++-- .../view_fundamentals/on_disappear.ex | 4 ++-- lib/live_view_native_swift_ui/types/event.ex | 20 ----------------- .../types/event_modifier.ex | 2 +- 71 files changed, 358 insertions(+), 85 deletions(-) rename Sources/LiveViewNative/Modifiers/Menus and Commands/{MenuIndicatorVisibilityModifier.swift => MenuIndicatorModifier.swift} (84%) delete mode 100644 lib/live_view_native_swift_ui/types/event.ex diff --git a/Sources/LiveViewNative/Modifiers/Documents Modifiers/RenameActionModifier.swift b/Sources/LiveViewNative/Modifiers/Documents Modifiers/RenameActionModifier.swift index 8b204235b..362b85491 100644 --- a/Sources/LiveViewNative/Modifiers/Documents Modifiers/RenameActionModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Documents Modifiers/RenameActionModifier.swift @@ -14,7 +14,7 @@ import SwiftUI /// ```html /// /// ``` @@ -30,33 +30,21 @@ struct RenameActionModifier: ViewModifier, Decodable { #if swift(>=5.8) @_documentation(visibility: public) #endif - private let event: String - /// The LiveView or LiveComponent to perform the event on. - /// - /// In a component, you may use the `@myself` assign to handle the event on the LiveComponent. - #if swift(>=5.8) - @_documentation(visibility: public) - #endif - private let target: Int? - @Environment(\.coordinatorEnvironment) private var coordinatorEnvironment + @Event private var action: Event.EventHandler init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - self.event = try container.decode(String.self, forKey: .event) - self.target = try container.decode(Int?.self, forKey: .target) + self._action = try container.decode(Event.self, forKey: .action) } private enum CodingKeys: String, CodingKey { - case event - case target + case action } func body(content: Content) -> some View { content .renameAction { - Task { - try await coordinatorEnvironment?.pushEvent("click", event, [String:Any](), target) - } + action(value: [String:String]()) } } } diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/MaskModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/MaskModifier.swift index f030aa263..d46d877b3 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/MaskModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/MaskModifier.swift @@ -15,7 +15,7 @@ import SwiftUI /// @native /// |> foreground_color(color: :blue) /// |> font(font: {:system, :large_title}) -/// |> mask(alignment: :center, content: :mask) +/// |> mask(alignment: :center, mask: :mask) /// } /// > /// opacity(opacity: 0.1)} /> @@ -41,7 +41,7 @@ struct MaskModifier: ViewModifier, Decodable { #if swift(>=5.8) @_documentation(visibility: public) #endif - private let content: String + private let mask: String @ObservedElement private var element @LiveContext private var context @@ -50,17 +50,17 @@ struct MaskModifier: ViewModifier, Decodable { let container = try decoder.container(keyedBy: CodingKeys.self) self.alignment = try container.decode(Alignment.self, forKey: .alignment) - self.content = try container.decode(String.self, forKey: .content) + self.mask = try container.decode(String.self, forKey: .mask) } func body(content: Content) -> some View { content.mask(alignment: alignment) { - context.buildChildren(of: element, forTemplate: self.content) + context.buildChildren(of: element, forTemplate: self.mask) } } enum CodingKeys: String, CodingKey { case alignment - case content + case mask } } diff --git a/Sources/LiveViewNative/Modifiers/Input Events Modifiers/OnDeleteCommandModifier.swift b/Sources/LiveViewNative/Modifiers/Input Events Modifiers/OnDeleteCommandModifier.swift index d25c940fa..a2dfbd8bc 100644 --- a/Sources/LiveViewNative/Modifiers/Input Events Modifiers/OnDeleteCommandModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Input Events Modifiers/OnDeleteCommandModifier.swift @@ -46,24 +46,24 @@ struct OnDeleteCommandModifier: ViewModifier, Decodable { #if swift(>=5.8) @_documentation(visibility: public) #endif - @Event private var action: Event.EventHandler + @Event private var perform: Event.EventHandler init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - self._action = try container.decode(Event.self, forKey: .action) + self._perform = try container.decode(Event.self, forKey: .perform) } func body(content: Content) -> some View { content #if os(macOS) .onDeleteCommand { - action() + perform() } #endif } enum CodingKeys: String, CodingKey { - case action + case perform } } diff --git a/Sources/LiveViewNative/Modifiers/Input Events Modifiers/OnHoverModifier.swift b/Sources/LiveViewNative/Modifiers/Input Events Modifiers/OnHoverModifier.swift index 48a0d0c6d..5405ea4e5 100644 --- a/Sources/LiveViewNative/Modifiers/Input Events Modifiers/OnHoverModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Input Events Modifiers/OnHoverModifier.swift @@ -44,24 +44,24 @@ struct OnHoverModifier: ViewModifier, Decodable { #if swift(>=5.8) @_documentation(visibility: public) #endif - @Event private var action: Event.EventHandler + @Event private var perform: Event.EventHandler init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - self._action = try container.decode(Event.self, forKey: .action) + self._perform = try container.decode(Event.self, forKey: .perform) } func body(content: Content) -> some View { content #if os(iOS) || os(macOS) .onHover { isHovering in - action(value: isHovering) + perform(value: isHovering) } #endif } enum CodingKeys: String, CodingKey { - case action + case perform } } diff --git a/Sources/LiveViewNative/Modifiers/Input Events Modifiers/OnMoveCommandModifier.swift b/Sources/LiveViewNative/Modifiers/Input Events Modifiers/OnMoveCommandModifier.swift index 857e97e61..fc3bc56ef 100644 --- a/Sources/LiveViewNative/Modifiers/Input Events Modifiers/OnMoveCommandModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Input Events Modifiers/OnMoveCommandModifier.swift @@ -52,12 +52,12 @@ struct OnMoveCommandModifier: ViewModifier, Decodable { #if swift(>=5.8) @_documentation(visibility: public) #endif - @Event private var action: Event.EventHandler + @Event private var perform: Event.EventHandler init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - self._action = try container.decode(Event.self, forKey: .action) + self._perform = try container.decode(Event.self, forKey: .perform) } func body(content: Content) -> some View { @@ -66,21 +66,21 @@ struct OnMoveCommandModifier: ViewModifier, Decodable { .onMoveCommand { direction in switch direction { case .up: - action(value: ["direction": "up"]) + perform(value: ["direction": "up"]) case .down: - action(value: ["direction": "down"]) + perform(value: ["direction": "down"]) case .left: - action(value: ["direction": "left"]) + perform(value: ["direction": "left"]) case .right: - action(value: ["direction": "right"]) + perform(value: ["direction": "right"]) @unknown default: - action(value: ["direction": String(describing: direction)]) + perform(value: ["direction": String(describing: direction)]) } } #endif } enum CodingKeys: String, CodingKey { - case action + case perform } } diff --git a/Sources/LiveViewNative/Modifiers/Menus and Commands/MenuIndicatorVisibilityModifier.swift b/Sources/LiveViewNative/Modifiers/Menus and Commands/MenuIndicatorModifier.swift similarity index 84% rename from Sources/LiveViewNative/Modifiers/Menus and Commands/MenuIndicatorVisibilityModifier.swift rename to Sources/LiveViewNative/Modifiers/Menus and Commands/MenuIndicatorModifier.swift index 44f91c8cd..80e64039e 100644 --- a/Sources/LiveViewNative/Modifiers/Menus and Commands/MenuIndicatorVisibilityModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Menus and Commands/MenuIndicatorModifier.swift @@ -10,7 +10,7 @@ import SwiftUI /// Specifies whether the indicator on a ``Menu`` should be visible. /// /// ```html -/// menu_indicator_visibility(visibility: :hidden)}> +/// menu_indicator(visibility: :hidden)}> /// /// Edit Actions /// @@ -28,7 +28,7 @@ import SwiftUI @_documentation(visibility: public) #endif @available(iOS 16.0, macOS 13.0, tvOS 16.0, *) -struct MenuIndicatorVisibilityModifier: ViewModifier, Decodable { +struct MenuIndicatorModifier: ViewModifier, Decodable { /// The indicator visibility. /// /// See ``LiveViewNative/SwiftUI/Visibility`` for possible values. @@ -38,8 +38,9 @@ struct MenuIndicatorVisibilityModifier: ViewModifier, Decodable { private let visibility: Visibility func body(content: Content) -> some View { -#if !os(watchOS) - content.menuIndicator(visibility) -#endif + content + #if !os(watchOS) + .menuIndicator(visibility) + #endif } } diff --git a/lib/live_view_native_swift_ui/modifiers/animation/matched_geometry_effect.ex b/lib/live_view_native_swift_ui/modifiers/animation/matched_geometry_effect.ex index d30079eb3..a842bb51f 100644 --- a/lib/live_view_native_swift_ui/modifiers/animation/matched_geometry_effect.ex +++ b/lib/live_view_native_swift_ui/modifiers/animation/matched_geometry_effect.ex @@ -10,4 +10,14 @@ defmodule LiveViewNativeSwiftUi.Modifiers.MatchedGeometryEffect do field :anchor, UnitPoint field :is_source, :boolean, default: true end + + def params([id: id, in: namespace, properties: properties, anchor: anchor, is_source: is_source]), + do: [ + id: id, + namespace: namespace, + properties: properties, + anchor: anchor, + is_source: is_source + ] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/controls_and_indicators/button_border_shape.ex b/lib/live_view_native_swift_ui/modifiers/controls_and_indicators/button_border_shape.ex index 3aecba949..57acd013e 100644 --- a/lib/live_view_native_swift_ui/modifiers/controls_and_indicators/button_border_shape.ex +++ b/lib/live_view_native_swift_ui/modifiers/controls_and_indicators/button_border_shape.ex @@ -5,4 +5,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ButtonBorderShape do field(:shape, Ecto.Enum, values: ~w(automatic capsule rounded_rectangle)a) field(:radius, :float, default: nil) end + + def params(shape) when is_atom(shape) and not is_boolean(shape) and not is_nil(shape), do: [shape: shape] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/documents/rename_action.ex b/lib/live_view_native_swift_ui/modifiers/documents/rename_action.ex index 3522cbfaf..f62b2563e 100644 --- a/lib/live_view_native_swift_ui/modifiers/documents/rename_action.ex +++ b/lib/live_view_native_swift_ui/modifiers/documents/rename_action.ex @@ -1,8 +1,18 @@ defmodule LiveViewNativeSwiftUi.Modifiers.RenameAction do use LiveViewNativePlatform.Modifier + alias LiveViewNativePlatform.Types.Event + modifier_schema "rename_action" do - field :event, :string - field :target, :integer + field :action, Event + end + + def params(params) do + with {:ok, _} <- Event.cast(params) do + [action: params] + else + _ -> + params + end end end diff --git a/lib/live_view_native_swift_ui/modifiers/drag_and_drop/draggable.ex b/lib/live_view_native_swift_ui/modifiers/drag_and_drop/draggable.ex index ca0bb6dcd..bd5db456a 100644 --- a/lib/live_view_native_swift_ui/modifiers/drag_and_drop/draggable.ex +++ b/lib/live_view_native_swift_ui/modifiers/drag_and_drop/draggable.ex @@ -6,4 +6,8 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Draggable do field :payload, :string field :preview, KeyName end + + def params(payload, [preview: preview]), do: [payload: payload, preview: preview] + def params(payload) when is_binary(payload), do: [payload: payload, preview: nil] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/drag_and_drop/drop_destination.ex b/lib/live_view_native_swift_ui/modifiers/drag_and_drop/drop_destination.ex index 8db51eace..6ad3a9b2e 100644 --- a/lib/live_view_native_swift_ui/modifiers/drag_and_drop/drop_destination.ex +++ b/lib/live_view_native_swift_ui/modifiers/drag_and_drop/drop_destination.ex @@ -1,7 +1,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.DropDestination do use LiveViewNativePlatform.Modifier - alias LiveViewNativeSwiftUi.Types.Event + alias LiveViewNativePlatform.Types.Event modifier_schema "drop_destination" do field :action, Event diff --git a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/background_style.ex b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/background_style.ex index f89b227da..971fafd4e 100644 --- a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/background_style.ex +++ b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/background_style.ex @@ -6,4 +6,13 @@ defmodule LiveViewNativeSwiftUi.Modifiers.BackgroundStyle do modifier_schema "background_style" do field :style, ShapeStyle end + + def params(params) do + with {:ok, _} <- ShapeStyle.cast(params) do + [style: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/blend_mode.ex b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/blend_mode.ex index 853506d30..8a4ad9f32 100644 --- a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/blend_mode.ex +++ b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/blend_mode.ex @@ -26,4 +26,8 @@ defmodule LiveViewNativeSwiftUi.Modifiers.BlendMode do destination_out )a) end + + def params(blend_mode) when is_atom(blend_mode) and not is_boolean(blend_mode) and not is_nil(blend_mode), + do: [blend_mode: blend_mode] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/border.ex b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/border.ex index b4f0c1177..ce78cec1a 100644 --- a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/border.ex +++ b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/border.ex @@ -7,4 +7,14 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Border do field :content, ShapeStyle field :width, :float, default: 1.0 end + + def params(content, [width: width]), do: [content: content, width: width] + def params(params) do + with {:ok, _} <- ShapeStyle.cast(params) do + [content: params, width: 1.0] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/brightness.ex b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/brightness.ex index 4e924ceba..5858eeb57 100644 --- a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/brightness.ex +++ b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/brightness.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Brightness do modifier_schema "brightness" do field :amount, :float end + + def params(amount) when is_number(amount), do: [amount: amount] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/clip_shape.ex b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/clip_shape.ex index 23375498c..f75f017da 100644 --- a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/clip_shape.ex +++ b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/clip_shape.ex @@ -7,4 +7,14 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ClipShape do field :shape, Shape field :style, FillStyle end + + def params(shape, [style: style]), do: [shape: shape, style: style] + def params(params) do + with {:ok, _} <- Shape.cast(params) do + [shape: params, style: nil] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/color_multiply.ex b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/color_multiply.ex index 69b61bbe4..ecc8eb29b 100644 --- a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/color_multiply.ex +++ b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/color_multiply.ex @@ -6,4 +6,13 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ColorMultiply do modifier_schema "color_multiply" do field :color, Color end + + def params(params) do + with {:ok, _} <- Color.cast(params) do + [color: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/contrast.ex b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/contrast.ex index ed791bc06..5ef051555 100644 --- a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/contrast.ex +++ b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/contrast.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Contrast do modifier_schema "contrast" do field :amount, :float end + + def params(amount) when is_number(amount), do: [amount: amount] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/corner_radius.ex b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/corner_radius.ex index ee68cabd7..5a00f061c 100644 --- a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/corner_radius.ex +++ b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/corner_radius.ex @@ -5,4 +5,8 @@ defmodule LiveViewNativeSwiftUi.Modifiers.CornerRadius do field(:radius, :float) field(:antialiased, :boolean, default: true) end + + def params(radius, [antialiased: antialiased]), do: [radius: radius, antialiased: antialiased] + def params(radius) when is_number(radius), do: [radius: radius] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/grayscale.ex b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/grayscale.ex index a618a6cc7..437face9f 100644 --- a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/grayscale.ex +++ b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/grayscale.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Grayscale do modifier_schema "grayscale" do field :amount, :float end + + def params(amount) when is_number(amount), do: [amount: amount] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/hue_rotation.ex b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/hue_rotation.ex index bf27f27fc..3592dbc8f 100644 --- a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/hue_rotation.ex +++ b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/hue_rotation.ex @@ -6,4 +6,13 @@ defmodule LiveViewNativeSwiftUi.Modifiers.HueRotation do modifier_schema "hue_rotation" do field :angle, Angle end + + def params(params) do + with {:ok, _} <- Angle.cast(params) do + [angle: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/mask.ex b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/mask.ex index 98c2dc550..b58b87807 100644 --- a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/mask.ex +++ b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/mask.ex @@ -17,6 +17,6 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Mask do trailing trailing_first_text_baseline )a, default: :center - field :content, KeyName + field :mask, KeyName end end diff --git a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/projection_effect.ex b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/projection_effect.ex index b5fdb79cb..43efb6a58 100644 --- a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/projection_effect.ex +++ b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/projection_effect.ex @@ -6,4 +6,13 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ProjectionEffect do modifier_schema "projection_effect" do field :transform, ProjectionTransform end + + def params(params) do + with {:ok, _} <- ProjectionTransform.cast(params) do + [transform: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/rotation_3d_effect.ex b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/rotation_3d_effect.ex index 30fd6fcd0..b2e039460 100644 --- a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/rotation_3d_effect.ex +++ b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/rotation_3d_effect.ex @@ -12,4 +12,14 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Rotation3DEffect do field :anchor_z, :float, default: 0.0 field :perspective, :float, default: 1.0 end + + def params(angle, [axis: axis, anchor: anchor, anchor_z: anchor_z, perspective: perspective]), + do: [ + angle: angle, + axis: axis, + anchor: anchor, + anchor_z: anchor_z, + perspective: perspective + ] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/rotation_effect.ex b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/rotation_effect.ex index 744139f91..15c14a853 100644 --- a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/rotation_effect.ex +++ b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/rotation_effect.ex @@ -8,4 +8,14 @@ defmodule LiveViewNativeSwiftUi.Modifiers.RotationEffect do field :angle, Angle field :anchor, UnitPoint end + + def params(angle, [anchor: anchor]), do: [angle: angle, anchor: anchor] + def params(params) do + with {:ok, _} <- Angle.cast(params) do + [angle: params, anchor: :center] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/saturation.ex b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/saturation.ex index 8271288da..e57e53a12 100644 --- a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/saturation.ex +++ b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/saturation.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Saturation do modifier_schema "saturation" do field :amount, :float end + + def params(amount) when is_number(amount), do: [amount: amount] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/tint.ex b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/tint.ex index cb2aa3895..d57003e7b 100644 --- a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/tint.ex +++ b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/tint.ex @@ -6,4 +6,13 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Tint do modifier_schema "tint" do field :color, Color end + + def params(params) do + with {:ok, _} <- Color.cast(params) do + [color: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/transform_effect.ex b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/transform_effect.ex index 2982dba53..6b1b46481 100644 --- a/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/transform_effect.ex +++ b/lib/live_view_native_swift_ui/modifiers/drawing_and_graphics/transform_effect.ex @@ -6,4 +6,13 @@ defmodule LiveViewNativeSwiftUi.Modifiers.TransformEffect do modifier_schema "transform_effect" do field :transform, AffineTransform end + + def params(params) do + with {:ok, _} <- AffineTransform.cast(params) do + [transform: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/focus/focus_scope.ex b/lib/live_view_native_swift_ui/modifiers/focus/focus_scope.ex index 9d16dbd3e..9e01c6fd5 100644 --- a/lib/live_view_native_swift_ui/modifiers/focus/focus_scope.ex +++ b/lib/live_view_native_swift_ui/modifiers/focus/focus_scope.ex @@ -6,4 +6,13 @@ defmodule LiveViewNativeSwiftUi.Modifiers.FocusScope do modifier_schema "focus_scope" do field :namespace, Namespace end + + def params(params) do + with {:ok, _} <- Namespace.cast(params) do + [namespace: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/focus/focusable.ex b/lib/live_view_native_swift_ui/modifiers/focus/focusable.ex index 10dac3b8a..e49be4142 100644 --- a/lib/live_view_native_swift_ui/modifiers/focus/focusable.ex +++ b/lib/live_view_native_swift_ui/modifiers/focus/focusable.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Focusable do modifier_schema "focusable" do field :is_focusable, :boolean, default: true end + + def params(is_focusable) when is_boolean(is_focusable), do: [is_focusable: is_focusable] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/focus/prefers_default_focus.ex b/lib/live_view_native_swift_ui/modifiers/focus/prefers_default_focus.ex index be261260d..e2c4f539f 100644 --- a/lib/live_view_native_swift_ui/modifiers/focus/prefers_default_focus.ex +++ b/lib/live_view_native_swift_ui/modifiers/focus/prefers_default_focus.ex @@ -7,4 +7,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.PrefersDefaultFocus do field :prefers_default_focus, :boolean, default: true field :namespace, Namespace end + + # def params(prefers_default_focus \\ true, [in: namespace]), do: [prefers_default_focus: prefers_default_focus, namespace: namespace] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/gestures/defers_system_gestures.ex b/lib/live_view_native_swift_ui/modifiers/gestures/defers_system_gestures.ex index e1dcadaee..dd1f697ab 100644 --- a/lib/live_view_native_swift_ui/modifiers/gestures/defers_system_gestures.ex +++ b/lib/live_view_native_swift_ui/modifiers/gestures/defers_system_gestures.ex @@ -6,4 +6,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.DefersSystemGestures do modifier_schema "defers_system_gestures" do field :edges, EdgeSet end + + def params([on: edges]), do: [edges: edges] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/gestures/gesture.ex b/lib/live_view_native_swift_ui/modifiers/gestures/gesture.ex index 255a97e7d..e068f7d06 100644 --- a/lib/live_view_native_swift_ui/modifiers/gestures/gesture.ex +++ b/lib/live_view_native_swift_ui/modifiers/gestures/gesture.ex @@ -2,7 +2,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.OnTapGesture do use LiveViewNativePlatform.Modifier alias LiveViewNativeSwiftUi.Types.Gesture - alias LiveViewNativeSwiftUi.Types.Event + alias LiveViewNativePlatform.Types.Event modifier_schema "gesture" do field :gesture, Gesture @@ -10,4 +10,8 @@ defmodule LiveViewNativeSwiftUi.Modifiers.OnTapGesture do field :priority, Ecto.Enum, values: ~w(low high simultaneous)a, default: :low field :mask, Ecto.Enum, values: ~w(none gesture subviews all)a, default: :all end + + def params(gesture, [action: action, priority: priority, mask: mask]), + do: [gesture: gesture, action: action, priority: priority, mask: mask] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/images/antialiased.ex b/lib/live_view_native_swift_ui/modifiers/images/antialiased.ex index ed5ffa077..a23556caf 100644 --- a/lib/live_view_native_swift_ui/modifiers/images/antialiased.ex +++ b/lib/live_view_native_swift_ui/modifiers/images/antialiased.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Antialiased do modifier_schema "antialiased" do field :is_active, :boolean, default: true end + + def params(is_active) when is_boolean(is_active), do: [is_active: is_active] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/images/interpolation.ex b/lib/live_view_native_swift_ui/modifiers/images/interpolation.ex index a802f42b9..ee20a9bef 100644 --- a/lib/live_view_native_swift_ui/modifiers/images/interpolation.ex +++ b/lib/live_view_native_swift_ui/modifiers/images/interpolation.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Interpolation do modifier_schema "interpolation" do field :interpolation, Ecto.Enum, values: ~w(low medium high none)a end + + def params(interpolation) when is_atom(interpolation) and not is_boolean(interpolation) and not is_nil(interpolation), do: [interpolation: interpolation] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/images/rendering_mode.ex b/lib/live_view_native_swift_ui/modifiers/images/rendering_mode.ex index 583db44e2..2b1011611 100644 --- a/lib/live_view_native_swift_ui/modifiers/images/rendering_mode.ex +++ b/lib/live_view_native_swift_ui/modifiers/images/rendering_mode.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.RenderingMode do modifier_schema "rendering_mode" do field :mode, Ecto.Enum, values: ~w(original template)a end + + def params(mode) when is_atom(mode) and not is_boolean(mode) and not is_nil(mode), do: [mode: mode] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/images/symbol_rendering_mode.ex b/lib/live_view_native_swift_ui/modifiers/images/symbol_rendering_mode.ex index 7dc0b11b0..5b42fb2f3 100644 --- a/lib/live_view_native_swift_ui/modifiers/images/symbol_rendering_mode.ex +++ b/lib/live_view_native_swift_ui/modifiers/images/symbol_rendering_mode.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.SymbolRenderingMode do modifier_schema "symbol_rendering_mode" do field :mode, Ecto.Enum, values: ~w(hierarchical monochrome multicolor palette)a end + + def params(mode) when is_atom(mode) and not is_boolean(mode) and not is_nil(mode), do: [mode: mode] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/images/symbol_variant.ex b/lib/live_view_native_swift_ui/modifiers/images/symbol_variant.ex index 301068e54..de5659ab8 100644 --- a/lib/live_view_native_swift_ui/modifiers/images/symbol_variant.ex +++ b/lib/live_view_native_swift_ui/modifiers/images/symbol_variant.ex @@ -6,4 +6,13 @@ defmodule LiveViewNativeSwiftUi.Modifiers.SymbolVariant do modifier_schema "symbol_variant" do field :variant, SymbolVariants end + + def params(params) do + with {:ok, _} <- SymbolVariants.cast(params) do + [variant: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/input_events/allows_hit_testing.ex b/lib/live_view_native_swift_ui/modifiers/input_events/allows_hit_testing.ex index 4601e273d..72fa94fad 100644 --- a/lib/live_view_native_swift_ui/modifiers/input_events/allows_hit_testing.ex +++ b/lib/live_view_native_swift_ui/modifiers/input_events/allows_hit_testing.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.AllowsHitTesting do modifier_schema "allows_hit_testing" do field :enabled, :boolean end + + def params(enabled) when is_boolean(enabled), do: [enabled: enabled] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/input_events/digital_crown_accessory_visibility.ex b/lib/live_view_native_swift_ui/modifiers/input_events/digital_crown_accessory_visibility.ex index b14c5b41c..b188a3503 100644 --- a/lib/live_view_native_swift_ui/modifiers/input_events/digital_crown_accessory_visibility.ex +++ b/lib/live_view_native_swift_ui/modifiers/input_events/digital_crown_accessory_visibility.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.DigitalCrownAccessoryVisibility do modifier_schema "digital_crown_accessory_visibility" do field :visibility, Ecto.Enum, values: ~w(automatic visible hidden)a end + + def params(visibility) when is_atom(visibility) and not is_boolean(visibility) and not is_nil(visibility), do: [visibility: visibility] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/input_events/hover_effect.ex b/lib/live_view_native_swift_ui/modifiers/input_events/hover_effect.ex index 071e91b38..21027a7fe 100644 --- a/lib/live_view_native_swift_ui/modifiers/input_events/hover_effect.ex +++ b/lib/live_view_native_swift_ui/modifiers/input_events/hover_effect.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.HoverEffect do modifier_schema "hover_effect" do field :effect, Ecto.Enum, values: ~w(automatic highlight lift)a, default: :automatic end + + def params(effect) when is_atom(effect) and not is_boolean(effect) and not is_nil(effect), do: [effect: effect] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/input_events/on_delete_command.ex b/lib/live_view_native_swift_ui/modifiers/input_events/on_delete_command.ex index eda8dfc54..326e98cee 100644 --- a/lib/live_view_native_swift_ui/modifiers/input_events/on_delete_command.ex +++ b/lib/live_view_native_swift_ui/modifiers/input_events/on_delete_command.ex @@ -1,9 +1,9 @@ defmodule LiveViewNativeSwiftUi.Modifiers.OnDeleteCommand do use LiveViewNativePlatform.Modifier - alias LiveViewNativeSwiftUi.Types.Event + alias LiveViewNativePlatform.Types.Event modifier_schema "on_delete_command" do - field :action, Event + field :perform, Event end end diff --git a/lib/live_view_native_swift_ui/modifiers/input_events/on_hover.ex b/lib/live_view_native_swift_ui/modifiers/input_events/on_hover.ex index 137495421..33fcf5bdf 100644 --- a/lib/live_view_native_swift_ui/modifiers/input_events/on_hover.ex +++ b/lib/live_view_native_swift_ui/modifiers/input_events/on_hover.ex @@ -1,9 +1,9 @@ defmodule LiveViewNativeSwiftUi.Modifiers.OnHover do use LiveViewNativePlatform.Modifier - alias LiveViewNativeSwiftUi.Types.Event + alias LiveViewNativePlatform.Types.Event modifier_schema "on_hover" do - field :action, Event + field :perform, Event end end diff --git a/lib/live_view_native_swift_ui/modifiers/input_events/on_move_command.ex b/lib/live_view_native_swift_ui/modifiers/input_events/on_move_command.ex index 82427728d..518e728ef 100644 --- a/lib/live_view_native_swift_ui/modifiers/input_events/on_move_command.ex +++ b/lib/live_view_native_swift_ui/modifiers/input_events/on_move_command.ex @@ -1,7 +1,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.OnMoveCommand do use LiveViewNativePlatform.Modifier - alias LiveViewNativeSwiftUi.Types.Event + alias LiveViewNativePlatform.Types.Event modifier_schema "on_move_command" do field :action, Event diff --git a/lib/live_view_native_swift_ui/modifiers/input_events/on_submit.ex b/lib/live_view_native_swift_ui/modifiers/input_events/on_submit.ex index 34ec05c92..0505e7673 100644 --- a/lib/live_view_native_swift_ui/modifiers/input_events/on_submit.ex +++ b/lib/live_view_native_swift_ui/modifiers/input_events/on_submit.ex @@ -2,10 +2,20 @@ defmodule LiveViewNativeSwiftUi.Modifiers.OnSubmit do use LiveViewNativePlatform.Modifier alias LiveViewNativeSwiftUi.Types.SubmitTriggers - alias LiveViewNativeSwiftUi.Types.Event + alias LiveViewNativePlatform.Types.Event modifier_schema "on_submit" do field :triggers, SubmitTriggers field :action, Event end + + def params([of: triggers], action), do: [triggers: triggers, action: action] + def params(params) do + with {:ok, _} <- Event.cast(params) do + [action: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/input_events/submit_scope.ex b/lib/live_view_native_swift_ui/modifiers/input_events/submit_scope.ex index 0168ccbd1..ec8454f53 100644 --- a/lib/live_view_native_swift_ui/modifiers/input_events/submit_scope.ex +++ b/lib/live_view_native_swift_ui/modifiers/input_events/submit_scope.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.SubmitScope do modifier_schema "submit_scope" do field :is_blocking, :boolean, default: true end + + def params(is_blocking) when is_boolean(is_blocking), do: [is_blocking: is_blocking] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/layout_adjustments/coordinate_space.ex b/lib/live_view_native_swift_ui/modifiers/layout_adjustments/coordinate_space.ex index 1e7b33d75..5baeaa88a 100644 --- a/lib/live_view_native_swift_ui/modifiers/layout_adjustments/coordinate_space.ex +++ b/lib/live_view_native_swift_ui/modifiers/layout_adjustments/coordinate_space.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.CoordinateSpace do modifier_schema "coordinate_space" do field :name, :string end + + def params(name) when is_binary(name), do: [name: name] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/layout_adjustments/ignores_safe_area.ex b/lib/live_view_native_swift_ui/modifiers/layout_adjustments/ignores_safe_area.ex index 4247a0b22..a0cf42153 100644 --- a/lib/live_view_native_swift_ui/modifiers/layout_adjustments/ignores_safe_area.ex +++ b/lib/live_view_native_swift_ui/modifiers/layout_adjustments/ignores_safe_area.ex @@ -7,5 +7,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.IgnoresSafeArea do field :regions, Ecto.Enum, values: ~w(all container keyboard)a, default: :all field :edges, EdgeSet end -end + def params(regions, [edges: edges]), do: [regions: regions, edges: edges] + def params(params), do: params +end diff --git a/lib/live_view_native_swift_ui/modifiers/lists/badge.ex b/lib/live_view_native_swift_ui/modifiers/lists/badge.ex index 94c210309..87931367b 100644 --- a/lib/live_view_native_swift_ui/modifiers/lists/badge.ex +++ b/lib/live_view_native_swift_ui/modifiers/lists/badge.ex @@ -8,4 +8,15 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Badge do field :label, :string field :count, :integer end + + def params(label) when is_binary(label), do: [label: label] + def params(count) when is_number(count), do: [count: count] + def params(params) do + with {:ok, _} <- KeyName.cast(params) do + [content: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/lists/delete_disabled.ex b/lib/live_view_native_swift_ui/modifiers/lists/delete_disabled.ex index ec1c116a3..e0b476e9e 100644 --- a/lib/live_view_native_swift_ui/modifiers/lists/delete_disabled.ex +++ b/lib/live_view_native_swift_ui/modifiers/lists/delete_disabled.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.DeleteDisabled do modifier_schema "delete_disabled" do field :is_disabled, :boolean end + + def params(is_disabled) when is_boolean(is_disabled), do: [is_disabled: is_disabled] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/lists/disclosure_group_style.ex b/lib/live_view_native_swift_ui/modifiers/lists/disclosure_group_style.ex index 4e988c3d7..55b13e48b 100644 --- a/lib/live_view_native_swift_ui/modifiers/lists/disclosure_group_style.ex +++ b/lib/live_view_native_swift_ui/modifiers/lists/disclosure_group_style.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.DisclosureGroupStyle do modifier_schema "disclosure_group_style" do field :style, Ecto.Enum, values: ~w(automatic)a end + + def params(style) when is_atom(style) and not is_boolean(style) and not is_nil(style), do: [style: style] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/lists/header_prominence.ex b/lib/live_view_native_swift_ui/modifiers/lists/header_prominence.ex index f942297b7..21952870f 100644 --- a/lib/live_view_native_swift_ui/modifiers/lists/header_prominence.ex +++ b/lib/live_view_native_swift_ui/modifiers/lists/header_prominence.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.HeaderProminence do modifier_schema "header_prominence" do field :prominence, Ecto.Enum, values: ~w(increased standard)a end -end \ No newline at end of file + + def params(prominence) when is_atom(prominence) and not is_boolean(prominence) and not is_nil(prominence), do: [prominence: prominence] + def params(params), do: params +end diff --git a/lib/live_view_native_swift_ui/modifiers/lists/list_item_tint.ex b/lib/live_view_native_swift_ui/modifiers/lists/list_item_tint.ex index 5db32efee..de1c7e053 100644 --- a/lib/live_view_native_swift_ui/modifiers/lists/list_item_tint.ex +++ b/lib/live_view_native_swift_ui/modifiers/lists/list_item_tint.ex @@ -6,4 +6,13 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ListItemTint do modifier_schema "list_item_tint" do field :tint, ListItemTint end + + def params(params) do + with {:ok, _} <- ListItemTint.cast(params) do + [tint: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/lists/list_row_background.ex b/lib/live_view_native_swift_ui/modifiers/lists/list_row_background.ex index 181585cb3..69a00e589 100644 --- a/lib/live_view_native_swift_ui/modifiers/lists/list_row_background.ex +++ b/lib/live_view_native_swift_ui/modifiers/lists/list_row_background.ex @@ -6,4 +6,13 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ListRowBackground do modifier_schema "list_row_background" do field :content, KeyName end + + def params(params) do + with {:ok, _} <- KeyName.cast(params) do + [content: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/lists/list_row_insets.ex b/lib/live_view_native_swift_ui/modifiers/lists/list_row_insets.ex index ccccdab02..310f053e0 100644 --- a/lib/live_view_native_swift_ui/modifiers/lists/list_row_insets.ex +++ b/lib/live_view_native_swift_ui/modifiers/lists/list_row_insets.ex @@ -6,4 +6,13 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ListRowInsets do modifier_schema "list_row_insets" do field :insets, EdgeInsets end + + def params(params) do + with {:ok, _} <- EdgeInsets.cast(params) do + [insets: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/lists/list_row_separator.ex b/lib/live_view_native_swift_ui/modifiers/lists/list_row_separator.ex index 5a93a0135..467ddb29b 100644 --- a/lib/live_view_native_swift_ui/modifiers/lists/list_row_separator.ex +++ b/lib/live_view_native_swift_ui/modifiers/lists/list_row_separator.ex @@ -3,6 +3,10 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ListRowSeparator do modifier_schema "list_row_separator" do field :visibility, Ecto.Enum, values: ~w(automatic visible hidden)a - field :edges, Ecto.Enum, values: ~w(all bottom top)a + field :edges, Ecto.Enum, values: ~w(all bottom top)a, default: :all end + + def params(visibility, [edges: edges]), do: [visibility: visibility, edges: edges] + def params(visibility) when is_atom(visibility) and not is_boolean(visibility) and not is_nil(visibility), do: [visibility: visibility] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/lists/list_row_separator_tint.ex b/lib/live_view_native_swift_ui/modifiers/lists/list_row_separator_tint.ex index 5d07eb1d1..75bace833 100644 --- a/lib/live_view_native_swift_ui/modifiers/lists/list_row_separator_tint.ex +++ b/lib/live_view_native_swift_ui/modifiers/lists/list_row_separator_tint.ex @@ -7,4 +7,14 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ListRowSeparatorTint do field :color, Color field :edges, Ecto.Enum, values: ~w(all bottom top)a, default: :all end + + def params(color, [edges: edges]), do: [color: color, edges: edges] + def params(params) do + with {:ok, _} <- Color.cast(params) do + [color: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/lists/list_section_separator.ex b/lib/live_view_native_swift_ui/modifiers/lists/list_section_separator.ex index 5edc212a0..39bb90e74 100644 --- a/lib/live_view_native_swift_ui/modifiers/lists/list_section_separator.ex +++ b/lib/live_view_native_swift_ui/modifiers/lists/list_section_separator.ex @@ -5,4 +5,8 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ListSectionSeparator do field :visibility, Ecto.Enum, values: ~w(automatic hidden visible)a field :edges, Ecto.Enum, values: ~w(all bottom top)a, default: :all end + + def params(visibility, [edges: edges]), do: [visibility: visibility, edges: edges] + def params(visibility) when is_atom(visibility) and not is_boolean(visibility) and not is_nil(visibility), do: [visibility: visibility] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/lists/list_section_separator_tint.ex b/lib/live_view_native_swift_ui/modifiers/lists/list_section_separator_tint.ex index be4b47e78..b72902e8c 100644 --- a/lib/live_view_native_swift_ui/modifiers/lists/list_section_separator_tint.ex +++ b/lib/live_view_native_swift_ui/modifiers/lists/list_section_separator_tint.ex @@ -7,4 +7,14 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ListSectionSeparatorTint do field :color, Color field :edges, Ecto.Enum, values: ~w(all bottom top)a, default: :all end + + def params(color, [edges: edges]), do: [color: color, edges: edges] + def params(params) do + with {:ok, _} <- Color.cast(params) do + [color: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/lists/list_style.ex b/lib/live_view_native_swift_ui/modifiers/lists/list_style.ex index 12357c24b..971e2471c 100644 --- a/lib/live_view_native_swift_ui/modifiers/lists/list_style.ex +++ b/lib/live_view_native_swift_ui/modifiers/lists/list_style.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ListStyle do modifier_schema "list_style" do field :style, Ecto.Enum, values: ~w(automatic bordered bordered_alternating carousel elliptical grouped inset inset_grouped inset_alternating plain sidebar)a end + + def params(style) when is_atom(style) and not is_boolean(style) and not is_nil(style), do: [style: style] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/lists/move_disabled.ex b/lib/live_view_native_swift_ui/modifiers/lists/move_disabled.ex index 301a5c497..11e0ae37a 100644 --- a/lib/live_view_native_swift_ui/modifiers/lists/move_disabled.ex +++ b/lib/live_view_native_swift_ui/modifiers/lists/move_disabled.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.MoveDisabled do modifier_schema "move_disabled" do field :is_disabled, :boolean end + + def params(is_disabled) when is_boolean(is_disabled), do: [is_disabled: is_disabled] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/lists/refreshable.ex b/lib/live_view_native_swift_ui/modifiers/lists/refreshable.ex index 82fd03395..af78d39c4 100644 --- a/lib/live_view_native_swift_ui/modifiers/lists/refreshable.ex +++ b/lib/live_view_native_swift_ui/modifiers/lists/refreshable.ex @@ -1,7 +1,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Refreshable do use LiveViewNativePlatform.Modifier - alias LiveViewNativeSwiftUi.Types.Event + alias LiveViewNativePlatform.Types.Event modifier_schema "refreshable" do field :action, Event diff --git a/lib/live_view_native_swift_ui/modifiers/menus_and_commands/menu_action_dismiss_behavior.ex b/lib/live_view_native_swift_ui/modifiers/menus_and_commands/menu_action_dismiss_behavior.ex index cb4cc9020..f786051d1 100644 --- a/lib/live_view_native_swift_ui/modifiers/menus_and_commands/menu_action_dismiss_behavior.ex +++ b/lib/live_view_native_swift_ui/modifiers/menus_and_commands/menu_action_dismiss_behavior.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.MenuActionDismissBehavior do modifier_schema "menu_action_dismiss_behavior" do field(:behavior, Ecto.Enum, values: ~w(automatic enabled disabled)a) end + + def params(behavior) when is_atom(behavior) and not is_boolean(behavior) and not is_nil(behavior), do: [behavior: behavior] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/menus_and_commands/menu_indicator_visibility.ex b/lib/live_view_native_swift_ui/modifiers/menus_and_commands/menu_indicator_visibility.ex index ace2b15ec..3a3b9b8be 100644 --- a/lib/live_view_native_swift_ui/modifiers/menus_and_commands/menu_indicator_visibility.ex +++ b/lib/live_view_native_swift_ui/modifiers/menus_and_commands/menu_indicator_visibility.ex @@ -1,7 +1,10 @@ defmodule LiveViewNativeSwiftUi.Modifiers.MenuIndicatorVisibility do use LiveViewNativePlatform.Modifier - modifier_schema "menu_indicator_visibility" do + modifier_schema "menu_indicator" do field(:visibility, Ecto.Enum, values: ~w(automatic hidden visible)a) end + + def params(visibility) when is_atom(visibility) and not is_boolean(visibility) and not is_nil(visibility), do: [visibility: visibility] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/menus_and_commands/menu_order.ex b/lib/live_view_native_swift_ui/modifiers/menus_and_commands/menu_order.ex index 873df7363..e60b3fd21 100644 --- a/lib/live_view_native_swift_ui/modifiers/menus_and_commands/menu_order.ex +++ b/lib/live_view_native_swift_ui/modifiers/menus_and_commands/menu_order.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.MenuOrder do modifier_schema "menu_order" do field(:order, Ecto.Enum, values: ~w(automatic fixed priority)a) end + + def params(order) when is_atom(order) and not is_boolean(order) and not is_nil(order), do: [order: order] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/menus_and_commands/menu_style.ex b/lib/live_view_native_swift_ui/modifiers/menus_and_commands/menu_style.ex index afa3a00c2..c149ba841 100644 --- a/lib/live_view_native_swift_ui/modifiers/menus_and_commands/menu_style.ex +++ b/lib/live_view_native_swift_ui/modifiers/menus_and_commands/menu_style.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.MenuStyle do modifier_schema "menu_style" do field(:style, Ecto.Enum, values: ~w(automatic button)a) end + + def params(style) when is_atom(style) and not is_boolean(style) and not is_nil(style), do: [style: style] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/keyboard_shortcut.ex b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/keyboard_shortcut.ex index f1d0e558f..79ba38c9b 100644 --- a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/keyboard_shortcut.ex +++ b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/keyboard_shortcut.ex @@ -1,7 +1,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.KeyboardShortcut do use LiveViewNativePlatform.Modifier - alias LiveViewNativeSwiftUi.Types.EventModifier + alias LiveViewNativePlatform.Types.EventModifier alias LiveViewNativeSwiftUi.Types.KeyEquivalent modifier_schema "keyboard_shortcut" do diff --git a/lib/live_view_native_swift_ui/modifiers/view_fundamentals/on_appear.ex b/lib/live_view_native_swift_ui/modifiers/view_fundamentals/on_appear.ex index f41f0b439..df9911eca 100644 --- a/lib/live_view_native_swift_ui/modifiers/view_fundamentals/on_appear.ex +++ b/lib/live_view_native_swift_ui/modifiers/view_fundamentals/on_appear.ex @@ -1,7 +1,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.OnAppear do use LiveViewNativePlatform.Modifier - - alias LiveViewNativeSwiftUi.Types.Event + + alias LiveViewNativePlatform.Types.Event modifier_schema "on_appear" do field :action, Event diff --git a/lib/live_view_native_swift_ui/modifiers/view_fundamentals/on_disappear.ex b/lib/live_view_native_swift_ui/modifiers/view_fundamentals/on_disappear.ex index 787878284..4bf434b9e 100644 --- a/lib/live_view_native_swift_ui/modifiers/view_fundamentals/on_disappear.ex +++ b/lib/live_view_native_swift_ui/modifiers/view_fundamentals/on_disappear.ex @@ -1,7 +1,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.OnDisappear do use LiveViewNativePlatform.Modifier - - alias LiveViewNativeSwiftUi.Types.Event + + alias LiveViewNativePlatform.Types.Event modifier_schema "on_disappear" do field :action, Event diff --git a/lib/live_view_native_swift_ui/types/event.ex b/lib/live_view_native_swift_ui/types/event.ex deleted file mode 100644 index bada53422..000000000 --- a/lib/live_view_native_swift_ui/types/event.ex +++ /dev/null @@ -1,20 +0,0 @@ -defmodule LiveViewNativeSwiftUi.Types.Event do - @derive Jason.Encoder - defstruct [:event, :type, :params, :target, :debounce, :throttle] - - use LiveViewNativePlatform.Modifier.Type - def type, do: :map - - def cast(nil), do: {:ok, nil} - def cast(event) when is_bitstring(event), do: {:ok, %__MODULE__{event: event}} - - def cast(value) when is_map(value) do - value = - value - |> Map.update(:params, Jason.encode!(Map.new()), fn params -> Jason.encode!(params) end) - - {:ok, struct(__MODULE__, value)} - end - - def cast(_), do: :error -end diff --git a/lib/live_view_native_swift_ui/types/event_modifier.ex b/lib/live_view_native_swift_ui/types/event_modifier.ex index c9908b06a..b43925b39 100644 --- a/lib/live_view_native_swift_ui/types/event_modifier.ex +++ b/lib/live_view_native_swift_ui/types/event_modifier.ex @@ -1,4 +1,4 @@ -defmodule LiveViewNativeSwiftUi.Types.EventModifier do +defmodule LiveViewNativePlatform.Types.EventModifier do use LiveViewNativePlatform.Modifier.Type def type, do: {:array, :string} From fa7d157fb0970d7f44c288a1ef5580c4e384a165 Mon Sep 17 00:00:00 2001 From: Carson Katri Date: Tue, 22 Aug 2023 16:15:33 -0400 Subject: [PATCH 08/13] Add more `params` impls --- .../HiddenModifier.swift | 21 +++--------------- .../OnAppearModifier.swift | 8 +++---- .../OnDisappearModifier.swift | 8 +++---- .../modifiers/documents/rename_action.ex | 2 +- .../drag_and_drop/drop_destination.ex | 2 +- .../modifiers/gestures/gesture.ex | 2 +- .../input_events/on_delete_command.ex | 2 +- .../modifiers/input_events/on_hover.ex | 2 +- .../modifiers/input_events/on_move_command.ex | 2 +- .../modifiers/input_events/on_submit.ex | 2 +- .../modifiers/lists/refreshable.ex | 2 +- .../modifiers/modal_presentations/alert.ex | 3 +++ .../confirmation_dialog.ex | 3 +++ .../modal_presentations/full_screen_cover.ex | 3 ++- .../interactive_dismiss_disabled.ex | 3 +++ .../presentation_background.ex | 3 +++ .../presentation_background_interaction.ex | 4 ++++ .../presentation_content_interaction.ex | 3 +++ .../presentation_corner_radius.ex | 3 +++ .../presentation_detents.ex | 11 ++++++++++ .../presentation_drag_indicator.ex | 3 +++ .../modifiers/modal_presentations/sheet.ex | 3 ++- .../navigation_bar_back_button_hidden.ex | 4 +++- .../navigation_bar_title_display_mode.ex | 3 +++ .../navigation/navigation_subtitle.ex | 3 +++ .../modifiers/navigation/navigation_title.ex | 3 +++ .../modifiers/navigation/tab_item.ex | 9 ++++++++ .../modifiers/navigation/tab_view_style.ex | 3 +++ .../scroll_views/scroll_bounce_behavior.ex | 4 ++++ .../scroll_views/scroll_content_background.ex | 2 ++ .../modifiers/scroll_views/scroll_disabled.ex | 3 +++ .../scroll_views/scroll_dismisses_keyboard.ex | 3 +++ .../scroll_views/scroll_indicators.ex | 4 ++++ .../modifiers/search/find_disabled.ex | 3 +++ .../modifiers/search/replace_disabled.ex | 2 ++ .../modifiers/search/search_completion.ex | 4 ++++ .../modifiers/search/search_scopes.ex | 3 +++ .../modifiers/search/search_suggestions.ex | 9 ++++++++ .../modifiers/shape/fill.ex | 10 +++++++++ .../modifiers/shape/inset.ex | 3 +++ .../modifiers/shape/rotation.ex | 10 +++++++++ .../modifiers/shape/stroke.ex | 10 +++++++++ .../modifiers/shape/stroke_border.ex | 10 +++++++++ .../modifiers/shape/trim.ex | 3 +++ .../modifiers/shapes/container_shape.ex | 9 ++++++++ .../modifiers/tables/table_style.ex | 3 +++ .../autocorrection_disabled.ex | 3 +++ .../text_input_and_output/baseline_offset.ex | 3 +++ ...lips_for_right_to_left_layout_direction.ex | 3 +++ .../modifiers/text_input_and_output/font.ex | 9 ++++++++ .../text_input_and_output/font_width.ex | 9 ++++++++ .../keyboard_shortcut.ex | 12 +++++++++- .../text_input_and_output/keyboard_type.ex | 3 +++ .../text_input_and_output/label_style.ex | 3 +++ .../text_input_and_output/line_limit.ex | 3 +++ .../minimum_scale_factor.ex | 4 +++- .../privacy_sensitive.ex | 3 +++ .../text_input_and_output/strikethrough.ex | 4 ++++ .../text_input_and_output/submit_label.ex | 2 ++ .../text_content_type.ex | 3 +++ .../text_input_and_output/text_field_style.ex | 3 +++ .../text_input_autocapitalization.ex | 3 +++ .../text_input_and_output/text_selection.ex | 3 +++ .../text_input_and_output/truncation_mode.ex | 3 +++ .../text_input_and_output/underline.ex | 4 ++++ .../modifiers/toolbar/toolbar_background.ex | 4 ++++ .../modifiers/toolbar/toolbar_color_scheme.ex | 3 +++ .../modifiers/toolbar/toolbar_role.ex | 3 +++ .../modifiers/toolbar/toolbar_visibility.ex | 3 +++ .../modifiers/view_configuration/help.ex | 3 +++ .../modifiers/view_configuration/hidden.ex | 7 +----- .../persistent_system_overlays.ex | 3 +++ .../view_configuration/status_bar_hidden.ex | 3 +++ .../modifiers/view_fundamentals/on_appear.ex | 4 ++-- .../view_fundamentals/on_disappear.ex | 4 ++-- .../view_groupings/control_group_style.ex | 3 +++ .../view_groupings/group_box_style.ex | 3 +++ .../modifiers/view_styles/content_shape.ex | 22 +++++++++++++++++++ .../modifiers/view_styles/index_view_style.ex | 3 +++ .../types/event_modifier.ex | 2 +- 80 files changed, 315 insertions(+), 50 deletions(-) diff --git a/Sources/LiveViewNative/Modifiers/View Configuration Modifiers/HiddenModifier.swift b/Sources/LiveViewNative/Modifiers/View Configuration Modifiers/HiddenModifier.swift index 140793993..5f799b831 100644 --- a/Sources/LiveViewNative/Modifiers/View Configuration Modifiers/HiddenModifier.swift +++ b/Sources/LiveViewNative/Modifiers/View Configuration Modifiers/HiddenModifier.swift @@ -10,28 +10,13 @@ import SwiftUI /// Hides any element. /// /// ```html -/// -/// This text is hidden -/// This text is visible -/// -/// -/// ## Arguments -/// * ``isActive`` +/// This text is hidden +/// ``` #if swift(>=5.8) @_documentation(visibility: public) #endif struct HiddenModifier: ViewModifier, Decodable { - /// A boolean indicating whether the view should be hidden. - #if swift(>=5.8) - @_documentation(visibility: public) - #endif - private var isActive: Bool - func body(content: Content) -> some View { - if isActive { - content.hidden() - } else { - content - } + content.hidden() } } diff --git a/Sources/LiveViewNative/Modifiers/View Fundamentals Modifiers/OnAppearModifier.swift b/Sources/LiveViewNative/Modifiers/View Fundamentals Modifiers/OnAppearModifier.swift index e98d96700..8dfcb4305 100644 --- a/Sources/LiveViewNative/Modifiers/View Fundamentals Modifiers/OnAppearModifier.swift +++ b/Sources/LiveViewNative/Modifiers/View Fundamentals Modifiers/OnAppearModifier.swift @@ -25,21 +25,21 @@ struct OnAppearModifier: ViewModifier, Decodable { #if swift(>=5.8) @_documentation(visibility: public) #endif - @Event private var action: Event.EventHandler + @Event private var perform: Event.EventHandler init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - self._action = try container.decode(Event.self, forKey: .action) + self._perform = try container.decode(Event.self, forKey: .perform) } func body(content: Content) -> some View { content.onAppear { - self.action() + self.perform() } } enum CodingKeys: String, CodingKey { - case action + case perform } } diff --git a/Sources/LiveViewNative/Modifiers/View Fundamentals Modifiers/OnDisappearModifier.swift b/Sources/LiveViewNative/Modifiers/View Fundamentals Modifiers/OnDisappearModifier.swift index 43a9a505b..3462de9f8 100644 --- a/Sources/LiveViewNative/Modifiers/View Fundamentals Modifiers/OnDisappearModifier.swift +++ b/Sources/LiveViewNative/Modifiers/View Fundamentals Modifiers/OnDisappearModifier.swift @@ -25,21 +25,21 @@ struct OnDisappearModifier: ViewModifier, Decodable { #if swift(>=5.8) @_documentation(visibility: public) #endif - @Event private var action: Event.EventHandler + @Event private var perform: Event.EventHandler init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - self._action = try container.decode(Event.self, forKey: .action) + self._perform = try container.decode(Event.self, forKey: .perform) } func body(content: Content) -> some View { content.onDisappear { - self.action() + self.perform() } } enum CodingKeys: String, CodingKey { - case action + case perform } } diff --git a/lib/live_view_native_swift_ui/modifiers/documents/rename_action.ex b/lib/live_view_native_swift_ui/modifiers/documents/rename_action.ex index f62b2563e..1a4d249d3 100644 --- a/lib/live_view_native_swift_ui/modifiers/documents/rename_action.ex +++ b/lib/live_view_native_swift_ui/modifiers/documents/rename_action.ex @@ -1,7 +1,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.RenameAction do use LiveViewNativePlatform.Modifier - alias LiveViewNativePlatform.Types.Event + alias LiveViewNativePlatform.Modifier.Types.Event modifier_schema "rename_action" do field :action, Event diff --git a/lib/live_view_native_swift_ui/modifiers/drag_and_drop/drop_destination.ex b/lib/live_view_native_swift_ui/modifiers/drag_and_drop/drop_destination.ex index 6ad3a9b2e..691b31b9b 100644 --- a/lib/live_view_native_swift_ui/modifiers/drag_and_drop/drop_destination.ex +++ b/lib/live_view_native_swift_ui/modifiers/drag_and_drop/drop_destination.ex @@ -1,7 +1,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.DropDestination do use LiveViewNativePlatform.Modifier - alias LiveViewNativePlatform.Types.Event + alias LiveViewNativePlatform.Modifier.Types.Event modifier_schema "drop_destination" do field :action, Event diff --git a/lib/live_view_native_swift_ui/modifiers/gestures/gesture.ex b/lib/live_view_native_swift_ui/modifiers/gestures/gesture.ex index e068f7d06..7d2a8065d 100644 --- a/lib/live_view_native_swift_ui/modifiers/gestures/gesture.ex +++ b/lib/live_view_native_swift_ui/modifiers/gestures/gesture.ex @@ -2,7 +2,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.OnTapGesture do use LiveViewNativePlatform.Modifier alias LiveViewNativeSwiftUi.Types.Gesture - alias LiveViewNativePlatform.Types.Event + alias LiveViewNativePlatform.Modifier.Types.Event modifier_schema "gesture" do field :gesture, Gesture diff --git a/lib/live_view_native_swift_ui/modifiers/input_events/on_delete_command.ex b/lib/live_view_native_swift_ui/modifiers/input_events/on_delete_command.ex index 326e98cee..e0ee7eb3f 100644 --- a/lib/live_view_native_swift_ui/modifiers/input_events/on_delete_command.ex +++ b/lib/live_view_native_swift_ui/modifiers/input_events/on_delete_command.ex @@ -1,7 +1,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.OnDeleteCommand do use LiveViewNativePlatform.Modifier - alias LiveViewNativePlatform.Types.Event + alias LiveViewNativePlatform.Modifier.Types.Event modifier_schema "on_delete_command" do field :perform, Event diff --git a/lib/live_view_native_swift_ui/modifiers/input_events/on_hover.ex b/lib/live_view_native_swift_ui/modifiers/input_events/on_hover.ex index 33fcf5bdf..ee322249b 100644 --- a/lib/live_view_native_swift_ui/modifiers/input_events/on_hover.ex +++ b/lib/live_view_native_swift_ui/modifiers/input_events/on_hover.ex @@ -1,7 +1,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.OnHover do use LiveViewNativePlatform.Modifier - alias LiveViewNativePlatform.Types.Event + alias LiveViewNativePlatform.Modifier.Types.Event modifier_schema "on_hover" do field :perform, Event diff --git a/lib/live_view_native_swift_ui/modifiers/input_events/on_move_command.ex b/lib/live_view_native_swift_ui/modifiers/input_events/on_move_command.ex index 518e728ef..b6efe4db1 100644 --- a/lib/live_view_native_swift_ui/modifiers/input_events/on_move_command.ex +++ b/lib/live_view_native_swift_ui/modifiers/input_events/on_move_command.ex @@ -1,7 +1,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.OnMoveCommand do use LiveViewNativePlatform.Modifier - alias LiveViewNativePlatform.Types.Event + alias LiveViewNativePlatform.Modifier.Types.Event modifier_schema "on_move_command" do field :action, Event diff --git a/lib/live_view_native_swift_ui/modifiers/input_events/on_submit.ex b/lib/live_view_native_swift_ui/modifiers/input_events/on_submit.ex index 0505e7673..dcbc4de16 100644 --- a/lib/live_view_native_swift_ui/modifiers/input_events/on_submit.ex +++ b/lib/live_view_native_swift_ui/modifiers/input_events/on_submit.ex @@ -2,7 +2,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.OnSubmit do use LiveViewNativePlatform.Modifier alias LiveViewNativeSwiftUi.Types.SubmitTriggers - alias LiveViewNativePlatform.Types.Event + alias LiveViewNativePlatform.Modifier.Types.Event modifier_schema "on_submit" do field :triggers, SubmitTriggers diff --git a/lib/live_view_native_swift_ui/modifiers/lists/refreshable.ex b/lib/live_view_native_swift_ui/modifiers/lists/refreshable.ex index af78d39c4..98590e9e8 100644 --- a/lib/live_view_native_swift_ui/modifiers/lists/refreshable.ex +++ b/lib/live_view_native_swift_ui/modifiers/lists/refreshable.ex @@ -1,7 +1,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Refreshable do use LiveViewNativePlatform.Modifier - alias LiveViewNativePlatform.Types.Event + alias LiveViewNativePlatform.Modifier.Types.Event modifier_schema "refreshable" do field :action, Event diff --git a/lib/live_view_native_swift_ui/modifiers/modal_presentations/alert.ex b/lib/live_view_native_swift_ui/modifiers/modal_presentations/alert.ex index e332dcd56..556e2104d 100644 --- a/lib/live_view_native_swift_ui/modifiers/modal_presentations/alert.ex +++ b/lib/live_view_native_swift_ui/modifiers/modal_presentations/alert.ex @@ -11,4 +11,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Alert do change_event() end + + def params(title, params) when is_binary(title) and is_list(params), do: [{:title, title} | params] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/modal_presentations/confirmation_dialog.ex b/lib/live_view_native_swift_ui/modifiers/modal_presentations/confirmation_dialog.ex index e1e40b32c..e5c4894ed 100644 --- a/lib/live_view_native_swift_ui/modifiers/modal_presentations/confirmation_dialog.ex +++ b/lib/live_view_native_swift_ui/modifiers/modal_presentations/confirmation_dialog.ex @@ -14,4 +14,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ConfirmationDialog do change_event() end + + def params(title, params) when is_binary(title) and is_list(params), do: [{:title, title} | params] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/modal_presentations/full_screen_cover.ex b/lib/live_view_native_swift_ui/modifiers/modal_presentations/full_screen_cover.ex index efb4ab40c..0fa89f8e6 100644 --- a/lib/live_view_native_swift_ui/modifiers/modal_presentations/full_screen_cover.ex +++ b/lib/live_view_native_swift_ui/modifiers/modal_presentations/full_screen_cover.ex @@ -1,7 +1,8 @@ defmodule LiveViewNativeSwiftUi.Modifiers.FullScreenCover do use LiveViewNativePlatform.Modifier - alias LiveViewNativeSwiftUi.Types.{Event, KeyName} + alias LiveViewNativeSwiftUi.Types.KeyName + alias LiveViewNativePlatform.Modifier.Types.Event modifier_schema "full_screen_cover" do field(:is_presented, :boolean) diff --git a/lib/live_view_native_swift_ui/modifiers/modal_presentations/interactive_dismiss_disabled.ex b/lib/live_view_native_swift_ui/modifiers/modal_presentations/interactive_dismiss_disabled.ex index 1d974b7d0..62e7555ed 100644 --- a/lib/live_view_native_swift_ui/modifiers/modal_presentations/interactive_dismiss_disabled.ex +++ b/lib/live_view_native_swift_ui/modifiers/modal_presentations/interactive_dismiss_disabled.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.InteractiveDismissDisabled do modifier_schema "interactive_dismiss_disabled" do field(:disabled, :boolean, default: true) end + + def params(disabled) when is_boolean(disabled), do: [disabled: disabled] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/modal_presentations/presentation_background.ex b/lib/live_view_native_swift_ui/modifiers/modal_presentations/presentation_background.ex index 53d3262fe..ce416f0aa 100644 --- a/lib/live_view_native_swift_ui/modifiers/modal_presentations/presentation_background.ex +++ b/lib/live_view_native_swift_ui/modifiers/modal_presentations/presentation_background.ex @@ -25,4 +25,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.PresentationBackground do field(:content, KeyName, default: nil) end + + def params(style) when is_atom(style) and not is_boolean(style) and not is_nil(style), do: [style: style] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/modal_presentations/presentation_background_interaction.ex b/lib/live_view_native_swift_ui/modifiers/modal_presentations/presentation_background_interaction.ex index 4b91e4e3d..3b468ccb4 100644 --- a/lib/live_view_native_swift_ui/modifiers/modal_presentations/presentation_background_interaction.ex +++ b/lib/live_view_native_swift_ui/modifiers/modal_presentations/presentation_background_interaction.ex @@ -7,4 +7,8 @@ defmodule LiveViewNativeSwiftUi.Modifiers.PresentationBackgroundInteraction do field(:mode, Ecto.Enum, values: ~w(automatic disabled enabled)a) field(:maximum_detent, PresentationDetent, default: nil) end + + def params(mode) when is_atom(mode) and not is_boolean(mode) and not is_nil(mode), do: [mode: mode] + def params({:enabled = mode, [up_through: maximum_detent]}), do: [mode: mode, maximum_detent: maximum_detent] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/modal_presentations/presentation_content_interaction.ex b/lib/live_view_native_swift_ui/modifiers/modal_presentations/presentation_content_interaction.ex index 7c9926e2f..012a30112 100644 --- a/lib/live_view_native_swift_ui/modifiers/modal_presentations/presentation_content_interaction.ex +++ b/lib/live_view_native_swift_ui/modifiers/modal_presentations/presentation_content_interaction.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.PresentationContentInteraction do modifier_schema "presentation_content_interaction" do field(:interaction, Ecto.Enum, values: ~w(automatic resizes scrolls)a) end + + def params(interaction) when is_atom(interaction) and not is_boolean(interaction) and not is_nil(interaction), do: [interaction: interaction] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/modal_presentations/presentation_corner_radius.ex b/lib/live_view_native_swift_ui/modifiers/modal_presentations/presentation_corner_radius.ex index c76cf409d..5ae8d50a3 100644 --- a/lib/live_view_native_swift_ui/modifiers/modal_presentations/presentation_corner_radius.ex +++ b/lib/live_view_native_swift_ui/modifiers/modal_presentations/presentation_corner_radius.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.PresentationCornerRadius do modifier_schema "presentation_corner_radius" do field(:radius, :float) end + + def params(radius) when is_number(radius), do: [radius: radius] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/modal_presentations/presentation_detents.ex b/lib/live_view_native_swift_ui/modifiers/modal_presentations/presentation_detents.ex index 68a5ca209..6c0fb6916 100644 --- a/lib/live_view_native_swift_ui/modifiers/modal_presentations/presentation_detents.ex +++ b/lib/live_view_native_swift_ui/modifiers/modal_presentations/presentation_detents.ex @@ -9,4 +9,15 @@ defmodule LiveViewNativeSwiftUi.Modifiers.PresentationDetents do change_event() end + + def params(detents, [selection: selection]), do: [detents: detents, selection: selection] + def params([detent | _] = params) do + with {:ok, _} <- PresentationDetent.cast(detent) do + [detents: params] + else + _ -> + params + end + end + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/modal_presentations/presentation_drag_indicator.ex b/lib/live_view_native_swift_ui/modifiers/modal_presentations/presentation_drag_indicator.ex index 99307c7df..7f964876d 100644 --- a/lib/live_view_native_swift_ui/modifiers/modal_presentations/presentation_drag_indicator.ex +++ b/lib/live_view_native_swift_ui/modifiers/modal_presentations/presentation_drag_indicator.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.PresentationDragIndicator do modifier_schema "presentation_drag_indicator" do field(:visibility, Ecto.Enum, values: ~w(automatic visible hidden)a) end + + def params(visibility) when is_atom(visibility) and not is_boolean(visibility) and not is_nil(visibility), do: [visibility: visibility] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/modal_presentations/sheet.ex b/lib/live_view_native_swift_ui/modifiers/modal_presentations/sheet.ex index bf2a1b206..961a6f088 100644 --- a/lib/live_view_native_swift_ui/modifiers/modal_presentations/sheet.ex +++ b/lib/live_view_native_swift_ui/modifiers/modal_presentations/sheet.ex @@ -1,7 +1,8 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Sheet do use LiveViewNativePlatform.Modifier - alias LiveViewNativeSwiftUi.Types.{Event, KeyName} + alias LiveViewNativeSwiftUi.Types.KeyName + alias LiveViewNativePlatform.Modifier.Types.Event modifier_schema "sheet" do field(:is_presented, :boolean) diff --git a/lib/live_view_native_swift_ui/modifiers/navigation/navigation_bar_back_button_hidden.ex b/lib/live_view_native_swift_ui/modifiers/navigation/navigation_bar_back_button_hidden.ex index ca6c59241..5ca1d5127 100644 --- a/lib/live_view_native_swift_ui/modifiers/navigation/navigation_bar_back_button_hidden.ex +++ b/lib/live_view_native_swift_ui/modifiers/navigation/navigation_bar_back_button_hidden.ex @@ -4,5 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.NavigationBarBackButtonHidden do modifier_schema "navigation_bar_back_button_hidden" do field :hides_back_button, :boolean, default: true end -end + def params(hides_back_button) when is_boolean(hides_back_button), do: [hides_back_button: hides_back_button] + def params(params), do: params +end diff --git a/lib/live_view_native_swift_ui/modifiers/navigation/navigation_bar_title_display_mode.ex b/lib/live_view_native_swift_ui/modifiers/navigation/navigation_bar_title_display_mode.ex index f718696ed..439040e3e 100644 --- a/lib/live_view_native_swift_ui/modifiers/navigation/navigation_bar_title_display_mode.ex +++ b/lib/live_view_native_swift_ui/modifiers/navigation/navigation_bar_title_display_mode.ex @@ -8,4 +8,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.NavigationBarTitleDisplayMode do large )a) end + + def params(display_mode) when is_atom(display_mode) and not is_boolean(display_mode) and not is_nil(display_mode), do: [display_mode: display_mode] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/navigation/navigation_subtitle.ex b/lib/live_view_native_swift_ui/modifiers/navigation/navigation_subtitle.ex index b04c5c945..52a16a1f7 100644 --- a/lib/live_view_native_swift_ui/modifiers/navigation/navigation_subtitle.ex +++ b/lib/live_view_native_swift_ui/modifiers/navigation/navigation_subtitle.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.NavigationSubtitle do modifier_schema "navigation_subtitle" do field :subtitle, :string end + + def params(subtitle) when is_binary(subtitle), do: [subtitle: subtitle] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/navigation/navigation_title.ex b/lib/live_view_native_swift_ui/modifiers/navigation/navigation_title.ex index 5c9e80ff0..fb4708f0b 100644 --- a/lib/live_view_native_swift_ui/modifiers/navigation/navigation_title.ex +++ b/lib/live_view_native_swift_ui/modifiers/navigation/navigation_title.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.NavigationTitle do modifier_schema "navigation_title" do field :title, :string end + + def params(title) when is_binary(title), do: [title: title] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/navigation/tab_item.ex b/lib/live_view_native_swift_ui/modifiers/navigation/tab_item.ex index e57d6d990..b8f476188 100644 --- a/lib/live_view_native_swift_ui/modifiers/navigation/tab_item.ex +++ b/lib/live_view_native_swift_ui/modifiers/navigation/tab_item.ex @@ -6,4 +6,13 @@ defmodule LiveViewNativeSwiftUi.Modifiers.TabItem do modifier_schema "tab_item" do field :label, KeyName end + + def params(params) do + with {:ok, _} <- KeyName.cast(params) do + [label: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/navigation/tab_view_style.ex b/lib/live_view_native_swift_ui/modifiers/navigation/tab_view_style.ex index 7cc2729f8..559688901 100644 --- a/lib/live_view_native_swift_ui/modifiers/navigation/tab_view_style.ex +++ b/lib/live_view_native_swift_ui/modifiers/navigation/tab_view_style.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.TabViewStyle do modifier_schema "tab_view_style" do field :style, Ecto.Enum, values: ~w(automatic carousel page page_always page_never)a end + + def params(style) when is_atom(style) and not is_boolean(style) and not is_nil(style), do: [style: style] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/scroll_views/scroll_bounce_behavior.ex b/lib/live_view_native_swift_ui/modifiers/scroll_views/scroll_bounce_behavior.ex index 3d7faa7b0..d3f53517b 100644 --- a/lib/live_view_native_swift_ui/modifiers/scroll_views/scroll_bounce_behavior.ex +++ b/lib/live_view_native_swift_ui/modifiers/scroll_views/scroll_bounce_behavior.ex @@ -5,4 +5,8 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ScrollBounceBehavior do field :behavior, Ecto.Enum, values: ~w(automatic always based_on_size)a field :axes, Ecto.Enum, values: [:horizontal, :vertical, :all], default: :vertical end + + def params(behavior, params) when is_list(params), do: [{:behavior, behavior} | params] + def params(behavior) when is_atom(behavior) and not is_boolean(behavior) and not is_nil(behavior), do: [behavior: behavior] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/scroll_views/scroll_content_background.ex b/lib/live_view_native_swift_ui/modifiers/scroll_views/scroll_content_background.ex index 65cec9175..1701fa6d5 100644 --- a/lib/live_view_native_swift_ui/modifiers/scroll_views/scroll_content_background.ex +++ b/lib/live_view_native_swift_ui/modifiers/scroll_views/scroll_content_background.ex @@ -4,4 +4,6 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ScrollContentBackground do modifier_schema "scroll_content_background" do field :visibility, Ecto.Enum, values: ~w(automatic visible hidden)a end + + def params(visibility) when is_atom(visibility) and not is_boolean(visibility) and not is_nil(visibility), do: [visibility: visibility] end diff --git a/lib/live_view_native_swift_ui/modifiers/scroll_views/scroll_disabled.ex b/lib/live_view_native_swift_ui/modifiers/scroll_views/scroll_disabled.ex index fd5dfb035..027cd3503 100644 --- a/lib/live_view_native_swift_ui/modifiers/scroll_views/scroll_disabled.ex +++ b/lib/live_view_native_swift_ui/modifiers/scroll_views/scroll_disabled.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ScrollDisabled do modifier_schema "scroll_disabled" do field :disabled, :boolean end + + def params(disabled) when is_boolean(disabled), do: [disabled: disabled] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/scroll_views/scroll_dismisses_keyboard.ex b/lib/live_view_native_swift_ui/modifiers/scroll_views/scroll_dismisses_keyboard.ex index 9c19e8eb6..2dcd78e43 100644 --- a/lib/live_view_native_swift_ui/modifiers/scroll_views/scroll_dismisses_keyboard.ex +++ b/lib/live_view_native_swift_ui/modifiers/scroll_views/scroll_dismisses_keyboard.ex @@ -9,4 +9,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ScrollDismissesKeyboard do never )a end + + def params(mode) when is_atom(mode) and not is_boolean(mode) and not is_nil(mode), do: [mode: mode] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/scroll_views/scroll_indicators.ex b/lib/live_view_native_swift_ui/modifiers/scroll_views/scroll_indicators.ex index 7fcdcb162..0f53193a9 100644 --- a/lib/live_view_native_swift_ui/modifiers/scroll_views/scroll_indicators.ex +++ b/lib/live_view_native_swift_ui/modifiers/scroll_views/scroll_indicators.ex @@ -5,4 +5,8 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ScrollIndicators do field :visibility, Ecto.Enum, values: ~w(automatic hidden never visible)a field :axes, Ecto.Enum, values: [:horizontal, :vertical, :all], default: :all end + + def params(visibility, params) when is_list(params), do: [{:visibility, visibility} | params] + def params(visibility) when is_atom(visibility) and not is_boolean(visibility) and not is_nil(visibility), do: [visibility: visibility] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/search/find_disabled.ex b/lib/live_view_native_swift_ui/modifiers/search/find_disabled.ex index eeaddb6a2..428fa1b39 100644 --- a/lib/live_view_native_swift_ui/modifiers/search/find_disabled.ex +++ b/lib/live_view_native_swift_ui/modifiers/search/find_disabled.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.FindDisabled do modifier_schema "find_disabled" do field :disabled, :boolean, default: true end + + def params(disabled) when is_boolean(disabled), do: [disabled: disabled] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/search/replace_disabled.ex b/lib/live_view_native_swift_ui/modifiers/search/replace_disabled.ex index e13b76a0e..c71943a27 100644 --- a/lib/live_view_native_swift_ui/modifiers/search/replace_disabled.ex +++ b/lib/live_view_native_swift_ui/modifiers/search/replace_disabled.ex @@ -4,4 +4,6 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ReplaceDisabled do modifier_schema "replace_disabled" do field :disabled, :boolean, default: true end + + def params(disabled) when is_boolean(disabled), do: [disabled: disabled] end diff --git a/lib/live_view_native_swift_ui/modifiers/search/search_completion.ex b/lib/live_view_native_swift_ui/modifiers/search/search_completion.ex index d0658d251..92c21f1b6 100644 --- a/lib/live_view_native_swift_ui/modifiers/search/search_completion.ex +++ b/lib/live_view_native_swift_ui/modifiers/search/search_completion.ex @@ -5,4 +5,8 @@ defmodule LiveViewNativeSwiftUi.Modifiers.SearchCompletion do field :completion, :string field :token, :string end + + def params(token) when is_atom(token) and not is_boolean(token) and not is_nil(token), do: [token: token] + def params(completion) when is_binary(completion), do: [completion: completion] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/search/search_scopes.ex b/lib/live_view_native_swift_ui/modifiers/search/search_scopes.ex index 5dae11fc5..f75dbc07e 100644 --- a/lib/live_view_native_swift_ui/modifiers/search/search_scopes.ex +++ b/lib/live_view_native_swift_ui/modifiers/search/search_scopes.ex @@ -10,4 +10,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.SearchScopes do change_event() end + + def params(active, params) when is_list(params), do: [{:active, active} | params] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/search/search_suggestions.ex b/lib/live_view_native_swift_ui/modifiers/search/search_suggestions.ex index b34668dd1..d40d69ebc 100644 --- a/lib/live_view_native_swift_ui/modifiers/search/search_suggestions.ex +++ b/lib/live_view_native_swift_ui/modifiers/search/search_suggestions.ex @@ -6,4 +6,13 @@ defmodule LiveViewNativeSwiftUi.Modifiers.SearchSuggestions do modifier_schema "search_suggestions" do field :suggestions, KeyName end + + def params(params) do + with {:ok, _} <- KeyName.cast(params) do + [suggestions: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/shape/fill.ex b/lib/live_view_native_swift_ui/modifiers/shape/fill.ex index e3cca5677..67779d754 100644 --- a/lib/live_view_native_swift_ui/modifiers/shape/fill.ex +++ b/lib/live_view_native_swift_ui/modifiers/shape/fill.ex @@ -7,4 +7,14 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Fill do field :content, ShapeStyle field :style, FillStyle end + + def params(content, params) when is_list(params), do: [{:content, content} | params] + def params(params) do + with {:ok, _} <- ShapeStyle.cast(params) do + [content: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/shape/inset.ex b/lib/live_view_native_swift_ui/modifiers/shape/inset.ex index bff496eb6..5cea91db4 100644 --- a/lib/live_view_native_swift_ui/modifiers/shape/inset.ex +++ b/lib/live_view_native_swift_ui/modifiers/shape/inset.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Inset do modifier_schema "inset" do field :amount, :float end + + def params([by: amount]), do: [amount: amount] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/shape/rotation.ex b/lib/live_view_native_swift_ui/modifiers/shape/rotation.ex index 8d3b70e4c..d54204575 100644 --- a/lib/live_view_native_swift_ui/modifiers/shape/rotation.ex +++ b/lib/live_view_native_swift_ui/modifiers/shape/rotation.ex @@ -7,4 +7,14 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Rotation do field :angle, Angle field :anchor, UnitPoint end + + def params(angle, params) when is_list(params), do: [{:angle, angle} | params] + def params(params) do + with {:ok, _} <- Angle.cast(params) do + [angle: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/shape/stroke.ex b/lib/live_view_native_swift_ui/modifiers/shape/stroke.ex index 44eb777e4..3a836d962 100644 --- a/lib/live_view_native_swift_ui/modifiers/shape/stroke.ex +++ b/lib/live_view_native_swift_ui/modifiers/shape/stroke.ex @@ -7,4 +7,14 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Stroke do field :content, ShapeStyle field :style, StrokeStyle end + + def params(content, params) when is_list(params), do: [{:content, content} | params] + def params(params) do + with {:ok, _} <- ShapeStyle.cast(params) do + [content: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/shape/stroke_border.ex b/lib/live_view_native_swift_ui/modifiers/shape/stroke_border.ex index 6fe661cc4..707b50ec2 100644 --- a/lib/live_view_native_swift_ui/modifiers/shape/stroke_border.ex +++ b/lib/live_view_native_swift_ui/modifiers/shape/stroke_border.ex @@ -8,4 +8,14 @@ defmodule LiveViewNativeSwiftUi.Modifiers.StrokeBorder do field :style, StrokeStyle field :antialiased, :boolean, default: true end + + def params(content, params) when is_list(params), do: [{:content, content} | params] + def params(params) do + with {:ok, _} <- ShapeStyle.cast(params) do + [content: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/shape/trim.ex b/lib/live_view_native_swift_ui/modifiers/shape/trim.ex index bdd3cad7b..1ae006236 100644 --- a/lib/live_view_native_swift_ui/modifiers/shape/trim.ex +++ b/lib/live_view_native_swift_ui/modifiers/shape/trim.ex @@ -5,4 +5,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Trim do field :start_fraction, :float, default: 0.0 field :end_fraction, :float, default: 1.0 end + + def params([from: start_fraction, to: end_fraction]), do: [start_fraction: start_fraction, end_fraction: end_fraction] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/shapes/container_shape.ex b/lib/live_view_native_swift_ui/modifiers/shapes/container_shape.ex index 547819f3d..fb853cdf7 100644 --- a/lib/live_view_native_swift_ui/modifiers/shapes/container_shape.ex +++ b/lib/live_view_native_swift_ui/modifiers/shapes/container_shape.ex @@ -6,4 +6,13 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ContainerShape do modifier_schema "container_shape" do field :shape, Shape end + + def params(params) do + with {:ok, _} <- Shape.cast(params) do + [shape: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/tables/table_style.ex b/lib/live_view_native_swift_ui/modifiers/tables/table_style.ex index 3ec428bd1..b632d9a71 100644 --- a/lib/live_view_native_swift_ui/modifiers/tables/table_style.ex +++ b/lib/live_view_native_swift_ui/modifiers/tables/table_style.ex @@ -10,4 +10,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.TableStyle do bordered_alternates_row_backgrounds )a end + + def params(style) when is_atom(style) and not is_boolean(style) and not is_nil(style), do: [style: style] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/autocorrection_disabled.ex b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/autocorrection_disabled.ex index 303f4b7dc..cf8253c20 100644 --- a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/autocorrection_disabled.ex +++ b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/autocorrection_disabled.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.AutocorrectionDisabled do modifier_schema "autocorrection_disabled" do field :disable, :boolean, default: true end + + def params(disable) when is_boolean(disable), do: [disable: disable] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/baseline_offset.ex b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/baseline_offset.ex index 763d13bb5..efe9bc4a7 100644 --- a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/baseline_offset.ex +++ b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/baseline_offset.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.BaselineOffset do modifier_schema "baseline_offset" do field :offset, :float end + + def params(offset) when is_number(offset), do: [offset: offset] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/flips_for_right_to_left_layout_direction.ex b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/flips_for_right_to_left_layout_direction.ex index d460c2559..8a250fcd0 100644 --- a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/flips_for_right_to_left_layout_direction.ex +++ b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/flips_for_right_to_left_layout_direction.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.FlipsForRightToLeftLayoutDirection do modifier_schema "flips_for_right_to_left_layout_direction" do field :enabled, :boolean end + + def params(enabled) when is_boolean(enabled), do: [enabled: enabled] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/font.ex b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/font.ex index 960dd4a51..78e5b36a4 100644 --- a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/font.ex +++ b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/font.ex @@ -6,4 +6,13 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Font do modifier_schema "font" do field :font, Font end + + def params(params) do + with {:ok, _} <- Font.cast(params) do + [font: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/font_width.ex b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/font_width.ex index efac4c21b..8ab005c63 100644 --- a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/font_width.ex +++ b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/font_width.ex @@ -6,4 +6,13 @@ defmodule LiveViewNativeSwiftUi.Modifiers.FontWidth do modifier_schema "font_width" do field :width, FontWidth end + + def params(params) do + with {:ok, _} <- FontWidth.cast(params) do + [width: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/keyboard_shortcut.ex b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/keyboard_shortcut.ex index 79ba38c9b..eb0147d35 100644 --- a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/keyboard_shortcut.ex +++ b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/keyboard_shortcut.ex @@ -1,11 +1,21 @@ defmodule LiveViewNativeSwiftUi.Modifiers.KeyboardShortcut do use LiveViewNativePlatform.Modifier - alias LiveViewNativePlatform.Types.EventModifier + alias LiveViewNativePlatform.Modifier.Types.EventModifier alias LiveViewNativeSwiftUi.Types.KeyEquivalent modifier_schema "keyboard_shortcut" do field :key, KeyEquivalent field :modifiers, EventModifier end + + def params(key, params) when is_list(params), do: [{:key, key} | params] + def params(params) do + with {:ok, _} <- KeyEquivalent.cast(params) do + [key: params] + else + _ -> + params + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/keyboard_type.ex b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/keyboard_type.ex index da4a48d30..a9742f571 100644 --- a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/keyboard_type.ex +++ b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/keyboard_type.ex @@ -16,4 +16,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.KeyboardType do ascii_capable_number_pad )a end + + def params(keyboard_type) when is_atom(keyboard_type) and not is_boolean(keyboard_type) and not is_nil(keyboard_type), do: [keyboard_type: keyboard_type] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/label_style.ex b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/label_style.ex index b0ef830d0..f8dbc2dba 100644 --- a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/label_style.ex +++ b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/label_style.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.LabelStyle do modifier_schema "label_style" do field :style, Ecto.Enum, values: ~w(automatic icon_only title_and_icon title_only)a end + + def params(style) when is_atom(style) and not is_boolean(style) and not is_nil(style), do: [style: style] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/line_limit.ex b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/line_limit.ex index 7ff783120..8139d3e8f 100644 --- a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/line_limit.ex +++ b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/line_limit.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.LineLimit do modifier_schema "line_limit" do field :number, :integer end + + def params(number) when is_integer(number), do: [number: number] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/minimum_scale_factor.ex b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/minimum_scale_factor.ex index 2838c5675..1a04496d4 100644 --- a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/minimum_scale_factor.ex +++ b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/minimum_scale_factor.ex @@ -4,5 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.MinimumScaleFactor do modifier_schema "minimum_scale_factor" do field :factor, :float end -end + def params(factor) when is_number(factor), do: [factor: factor] + def params(params), do: params +end diff --git a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/privacy_sensitive.ex b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/privacy_sensitive.ex index 39ea00bbc..ab57cb2b4 100644 --- a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/privacy_sensitive.ex +++ b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/privacy_sensitive.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.PrivacySensitive do modifier_schema "privacy_sensitive" do field :sensitive, :boolean end + + def params(sensitive) when is_boolean(sensitive), do: [sensitive: sensitive] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/strikethrough.ex b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/strikethrough.ex index 736baec58..681ff9e03 100644 --- a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/strikethrough.ex +++ b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/strikethrough.ex @@ -8,4 +8,8 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Strikethrough do field :pattern, Ecto.Enum, values: ~w(dash dash_dot dash_dot_dot dot solid)a, default: :solid field :color, Color end + + def params(is_active, params) when is_list(params), do: [{:is_active, is_active} | params] + def params(is_active) when is_boolean(is_active), do: [is_active: is_active] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/submit_label.ex b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/submit_label.ex index ad3ab2075..56ad47fa0 100644 --- a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/submit_label.ex +++ b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/submit_label.ex @@ -14,4 +14,6 @@ defmodule LiveViewNativeSwiftUi.Modifiers.SubmitLabel do continue )a) end + + def params(submit_label) when is_atom(submit_label) and not is_boolean(submit_label) and not is_nil(submit_label), do: [submit_label: submit_label] end diff --git a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/text_content_type.ex b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/text_content_type.ex index 25d66b0ed..9788cd36e 100644 --- a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/text_content_type.ex +++ b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/text_content_type.ex @@ -35,4 +35,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.TextContentType do shipment_tracking_number )a) end + + def params(text_content_type) when is_atom(text_content_type) and not is_boolean(text_content_type) and not is_nil(text_content_type), do: [text_content_type: text_content_type] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/text_field_style.ex b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/text_field_style.ex index 6e92cb523..0b8ef0ed5 100644 --- a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/text_field_style.ex +++ b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/text_field_style.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.TextFieldStyle do modifier_schema "text_field_style" do field :style, Ecto.Enum, values: ~w(automatic plain rounded_border square_border)a end + + def params(style) when is_atom(style) and not is_boolean(style) and not is_nil(style), do: [style: style] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/text_input_autocapitalization.ex b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/text_input_autocapitalization.ex index a8f48f90c..1b89b89fd 100644 --- a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/text_input_autocapitalization.ex +++ b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/text_input_autocapitalization.ex @@ -9,4 +9,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.TextInputAutocapitalization do never )a end + + def params(autocapitalization) when is_atom(autocapitalization) and not is_boolean(autocapitalization) and not is_nil(autocapitalization), do: [autocapitalization: autocapitalization] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/text_selection.ex b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/text_selection.ex index 19c6caf6f..eed48b377 100644 --- a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/text_selection.ex +++ b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/text_selection.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.TextSelection do modifier_schema "text_selection" do field :selectable, :boolean end + + def params(selectable) when is_boolean(selectable), do: [selectable: selectable] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/truncation_mode.ex b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/truncation_mode.ex index ff812c5b5..aa79db3c2 100644 --- a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/truncation_mode.ex +++ b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/truncation_mode.ex @@ -8,4 +8,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.TruncationMode do tail )a end + + def params(mode) when is_atom(mode) and not is_boolean(mode) and not is_nil(mode), do: [mode: mode] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/underline.ex b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/underline.ex index 2e4a9782a..93663e7d8 100644 --- a/lib/live_view_native_swift_ui/modifiers/text_input_and_output/underline.ex +++ b/lib/live_view_native_swift_ui/modifiers/text_input_and_output/underline.ex @@ -7,4 +7,8 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Underline do field :pattern, Ecto.Enum, values: ~w(dash dash_dot dash_dot_dot dot solid)a, default: :solid field :color, Color end + + def params(is_active, params) when is_list(params), do: [{:is_active, is_active} | params] + def params(is_active) when is_boolean(is_active), do: [is_active: is_active] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/toolbar/toolbar_background.ex b/lib/live_view_native_swift_ui/modifiers/toolbar/toolbar_background.ex index 561394070..44274e37f 100644 --- a/lib/live_view_native_swift_ui/modifiers/toolbar/toolbar_background.ex +++ b/lib/live_view_native_swift_ui/modifiers/toolbar/toolbar_background.ex @@ -8,4 +8,8 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ToolbarBackground do field :visibility, Ecto.Enum, values: ~w(automatic hidden visible)a field :bars, Ecto.Enum, values: ~w(automatic bottom_bar navigation_bar tab_bar window_toolbar)a end + + def params(visibility, params) when is_atom(visibility) and not is_boolean(visibility) and not is_nil(visibility) and is_list(params), do: [{:visibility, visibility} | params] + def params(style, params) when is_list(params), do: [{:style, style} | params] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/toolbar/toolbar_color_scheme.ex b/lib/live_view_native_swift_ui/modifiers/toolbar/toolbar_color_scheme.ex index bd3c30596..8f728fe06 100644 --- a/lib/live_view_native_swift_ui/modifiers/toolbar/toolbar_color_scheme.ex +++ b/lib/live_view_native_swift_ui/modifiers/toolbar/toolbar_color_scheme.ex @@ -5,4 +5,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ToolbarColorScheme do field :color_scheme, Ecto.Enum, values: ~w(dark light)a field :bars, Ecto.Enum, values: ~w(automatic bottom_bar navigation_bar tab_bar window_toolbar)a end + + def params(color_scheme, params) when is_list(params), do: [{:color_scheme, color_scheme} | params] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/toolbar/toolbar_role.ex b/lib/live_view_native_swift_ui/modifiers/toolbar/toolbar_role.ex index 784a32da4..733f06d21 100644 --- a/lib/live_view_native_swift_ui/modifiers/toolbar/toolbar_role.ex +++ b/lib/live_view_native_swift_ui/modifiers/toolbar/toolbar_role.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ToolbarRole do modifier_schema "toolbar_role" do field :role, Ecto.Enum, values: ~w(automatic browser editor navigation_stack)a end + + def params(role) when is_atom(role) and not is_boolean(role) and not is_nil(role), do: [role: role] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/toolbar/toolbar_visibility.ex b/lib/live_view_native_swift_ui/modifiers/toolbar/toolbar_visibility.ex index a1f04973d..1cfab716e 100644 --- a/lib/live_view_native_swift_ui/modifiers/toolbar/toolbar_visibility.ex +++ b/lib/live_view_native_swift_ui/modifiers/toolbar/toolbar_visibility.ex @@ -5,4 +5,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ToolbarVisibility do field :visibility, Ecto.Enum, values: ~w(automatic hidden visible)a field :bars, Ecto.Enum, values: ~w(automatic bottom_bar navigation_bar tab_bar window_toolbar)a end + + def params(visibility, params) when is_list(params), do: [{:visibility, visibility} | params] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/view_configuration/help.ex b/lib/live_view_native_swift_ui/modifiers/view_configuration/help.ex index fca05ed07..f1bf36a54 100644 --- a/lib/live_view_native_swift_ui/modifiers/view_configuration/help.ex +++ b/lib/live_view_native_swift_ui/modifiers/view_configuration/help.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Help do modifier_schema "help" do field :text, :string end + + def params(text) when is_binary(text), do: [text: text] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/view_configuration/hidden.ex b/lib/live_view_native_swift_ui/modifiers/view_configuration/hidden.ex index 8cd16bc35..f3adad4ca 100644 --- a/lib/live_view_native_swift_ui/modifiers/view_configuration/hidden.ex +++ b/lib/live_view_native_swift_ui/modifiers/view_configuration/hidden.ex @@ -1,10 +1,5 @@ defmodule LiveViewNativeSwiftUi.Modifiers.Hidden do use LiveViewNativePlatform.Modifier - modifier_schema "hidden" do - field :is_active, :boolean - end - - def params(is_active) when is_boolean(is_active), do: [is_active: is_active] - def params(params), do: params + modifier_schema "hidden" end diff --git a/lib/live_view_native_swift_ui/modifiers/view_configuration/persistent_system_overlays.ex b/lib/live_view_native_swift_ui/modifiers/view_configuration/persistent_system_overlays.ex index bc353a91e..e61fdee7e 100644 --- a/lib/live_view_native_swift_ui/modifiers/view_configuration/persistent_system_overlays.ex +++ b/lib/live_view_native_swift_ui/modifiers/view_configuration/persistent_system_overlays.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.PersistentSystemOverlays do modifier_schema "persistent_system_overlays" do field :visibility, Ecto.Enum, values: ~w(automatic hidden visible)a end + + def params(visibility) when is_atom(visibility) and not is_boolean(visibility) and not is_nil(visibility), do: [visibility: visibility] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/view_configuration/status_bar_hidden.ex b/lib/live_view_native_swift_ui/modifiers/view_configuration/status_bar_hidden.ex index ca623dd73..06976b73f 100644 --- a/lib/live_view_native_swift_ui/modifiers/view_configuration/status_bar_hidden.ex +++ b/lib/live_view_native_swift_ui/modifiers/view_configuration/status_bar_hidden.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.StatusBarHidden do modifier_schema "status_bar_hidden" do field :hidden, :boolean end + + def params(hidden) when is_boolean(hidden), do: [hidden: hidden] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/view_fundamentals/on_appear.ex b/lib/live_view_native_swift_ui/modifiers/view_fundamentals/on_appear.ex index df9911eca..12319a59e 100644 --- a/lib/live_view_native_swift_ui/modifiers/view_fundamentals/on_appear.ex +++ b/lib/live_view_native_swift_ui/modifiers/view_fundamentals/on_appear.ex @@ -1,9 +1,9 @@ defmodule LiveViewNativeSwiftUi.Modifiers.OnAppear do use LiveViewNativePlatform.Modifier - alias LiveViewNativePlatform.Types.Event + alias LiveViewNativePlatform.Modifier.Types.Event modifier_schema "on_appear" do - field :action, Event + field :perform, Event end end diff --git a/lib/live_view_native_swift_ui/modifiers/view_fundamentals/on_disappear.ex b/lib/live_view_native_swift_ui/modifiers/view_fundamentals/on_disappear.ex index 4bf434b9e..483d9fd3e 100644 --- a/lib/live_view_native_swift_ui/modifiers/view_fundamentals/on_disappear.ex +++ b/lib/live_view_native_swift_ui/modifiers/view_fundamentals/on_disappear.ex @@ -1,9 +1,9 @@ defmodule LiveViewNativeSwiftUi.Modifiers.OnDisappear do use LiveViewNativePlatform.Modifier - alias LiveViewNativePlatform.Types.Event + alias LiveViewNativePlatform.Modifier.Types.Event modifier_schema "on_disappear" do - field :action, Event + field :perform, Event end end diff --git a/lib/live_view_native_swift_ui/modifiers/view_groupings/control_group_style.ex b/lib/live_view_native_swift_ui/modifiers/view_groupings/control_group_style.ex index 433e51277..7d1a3a154 100644 --- a/lib/live_view_native_swift_ui/modifiers/view_groupings/control_group_style.ex +++ b/lib/live_view_native_swift_ui/modifiers/view_groupings/control_group_style.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ControlGroupStyle do modifier_schema "control_group_style" do field :style, Ecto.Enum, values: ~w(automatic compact_menu menu navigation)a end + + def params(style) when is_atom(style) and not is_boolean(style) and not is_nil(style), do: [style: style] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/view_groupings/group_box_style.ex b/lib/live_view_native_swift_ui/modifiers/view_groupings/group_box_style.ex index e05edc77e..66ff57388 100644 --- a/lib/live_view_native_swift_ui/modifiers/view_groupings/group_box_style.ex +++ b/lib/live_view_native_swift_ui/modifiers/view_groupings/group_box_style.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.GroupBoxStyle do modifier_schema "group_box_style" do field :style, Ecto.Enum, values: ~w(automatic)a end + + def params(style) when is_atom(style) and not is_boolean(style) and not is_nil(style), do: [style: style] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/modifiers/view_styles/content_shape.ex b/lib/live_view_native_swift_ui/modifiers/view_styles/content_shape.ex index bcfc45611..97c33ff1f 100644 --- a/lib/live_view_native_swift_ui/modifiers/view_styles/content_shape.ex +++ b/lib/live_view_native_swift_ui/modifiers/view_styles/content_shape.ex @@ -8,4 +8,26 @@ defmodule LiveViewNativeSwiftUi.Modifiers.ContentShape do field :shape, Shape field :eo_fill, :boolean end + + def params(shape, params) when is_list(params) do + with {:ok, _} <- ContentShapeKind.cast(shape) do + [{:kind, shape} | params] + else + _ -> + [{:shape, shape} | params] + end + end + def params(params) do + with {:ok, _} <- ContentShapeKind.cast(params) do + [kind: params] + else + _ -> + with {:ok, _} <- Shape.cast(params) do + [shape: params] + else + _ -> + params + end + end + end end diff --git a/lib/live_view_native_swift_ui/modifiers/view_styles/index_view_style.ex b/lib/live_view_native_swift_ui/modifiers/view_styles/index_view_style.ex index 4603b120f..c84d04aca 100644 --- a/lib/live_view_native_swift_ui/modifiers/view_styles/index_view_style.ex +++ b/lib/live_view_native_swift_ui/modifiers/view_styles/index_view_style.ex @@ -4,4 +4,7 @@ defmodule LiveViewNativeSwiftUi.Modifiers.IndexViewStyle do modifier_schema "index_view_style" do field :style, Ecto.Enum, values: ~w(page page_always page_automatic page_interactive page_never)a end + + def params(style) when is_atom(style) and not is_boolean(style) and not is_nil(style), do: [style: style] + def params(params), do: params end diff --git a/lib/live_view_native_swift_ui/types/event_modifier.ex b/lib/live_view_native_swift_ui/types/event_modifier.ex index b43925b39..d27c31def 100644 --- a/lib/live_view_native_swift_ui/types/event_modifier.ex +++ b/lib/live_view_native_swift_ui/types/event_modifier.ex @@ -1,4 +1,4 @@ -defmodule LiveViewNativePlatform.Types.EventModifier do +defmodule LiveViewNativePlatform.Modifier.Types.EventModifier do use LiveViewNativePlatform.Modifier.Type def type, do: {:array, :string} From 560af91453aaa3a553005c26d426ed9cc6eb7378 Mon Sep 17 00:00:00 2001 From: Carson Katri Date: Tue, 22 Aug 2023 17:03:24 -0400 Subject: [PATCH 09/13] Update all docs --- .../Image Modifiers/AntialiasedModifier.swift | 2 +- .../InterpolationModifier.swift | 4 ++-- .../RenderingModeModifier.swift | 6 +++--- .../Image Modifiers/ResizableModifier.swift | 4 ++-- .../AnimationModifier.swift | 8 ++++---- .../ContentTransitionModifier.swift | 11 +++++------ .../KeyframeAnimatorModifier.swift | 4 ++-- .../MatchedGeometryEffectModifier.swift | 10 +++++----- .../TransitionModifier.swift | 2 +- .../ButtonBorderShapeModifier.swift | 4 ++-- .../ControlSizeModifier.swift | 4 ++-- .../HorizontalRadioGroupLayoutModifier.swift | 2 +- .../DraggableModifier.swift | 4 ++-- .../DropDestinationModifier.swift | 4 ++-- .../BlendModeModifier.swift | 11 +++++------ .../BlurModifier.swift | 2 +- .../BorderModifier.swift | 2 +- .../BrightnessModifier.swift | 2 +- .../ClipShapeModifier.swift | 6 +++--- .../ClippedModifier.swift | 3 +-- .../ColorInvertModifier.swift | 2 +- .../ColorMultiplyModifier.swift | 2 +- .../CompositingGroupModifier.swift | 7 +++---- .../ContrastModifier.swift | 2 +- .../CornerRadiusModifier.swift | 2 +- .../DrawingGroupModifier.swift | 19 +++++++++---------- .../ForegroundColorModifier.swift | 2 +- .../GrayscaleModifier.swift | 2 +- .../HueRotationModifier.swift | 5 ++--- .../LuminanceToAlphaModifier.swift | 7 +++---- .../MaskModifier.swift | 7 +++---- .../ProjectionEffectModifier.swift | 2 +- .../Rotation3DEffectModifier.swift | 2 +- .../RotationEffectModifier.swift | 2 +- .../SaturationModifier.swift | 2 +- .../ScaleEffectModifier.swift | 2 +- .../ScaledToFillModifier.swift | 2 +- .../ScaledToFitModifier.swift | 2 +- .../ShadowModifier.swift | 2 +- .../SymbolVariantModifier.swift | 4 ++-- .../TransformEffectModifier.swift | 2 +- .../Focus Modifiers/FocusScopeModifier.swift | 4 ++-- .../FocusSectionModifier.swift | 2 +- .../Focus Modifiers/FocusableModifier.swift | 4 ++-- .../PrefersDefaultFocusModifier.swift | 4 ++-- .../DefersSystemGesturesModifier.swift | 5 ++--- .../Gestures Modifiers/GestureModifier.swift | 8 ++++---- .../Images Modifiers/ImageScaleModifier.swift | 2 +- .../SymbolRenderingModeModifier.swift | 2 +- .../AllowsHitTestingModifier.swift | 5 ++--- .../DigitalCrownAccessoryModifier.swift | 5 ++--- ...italCrownAccessoryVisibilityModifier.swift | 9 +++------ .../HoverEffectModifier.swift | 2 +- .../OnDeleteCommandModifier.swift | 4 ++-- .../OnHoverModifier.swift | 4 ++-- .../OnMoveCommandModifier.swift | 4 ++-- .../OnSubmitModifier.swift | 7 +++---- .../SubmitScopeModifier.swift | 4 ++-- .../CoordinateSpaceModifier.swift | 2 +- .../FixedSizeModifier.swift | 4 ++-- .../FrameModifier.swift | 6 +++--- .../IgnoresSafeAreaModifier.swift | 2 +- .../LayoutPriorityModifier.swift | 2 +- .../OffsetModifier.swift | 2 +- .../PaddingModifier.swift | 8 ++++---- .../PositionModifier.swift | 2 +- .../SafeAreaInsetModifier.swift | 2 +- .../ScenePaddingModifier.swift | 2 +- .../BackgroundModifier.swift | 6 +++--- .../GridCellAnchorModifier.swift | 2 +- .../GridCellColumnsModifier.swift | 2 +- .../GridCellUnsizedAxesModifier.swift | 2 +- .../GridColumnAlignmentModifier.swift | 2 +- .../OverlayModifier.swift | 8 ++++---- .../ZIndexModifier.swift | 4 ++-- .../Lists Modifiers/BadgeModifier.swift | 6 +++--- .../DeleteDisabledModifier.swift | 2 +- .../HeaderProminenceModifier.swift | 2 +- .../ListItemTintModifier.swift | 6 +++--- .../ListRowBackgroundModifier.swift | 2 +- .../ListRowInsetsModifier.swift | 2 +- .../ListRowSeparatorTintModifier.swift | 4 ++-- .../ListSectionSeparatorModifier.swift | 2 +- .../ListSectionSeparatorTintModifier.swift | 4 ++-- .../Lists Modifiers/ListStyleModifier.swift | 2 +- .../MoveDisabledModifier.swift | 2 +- .../Lists Modifiers/RefreshableModifier.swift | 4 ++-- .../SwipeActionsModifier.swift | 5 ++--- .../ContextMenuModifier.swift | 4 ++-- .../MenuActionDismissBehaviorModifier.swift | 2 +- .../MenuIndicatorModifier.swift | 2 +- .../MenuOrderModifier.swift | 2 +- .../MenuStyleModifier.swift | 2 +- .../Modal Presentations/AlertModifier.swift | 3 +-- .../ConfirmationDialogModifier.swift | 3 +-- .../FullScreenCoverModifier.swift | 2 +- .../InteractiveDismissDisabledModifier.swift | 4 ++-- .../Modal Presentations/PopoverModifier.swift | 4 ++-- ...ntationBackgroundInteractionModifier.swift | 4 ++-- .../PresentationBackgroundModifier.swift | 4 ++-- ...resentationCompactAdaptationModifier.swift | 4 ++-- ...esentationContentInteractionModifier.swift | 4 ++-- .../PresentationCornerRadiusModifier.swift | 4 ++-- .../PresentationDetentsModifier.swift | 6 +++--- .../PresentationDragIndicatorModifier.swift | 4 ++-- ...avigationBarBackButtonHiddenModifier.swift | 2 +- ...avigationBarTitleDisplayModeModifier.swift | 9 ++++----- .../NavigationSubtitleModifier.swift | 2 +- .../NavigationTitleModifier.swift | 2 +- .../TabItemModifier.swift | 2 +- .../TabViewStyleModifier.swift | 2 +- .../ScrollBounceBehaviorModifier.swift | 2 +- .../ScrollContentBackgroundModifier.swift | 2 +- .../ScrollDisabledModifier.swift | 2 +- .../ScrollDismissesKeyboardModifier.swift | 2 +- .../ScrollIndicatorsModifier.swift | 2 +- .../FindDisabledModifier.swift | 2 +- .../FindNavigatorModifier.swift | 2 +- .../ReplaceDisabledModifier.swift | 2 +- .../SearchCompletionModifier.swift | 4 ++-- .../SearchScopesModifier.swift | 5 ++--- .../SearchSuggestionsModifier.swift | 9 ++++----- .../Search Modifiers/SearchableModifier.swift | 4 ++-- .../ContainerShapeModifier.swift | 4 ++-- .../Tables Modifiers/TableStyleModifier.swift | 2 +- .../AutocorrectionDisabledModifier.swift | 4 ++-- .../BaselineOffsetModifier.swift | 2 +- .../BoldModifier.swift | 4 ++-- .../DynamicTypeSizeModifier.swift | 4 ++-- ...orRightToLeftLayoutDirectionModifier.swift | 2 +- .../FontDesignModifier.swift | 8 ++++---- .../FontModifier.swift | 2 +- .../FontWeightModifier.swift | 2 +- .../FontWidthModifier.swift | 2 +- .../ItalicModifier.swift | 4 ++-- .../KerningModifier.swift | 2 +- .../KeyboardShortcutModifier.swift | 8 ++++---- .../KeyboardTypeModifier.swift | 2 +- .../LineLimitModifier.swift | 2 +- .../LineSpacingModifier.swift | 2 +- .../MinimumScaleFactorModifier.swift | 2 +- .../MonospacedDigitModifier.swift | 2 +- .../MonospacedModifier.swift | 2 +- .../MultilineTextAlignmentModifier.swift | 2 +- .../PrivacySensitiveModifier.swift | 2 +- .../StrikethroughModifier.swift | 2 +- .../SubmitLabelModifier.swift | 2 +- .../TextCaseModifier.swift | 2 +- .../TextContentTypeModifier.swift | 6 +++--- .../TextFieldStyleModifier.swift | 2 +- .../TextInputAutocapitalizationModifier.swift | 2 +- .../TextSelectionModifier.swift | 2 +- .../TrackingModifier.swift | 2 +- .../TruncationModeModifier.swift | 2 +- .../UnderlineModifier.swift | 2 +- .../ToolbarBackgroundModifier.swift | 4 ++-- .../ToolbarColorSchemeModifier.swift | 2 +- .../Toolbars Modifiers/ToolbarModifier.swift | 4 ++-- .../ToolbarRoleModifier.swift | 2 +- .../ToolbarTitleMenuModifier.swift | 2 +- .../DisabledModifier.swift | 2 +- .../HelpModifier.swift | 2 +- .../LabelsHiddenModifier.swift | 2 +- .../OpacityModifier.swift | 2 +- .../PersistentSystemOverlaysModifier.swift | 2 +- .../PreferredColorSchemeModifier.swift | 2 +- .../RedactedModifier.swift | 2 +- .../StatusBarHiddenModifier.swift | 2 +- .../UnredactedModifier.swift | 2 +- .../OnAppearModifier.swift | 2 +- .../OnDisappearModifier.swift | 2 +- .../ContentShapeModifier.swift | 6 +++--- .../IndexViewStyleModifier.swift | 9 ++++----- .../Shape Modifiers/FillModifier.swift | 2 +- .../Shape Modifiers/InsetModifier.swift | 2 +- .../Shape Modifiers/OffsetShapeModifier.swift | 2 +- .../Shape Modifiers/RotationModifier.swift | 2 +- .../Shape Modifiers/SizeModifier.swift | 2 +- .../StrokeBorderModifier.swift | 2 +- .../Shape Modifiers/StrokeModifier.swift | 2 +- .../Shape Modifiers/TrimModifier.swift | 2 +- .../LiveViewNative/Utils/AnyTransition.swift | 2 +- .../LiveViewNative/Utils/ShapeReference.swift | 2 +- .../Views/Accessibility/ScaledMetric.swift | 2 +- .../LiveViewNative/Views/Images/Image.swift | 2 +- .../Layout Containers/Groups/Group.swift | 2 +- .../Presentation Containers/TabView.swift | 2 +- .../Scroll Views/ScrollView.swift | 2 +- .../Views/Text Input and Output/Text.swift | 4 ++-- .../Text Input and Output/TextField.swift | 11 +++++------ .../Views/Toolbars/ToolbarItem.swift | 2 +- .../rotation_3d_effect.ex | 9 +-------- .../modifiers/focus/prefers_default_focus.ex | 3 ++- .../modifiers/gestures/gesture.ex | 3 +-- .../modifiers/view_styles/content_shape.ex | 9 +-------- 195 files changed, 320 insertions(+), 357 deletions(-) diff --git a/Sources/LiveViewNative/Image Modifiers/AntialiasedModifier.swift b/Sources/LiveViewNative/Image Modifiers/AntialiasedModifier.swift index e0153df23..fd5849d69 100644 --- a/Sources/LiveViewNative/Image Modifiers/AntialiasedModifier.swift +++ b/Sources/LiveViewNative/Image Modifiers/AntialiasedModifier.swift @@ -10,7 +10,7 @@ import SwiftUI /// Enables/disables antialiasing. /// /// ```html -/// +/// /// ``` /// /// ## Arguments diff --git a/Sources/LiveViewNative/Image Modifiers/InterpolationModifier.swift b/Sources/LiveViewNative/Image Modifiers/InterpolationModifier.swift index 6d1e23246..814288688 100644 --- a/Sources/LiveViewNative/Image Modifiers/InterpolationModifier.swift +++ b/Sources/LiveViewNative/Image Modifiers/InterpolationModifier.swift @@ -15,11 +15,11 @@ import SwiftUI /// ```html /// resizable() |> interpolation(interpolation: :none)} +/// modifiers={resizable([]) |> interpolation(:none)} /// /> /// resizable() |> interpolation(interpolation: :medium)} +/// modifiers={resizable([]) |> interpolation(:medium)} /// /> /// ``` /// diff --git a/Sources/LiveViewNative/Image Modifiers/RenderingModeModifier.swift b/Sources/LiveViewNative/Image Modifiers/RenderingModeModifier.swift index 7f7eb1161..4819b1029 100644 --- a/Sources/LiveViewNative/Image Modifiers/RenderingModeModifier.swift +++ b/Sources/LiveViewNative/Image Modifiers/RenderingModeModifier.swift @@ -13,8 +13,8 @@ import SwiftUI /// The `template` mode renders nontransparent pixels as the foreground color. /// /// ```html -/// -/// +/// +/// /// ``` /// /// This modifier can also be used to render multicolor SF Symbols. @@ -23,7 +23,7 @@ import SwiftUI /// ```html /// /// ``` /// diff --git a/Sources/LiveViewNative/Image Modifiers/ResizableModifier.swift b/Sources/LiveViewNative/Image Modifiers/ResizableModifier.swift index 4bba51617..4fafd8897 100644 --- a/Sources/LiveViewNative/Image Modifiers/ResizableModifier.swift +++ b/Sources/LiveViewNative/Image Modifiers/ResizableModifier.swift @@ -10,8 +10,8 @@ import SwiftUI /// Enables an image to fill the available space. /// /// ```html -/// -/// +/// +/// /// ``` /// /// ## Arguments diff --git a/Sources/LiveViewNative/Modifiers/Animations Modifiers/AnimationModifier.swift b/Sources/LiveViewNative/Modifiers/Animations Modifiers/AnimationModifier.swift index 8b89d864f..dda175c05 100644 --- a/Sources/LiveViewNative/Modifiers/Animations Modifiers/AnimationModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Animations Modifiers/AnimationModifier.swift @@ -16,8 +16,8 @@ import SwiftUI /// /// ```html /// /// ``` /// @@ -27,8 +27,8 @@ import SwiftUI /// /// ```html /// /// ``` /// diff --git a/Sources/LiveViewNative/Modifiers/Animations Modifiers/ContentTransitionModifier.swift b/Sources/LiveViewNative/Modifiers/Animations Modifiers/ContentTransitionModifier.swift index b7f8e7a71..700784732 100644 --- a/Sources/LiveViewNative/Modifiers/Animations Modifiers/ContentTransitionModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Animations Modifiers/ContentTransitionModifier.swift @@ -13,13 +13,12 @@ import SwiftUI /// /// ```html /// content_transition(transition: :numeric_text) -/// |> animation(value: @count) -/// } +/// modifiers={ +/// content_transition(:numeric_text) +/// |> animation(value: @count) +/// } /// > -/// <%= @count %> +/// <%= @count %> /// /// ``` /// diff --git a/Sources/LiveViewNative/Modifiers/Animations Modifiers/KeyframeAnimatorModifier.swift b/Sources/LiveViewNative/Modifiers/Animations Modifiers/KeyframeAnimatorModifier.swift index ad0f51b68..f26b5b026 100644 --- a/Sources/LiveViewNative/Modifiers/Animations Modifiers/KeyframeAnimatorModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Animations Modifiers/KeyframeAnimatorModifier.swift @@ -19,7 +19,7 @@ import SwiftUI /// keyframe_animator( +/// keyframe_animator( /// initial_value: 1.0, /// trigger: "#{@liked}", /// keyframes: [ @@ -27,7 +27,7 @@ import SwiftUI /// {:spring, 1.5, [duration: 0.8, spring: :bouncy]}, /// {:spring, 1.0, [spring: :bouncy]} /// ], -/// modifiers: @native |> scale_effect(x: 1.0, y: 1.0), +/// modifiers: scale_effect(x: 1.0, y: 1.0), /// properties: [scale_effect: [:x, :y]] /// ) /// } diff --git a/Sources/LiveViewNative/Modifiers/Animations Modifiers/MatchedGeometryEffectModifier.swift b/Sources/LiveViewNative/Modifiers/Animations Modifiers/MatchedGeometryEffectModifier.swift index c500df921..466baee4a 100644 --- a/Sources/LiveViewNative/Modifiers/Animations Modifiers/MatchedGeometryEffectModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Animations Modifiers/MatchedGeometryEffectModifier.swift @@ -21,13 +21,13 @@ import SwiftUI /// Use the same `id` argument for elements that should be paired. /// /// ```html -/// animation(value: Atom.to_string(@is_flipped))}> +/// /// <%= if @is_flipped do %> -/// matched_geometry_effect(id: "a", namespace: :animation)}>A -/// matched_geometry_effect(id: "b", namespace: :animation)}>B +/// A +/// B /// <% else %> -/// matched_geometry_effect(id: "b", namespace: :animation)}>B -/// matched_geometry_effect(id: "a", namespace: :animation)}>A +/// B +/// A /// <% end %> /// /// diff --git a/Sources/LiveViewNative/Modifiers/Animations Modifiers/TransitionModifier.swift b/Sources/LiveViewNative/Modifiers/Animations Modifiers/TransitionModifier.swift index 60259a660..087ae196c 100644 --- a/Sources/LiveViewNative/Modifiers/Animations Modifiers/TransitionModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Animations Modifiers/TransitionModifier.swift @@ -13,7 +13,7 @@ import SwiftUI /// /// ```html /// <%= if @show do %> -/// Scaled +/// Scaled /// <% end %> /// ``` /// diff --git a/Sources/LiveViewNative/Modifiers/Controls and Indicators Modifiers/ButtonBorderShapeModifier.swift b/Sources/LiveViewNative/Modifiers/Controls and Indicators Modifiers/ButtonBorderShapeModifier.swift index 2906f9033..8ffc75530 100644 --- a/Sources/LiveViewNative/Modifiers/Controls and Indicators Modifiers/ButtonBorderShapeModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Controls and Indicators Modifiers/ButtonBorderShapeModifier.swift @@ -10,10 +10,10 @@ import SwiftUI /// Alters the shape of any bordered buttons' borders. /// /// ```html -/// -/// /// ``` diff --git a/Sources/LiveViewNative/Modifiers/Controls and Indicators Modifiers/ControlSizeModifier.swift b/Sources/LiveViewNative/Modifiers/Controls and Indicators Modifiers/ControlSizeModifier.swift index 9468e9a23..45a449b77 100644 --- a/Sources/LiveViewNative/Modifiers/Controls and Indicators Modifiers/ControlSizeModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Controls and Indicators Modifiers/ControlSizeModifier.swift @@ -10,8 +10,8 @@ import SwiftUI /// Sets the size of controls within this view. /// /// ```html -/// -/// +/// +/// /// ``` /// /// ## Arguments diff --git a/Sources/LiveViewNative/Modifiers/Controls and Indicators Modifiers/HorizontalRadioGroupLayoutModifier.swift b/Sources/LiveViewNative/Modifiers/Controls and Indicators Modifiers/HorizontalRadioGroupLayoutModifier.swift index f215b46d2..b51971473 100644 --- a/Sources/LiveViewNative/Modifiers/Controls and Indicators Modifiers/HorizontalRadioGroupLayoutModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Controls and Indicators Modifiers/HorizontalRadioGroupLayoutModifier.swift @@ -10,7 +10,7 @@ import SwiftUI /// Changes radio-group style ``Picker``s to lay out horizontally. /// /// ```html -/// horizontal_radio_group_layout()}> +/// horizontal_radio_group_layout()}> /// ... /// /// ``` diff --git a/Sources/LiveViewNative/Modifiers/Drag and Drop Modifiers/DraggableModifier.swift b/Sources/LiveViewNative/Modifiers/Drag and Drop Modifiers/DraggableModifier.swift index 2269ad01e..d598ccee8 100644 --- a/Sources/LiveViewNative/Modifiers/Drag and Drop Modifiers/DraggableModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drag and Drop Modifiers/DraggableModifier.swift @@ -10,8 +10,8 @@ import SwiftUI /// Activates this view as the source of a drag and drop operation. /// /// ```html -/// ABC -/// +/// ABC +/// /// ABC /// /// diff --git a/Sources/LiveViewNative/Modifiers/Drag and Drop Modifiers/DropDestinationModifier.swift b/Sources/LiveViewNative/Modifiers/Drag and Drop Modifiers/DropDestinationModifier.swift index c04de90f7..5953f20e1 100644 --- a/Sources/LiveViewNative/Modifiers/Drag and Drop Modifiers/DropDestinationModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drag and Drop Modifiers/DropDestinationModifier.swift @@ -10,8 +10,8 @@ import SwiftUI /// Defines the destination of a drag and drop operation that handles the dropped content with an event that you specify. /// /// ```html -/// ABC -/// +/// ABC +/// /// Drop Here /// /// ``` diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/BlendModeModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/BlendModeModifier.swift index ebb8fd2f2..8ceb935e2 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/BlendModeModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/BlendModeModifier.swift @@ -11,14 +11,13 @@ import SwiftUI /// /// ```html /// -/// frame(width: 50, height: 50, alignment: :center)} /> +/// /// frame(width: 50, height: 50, alignment: :center) -/// |> rotation_effect(angle: {:degrees, 45}) -/// |> padding(all: -20) -/// |> blend_mode(blend_mode: :color_burn) +/// frame(width: 50, height: 50, alignment: :center) +/// |> rotation_effect({:degrees, 45}) +/// |> padding(-20) +/// |> blend_mode(:color_burn) /// } /// /> /// diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/BlurModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/BlurModifier.swift index 1afca8e1f..ce71c1368 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/BlurModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/BlurModifier.swift @@ -12,7 +12,7 @@ import SwiftUI /// Set the ``radius`` to control the strength of the blur. /// /// ```html -/// Hello, world! +/// Hello, world! /// ``` /// /// ## Arguments diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/BorderModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/BorderModifier.swift index 098d5808a..3e12b364a 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/BorderModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/BorderModifier.swift @@ -10,7 +10,7 @@ import SwiftUI /// Applies a border to any element. /// /// ```html -/// +/// /// Purple border inside the view bounds. /// /// ``` diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/BrightnessModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/BrightnessModifier.swift index cff87e6ae..52faf6354 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/BrightnessModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/BrightnessModifier.swift @@ -10,7 +10,7 @@ import SwiftUI /// Brighten the intensity of the colors in a view. /// /// ```html -/// brightness(amount: 0.5)} /> +/// /// ``` /// /// ## Arguments diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ClipShapeModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ClipShapeModifier.swift index c27dc836d..a609cc0dc 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ClipShapeModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ClipShapeModifier.swift @@ -12,7 +12,7 @@ import SwiftUI /// Provide a ``ShapeReference`` to clip the element with. /// /// ```html -/// +/// /// Hello, /// world! /// @@ -22,10 +22,10 @@ import SwiftUI /// This lets you apply modifiers to the clip shape. /// /// ```html -/// +/// /// Hello, /// world! -/// rotation(angle: {:degrees, 45})} /> +/// /// /// ``` /// diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ClippedModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ClippedModifier.swift index fc59fabc8..698eda2f5 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ClippedModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ClippedModifier.swift @@ -12,8 +12,7 @@ import SwiftUI /// ```html /// foreground_color(color: :mint) +/// foreground_color(:mint) /// |> frame(width: 20, height: 20) /// |> clipped(antialiased: true) /// } diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ColorInvertModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ColorInvertModifier.swift index bf83e523f..f41c97309 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ColorInvertModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ColorInvertModifier.swift @@ -10,7 +10,7 @@ import SwiftUI /// Inverts the colors in this view. /// /// ```html -/// foreground_style(primary: {:color, :red}) |> color_invert()} /> +/// color_invert()} /> /// ``` #if swift(>=5.8) @_documentation(visibility: public) diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ColorMultiplyModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ColorMultiplyModifier.swift index 43133fadc..63a38a923 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ColorMultiplyModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ColorMultiplyModifier.swift @@ -10,7 +10,7 @@ import SwiftUI /// Adds a color multiplication effect to this view. /// /// ```html -/// +/// /// ``` /// /// ## Arguments diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/CompositingGroupModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/CompositingGroupModifier.swift index 49c88d6c0..84d0716ec 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/CompositingGroupModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/CompositingGroupModifier.swift @@ -15,13 +15,12 @@ import SwiftUI /// /// compositing_group() -/// |> opacity(opacity: 0.5) +/// compositing_group([]) +/// |> opacity(0.5) /// } /// > /// Hello, world! -/// Hello, world! +/// Hello, world! /// /// /// ``` diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ContrastModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ContrastModifier.swift index bda669ca7..bf8fd3f45 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ContrastModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ContrastModifier.swift @@ -10,7 +10,7 @@ import SwiftUI /// Sets the contrast and separation between similar colors in this view. /// /// ```html -/// foreground_style(primary: {:color, :red}) |> contrast(amount: 0.5)} /> +/// contrast(0.5)} /> /// ``` /// /// ## Arguments diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/CornerRadiusModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/CornerRadiusModifier.swift index 3ad2118f9..05c38eab2 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/CornerRadiusModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/CornerRadiusModifier.swift @@ -10,7 +10,7 @@ import SwiftUI /// Clips this view to its bounding frame, with the specified corner ``radius``. /// /// ```html -/// corner_radius(radius: 8)} /> +/// /// ``` /// /// ## Arguments diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/DrawingGroupModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/DrawingGroupModifier.swift index 980de8b3e..80714c976 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/DrawingGroupModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/DrawingGroupModifier.swift @@ -11,16 +11,15 @@ import SwiftUI /// /// ```html /// -/// drawing_group(opaque: false, color_mode: :non_linear) -/// |> opacity(opacity: 0.5) -/// } -/// > -/// Hello, world! -/// Hello, world! -/// +/// opacity(opacity: 0.5) +/// } +/// > +/// Hello, world! +/// Hello, world! +/// /// /// ``` /// diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ForegroundColorModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ForegroundColorModifier.swift index 3dcb404c5..6e1823309 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ForegroundColorModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ForegroundColorModifier.swift @@ -9,7 +9,7 @@ import SwiftUI /// Applies a foreground color to a view. /// ```html -/// +/// /// Minty fresh text. /// /// ``` diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/GrayscaleModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/GrayscaleModifier.swift index 709715759..2fb45f8c4 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/GrayscaleModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/GrayscaleModifier.swift @@ -12,7 +12,7 @@ import SwiftUI /// A grayscale effect reduces the intensity of colors in this view. /// /// ```html -/// +/// /// ``` /// /// ## Arguments diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/HueRotationModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/HueRotationModifier.swift index 032b481ed..f0c62d12a 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/HueRotationModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/HueRotationModifier.swift @@ -17,9 +17,8 @@ import SwiftUI /// foreground_style(primary: {:linear_gradient, %{ :gradient => {:colors, [:blue, :red, :green]}, :start_point => {0.5, 0}, :end_point => {0.5, 1} }}) -/// |> hue_rotation(angle: {:degrees, item * 36}) +/// foreground_style({:linear_gradient, %{ :gradient => {:colors, [:blue, :red, :green]}, :start_point => {0.5, 0}, :end_point => {0.5, 1} }}) +/// |> hue_rotation({:degrees, item * 36}) /// |> frame(width: 60, height: 60, alignment: :center) /// } /// /> diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/LuminanceToAlphaModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/LuminanceToAlphaModifier.swift index 45163f57c..86ff9b2f3 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/LuminanceToAlphaModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/LuminanceToAlphaModifier.swift @@ -15,14 +15,13 @@ import SwiftUI /// background(alignment: :center, content: :heart_bg) -/// |> foreground_color(color: :red) +/// background(alignment: :center, content: :heart_bg) +/// |> foreground_color(:red) /// |> luminance_to_alpha() /// } /// > /// -/// frame(width: 32, height: 32) |> foreground_color(color: :red)} /> +/// foreground_color(:red)} /> /// /// /// ``` diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/MaskModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/MaskModifier.swift index d46d877b3..968138035 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/MaskModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/MaskModifier.swift @@ -12,13 +12,12 @@ import SwiftUI /// ```html /// foreground_color(color: :blue) -/// |> font(font: {:system, :large_title}) +/// foreground_color(:blue) +/// |> font({:system, :large_title}) /// |> mask(alignment: :center, mask: :mask) /// } /// > -/// opacity(opacity: 0.1)} /> +/// /// /// ``` /// diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ProjectionEffectModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ProjectionEffectModifier.swift index a0438e4ce..973bb9004 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ProjectionEffectModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ProjectionEffectModifier.swift @@ -14,7 +14,7 @@ import SwiftUI /// - Note: The frame of the element is not affected. /// /// ```html -/// +/// /// Rotation by passing an angle in degrees /// /// ``` diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/RotationEffectModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/RotationEffectModifier.swift index 5341491ea..284ec8f5f 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/RotationEffectModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/RotationEffectModifier.swift @@ -12,7 +12,7 @@ import SwiftUI /// Pass an ``angle`` in degrees or radians to rotate the element. /// /// ```html -/// +/// /// Rotation by passing an angle in degrees /// /// ``` diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/SaturationModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/SaturationModifier.swift index d0ea77c89..a3b02a41a 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/SaturationModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/SaturationModifier.swift @@ -12,7 +12,7 @@ import SwiftUI /// Use color saturation to increase or decrease the intensity of colors in a view. /// /// ```html -/// +/// /// ``` /// /// ## Arguments diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ScaleEffectModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ScaleEffectModifier.swift index 69b06bb61..1405a3480 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ScaleEffectModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ScaleEffectModifier.swift @@ -10,7 +10,7 @@ import SwiftUI /// Scales this view’s rendered output by the given vertical and horizontal size amounts, relative to an anchor point. /// /// ```html -/// +/// /// Scale by a width and height factor /// /// ``` diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ScaledToFillModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ScaledToFillModifier.swift index 0c7b0c933..05a3bde99 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ScaledToFillModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ScaledToFillModifier.swift @@ -10,7 +10,7 @@ import SwiftUI /// Scales this view to fill its parent, maintaining this view’s aspect ratio. /// /// ```html -/// +/// /// This view will fill its parent. /// /// ``` diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ScaledToFitModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ScaledToFitModifier.swift index 07c67a600..52c350873 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ScaledToFitModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ScaledToFitModifier.swift @@ -10,7 +10,7 @@ import SwiftUI /// Scales this view to fit its parent, maintaining this view’s aspect ratio. /// /// ```html -/// +/// /// This view will fit its parent. /// /// ``` diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ShadowModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ShadowModifier.swift index 699162bf1..05c9a73fd 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ShadowModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/ShadowModifier.swift @@ -10,7 +10,7 @@ import SwiftUI /// Adds a shadow to this view. /// /// ```html -/// Shadowed Text +/// Shadowed Text /// ``` /// /// ## Arguments diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/SymbolVariantModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/SymbolVariantModifier.swift index 933511d6e..e417ee3aa 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/SymbolVariantModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/SymbolVariantModifier.swift @@ -12,8 +12,8 @@ import SwiftUI /// See ``LiveViewNative/SwiftUI/SymbolVariants`` for a list of possible values. /// /// ```html -/// -/// +/// +/// /// ``` /// /// ## Arguments diff --git a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/TransformEffectModifier.swift b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/TransformEffectModifier.swift index 6a359549c..8fde576d5 100644 --- a/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/TransformEffectModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Drawing and Graphics Modifiers/TransformEffectModifier.swift @@ -14,7 +14,7 @@ import SwiftUI /// - Note: The frame of the element is not affected. /// /// ```html -/// -/// +/// /// Username -/// Password +/// Password /// /// /// ``` diff --git a/Sources/LiveViewNative/Modifiers/Focus Modifiers/FocusSectionModifier.swift b/Sources/LiveViewNative/Modifiers/Focus Modifiers/FocusSectionModifier.swift index af56e948e..01eac6474 100644 --- a/Sources/LiveViewNative/Modifiers/Focus Modifiers/FocusSectionModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Focus Modifiers/FocusSectionModifier.swift @@ -19,7 +19,7 @@ import SwiftUI /// /// ```html /// -/// +/// /// /// /// diff --git a/Sources/LiveViewNative/Modifiers/Focus Modifiers/FocusableModifier.swift b/Sources/LiveViewNative/Modifiers/Focus Modifiers/FocusableModifier.swift index cf7be84c5..dbc33a267 100644 --- a/Sources/LiveViewNative/Modifiers/Focus Modifiers/FocusableModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Focus Modifiers/FocusableModifier.swift @@ -12,12 +12,12 @@ import SwiftUI /// You can apply this modifier to elements that do not receive focus by default. /// /// ```html -/// +/// /// ``` /// /// Or disable focusability for an element. /// ```html -/// /// ``` diff --git a/Sources/LiveViewNative/Modifiers/Focus Modifiers/PrefersDefaultFocusModifier.swift b/Sources/LiveViewNative/Modifiers/Focus Modifiers/PrefersDefaultFocusModifier.swift index fbba730bc..0467692bc 100644 --- a/Sources/LiveViewNative/Modifiers/Focus Modifiers/PrefersDefaultFocusModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Focus Modifiers/PrefersDefaultFocusModifier.swift @@ -13,9 +13,9 @@ import SwiftUI /// /// ```html /// -/// +/// /// Username -/// Password +/// Password /// /// /// diff --git a/Sources/LiveViewNative/Modifiers/Gestures Modifiers/DefersSystemGesturesModifier.swift b/Sources/LiveViewNative/Modifiers/Gestures Modifiers/DefersSystemGesturesModifier.swift index 8964dbe1e..277b79cdd 100644 --- a/Sources/LiveViewNative/Modifiers/Gestures Modifiers/DefersSystemGesturesModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Gestures Modifiers/DefersSystemGesturesModifier.swift @@ -13,9 +13,8 @@ import SwiftUI /// /// ```html /// gesture(...) -/// |> defers_system_gestures(edges: :vertical) +/// gesture(...) +/// |> defers_system_gestures(on: :vertical) /// } /> /// ``` /// diff --git a/Sources/LiveViewNative/Modifiers/Gestures Modifiers/GestureModifier.swift b/Sources/LiveViewNative/Modifiers/Gestures Modifiers/GestureModifier.swift index c67bf77c9..fd1ded9b8 100644 --- a/Sources/LiveViewNative/Modifiers/Gestures Modifiers/GestureModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Gestures Modifiers/GestureModifier.swift @@ -14,7 +14,7 @@ import SwiftUI /// Pass in a ``gesture`` and an event name. /// /// ```html -/// +/// /// ``` /// /// ```elixir @@ -122,7 +122,7 @@ enum GesturePriority: String, Decodable { /// ```html /// @@ -136,7 +136,7 @@ enum GesturePriority: String, Decodable { /// ```html /// @@ -150,7 +150,7 @@ enum GesturePriority: String, Decodable { /// ```html /// diff --git a/Sources/LiveViewNative/Modifiers/Images Modifiers/ImageScaleModifier.swift b/Sources/LiveViewNative/Modifiers/Images Modifiers/ImageScaleModifier.swift index 17bfef8bc..9d87ccd9d 100644 --- a/Sources/LiveViewNative/Modifiers/Images Modifiers/ImageScaleModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Images Modifiers/ImageScaleModifier.swift @@ -10,7 +10,7 @@ import SwiftUI /// Adjusts the scaling of images within an element. /// /// ```html -/// +/// /// /// /// ``` diff --git a/Sources/LiveViewNative/Modifiers/Images Modifiers/SymbolRenderingModeModifier.swift b/Sources/LiveViewNative/Modifiers/Images Modifiers/SymbolRenderingModeModifier.swift index 7f551028d..c0d6eece2 100644 --- a/Sources/LiveViewNative/Modifiers/Images Modifiers/SymbolRenderingModeModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Images Modifiers/SymbolRenderingModeModifier.swift @@ -10,7 +10,7 @@ import SwiftUI /// Sets the rendering mode for symbol images within this view. /// /// ```html -/// +/// /// /// /// ``` diff --git a/Sources/LiveViewNative/Modifiers/Input Events Modifiers/AllowsHitTestingModifier.swift b/Sources/LiveViewNative/Modifiers/Input Events Modifiers/AllowsHitTestingModifier.swift index 62597de69..2c2850e4e 100644 --- a/Sources/LiveViewNative/Modifiers/Input Events Modifiers/AllowsHitTestingModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Input Events Modifiers/AllowsHitTestingModifier.swift @@ -12,9 +12,8 @@ import SwiftUI /// ```html /// frame(width: 32, height: 32) -/// |> allows_hit_testing(enabled: true) +/// frame(width: 32, height: 32) +/// |> allows_hit_testing(true) /// } /// /> /// ``` diff --git a/Sources/LiveViewNative/Modifiers/Input Events Modifiers/DigitalCrownAccessoryModifier.swift b/Sources/LiveViewNative/Modifiers/Input Events Modifiers/DigitalCrownAccessoryModifier.swift index 9b991dc47..6079b26c7 100644 --- a/Sources/LiveViewNative/Modifiers/Input Events Modifiers/DigitalCrownAccessoryModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Input Events Modifiers/DigitalCrownAccessoryModifier.swift @@ -13,9 +13,8 @@ import SwiftUI /// /// ```html /// digital_crown_accessory(content: :dca_view) -/// |> digital_crown_accessory_visibility(visibility: :visible) +/// digital_crown_accessory(content: :dca_view) +/// |> digital_crown_accessory_visibility(:visible) /// }> /// /// diff --git a/Sources/LiveViewNative/Modifiers/Input Events Modifiers/DigitalCrownAccessoryVisibilityModifier.swift b/Sources/LiveViewNative/Modifiers/Input Events Modifiers/DigitalCrownAccessoryVisibilityModifier.swift index 91fd23b40..ccc532ef1 100644 --- a/Sources/LiveViewNative/Modifiers/Input Events Modifiers/DigitalCrownAccessoryVisibilityModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Input Events Modifiers/DigitalCrownAccessoryVisibilityModifier.swift @@ -13,13 +13,10 @@ import SwiftUI /// /// ```html /// digital_crown_accessory(content: :dca_view) -/// |> digital_crown_accessory_visibility(visibility: :visible) +/// digital_crown_accessory(content: :dca_view) +/// |> digital_crown_accessory_visibility(:visible) /// }> -/// -/// -/// +/// /// /// ``` /// diff --git a/Sources/LiveViewNative/Modifiers/Input Events Modifiers/HoverEffectModifier.swift b/Sources/LiveViewNative/Modifiers/Input Events Modifiers/HoverEffectModifier.swift index 9eb69816b..cb9f7c143 100644 --- a/Sources/LiveViewNative/Modifiers/Input Events Modifiers/HoverEffectModifier.swift +++ b/Sources/LiveViewNative/Modifiers/Input Events Modifiers/HoverEffectModifier.swift @@ -12,7 +12,7 @@ import SwiftUI /// Note: The system may fall back to a more appropriate effect. /// /// ```html -///