Skip to content

Theming and strings

The package draws itself from your ThemeData’s colour scheme. For your own design, put a CrmTheme in the theme’s extensions: its accent (buttons, the user’s bubbles, the send button), tints, lines, spacing, corners, type and motion. Start from your scheme and change what you need:

ThemeData(
colorScheme: scheme,
extensions: [
CrmTheme.fromScheme(scheme).copyWith(
accent: const Color(0xFF8F4C00),
onAccent: Colors.white,
radii: const CrmRadii(row: 20, card: 28),
),
],
)

Surfaces, text and error colours always come from the colour scheme. Check your accent against your surfaces: the package’s own screens meet the tap-target, label and contrast guidelines with its defaults.

The screens follow the platform: on iOS a chevron, Cupertino spinners, bouncing scroll and page sheets with a grabber; on Android Material 3 sheets and the predictive back gesture. They follow ThemeData.platform, so you can show either look on one phone.

Your team can style the package’s screens on PurrCRM, under Settings › your app › Messenger: the accent, the corners and buttons, light or dark, the messenger’s header and words, the launcher, and the animation (see Style the messenger and messages). The screens follow it the next time the app opens, with no new release.

Anything you set in code wins. Each part of the look comes from, in order:

  1. your CrmTheme, where you set that part (accent, corner, buttonShape, darkMode, motion);
  2. the look your team published on PurrCRM;
  3. the package’s own default.

So a CrmTheme that sets only accent keeps your accent and takes everything else from PurrCRM. When the phone is set to reduce motion, nothing animates, whatever the look or your theme says.

When your team turns the launcher on, a round button floats over your app’s pages. It opens the messenger and shows how many messages are unread. It puts itself away while the messenger, a message or the keyboard is up, and before setReady(true).

To decide in code instead, pass launcher to CrmOverlay: true always shows it, false never does, and leaving it out follows your team’s choice. To keep it off one page, a checkout say, wrap the page in CrmHideLauncher:

CrmHideLauncher(child: CheckoutPage())

Add CrmLocalizations.delegate to your localizations delegates. The package’s own words are English, and English is used when no delegate is installed. Wherever a string names your app, it says CrmConfig.productName (“Talk to the Northwind team”).

Two kinds of words reach your users, by different ways:

  • What your team writes (messages, articles, the help bot’s questions) comes from PurrCRM already in the user’s language. The package sends the phone’s language (CrmConfig.languageTag) with every request, and picks nothing itself. See Languages.
  • The package’s own words (its buttons, its errors) are in its ARB files, which crmSupportedLocales lists: English for now. You can say any of them in your own words, in any language.

A word table changes the package’s words without changing the package. It maps a string’s key, as in the package’s lib/l10n/crm_en.arb, to your words, by language tag. Give your tables to CrmStringsDelegate, in place of CrmLocalizations.delegate:

MaterialApp(
supportedLocales: const [Locale('en'), Locale('cy')],
localizationsDelegates: [
CrmStringsDelegate(
tables: {
'cy': {
'helpCenterTitle': 'Erthyglau help',
'conversationTyping': '{name} yn teipio',
'messengerUnread':
'{count, plural, =1{1 heb ei ddarllen} other{{count} heb eu darllen}}',
// ...the rest stay English.
},
// Your own words in English too: change only what you want.
'en': {'ticketNew': 'Report a problem'},
},
),
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
)
  • Write each entry as the ARB file writes it, with the same {placeholders}, and {count, plural, ...} or select where it has them.
  • A table need not be whole. A key it leaves out is said in the package’s own words for that language, else in English.
  • An entry the package can’t use (a placeholder the string doesn’t have, a plural that doesn’t parse, a key that isn’t one of its strings) is said in English too. A table never makes a screen fail.
  • crmStringPlaceholders lists every key with its placeholders. crmWordTableProblems(table) says which entries of a table would not be used, and why: check your tables with it in a test, or when you load them from your translation service.

Tables are matched to the phone’s language as below. A table and your own CrmLocalizations for the same language go together: the table’s words come first.

Instead of a table, you can give your own CrmLocalizations to CrmStringsDelegate, in place of CrmLocalizations.delegate:

import 'package:crm_sdk/l10n/crm_localizations_en.dart';
class CrmWelsh extends CrmLocalizationsEn {
CrmWelsh() : super('cy');
@override
String get helpCenterTitle => 'Erthyglau help';
// ...every string, or the ones you have; the rest stay English.
}
MaterialApp(
supportedLocales: const [Locale('en'), Locale('cy')],
localizationsDelegates: [
CrmStringsDelegate(strings: {'cy': CrmWelsh()}),
GlobalMaterialLocalizations.delegate,
// ...
],
)

A language tag alone (cy) serves each of its regions (cy-GB); the most precise one that fits the phone wins (zh-Hant-TW, then zh-Hant, then zh-TW, then zh). CrmStringsDelegate(supportedLocales: [...]) limits the package to fewer languages.