From 0ae9e6a58c53bd210da268081a398f1150bcc201 Mon Sep 17 00:00:00 2001 From: Carson Katri Date: Tue, 22 Aug 2023 16:15:33 -0400 Subject: [PATCH] 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}