LiveViewNative

Client Spec {: .info}

format: :jetpack

module_suffix: Jetpack

template_sigil: ~LVN

component: LiveViewNative.Jetpack.Component

The LiveViewNative Jetpack package lets you use Phoenix LiveView to build native Android apps with Jetpack Compose.

Installation

  1. In Android Studio, select File → Add Packages...
  2. Enter the package URL https://github.com/liveview-native/liveview-client-jetpack
  3. Select Add Package

Usage

Create a LiveView to connect to a Phoenix server running on http://localhost:4000.

// add jetpack

Now when you start up your app, the LiveView will automatically connect and serve your native app.

Elixir Library

Installation

If available in Hex, the package can be installed by adding live_view_native_jetpack to your list of dependencies in mix.exs:

def deps do
  [
    {:live_view_native_jetpack, "~> 0.3.0"}
  ]
end

Then add the Jepack plugin to your list of LiveView Native plugins:

config :live_view_native, plugins: [
  LiveViewNative.Jetpack
]

Usage

This plugin provides the Jetpack rendering behavior of a Phoenix LiveView. Start by adding this plugin to a LiveView. We do this with LiveViewNative.LiveView:

defmodule MyAppWeb.HomeLive do
  use MyAppWeb :live_view
  use LiveViewNative.LiveView,
    formats: [:jetpack],
    layouts: [
      jetpack: {MyAppWeb.Layouts.Jetpack, :app}
    ]

end

then just like all format LiveView Native rendering components you will create a new module namespaced under the calling module with the module_suffix appended:

defmodule MyAppWeb.HomeLive.Jetpack do
  use LiveViewNative.Component,
    format: :jetpack

  def render(assigns, _interface) do
    ~LVN"""
    <Text>Hello, Jetpack!</Text>
    """
  end
end

Further details on additional options and an explanation of template rendering vs using render/2 are in the LiveView Native docs.

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/live_view_native_jetpack.

Resources