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

Update documentation and guides #78

Merged
merged 2 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LiveView Native is a platform for building native applications using [Elixir](ht
# lib/my_app_web/live/hello_live.ex
defmodule MyAppWeb.HelloLive do
use Phoenix.LiveView
use LiveViewNative.LiveView
use MyAppWeb, :live_view

@impl true
def render(%{format: :swiftui} = assigns) do
Expand Down
Binary file added guides/assets/images/first-ios.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added guides/assets/images/first-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified guides/assets/images/hello-ipad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified guides/assets/images/hello-iphone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified guides/assets/images/hello-mac.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added guides/assets/images/hello-watch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified guides/assets/images/hello-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion guides/common-features/handling-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ basic example of sharing a `handle_event/3` callback in this way:
# hello_live.ex
defmodule MyAppWeb.HelloLive do
use Phoenix.LiveView
use LiveViewNative.LiveView
use MyAppWeb, :live_view

@impl true
def mount(_params, _session, socket) do
Expand Down
188 changes: 0 additions & 188 deletions guides/common-features/modifiers.md

This file was deleted.

20 changes: 8 additions & 12 deletions guides/common-features/render-patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Each function clause matches on the `:format`, allowing each platform to define
# lib/my_app_web/live/hello_live.ex
defmodule MyAppWeb.HelloLive do
use Phoenix.LiveView
use LiveViewNative.LiveView
use MyAppWeb, :live_view

@impl true
def render(%{format: :swiftui} = assigns) do
Expand Down Expand Up @@ -50,8 +50,6 @@ defmodule MyAppWeb.SharedComponents do
use Phoenix.Component
use LiveViewNative.Component

import ElixirconfChatWeb.Modclasses.SwiftUi, only: [modclass: 3]

def logo(%{format: :swiftui} = assigns) do
~SWIFTUI"""
<VStack>
Expand Down Expand Up @@ -85,7 +83,7 @@ template files are namespaced according to their `:format`:
```elixir
defmodule MyAppWeb.HelloLive do
use Phoenix.LiveView
use LiveViewNative.LiveView
use MyAppWeb, :live_view

@impl true
def render(%{} = assigns) do
Expand All @@ -106,7 +104,7 @@ end
### hello_live.swiftui.heex
```heex
<VStack id="template-ios">
<HStack modifiers={padding(5)}>
<HStack class="p-5">
<Text>A SwiftUI template, courtesy of hello_live.swiftui.heex</Text>
</HStack>
</VStack>
Expand All @@ -125,19 +123,17 @@ defmodule MyAppWeb.SharedComponents do
use Phoenix.Component
use LiveViewNative.Component

import ElixirconfChatWeb.Modclasses.SwiftUi, only: [modclass: 3]

def logo(%{format: :swiftui} = assigns) do
~SWIFTUI"""
<VStack>
<%= case @native.platform_config.user_interface_idiom do %>
<% "mac" -> %>
<%= case @target do %>
<% :mac -> %>
<Text>Hello macOS!</Text>
<% "pad" -> %>
<% :pad -> %>
<Text>Hello iPadOS!</Text>
<% "watch" -> %>
<% :watch -> %>
<Text>Hello watchOS!</Text>
<% "tv" -> %>
<% :tv -> %>
<Text>Hello tvOS!</Text>
<% _ -> %>
<Text>Hello iOS!</Text>
Expand Down
3 changes: 1 addition & 2 deletions guides/common-features/template-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ defmodule MyAppWeb.MyComponents do
<HStack>
<Image name={@album.cover} />
<VStack alignment="leading">
<Text modifiers={font_weight(:bold)}><%= song.title %></Text>
<Text class="bold"><%= song.title %></Text>
<Text><%= song.artist.name %></Text>
</VStack>
</HStack>
Expand Down Expand Up @@ -71,7 +71,6 @@ Here we can observe various semantic changes to port SwiftUI code to EEx:
2. The struct value `album` is an assign, `@album`, instead.
3. Instead of passing `album.songs` as an argument, we use a comprehension.
- `<Text>` elements take their arguments as values, similar to HTML.
4. We can't call a function on an element like in SwiftUI, so the `.fontWeight(.bold)` modifier function is called as `font_weight(:bold)` and passed to the `modifiers` attribute.

These conventions can generally be applied to all sorts of examples when using LiveView Native to build SwiftUI views.
Because LiveView Native is modular, each platform library will have its own way of "bridging the gap" between the Elixir
Expand Down
Loading
Loading