Comments (5)
With the LiveViewNative 0.2 beta, there's a PR to get layouts working: liveview-native/live_view_native#108
from surface.
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.
This seems the relevant code in Surface: https://github.com/surface-ui/surface/blob/v0.11.0/lib/surface/renderer.ex
And in LVN:
- Render logic: https://github.com/liveview-native/live_view_native/blob/main/lib/live_view_native/extensions/render.ex
- Native definitions: https://github.com/liveview-native/live_view_native/blob/main/lib/live_view_native/extensions.ex#L29
- Example of how they support regular heex: https://github.com/liveview-native/live_view_native/blob/main/lib/live_view_native/platforms/web.ex
I'm happy to give it a go, though some guidance on how to best integrate them would be helpful!
from surface.
i think it mostly works, the main issue RN is layouts, me thinks.
from surface.
@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)
- Since update : no route found for POST after a <Form> is submitted HOT 1
- Improve error messaging when using `<#slot />` in template via `embed_sface/1` macro
- Setting which modules can pass context values outside of config
- Erlang Error in Elixir Language Server with Surface HOT 1
- [Using a plugin] Scoped CSS changes require two page reloads. HOT 1
- inputs_for/3 warning HOT 1
- Warnings on Select component with disabled property
- Props missing inside `handle_event()` `socket.assigns` map. HOT 3
- mix surface.init: no function clause matching in Sourceror.Zipper.down/1 HOT 3
- Submitted forms don't carry the "submitter" attribute
- Surface CSS scoping attributes don't work when root component is a component
- When using :on-click={"name", target="#target_id"} I cannot seem to get a sibling to target another sibling node that is rendered in the same parent. HOT 1
- Compatibility with LiveView 0.20 HOT 7
- Question: How would you make the sample tab component to use svg icons instead of font icons HOT 4
- Elixir 1.16: negative steps are not supported in String.slice/2, pass 1..-2//1 instead
- Malformed HTML when using LiveRedirect with another component inside HOT 1
- Mix.env() usage can cause troubles in release HOT 2
- Question: Form example on latest version HOT 2
- error: module Surface.Components.Form.Inputs is not loaded and could not be found. This may be happening because the module you are trying to load directly or indirectly depends on the current module<Description> HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from surface.