Skip to content

Commit

Permalink
Merge pull request #78 from liveview-native/update-docs-0.2
Browse files Browse the repository at this point in the history
Update documentation and guides
  • Loading branch information
supernintendo authored Dec 9, 2023
2 parents 79d465c + a949e1d commit 7e33056
Show file tree
Hide file tree
Showing 17 changed files with 294 additions and 264 deletions.
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

0 comments on commit 7e33056

Please sign in to comment.