Messaging UI - Themes, Colors and Customize Screen

The messaging UI has a light and a dark theme, and follows the system setting by default. mesibo lets the app set the colors of both themes, the text size and the chat wallpaper, so that the messaging screens match the rest of the app.

The users of the app can also choose their own look, in the ready-to-use Customize screen. The app saves the look they choose, called a customization, and can keep it on its own server to restore it on the user’s other devices.

Colors

A color is a 32-bit value, 0xAARRGGBB. In JSON it is "#AARRGGBB" or "#RRGGBB".

Every color has a default for the light theme and one for the dark theme. setDefaults(dark) sets them. A color is always the exact color shown; there is no “0 means default”.

The theme group has the colors shared by all screens:

OptionLightDarkUsed for
accentColor#FF00A884#FF00A884buttons, switches, selected items
toolbarColor, toolbarTextColor, toolbarIconColorwhite, #FF111B21#FF1F2C34, #FFE9EDEFthe toolbar, its title and its icons
backgroundColor#FFFFFFFF#FF111B21the background of the screens
surfaceColor#FFF0F2F5#FF202C33cards, sheets, the search field
textPrimaryColor, textSecondaryColor#FF111B21, #FF667781#FFE9EDEF, #FF8696A0text, and less important text
dividerColor, borderColor#FFE9EDEF, #FFD1D7DB#FF222D34, #FF374248separators, outlines
errorColor#FFEA0038#FFF15C6Derrors and destructive actions
selectionColor#3300A884#4400A884selected rows and messages
inputBackgroundColor#FFFFFFFF#FF2A3942the message input
chipBackgroundColor, chipTextColor#FFFFFFFF, #FF54656F#FF182229, #FF8696A0dates in a chat
quoteBackgroundColor#14000000#26FFFFFFa quoted message
noticeBackgroundColor#FFFFF5C4#FF182229notices in a chat
metaColor#FF667781#FF99AAB4the time in a message
linkColor#FF027EB5#FF53BDEBlinks, phone numbers and emails
onlineColor#FF25D366#FF25D366the online dot
patternColor, wallpaperDimColor#12000000, transparent#0DFFFFFF, #59000000the wallpaper pattern, and the dim over a wallpaper photo
onAccentColor, onMediaColorwhitewhitetext and icons on the accent color, and over pictures
mediaScrimColor, dimColor, shadowColor#66000000, #59000000, blackthe samebehind text over pictures, behind sheets, shadows
toastBackgroundColor, toastTextColor#E01A1A1A, whitethe sameshort messages
letterAvatarTextColor, letterAvatarColorswhite, a palettethe sameletter avatars

Other groups have the colors of their own parts:

GroupColors
messageAppearancebackgroundColor, myBubbleColor, peerBubbleColor, myTextColor, peerTextColor
voiceMessageswaveColor, myPlayedColor, peerPlayedColor, recordingColor
userListbackgroundColor, nameColor, messageColor, readIconColor, sensitiveIconColor, muteActionColor, archiveActionColor
messageStatusthe icons by the time of a message, see Message status

A color of a group comes from its own options or from theme, never from another group.

Colors usually differ between the light and the dark theme. The app sets them in MesiboUI_onConfig, which mesibo calls for each theme with dark set to tell which (see Automatic Theme Changes):

@Override
public void MesiboUI_onConfig(MesiboUiConfig config, boolean dark) {
    config.theme.toolbarColor = 0xff00868b;
    config.theme.toolbarTextColor = 0xffffffff;
    config.theme.toolbarIconColor = 0xffffffff;
    config.theme.accentColor = 0xff00868b;
    if (!dark)
        config.messageAppearance.myBubbleColor = 0xffd9fdd3;
}
override fun MesiboUI_onConfig(config: MesiboUiConfig, dark: Boolean) {
    config.theme.toolbarColor = 0xff00868b.toInt()
    config.theme.toolbarTextColor = 0xffffffff.toInt()
    config.theme.toolbarIconColor = 0xffffffff.toInt()
    config.theme.accentColor = 0xff00868b.toInt()
    if (!dark)
        config.messageAppearance.myBubbleColor = 0xffd9fdd3.toInt()
}
func MesiboUI_onConfig(config: MesiboUiConfig, dark: Bool) {
    config.theme.toolbarColor = 0xff00868b
    config.theme.toolbarTextColor = 0xffffffff
    config.theme.toolbarIconColor = 0xffffffff
    config.theme.accentColor = 0xff00868b
    if !dark {
        config.messageAppearance.myBubbleColor = 0xffd9fdd3
    }
}
- (void)MesiboUI_onConfig:(MesiboUiConfig *)config dark:(BOOL)dark {
    config.theme.toolbarColor = 0xff00868b;
    config.theme.toolbarTextColor = 0xffffffff;
    config.theme.toolbarIconColor = 0xffffffff;
    config.theme.accentColor = 0xff00868b;
    if (!dark)
        config.messageAppearance.myBubbleColor = 0xffd9fdd3;
}
MesiboUiConfig config = await MesiboUI().getConfig();
config.theme.toolbarColor = 0xff00868b;
config.theme.accentColor = 0xff00868b;
await MesiboUI().setConfig(config);

