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
- func CanInstallPackages(cx *core.Scope, done func(allowed bool))
- func ExitApp(cx *core.Scope)
- func InstallPackage(cx *core.Scope, path string, done func(started bool, err error))
- func IsAppClip(cx *core.Scope) bool
- func IsAvailable(cx *core.Scope) bool
- func OpenInstallSettings(cx *core.Scope, done func(opened bool))
- func OpenedURL(cx *core.Scope) string
- func OverlayPermission(cx *core.Scope, done func(core.OverlayPermission))
- func PlayHaptic(cx *core.Scope, h Haptic)
- func RequestOverlayPermission(cx *core.Scope, done func(core.OverlayPermission))
- type Haptic
- type InputAccessoryView
- type Overlay
- type OverlayEnd
- type OverlayOptions
- type TabBar
- type TabBarItem
Constants ¶
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.
const ( OverlayDenied = core.OverlayDenied OverlayGranted = core.OverlayGranted )
The permissions OverlayPermission answers, core.OverlayPermission values.
const ( OverlayEndDenied = core.OverlayEndDenied 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.
Variables ¶
This section is empty.
Functions ¶
func CanInstallPackages ¶
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 ExitApp ¶
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 InstallPackage ¶
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 ¶
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 ¶
IsAvailable reports whether the app runs on iOS or Android, where this package's components show.
func OpenInstallSettings ¶
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 ¶
OpenedURL returns the web link that last opened the app: on iOS an App Clip's invocation, such as https://example.com/order?table=12, which says what the clip shows; "" when no link opened it, and elsewhere. It changes as a link opens the running app again, so what reads it in a component follows.
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 ¶
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 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.
Types ¶
type Haptic ¶
Haptic is feedback the device plays under the user's finger, from HapticSelection to HapticError.
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 ¶
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 the current owner and closes as that owner goes; opened in the app's own scope it lasts as long as the app's process. 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 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 is the system's where the style leaves it open. Elsewhere it takes no room and shows nothing, and the app shows its tabs with base.Tabs.