mobile

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 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 mobile holds what only iOS and Android have: the system's tab bar and a bar above the software keyboard, as NSH's nsh/mobile. It builds on every platform, so one app runs everywhere: elsewhere its components take no room, and IsAvailable says whether they show.

Index

Constants

View Source
const (
	// AppClipOverlayBottom puts the recommendation at the screen's bottom.
	AppClipOverlayBottom = core.AppClipOverlayBottom
	// AppClipOverlayBottomRaised leaves room for a bottom bar.
	AppClipOverlayBottomRaised = core.AppClipOverlayBottomRaised
)
View Source
const (
	TabBarBottom    = core.TabBarBottom
	TabBarLeading   = core.TabBarLeading
	TabBarTrailing  = core.TabBarTrailing
	TabBarAutomatic = core.TabBarAutomatic
)

The edges a TabBar may sit on: the bottom by default, a vertical leading or trailing edge, or following the system's choice (core.Env.VerticalBarEdge).

View Source
const (
	HapticSelection = core.HapticSelection
	HapticLight     = core.HapticLight
	HapticMedium    = core.HapticMedium
	HapticHeavy     = core.HapticHeavy
	HapticSoft      = core.HapticSoft
	HapticRigid     = core.HapticRigid
	HapticSuccess   = core.HapticSuccess
	HapticWarning   = core.HapticWarning
	HapticError     = core.HapticError
)

The haptics PlayHaptic plays: a selection changing, an impact of a weight, and a task's outcome.

View Source
const (
	OverlayDenied      = core.OverlayDenied
	OverlayGranted     = core.OverlayGranted
	OverlayUnavailable = core.OverlayUnavailable
)

The permissions OverlayPermission answers, core.OverlayPermission values.

View Source
const (
	OverlayEndDenied      = core.OverlayEndDenied
	OverlayEndUnavailable = core.OverlayEndUnavailable
	OverlayEndRevoked     = core.OverlayEndRevoked
	OverlayEndRemoved     = core.OverlayEndRemoved
	OverlayEndFailed      = core.OverlayEndFailed
)

Why the platform closes an overlay itself: the permission missing as it opened, or the app's manifest not asking for it, the user revoking it, the system or the user stopping its service, or the platform failing to show it.

View Source
const (
	GestureEdgeTop    = core.GestureEdgeTop
	GestureEdgeLeft   = core.GestureEdgeLeft
	GestureEdgeBottom = core.GestureEdgeBottom
	GestureEdgeRight  = core.GestureEdgeRight
)

Variables

This section is empty.

Functions

func AssetPackReady

func AssetPackReady(ctx context.Context, name string) (bool, error)

AssetPackReady reports whether the store pack is available locally. Call it off the UI thread. Platforms without store packs return errors.ErrUnsupported.

func CanInstallPackages

func CanInstallPackages(cx *core.Scope, done func(allowed bool))

CanInstallPackages calls done with whether the user lets the app install packages on Android, as PackageManager.canRequestPackageInstalls says: false until they allow it in the setting OpenInstallSettings opens, and always for an app whose manifest does not ask for REQUEST_INSTALL_PACKAGES. Elsewhere it answers false.

func DeferSystemGestures

func DeferSystemGestures(cx *core.Scope, opts SystemGestureOptions) (release func())

DeferSystemGestures asks the OS to give the current surface's touches priority over navigation gestures. iOS takes IOSEdges. Android 10 and later take AndroidRects in surface points, subject to the system's exclusion limits. Other targets ignore the request. The request lasts until release runs or the current scope is cleaned up. Simultaneous requests on one surface combine. Calling release more than once is safe.

func ExitApp

func ExitApp(cx *core.Scope)

ExitApp leaves the app on Android as its back button does when nothing in the app takes it: the task's root activity goes to the background, any other finishes. iOS apps never leave themselves, so it does nothing there, as elsewhere.

func Immersive

func Immersive(cx *core.Scope, on bool)

Immersive requests that the window hide its system bars. Android hides its status and navigation bars and reveals them briefly on an edge swipe. HarmonyOS asks the system to hide its status bar, navigation bar and navigation indicator. iOS hides the status bar and lets UIKit hide the home indicator. Pass false to return to the window's regular settings. A shown screen or modal can override it in its StatusBar. Other targets ignore it.

func InstallPackage

func InstallPackage(cx *core.Scope, path string, done func(started bool, err error))