The defaults of a theme

A new MesiboUiConfig has the defaults of the light theme. setDefaults(true) sets the dark theme’s colors, setDefaults(false) the light theme’s.

To write a customization based on a theme’s defaults: set the defaults, change the options, then write the configuration as JSON.

MesiboUiConfig config = new MesiboUiConfig();
config.setDefaults(true);                       // the dark theme's colors; false: the light theme's
config.theme.accentColor = 0xff7e57c2;          // the changes
String json = config.toJson(false);             // every option, with its value
val config = MesiboUiConfig()
config.setDefaults(true)                        // the dark theme's colors; false: the light theme's
config.theme.accentColor = 0xff7e57c2.toInt()   // the changes
val json = config.toJson(false)                 // every option, with its value
let config = MesiboUiConfig()
config.setDefaults(true)                        // the dark theme's colors; false: the light theme's
config.theme.accentColor = 0xff7e57c2           // the changes
let json = config.toJson(false)                 // every option, with its value
MesiboUiConfig *config = [MesiboUiConfig new];
[config setDefaults:YES];                       // the dark theme's colors; NO: the light theme's
config.theme.accentColor = 0xff7e57c2;          // the changes
NSString *json = [config toJson:NO];            // every option, with its value

Text size

messageAppearance.textSize sets the size of the text of messages. The size also follows the text size set in the system.

SizeAndroidiOSJSON
SmallMesiboUI.TEXTSIZE_SMALLMESIBO_TEXTSIZE_SMALL"small"
Medium (default)MesiboUI.TEXTSIZE_MEDIUMMESIBO_TEXTSIZE_MEDIUM"medium"
LargeMesiboUI.TEXTSIZE_LARGEMESIBO_TEXTSIZE_LARGE"large"
Extra largeMesiboUI.TEXTSIZE_EXTRALARGEMESIBO_TEXTSIZE_EXTRALARGE"extra_large"

Wallpaper

The chat background is, in this order of priority:

  1. messageAppearance.wallpaperPath: a picture file.
  2. messageAppearance.wallpaperImage: a picture set in code (Bitmap on Android, UIImage on iOS).
  3. messageAppearance.backgroundColor, with a faint pattern when messageAppearance.showWallpaperPattern is on.

wallpaperPath is a full path, or a file name in mesibo’s own folder:

  • Android: files/mesiboui in the app’s files.
  • iOS: Application Support/MesiboUI. A file name stays valid when iOS moves the app’s folder on an update.

The Customize screen keeps the photos the user chooses in that folder. In the dark theme, a wallpaper photo is dimmed with theme.wallpaperDimColor, so the bubbles stay readable.

Light and dark theme

By default, the messaging UI follows the system’s light or dark setting, also when it changes while the app runs. setTheme selects a theme. It applies at once; the open screens are drawn again.

MesiboUI.setTheme(MesiboUI.THEME_SYSTEM); // or MesiboUI.THEME_LIGHT, MesiboUI.THEME_DARK
MesiboUI.setTheme(MesiboUI.THEME_SYSTEM) // or MesiboUI.THEME_LIGHT, MesiboUI.THEME_DARK
MesiboUI.setTheme(MESIBO_THEME_SYSTEM) // or MESIBO_THEME_LIGHT, MESIBO_THEME_DARK
[MesiboUI setTheme:MESIBO_THEME_SYSTEM]; // or MESIBO_THEME_LIGHT, MESIBO_THEME_DARK
MesiboUI().setTheme(MesiboUI.THEME_SYSTEM); // or MesiboUI.THEME_LIGHT, MesiboUI.THEME_DARK

