Dock and tray
On macOS an app has a Dock icon, and can put icons in the status area at the right of the menu bar.
On Linux tray icons go in the panel's status area, as StatusNotifierItems, where the desktop runs a
StatusNotifierWatcher (KDE Plasma, and GNOME with the AppIndicator extension), and there is no Dock.
On iOS and Android neither exists. Where one is missing its available() is false, and every
call does nothing.
import { Dock } from '@ng-native/device';
import { TrayIcon } from '@ng-native/components';
<tray-icon> once TrayIcon is in the component's importsinject(Dock)Platforms of Dock. Available on macOS. Absent on Linux, iPadOS, iPhone, Android and Web host, where available() is false.
Platforms of <tray-icon>. Available on macOS and Linux (while a StatusNotifierWatcher runs). Absent on iPadOS, iPhone, Android and Web host, where available() is false.
The Dock
import { Dock } from '@ng-native/device';
const dock = inject(Dock);
dock.setMenu([{ label: 'New Window', select: () => windows.open(Editor) }]);
const stop = dock.bounce({ critical: true });setMenu puts items above the ones macOS adds to the Dock icon's menu, and null takes them away.
bounce bounces the icon once, or with critical until the app comes to the front, and answers a
function that stops it. The Dock badge is the Notifications badge
count, as an app icon's is on iOS: Notifications.setBadge(3).
Tray icons
A <tray-icon> shows an icon for as long as the element is there. Its <menu-item>s are the menu a
click opens; with none, a click fires (press).
<tray-icon sfSymbol="timer" [title]="remaining()" tooltip="Focus timer">
<menu-item label="Pause" (select)="pause()" />
<menu-separator />
<menu-item menuRole="quit" label="Quit" />
</tray-icon>sfSymbol draws a symbol that follows the menu bar's light or dark appearance; image names an
image asset of the app's own. On Linux image names an icon in the icon theme, the app's own icon
stands in without one, and sfSymbol is not drawn. A menu-bar-only app pairs it with
provideMainWindow({ autoOpen: false }); see Windows.
Reference
Dockservice@ng-native/deviceimport { Dock } from '@ng-native/device';Methods
setMenu(entries: readonly MenuEntry[] | null): void Show entries in the Dock icon's menu, above the items macOS adds (Options, Show All Windows, Hide, Quit); an empty list or null takes them away. Items are MenuItemModel s, as a <menu-item> registers them.
bounce(options: { critical?: boolean } = {}): () => void Bounce the Dock icon until the app comes to the front: once, or with critical until then. Nothing while the app is in front. Answers the function that stops it.
tray-iconcomponent@ng-native/componentsimport { TrayIcon } from '@ng-native/components';and add TrayIcon to the component's imports An icon in the macOS menu bar's status area, for as long as the element is there. Its <menu-item> s are the menu a click opens; with none, a click fires (press) . On iOS and Android nothing is drawn.
Inputs
titlestringsfSymbolstringAn SF Symbol, drawn to follow the menu bar's light or dark appearance.
imagestringAn image asset of the app's own.
tooltipstringOutputs
pressvoid