Code Monkey home page Code Monkey logo

Comments (5)

mayel avatar mayel commented on July 30, 2024 2

With the LiveViewNative 0.2 beta, there's a PR to get layouts working: liveview-native/live_view_native#108

from surface.

mayel avatar mayel commented on July 30, 2024

So gave it a shot and the good news is that it mostly works! :)

Surface and LiveViewNative happily live side by side in components and views. E.g.:

        use Surface.Component
        use LiveViewNative.Component

The only thing that doesn't seem to work is collocating .sface and LVN files as I mentioned above and documented here: https://hexdocs.pm/live_view_native/render-patterns.html#external-template-files

This works in the meantime, though I'd still prefer being able to have separate files:

  def render(%{platform_id: :swiftui} = assigns) do
    # This UI renders on the iOS/Mac app
    ~SWIFTUI"""
    <VStack>
      <Text>
        Hello native!
      </Text>
    </VStack>
    """
  end

  def render(assigns) do
    assigns
    |> render_sface()
  end

from surface.

mayel avatar mayel commented on July 30, 2024

This seems the relevant code in Surface: https://github.com/surface-ui/surface/blob/v0.11.0/lib/surface/renderer.ex

And in LVN:

I'm happy to give it a go, though some guidance on how to best integrate them would be helpful!

from surface.

noozo avatar noozo commented on July 30, 2024

i think it mostly works, the main issue RN is layouts, me thinks.

from surface.

mayel avatar mayel commented on July 30, 2024

@noozo I had no issues doing this for the live layout:

defmodule MyApp.Web.LayoutLive do
        use Surface.Component
        use LiveViewNative.Component

  def render(%{platform_id: :swiftui} = assigns) do
    # This renders a layout for the iOS/Mac app
    ~SWIFTUI"""
    <VStack>
      <%= @inner_content %>
    </VStack>
    """
  end

  def render(assigns) do
  # This layout renders for the web (with Surface)
    ~F"""
    <div
      id="layout_live"
[...]

from surface.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.