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.
- In Android Studio, select File โ Add Packages...
- Enter the package URL
https://github.com/liveview-native/liveview-client-jetpack
- Select Add Package
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.
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
]
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.
- Browse the documentation to read about the API.
- Check out the ElixirConf '22 chat app for an example of a complete app.