Mob.Theme.Adaptive (mob v0.9.34)

Copy Markdown View Source

Theme that follows the OS-level light / dark setting.

At call time theme/0 reads Mob.Theme.color_scheme/0 and returns Mob.Theme.Light.theme/0 or Mob.Theme.Dark.theme/0. Built for outdoor working users — sun-readable in daytime, eye-friendly at night.

Usage

defmodule MyApp do
  use Mob.App, theme: Mob.Theme.Adaptive
end

Reactive switching

Mob.Theme.AdaptiveWatcher (started by use Mob.App) calls Mob.Theme.set(Mob.Theme.Adaptive) again whenever the OS appearance flips, as long as the active theme was set from this module. Setting a fixed theme afterwards (another module, a struct, a keyword list) stops that until Mob.Theme.Adaptive is set again.

Mob.Theme.set/1 repaints the screen on show, so it switches to the new theme as soon as the OS flips.

Summary

Functions

Returns the Light or Dark theme struct based on the current OS appearance.

Functions

theme()

@spec theme() :: Mob.Theme.t()

Returns the Light or Dark theme struct based on the current OS appearance.