The public BOSS API is located at /public/boss/. Any application may interact with OS features using:
os: Provides OS-level functions such as sign in, clipboard functions, or launching a deeplinkos.network: Provides API to make network calls to backend servicesos.notification: Forwards app/system events and notifications to the OSos.ui: Provides access to OS UI featuresos.ui.desktop: Provides API to interact with desktopos.ui.notification: Provides API to display notifications from the BOSS system or an app
The following is a list of UI components you can use in your apps.
To see all components in action, please visit UI Components.
UIButtonincludingdefault,primary, andsecondaryactionsUICheckboxWIPUIFolderWIP displays a file-system navigatorUIListBox- Provides a flat list of options that a user may select. Supports:- selecting multiple options
- selecting a single option
- treating options like buttons
UILittleControlsa group of small up and down arrowsUIMenudisplay menu options in the OS bar (e.g.File,View,Help)UIModala composition of UI components. Touches are prevented outside of the modal until the modal is dismissed.UIPopupdisplays drop-down of selections- TBD:
UIRadio UITabsprovides a horiztonal list of file-like tabsUITextFielddisplays text fieldUIWindowis a composition of UI components- Optionally allows a close button
- Optionally allows a fullscreen button
ui-window container.group: ShowUIWindowcontainer w/ no padding and a 1px border between components
- A comprehensive library of CSS selector for layout
hbox,vbox,gap-*,align-*: A horizontal and vertical box model w/ several gap and alignment optionscontrols: Standardized way of groupingUIButtons to the rightUITextFieldhelpers includeread-only,text-field,text-area
The OS comes with several convenient UI modals including:
Alertviaos.ui.showAlert(msg: str): Display an alert to a userDeleteviaos.ui.showDelete(msg: str, cancel: function, ok: function): Display a modal that asks the user if they want to delete somethingErrorviaos.ui.showError(msg: str): Display an error messageInfoviaos.ui.showInfo(msg: str): Display an alert to a user. This has the option of beingawaited until dismissed.ProgressBarviaos.ui.showProgressBar(title: str, fn: function, indeterminate: bool=false): Display a progress bar with an optionalfnthat is called when theStopbutton is pressed.
Loadingviaos.ui.showBusy(): Shows a watch until you callos.ui.hideBusy(). This API may change in the future.
Notifications are (currently) temporary backend app/system information that are communicated to the end-user immediately.
Events are opaque messages sent from a backend app/system, which are designed to be consumed by a front-end app, or BOSS system, to perform a state change in the app.
For example, Wordy sends an event, and notification, when one of your friends makes a guess on a puzzle. The notification lets you know a friend has made a move. The event is used to update the UI within the Wordy app.
The (App structure)[/docs/app-structure.md] shows how to register your controller to recieve events.
To send a notification, or event, from your backend app do the following
from lib.server import get_friends, send_events
@router.post("/flip-switch")
@require_user()
async def _guess(boss_user: User, request: Request):
""" Contrived example showing how to send an event and
notification. """
# Query for a list of friends to send message to
user, friends = await get_friends(request)
friend_ids = [f.userId for f in friends]
# Create the event you want to send
event = {
"user": user.model_dump_json(),
"flip_switch": True
}
# Send event that the front-end app will consume to update its state.
#
# NOTE: The request is required to send messages to Swift notification
# system, as it contains the session cookie for this user.
send_events(request, "io.bithead.my-app.switch", data=event, user_ids=friend_ids)
# Send a notification. This is displayed to every user, so long as
# they are signed in and BOSS is loaded.
send_notifications(request, user_ids=friend_ids, title="Switch state", body="The switch was flipped")