Mob - Native BEAM / Elixir on Native Mobile

Hi, I forked your repo and converted the C NIF to Rust (yes, I prefer working with Rust over C/C++). I’m also trying to apply a new declarative UI style like this:

Each screen:

screen :home_screen do
  mount do
    assign(:count, 0)
  end

  column padding: :space_md, gap: 8 do
    text text: "Welcome to Dala!", text_size: :xl
    text text: "Count: #{assigns.count}"
    
    button text: "Increment", on_tap: :increment do
      # Inline handler - generates handle_info clause automatically
      assign(socket, :count, socket.assigns.count + 1)
    end
    
    button text: "Go to Detail", on_tap: :navigate do
      push_screen(socket, MyApp.DetailScreen)
    end
  end
end

# You can still add a generic handle_info outside
handle_info(_message, socket), do: {:noreply, socket}

Home screen:

defmodule MyApp do
  use Dala.App

  screens do
    screen :home_screen, module: MyApp.HomeScreen
    screen :detail_screen, module: MyApp.DetailScreen
  end

  def on_start do
    {:ok, _pid} = Dala.Screen.start_root(MyApp.HomeScreen)
    :ok
  end
end

I’ll come back and share more later.

2 Likes