pub trait Plugin: DynClone + Debug {
// Required methods
fn details(&self, mocked: bool) -> PluginDetails;
fn name(&self) -> PluginName;
fn icon_name(&self) -> &'static str;
fn localised_name(&self) -> String;
// Provided methods
fn summary(&self) -> PluginSummaryRow { ... }
fn overview(&self) -> PluginOverviewRow { ... }
}
Expand description
The Plugin trait should be implemented for additional data sources of Health.
The trait automatically provides an implementation of Plugin::overview()
, returning a PluginOverviewRow containing
the localised name and the icon of the plugin. The user may click on this row to access the (mocked) PluginDetails
page to see what the plugin does and to enable it.
Once the plugin is enabled, the PluginSummaryRow returned by Plugin::summary()
is shown to the user in the list
of enabled plugins, giving the user a quick glance over the data (e.g. “Today you’ve done X of Y steps”). Upon clicking
this PluginSummaryRow, the user is taken to the (unmocked) PluginDetails page.
To create a new plugin, you should do the following things:
- Create a new subfolder in
src/plugins/$plugin_name
- Create a
details.rs
andsummary.rs
, containing the subclass of PluginDetails and PluginSummaryRow respectively. - Add the name of your plugin to PluginName (and fix compile errors from non-exhaustive match arms).
- Create a
plugin.rs
and implement the Plugin trait. - Finally, add your plugin to the list in the Registrar
Required Methods§
sourcefn details(&self, mocked: bool) -> PluginDetails
fn details(&self, mocked: bool) -> PluginDetails
Returns a card view containing details,e.g. steps over some weeks. May be mocked via the is-mocked
property.
sourcefn name(&self) -> PluginName
fn name(&self) -> PluginName
The non-localised name of the plugin, used as ID. !Must! be unique across plugins
sourcefn icon_name(&self) -> &'static str
fn icon_name(&self) -> &'static str
The name of the icon that should be used for the overview row
sourcefn localised_name(&self) -> String
fn localised_name(&self) -> String
The localised name of the plugin, that’s displayed to the user.
Provided Methods§
sourcefn summary(&self) -> PluginSummaryRow
fn summary(&self) -> PluginSummaryRow
Returns a card view with a short overview of the data, e.g 2000/10000 steps done for the home page
sourcefn overview(&self) -> PluginOverviewRow
fn overview(&self) -> PluginOverviewRow
Returns an entry for the “browse all” listbox.