InstallPackage hands the APK at path, in the app's own storage, to Android's package installer, which asks the user to confirm. done, when not nil, learns whether the installer started, with the error when it did not: a missing file, an app whose manifest does not ask for android.permission.REQUEST_INSTALL_PACKAGES (nsgo.yaml's android.permissions; an embedding host's own manifest), or a failed launch. That it started says nothing of whether the user installed the package. Where the user has not let the app install packages (CanInstallPackages), the installer sends them to the setting first. The installer reads the file through a content URI the runtime grants it, so the app keeps it until the installer is done and deletes it itself. Elsewhere it answers with an error. It never installs silently.

func IsAppClip

func IsAppClip(cx *core.Scope) bool

IsAppClip reports whether the app runs as an iOS App Clip, the part of an app nsgo.yaml's app_clip builds, which the system runs from a link, a code or an NFC tag without installing the app. An app whose clip is its own package shows the clip's screens when it does.

func IsAvailable

func IsAvailable(cx *core.Scope) bool

IsAvailable reports whether the app runs on iOS or Android, where this package's components show; a watch, which reports iOS, and a web build that runs as one (core.Env.Simulated) do not.

func OnOpenLinks(cx *core.Scope, fn func(links []string))

OnOpenLinks runs fn with declared URL-scheme and associated HTTPS links the system asks the app to open. nsgo.yaml's url_schemes registers schemes, and app_links registers Android HTTPS hosts. They reach the running app, and the link the app launched to open waits for the first handler. A link carries whatever the page that made it chose, so treat its contents as untrusted input and confirm with the user before acting on it. It is desktop.OnOpenLinks for phones, and either hears the same links.

func OnShared

func OnShared(cx *core.Scope, fn func(items []SharedItem))

OnShared calls fn for each share the system delivers while cx lives. Shares that launch the app wait for its first handler. On Android, nsgo.yaml's android.share_types declares which media types the app receives.

func OpenAssetPackFile

func OpenAssetPackFile(name, path string) (io.ReadCloser, error)

OpenAssetPackFile opens a slash-separated path in a downloaded store pack. Close the returned reader after use.

func OpenInstallSettings

func OpenInstallSettings(cx *core.Scope, done func(opened bool))

OpenInstallSettings opens Android's setting that lets the app install packages, for the user to allow it, and calls done with whether it opened. Elsewhere it answers false.

func OpenedURL

func OpenedURL(cx *core.Scope) string

OpenedURL returns the last link that invoked the iOS or Android app, or the current address of a whole-page web app. It is available before the root renders and follows later invocations and browser address changes. It returns "" when no invocation was supplied or the surface is embedded in a containing page.

func OverlayPermission

func OverlayPermission(cx *core.Scope, done func(core.OverlayPermission))

OverlayPermission calls done with whether the app may show overlays on Android, as Settings.canDrawOverlays says, without asking the user; unavailable for an app whose manifest does not ask for SYSTEM_ALERT_WINDOW, and elsewhere.

func PlayHaptic

func PlayHaptic(cx *core.Scope, h Haptic)

PlayHaptic plays h: through UIKit's feedback generators on iOS, and on Android through the view's haptic feedback, its nearest constant, where the user's touch feedback setting allows it. Devices without haptics, and every other platform, play nothing.

func PlayHapticPattern

func PlayHapticPattern(cx *core.Scope, pattern HapticPattern)

PlayHapticPattern plays pattern in place of the current one. An empty pattern stops playback. Env.CanPlayHapticPattern reports support.

func RequestOverlayPermission

func RequestOverlayPermission(cx *core.Scope, done func(core.OverlayPermission))

RequestOverlayPermission opens Android's setting that lets the app draw over other apps, for the user to grant it, and calls done with the permission as the app comes back to the front; at once where the permission is granted already or unavailable. Ask as the user does something that needs it.

func ShowAppClipOverlay

func ShowAppClipOverlay(cx *core.Scope, position AppClipOverlayPosition) (dismiss func())

ShowAppClipOverlay asks the App Store to recommend this App Clip's full app, using StoreKit's App Clip configuration. Call it from an explicit user action. StoreKit decides whether it can load and display the offer; this does not install an app or report a successful presentation.

The returned dismiss function is safe to call repeatedly or from another goroutine. The current scope's cleanup also dismisses its own request, without dismissing a newer request. Outside a real iOS App Clip, or when a confined owner is refused presentation, this is a no-op.

Types

type AppClipOverlayPosition

type AppClipOverlayPosition = core.AppClipOverlayPosition

AppClipOverlayPosition locates the system's full-app recommendation.

