BB.TUI.Panels.StatusBar (BB.TUI v0.2.0)

Copy Markdown View Source

Status bar — single-line bar at the bottom of the dashboard.

Carries (in order) the robot module, a colored safety badge, a runtime-state pill, a battery / power segment (only when the robot has published electrical telemetry), the global key hints (Tab / q / ?), and a set of context-sensitive key pills for the active panel.

Every segment is a %ExRatatui.Text.Span{} so each piece can carry its own color: the safety badge changes color with the safety state (green / yellow / red / dim), the battery readout colors by remaining charge (BB.TUI.Theme.battery_color/1), key labels render as cyan pills (red for q), descriptions render dim. See BB.TUI.Theme.brand_title/2, safety_badge/1, key_pill/2 for the underlying primitives.

The battery segment prefers BB.Message.Sensor.BatteryState (charge percentage, or voltage when percentage is unmeasured) and falls back to BB.Message.Sensor.PowerState (bus voltage) when only the latter is available — making the charge level visible at a glance over SSH.

Pure function — takes state, returns a widget struct.

Summary

Functions

Renders the status bar as a Paragraph widget.

Functions

render(state)

@spec render(BB.TUI.State.t()) :: struct()

Renders the status bar as a Paragraph widget.

Examples

iex> state = %BB.TUI.State{
...>   robot: MyApp.Robot, ui: %BB.TUI.State.UI{active_panel: :safety},
...>   safety: %BB.TUI.State.Safety{state: :armed, runtime: :idle}
...> }
iex> %ExRatatui.Widgets.Paragraph{text: %ExRatatui.Text.Line{spans: spans}} =
...>   BB.TUI.Panels.StatusBar.render(state)
iex> Enum.map_join(spans, "", & &1.content) =~ "MyApp.Robot"
true

iex> state = %BB.TUI.State{
...>   robot: MyApp.Robot, ui: %BB.TUI.State.UI{active_panel: :safety},
...>   safety: %BB.TUI.State.Safety{state: :armed, runtime: :idle}
...> }
iex> %ExRatatui.Widgets.Paragraph{text: %ExRatatui.Text.Line{spans: spans}} =
...>   BB.TUI.Panels.StatusBar.render(state)
iex> Enum.map_join(spans, "", & &1.content) =~ "ARMED"
true