minimum viable user interaction system

This commit is contained in:
Eric S. Londres 2022-08-15 21:23:21 -04:00
commit 23182d7c10
Signed by: slondr
GPG Key ID: A2D25B4D5CB970E4
9 changed files with 167 additions and 0 deletions

4
.formatter.exs Normal file
View File

@ -0,0 +1,4 @@
# Used by "mix format"
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
]

28
.gitignore vendored Normal file
View File

@ -0,0 +1,28 @@
# The directory Mix will write compiled artifacts to.
/_build/
# If you run "mix test --cover", coverage assets end up here.
/cover/
# The directory Mix downloads your dependencies sources to.
/deps/
# Where 3rd-party dependencies like ExDoc output generated docs.
/doc/
# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch
# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump
# Also ignore archive artifacts (built via "mix archive.build").
*.ez
# Ignore package tarball (built via "mix hex.build").
foo-*.tar
# Ignore scripts marked as secret - usually passwords and such in config files
*.secret.exs
*.secrets.exs

4
README.md Normal file
View File

@ -0,0 +1,4 @@
Readme text goes here
From template

27
config/config.exs Normal file
View File

@ -0,0 +1,27 @@
# This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
use Mix.Config
# Configure the main viewport for the Scenic application
config :beepboop, :viewport, [
name: :main_viewport,
size: {700, 600},
default_scene: {Beepboop.Scene.Home, nil},
drivers: [
[
module: Scenic.Driver.Local,
name: :local
# opts: [resizeable: true, title: "beepboop"]
]
]
]
config :scenic, :assets, module: Beepboop.Assets
# It is also possible to import configuration files, relative to this
# directory. For example, you can emulate configuration per environment
# by uncommenting the line below and defining dev.exs, test.exs and such.
# Configuration from the imported file will override the ones defined
# here (which is why it is important to import them last).
#
# import_config "prod.exs"

3
lib/assets.ex Normal file
View File

@ -0,0 +1,3 @@
defmodule Beepboop.Assets do
use Scenic.Assets.Static, otp_app: :beepboop
end

17
lib/beepboop.ex Normal file
View File

@ -0,0 +1,17 @@
defmodule Beepboop do
@moduledoc """
Starter application using the Scenic framework.
"""
def start(_type, _args) do
# load the viewport configuration from config
main_viewport_config = Application.get_env(:beepboop, :viewport)
# start the application with the viewport
children = [
{Scenic, [main_viewport_config]}
]
Supervisor.start_link(children, strategy: :one_for_one)
end
end

44
lib/scenes/home.ex Normal file
View File

@ -0,0 +1,44 @@
defmodule Beepboop.Scene.Home do
use Scenic.Scene
require Logger
# alias Scenic.Graph
# alias Scenic.ViewPort
import Scenic.Primitives
import Scenic.Components
import Scenic.Graph
# ============================================================================
# setup
# --------------------------------------------------------
def init(scene, _params, _opts) do
graph = Scenic.Graph.build(font: :roboto)
|> text("Hello worl", id: :text)
|> button("OK", id: :push_me)
scene = assign(scene, some_state: 123, graph: graph)
|> push_graph(graph)
{:ok, scene}
end
# display any received events
def handle_event(event, _, %{assigns: %{graph: graph}} = scene) do
IO.puts inspect event
graph = Scenic.Graph.modify( graph, :text, &text(&1, inspect(event)))
scene =
scene
|> assign( graph: graph )
|> push_graph( graph )
{:noreply, scene}
end
end

30
mix.exs Normal file
View File

@ -0,0 +1,30 @@
defmodule Beepboop.MixProject do
use Mix.Project
def project do
[
app: :beepboop,
version: "0.1.0",
elixir: "~> 1.7",
build_embedded: true,
start_permanent: Mix.env() == :prod,
deps: deps()
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
mod: {Beepboop, []},
extra_applications: [:crypto]
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:scenic, "~> 0.11.0-beta.0"},
{:scenic_driver_local, "~> 0.11-beta.0"}
]
end
end

10
mix.lock Normal file
View File

@ -0,0 +1,10 @@
%{
"elixir_make": {:hex, :elixir_make, "0.6.3", "bc07d53221216838d79e03a8019d0839786703129599e9619f4ab74c8c096eac", [:mix], [], "hexpm", "f5cbd651c5678bcaabdbb7857658ee106b12509cd976c2c2fca99688e1daf716"},
"ex_image_info": {:hex, :ex_image_info, "0.2.4", "610002acba43520a9b1cf1421d55812bde5b8a8aeaf1fe7b1f8823e84e762adb", [:mix], [], "hexpm", "fd1a7e02664e3b14dfd3b231d22fdd48bd3dd694c4773e6272b3a6228f1106bc"},
"font_metrics": {:hex, :font_metrics, "0.5.1", "10ce0b8b1bf092a2d3d307e05a7c433787ae8ca7cd1f3cf959995a628809a994", [:mix], [{:nimble_options, "~> 0.3", [hex: :nimble_options, repo: "hexpm", optional: false]}], "hexpm", "192e4288772839ae4dadccb0f5b1d5c89b73a0c3961ccea14b6181fdcd535e54"},
"input_event": {:hex, :input_event, "0.4.3", "ea1c6c81fd245f617858294ce106bf4b9c35822eaa94793ffa104cc0ae1bd323", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "818bd6b20d3a6ccac868074138eae5dbae17baf2f7711b2852253d6461ad80db"},
"nimble_options": {:hex, :nimble_options, "0.3.7", "1e52dd7673d36138b1a5dede183b5d86dff175dc46d104a8e98e396b85b04670", [:mix], [], "hexpm", "2086907e6665c6b6579be54ef5001928df5231f355f71ed258f80a55e9f63633"},
"scenic": {:hex, :scenic, "0.11.0-beta.0", "e753ebfa61eaa060810831be0eb346c544f345d47d53d12c2f58f1614e66bfa2", [:make, :mix], [{:elixir_make, "~> 0.6.2", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:ex_image_info, "~> 0.2.4", [hex: :ex_image_info, repo: "hexpm", optional: false]}, {:font_metrics, "~> 0.5.0", [hex: :font_metrics, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.3.4", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:truetype_metrics, "~> 0.5", [hex: :truetype_metrics, repo: "hexpm", optional: false]}], "hexpm", "cace35efcc1d8e914f03abad5677ebd4d648be1cbd04d93c4af0d97a5c2df722"},
"scenic_driver_local": {:hex, :scenic_driver_local, "0.11.0-beta.0", "da8c58b60346daf51d6c0133e7b296f851d97fe86a5d0988bff99f8ae19ff186", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:input_event, "~> 0.4", [hex: :input_event, repo: "hexpm", optional: false]}, {:scenic, "~> 0.11.0-beta.0", [hex: :scenic, repo: "hexpm", optional: false]}], "hexpm", "8812762a9721c73a5ee4c306f6ea1eafa7bd1de6997709f9e1243f734610f780"},
"truetype_metrics": {:hex, :truetype_metrics, "0.6.0", "683765005d6c4b4df2452459e3fc2310a037fea183caa3cbdc3d564b22fb2119", [:mix], [{:font_metrics, "~> 0.5", [hex: :font_metrics, repo: "hexpm", optional: false]}], "hexpm", "e252d5ff51ed736c446ad4f7d9b2be72d915e3d8107c337b1c914ee20802caf6"},
}