device

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package device holds small device controls of mobile apps: asking for a store rating, opening the app's settings page, keeping the screen on, screen brightness, the status bar, and the software keyboard.

device.KeepScreenOn(a, true)
device.SetStatusBar(a, device.StatusBar{Style: device.StatusBarLight})
device.OnKeyboard(a, func(h float64) { ... }) // h = 0: hidden

| | iOS | Android | |---|---|---| | RequestReview | SKStoreReviewController (the system decides whether to show it; never in TestFlight) | opens the Play Store page (market://, else https://play.google.com) | | OpenSettings | UIApplicationOpenSettingsURLString | ACTION_APPLICATION_DETAILS_SETTINGS | | KeepScreenOn | UIApplication.idleTimerDisabled | FLAG_KEEP_SCREEN_ON | | Brightness | UIScreen.brightness (the whole screen, until the device locks) | the window's screenBrightness (only while the app is in front); read: the system setting | | SetStatusBar | the pages' preferredStatusBarStyle / prefersStatusBarHidden; Color: ErrUnsupported | WindowInsetsController appearance / hide; Color fills the bar's background | | keyboard | UIKeyboardWillChangeFrame / WillHide notifications | IME window insets (API 30+; older: 0) |

Every function returns ErrUnsupported on desktop and tango.ErrNotRunning after the app quit.

Index

Constants

View Source
const (
	StatusBarDefault = platform.StatusBarDefault // follows light/dark mode
	StatusBarLight   = platform.StatusBarLight   // white content, for dark pages
	StatusBarDark    = platform.StatusBarDark    // dark content, for light pages
)

Variables

View Source
var ErrUnsupported = platform.ErrUnsupported

Functions

func Brightness

func Brightness(a *tango.App) (float64, error)

Brightness returns the screen brightness, 0 to 1.

func HideKeyboard

func HideKeyboard(a *tango.App) error

HideKeyboard dismisses the software keyboard.

func KeepScreenOn

func KeepScreenOn(a *tango.App, on bool) error

KeepScreenOn stops (on) or allows (off) the screen from dimming and locking while the app is in front.

func KeyboardHeight

func KeyboardHeight(a *tango.App) (float64, error)

KeyboardHeight returns the height of the software keyboard in CSS pixels, 0 when hidden.

func OnKeyboard

func OnKeyboard(a *tango.App, fn func(height float64))

OnKeyboard calls fn on the main thread when the keyboard appears, disappears (height 0) or changes height. It does nothing where the backend reports no keyboard.

func OpenSettings

func OpenSettings(a *tango.App) error

OpenSettings opens the app's page in the system settings, e.g. after the user denied a permission.

func RequestReview

func RequestReview(a *tango.App) error

RequestReview asks the user to rate the app. Ask at a natural pause, not in response to a button labelled "Rate us" on iOS (the prompt may not appear); Android opens the store page.

func ResetBrightness

func ResetBrightness(a *tango.App) error

ResetBrightness gives the brightness back to the system (Android; on iOS the system restores its own value when the device locks).

func SetBrightness

func SetBrightness(a *tango.App, v float64) error

SetBrightness sets the screen brightness (clamped to 0-1).

func SetStatusBar

func SetStatusBar(a *tango.App, s StatusBar) error

SetStatusBar sets the status bar's content style, visibility and (Android) background color.

Types

type StatusBar

type StatusBar = platform.StatusBar

StatusBar describes how the status bar looks.

type StatusBarStyle

type StatusBarStyle = platform.StatusBarStyle

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL