Skip to content

Support passing view references in AnyShape implementation #1326

@BrooklinJazz

Description

@BrooklinJazz

To convert the following SwiftUI example into the LVN DSL

Image("turtlerock")
  .clipShape(Circle())

I wanted to pass a Circle view to the clipShape modifier using the template attribute like so:

Template

<Image class="image" name="turtlerock">
    <Circle template="example"/>
</Image>

Stylesheet

defmodule LvnWorkshopWeb.Styles.SwiftUI do
  use LiveViewNative.Stylesheet, :swiftui

  ~SHEET"""
  "image" do
    clipShape(shape: :example)
  end
  """
end

However @carson-katri informed me we don't support that syntax, and only support the list of standard shapes: https://developer.apple.com/documentation/swiftui/shape

So we can convert the following syntax into the LVN DSL:

Image("turtlerock")
  .clipShape(.circle)

But not the original syntax used in the example:

Image("turtlerock")
  .clipShape(Circle())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions