Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support passing view references in AnyShape implementation #1326

Open
BrooklinJazz opened this issue Apr 17, 2024 · 5 comments
Open

Support passing view references in AnyShape implementation #1326

BrooklinJazz opened this issue Apr 17, 2024 · 5 comments
Milestone

Comments

@BrooklinJazz
Copy link
Contributor

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())
@carson-katri
Copy link
Contributor

This issue should be moved to the SwiftUI client

@carson-katri carson-katri transferred this issue from liveview-native/live_view_native Apr 19, 2024
@bcardarella
Copy link
Collaborator

@carson-katri is it possible through the Registry to add support for these on an ad-hoc basis? So if a dev wanted to add support for a non-standard shape in this case they can still do so?

@carson-katri
Copy link
Contributor

Currently there is no way to add custom shapes that can be passed to existing modifiers through the registry. You can create your own modifier that uses your custom shape though.

@bcardarella
Copy link
Collaborator

ok, I'd like to explore this in the future but we can go with the work around for now.

@AZholtkevych
Copy link

Added to backlog

@bcardarella bcardarella added this to the 0.5.0 milestone Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

4 participants