Behaviour for Mob application entry point.
Usage
defmodule MyApp do
use Mob.App
def navigation(_platform) do
stack(:home, root: MyApp.HomeScreen)
end
def on_start do
Mob.Screen.start_root(MyApp.HomeScreen)
Mob.Dist.ensure_started(node: :"my_app@127.0.0.1", cookie: :secret)
end
enduse Mob.App generates a start/0 that the BEAM entry point calls. It
handles all framework initialization (native logger, navigation registry)
before delegating to on_start/0. App code only goes in on_start/0.
Navigation
Implement navigation/1 to declare the app's navigation structure.
Use the helper functions stack/2, tab_bar/1, and drawer/1:
def navigation(:ios), do: tab_bar([stack(:home, root: HomeScreen), ...])
def navigation(:android), do: drawer([stack(:home, root: HomeScreen), ...])
def navigation(_), do: stack(:home, root: HomeScreen)All name atoms used in stacks become valid push_screen destinations
without needing to reference modules directly.
Summary
Callbacks
App-specific startup hook. Called by the generated start/0 after all
framework initialization is complete.
Functions
Declare a side drawer containing multiple named stacks.
Declare a navigation stack.
Declare a tab bar containing multiple named stacks.
Callbacks
@callback on_start() :: term()
App-specific startup hook. Called by the generated start/0 after all
framework initialization is complete.
Override to start your root screen, configure Erlang distribution, set the Logger level, etc. The default implementation is a no-op.
Functions
Declare a side drawer containing multiple named stacks.
Renders as a ModalNavigationDrawer on Android. iOS uses a custom slide-in panel (native UIKit drawer support deferred).
Declare a navigation stack.
name is the atom identifier used with push_screen/2,3, pop_to/2,
and reset_to/2,3. The :root option is the module mounted when the stack
is first entered.
Options:
:root(required) — screen module that is the stack's initial screen:title— optional display label shown in tabs or drawer entries
Declare a tab bar containing multiple named stacks.
Each branch must be a stack/2 map. Renders as a bottom NavigationBar on
Android and a UITabBarController on iOS.