UI Listener - Configuration Callback
An app with a fixed theme, light or dark, sets the configuration with getConfig and does not need
this callback (see Setting the configuration). The
callback is needed in two cases only, when mesibo applies a theme on its own:
- The app follows the system’s light or dark setting (
THEME_SYSTEM, the default), and the system switches between light and dark. - The user applies or resets a look in mesibo’s Customize screen.
The app then sets its options in this callback, and not with getConfig.
Even an app that does not use the Customize screen is recommended to implement this callback and set its options here. The app can then follow the system’s light or dark setting, as users expect, and its options are applied to both themes, for the best user experience.
mesibo makes a new configuration, and calls MesiboUI_onConfig() with it, each time a theme is
applied:
- the first time the configuration is used,
- when the app calls
MesiboUI.setTheme()orMesiboUI.applyCustomization(), - when the system switches between light and dark (with
THEME_SYSTEM, the default), - when the user applies or resets the look in the Customize screen.
The new configuration starts with the theme’s defaults, then the customization saved for that
theme, if any. Nothing set on an earlier configuration stays, so the app sets its configuration here, for
both themes; dark tells which theme it is for. mesibo then draws the open screens again, so a theme
change needs no restart.
@Override
public void MesiboUI_onConfig(MesiboUiConfig config, boolean dark) {
config.userList.emptyMessage = "No messages yet";
config.profileViewer.showAddress = true;
config.theme.accentColor = 0xFF00868B;
}
override fun MesiboUI_onConfig(config: MesiboUiConfig, dark: Boolean) {
config.userList.emptyMessage = "No messages yet"
config.profileViewer.showAddress = true
config.theme.accentColor = 0xFF00868B.toInt()
}
func MesiboUI_onConfig(config: MesiboUiConfig, dark: Bool) {
config.userList.emptyMessage = "No messages yet"
config.profileViewer.showAddress = true
config.theme.accentColor = 0xFF00868B
}
- (void)MesiboUI_onConfig:(MesiboUiConfig *)config dark:(BOOL)dark {
config.userList.emptyMessage = @"No messages yet";
config.profileViewer.showAddress = YES;
config.theme.accentColor = 0xFF00868B;
}
MesiboUiConfig config = await MesiboUI().getConfig();
config.userList.emptyMessage = "No messages yet";
config.profileViewer.showAddress = true;
config.theme.accentColor = 0xFF00868B;
await MesiboUI().setConfig(config);
In Flutter, mesibo keeps the options applied with setConfig(), and applies them again to each new
configuration, so Flutter needs no callback.
See UI Configuration for every option, and Configuration as JSON to set them from JSON, for example from the app’s server.