type Haptic

type Haptic = core.Haptic

Haptic is feedback the device plays under the user's finger, from HapticSelection to HapticError.

type HapticEvent

type HapticEvent = core.HapticEvent

HapticEvent is one event in a HapticPattern.

type HapticPattern

type HapticPattern = core.HapticPattern

HapticPattern is a sequence of timed pulses.

type InputAccessoryView

type InputAccessoryView = core.InputAccessoryView

InputAccessoryView is a bar that rides above the software keyboard while an Input naming its ID in InputAccessoryViewID has focus. It is as wide as the surface and as tall as its content, and shows nothing where it is written.

type Overlay

type Overlay = core.Window

Overlay is a window over other apps on Android, the surface OpenOverlay opens: Show, Hide, Focus and Close it, and Visible says whether it shows. Its methods do nothing on a nil Overlay, which OpenOverlay returns where there is none.

func OpenOverlay

func OpenOverlay(cx *core.Scope, opts OverlayOptions, content func(cx *core.Scope) core.Node) *Overlay

OpenOverlay opens a window over other apps on Android showing content, a tree of its own on the app's one engine, which belongs to cx itself rather than the running owner and closes as cx goes; opened with the app's own scope it lasts as long as the app's process even when opened from a button or callback handler. It takes touches and leaves the keys and the touches around it to the app in front, unless its options say otherwise, and a foreground service keeps the app's process while it shows. The app lists android.permission.SYSTEM_ALERT_WINDOW in nsgo.yaml's android.permissions, and the user grants it (RequestOverlayPermission): without it the overlay ends at once, OverlayEndDenied. The app has one overlay at a time: OpenOverlay returns nil while another is open, and on every other platform, where desktop.OpenPanel floats a window instead.

type OverlayEnd

type OverlayEnd = core.OverlayEnd

OverlayEnd is why the platform closed an overlay itself (OverlayOptions.OnEnd).

type OverlayOptions

type OverlayOptions = core.OverlayOptions

OverlayOptions are an overlay's size, place, input modes and what hears it end.

type PictureInPicture

type PictureInPicture = core.PictureInPicture

PictureInPicture renders an independent NSGo tree into iOS Picture in Picture. The system window takes only play, pause and skip commands; other input is unavailable. Background suspension retains the last rendered frame. Ref starts and stops it; deleting its scope stops it. Unsupported platforms call OnState with Supported=false. Its layer renderer supports views, text, images, Canvas and Video frames exposed by AVFoundation. Web views, Metal shaders and backdrop effects do not render. Use the outer Ref to start the session and forward its playback callbacks to the Video when the two share playback state.

type PictureInPictureState

type PictureInPictureState = core.PictureInPictureState

PictureInPictureState describes support, readiness, activity and errors.

type SharedItem

type SharedItem = core.SharedItem

SharedItem is text (Text) or a file (Path and Name) received from another app. MIME is the item's media type. Copy the file out of the app's cache if it needs to outlive the cache.

type SystemGestureEdge

type SystemGestureEdge = core.SystemGestureEdge

SystemGestureEdge is a mask of physical screen edges.

type SystemGestureOptions

type SystemGestureOptions = core.SystemGestureOptions

SystemGestureOptions names edges on iOS and exclusion rectangles on Android.

type TabBadge

type TabBadge = core.TabBadge

TabBadge shows text or a dot on a tab. The zero value clears it.

type TabBar

type TabBar = core.TabBar

TabBar is the system's tab bar for an app's top-level sections: UITabBar on iOS (Liquid Glass from iOS 26), a Material 3 navigation bar on Android, each in the system's look. The app gives the tabs, says which is selected, hears the user's choice with OnChange and shows the selected tab's content; it places the bar with its style, whose height (or width on a vertical edge) is the system's where the style leaves it open. Set Edge (or EdgeFunc) to TabBarLeading or TabBarTrailing to draw the bar vertically on that edge, or TabBarAutomatic to follow the system's choice (core.Env.VerticalBarEdge). Elsewhere it takes no room and shows nothing, and the app shows its tabs with base.Tabs.

type TabBarEdge

type TabBarEdge = core.TabBarEdge

TabBarEdge is the edge along which a TabBar lays out its tabs.

type TabBarItem

type TabBarItem = core.TabBarItem

TabBarItem is one tab of a TabBar.

Directories

Path Synopsis
Package locales holds the mobile components' localized messages.
Package locales holds the mobile components' localized messages.

Jump to

Keyboard shortcuts

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