Each time a theme is applied, mesibo makes a new configuration:

  1. It sets the theme’s defaults (setDefaults).
  2. It applies the customization saved for that theme, if any (see Customizations).
  3. It calls the app’s MesiboUI_onConfig.

The open screens then use the new configuration. Options set on an earlier configuration are lost. An app that follows the system’s light or dark setting, or uses the Customize screen, sets its options in MesiboUI_onConfig, see Automatic Theme Changes.

Customizations

A customization is a JSON of options for the light theme or for the dark theme. It comes from the Customize screen, or from the app’s server. mesibo keeps one customization per theme, in mesibo’s key-value store, and applies it each time that theme is applied. mesibo must be set up before the customization functions are used.

FunctionAndroidiOSFlutter
Save the customization of a theme; an empty JSON deletes it. Saving does not apply itMesiboUI.saveCustomization(json, dark)[MesiboUI saveCustomization:json dark:dark]MesiboUI().saveCustomization(json, dark)
Get the saved customization; null (nil) if noneMesiboUI.getCustomization(dark)[MesiboUI getCustomization:dark]MesiboUI().getCustomization(dark)
Apply the current theme again, with its saved customizationMesiboUI.applyCustomization()[MesiboUI applyCustomization]MesiboUI().applyCustomization()

applyCustomization does nothing when the current theme is applied and its customization has not changed since.

To use a customization from the server at once:

MesiboUI.saveCustomization(json, false);
MesiboUI.applyCustomization();
MesiboUI.saveCustomization(json, false)
MesiboUI.applyCustomization()
MesiboUI.saveCustomization(json, dark: false)
MesiboUI.applyCustomization()
[MesiboUI saveCustomization:json dark:NO];
[MesiboUI applyCustomization];
await MesiboUI().saveCustomization(json, false);
await MesiboUI().applyCustomization();

Customize screen

launchCustomize opens the Customize screen. The user chooses the look of the messaging UI for the current theme, light or dark. The screen has three tabs, each with a preview:

TabOptions
Themeready-made palettes, the accent color, the toolbar colors
Chat listthe background, name and last message colors, letter avatars, the search mode, filters, archived chats, swipe actions, online indicator, profile popup
Chata wallpaper photo, bubble and text colors, the colors of the icons by the time, the text size, wallpaper pattern, bubble tail, large emoji, swipe to reply, covering the user’s own sensitive messages

Changes are not applied while the user edits. The buttons:

  • Back closes the screen. If something changed, it first asks: Discard the changes, or Cancel to stay.
  • Apply calls the app’s callback with the customization as JSON: the changes, merged with the customization saved before for that theme. dark tells which theme it is for.
  • Reset calls the callback with an empty JSON. The customization of that theme, and its wallpaper photo, are deleted.

The callback saves the customization to keep it. It returns true (YES) to apply it now, or false (NO) to leave the screens unchanged. Without a callback, the changes are applied at once but not saved.

MesiboUI.launchCustomize(context, (json, dark) -> {
    MesiboUI.saveCustomization(json, dark);   // empty after Reset: deleted
    return true;
});
MesiboUI.launchCustomize(context) { json, dark ->
    MesiboUI.saveCustomization(json, dark)    // empty after Reset: deleted
    true
}
MesiboUI.launchCustomize(self) { json, dark in
    MesiboUI.saveCustomization(json, dark: dark)   // empty after Reset: deleted
    return true
}
[MesiboUI launchCustomize:self closed:^BOOL(NSString *json, BOOL dark) {
    [MesiboUI saveCustomization:json dark:dark];   // empty after Reset: deleted
    return YES;
}];
MesiboUI().launchCustomize((json, dark) {
  MesiboUI().saveCustomization(json, dark);   // empty after Reset: deleted
});

A wallpaper photo chosen by the user is already saved in mesibo’s folder. The JSON has its file name in messageAppearance.wallpaperPath.

On Android, a tap on a color shows a grid of colors and a field for a color code. On iOS, it opens the system color picker.