In the HelloWorld and Coffee To Go examples in the WebRunnableBundle the menuItems function was implemented to export the service package icon into the Service Launcher card, from where user can run it. There are other places, where the service package functionality can be triggered. As for now, it is allowed to add service packages custom icons into the dock area and into the Spring Board card:
Figure 1. Custom icons in dock area and Spring Board card
There is an example in the SDK package named menuitems that showcases how to implement this.
MenuItem implementation
In order to implement any custom icon for the service package, a MenuItem should be exported in the runnable bundle.
Depending on the type of MenuItem, its optional fields may be additionally ignored or required.
For ServicesLauncher type fields svgIcon, callback and title are required and component is ignored.
For most of other types svgIcon is ignored, component is required and callback is optional.
The component parameter, when needed, should be implemented as a React Component which should match the following type definition: React.Component<MenuComponentProps>.
position field defines in which order icons will be rendered in set of icons of one type for one service package.
It allows component to get the device and user Entity, get the properties of its MenuItem and receive container-specific data.
For the menu items that are rendered by the component, the callback parameter, if defined, will not be used automatically as in case of ServicesLauncher type. The UI interaction has to be implemented inside the component implementation. But it might be useful to define reaction in callback function outside and use it inside the component:
title and description will not be rendered automatically for the icons, that require component. But it is possible to use them inside of the component renderer by accessing props.menuItem.
Dock area
In order to add a custom icon into the dock area, a runnable bundle of a service package should export a MenuItem of type SettingsMenu as shown below:
ThemeContext should be used to get the sizes, margins and colors of the client common elements. In this case dockItemSize and dockIconSize were used to get the standard docker item sizes.
The data property in props of component inside the docker area container will be undefined.
Spring Board card area
MenuItem for Spring Board card should be defined like this: