NutrientTheme

fun NutrientTheme(colorScheme: UiColorScheme? = null, iconScheme: UiIconScheme? = null, content: @Composable () -> Unit)

Provides the SDK's UiColorScheme and UiIconScheme to content and keeps them in step with runtime theme changes (THEME-3). Read them inside content with NutrientTheme.colorScheme and NutrientTheme.iconScheme.

The colors come from the first of these that is set:

  1. colorScheme, when it isn't null, or else the one passed to an enclosing NutrientTheme, so a nested one, such as NutrientSettingsView's, keeps it.

  2. The scheme set on the activity with PdfActivity.setColorScheme() or PdfUiFragment.setColorScheme(): the light or the dark one of the pair, by whether the XML theme of LocalContext is light, so it agrees with the View chrome that theme draws. A DayNight theme makes that the configuration's night mode; a PdfActivityConfiguration whose theme mode is NIGHT applies the dark theme whatever the device says, and so shows the dark scheme. A theme that declares no lightness follows the night mode.

  3. The XML theme attributes of LocalContext (UiColorScheme.fromXmlTheme): the activity's, or those of a theme overlay around this composition, such as android:theme or a ContextThemeWrapper.

Within the scheme, a slice color that is set wins over the Material role it would otherwise take from UiColorScheme.material. Above the scheme, a component's own colors parameter, such as NutrientMainToolbar(colors = …), wins for that component, and a View's color setter, such as PdfThumbnailBar.setBackgroundColor(), wins for that view once it is called.

This is the same resolution every SDK screen uses, so a toolbar wrapped in NutrientTheme and the outline, settings or tab bar of the same activity show the same colors.

The scheme's UiColorScheme.material is installed as the MaterialTheme of content, so stock Material 3 components in it (ripples, switches, sheet handles, text fields) follow the SDK's colors. Typography, shapes and the current text style stay those of the enclosing composition. An app that wraps SDK composables in its own MaterialTheme and wants that theme's colors to apply passes UiColorScheme.fromMaterial(MaterialTheme.colorScheme) as colorScheme.

A theme set with Activity.setTheme() while the activity runs, and a configuration change an activity handles itself, reach every NutrientTheme in it without an Activity recreation: PdfActivity and PdfUiFragment take care of that, and the scheme set with setColorScheme() is state.

Parameters

colorScheme

The colors to provide, or null to use the activity's.

iconScheme

The icons to provide, or null for those passed to an enclosing NutrientTheme, otherwise UiIconScheme.default.

content

The content the schemes are provided to.