# `Dala.Wakelock`
[🔗](https://github.com/manhvu/dala/blob/main/lib/dala/hardware/wakelock.ex#L1)

Screen wakelock — keep the device screen on.

Mirrors the `wakelock_plus` Flutter plugin API. No special permissions
required on either platform.

## Usage

    # Keep the screen on
    Dala.Wakelock.enable()

    # Let the screen turn off again
    Dala.Wakelock.disable()

    # Toggle based on a boolean
    Dala.Wakelock.toggle(enable: true)

    # Check current state
    if Dala.Wakelock.enabled?(), do: ...

## Platform details

- **iOS** — sets `UIApplication.sharedApplication.idleTimerDisabled`.
- **Android** — sets `WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON`
  on the main Activity's window.

No permissions are needed because this is a *screen* wakelock, not a
partial (CPU) wakelock that would keep the app alive in the background.

# `disable`

```elixir
@spec disable() :: :ok
```

Disable the screen wakelock. The screen will be allowed to turn off
normally.

# `enable`

```elixir
@spec enable() :: :ok
```

Enable the screen wakelock. The device screen will stay on until
`disable/0` is called.

# `enabled?`

```elixir
@spec enabled?() :: boolean()
```

Returns `true` if the screen wakelock is currently enabled.

# `toggle`

```elixir
@spec toggle(keyword()) :: :ok
```

Toggle the wakelock on or off.

    Dala.Wakelock.toggle(enable: true)   # enable
    Dala.Wakelock.toggle(enable: false)  # disable

---

*Consult [api-reference.md](api-reference.md) for complete listing*
