summaryrefslogtreecommitdiff
path: root/lua/main.lua
blob: 5cfba47b4425a7075fd4d1eddc81fc771aa3d12e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
local font = require("font")
local vol = require("volume")
local theme = require("theme")

-- Set up property bindings that are used across every screen.
GLOBAL_BINDINGS = {
  vol.current_pct:bind(function(pct)
    require("alerts").show(function()
      local container = lvgl.Object(nil, {
        w = lvgl.PCT(80),
        h = lvgl.SIZE_CONTENT,
        flex = {
          flex_direction = "column",
          justify_content = "center",
          align_items = "center",
          align_content = "center",
        },
        bg_opa = lvgl.OPA(100),
        bg_color = "#fafafa",
        radius = 8,
        pad_all = 2,
      })
      container:Label {
        text = string.format("Volume %i%%", pct),
        text_font = font.fusion_10
      }
      container:Bar {
        w = lvgl.PCT(100),
        h = 8,
        range = { min = 0, max = 100 },
        value = pct,
      }
      container:center()
    end)
  end),
}

local lvgl = require("lvgl")
local my_theme = {
  base = {
    {lvgl.PART.MAIN, lvgl.Style {
      bg_opa = lvgl.OPA(0),
      text_font = font.fusion_12,
      text_color = "#ff0000", -- Red to check it applies
    }},
    {lvgl.STATE.FOCUSED, lvgl.Style {
      bg_opa = lvgl.OPA(100),
      bg_color = "#0000ff", -- ew
      text_color = "#ff0000", -- Red to check it applies
    }},
  },
  button = {
    {lvgl.STATE.FOCUSED, lvgl.Style {
      bg_color = "#00ff00",
    }},
    {lvgl.PART.MAIN, lvgl.Style {
      bg_color = "#00ff00",
    }},
  },
}
theme.set(my_theme)

local backstack = require("backstack")
local main_menu = require("main_menu")

backstack.push(main_menu)