Pantrix UI

Status Bar

The bar at the bottom of a window or of a pane that says how things stand: a document's validity and size at its start, the caret's line and column and the text's encoding at its end. Its buttons keep its height, short as it is, and are pressed past it.

import com.pantrixui.components.container.statusbar.PantrixStatusBar

Examples

A document's status

A document's status, at the width chosen: that it is valid, in a tag, and its size, in a button that opens its summary; at the end the caret's place and the text's layout. As the bar narrows, the text's layout falls into the "…" menu first, and then the caret's place.

var width by rememberSaveable { mutableStateOf(640) }
var summary by rememberSaveable { mutableStateOf(false) }
Column(verticalArrangement = Arrangement.spacedBy(PantrixTheme.spacing.sm)) {
    PantrixSegmentButton(
        options = listOf(
            SegmentOption(value = 640, label = "640 dp", tagKey = "640"),
            SegmentOption(value = 320, label = "320 dp", tagKey = "320")
        ),
        selected = width,
        onSelect = { width = it },
        tagKey = "width"
    )
    PantrixText(
        text = if (summary) "The summary is open." else "The summary is closed: press the size.",
        color = PantrixTheme.colors.textSecondary,
        tagKey = "summary"
    )
    PantrixStatusBar(
        start = {
            item(key = "valid", label = "Valid", priority = 3) {
                PantrixTag(text = "Valid", tone = TagTone.Success, tagKey = "valid")
            }
            button(
                key = "size",
                text = "41 lines · 742 B",
                onClick = { summary = !summary },
                selected = summary,
                contentDescription = if (summary) "Close the summary, 742 B" else "Show the summary, 742 B",
                priority = 2
            )
        },
        end = {
            text(key = "caret", text = "Ln 12, Col 4", priority = 1)
            text(key = "layout", text = "UTF-8 · LF · 2 spaces")
        },
        modifier = Modifier.widthIn(max = width.dp).fillMaxWidth(),
        tagKey = "document"
    )
}

A status said when it changes

A status the reader waits on: "Saving…" while it saves, "Saved" when it is done. Since it is given live, a screen reader says each change. The bar's name here is "Editor status".

var saving by rememberSaveable { mutableStateOf(false) }
Column(verticalArrangement = Arrangement.spacedBy(PantrixTheme.spacing.sm)) {
    PantrixButton(text = if (saving) "Finish" else "Save", onClick = { saving = !saving }, tagKey = "save")
    PantrixStatusBar(
        start = { text(key = "saved", text = if (saving) "Saving…" else "Saved", live = true) },
        contentDescription = "Editor status",
        tagKey = "editor"
    )
}

Its own style and colours

In its own style and colours: a lower bar, the app's fill and line, and the selected button's colour.

val colors = PantrixTheme.colors
PantrixStatusBar(
    start = {
        button(key = "branch", text = "main", onClick = {}, selected = true)
        text(key = "changes", text = "3 changes")
    },
    end = { text(key = "time", text = "14:32") },
    style = StatusBarStyle(height = 24.dp, gap = 12.dp),
    colors = StatusBarColors(
        container = colors.primary.container,
        line = colors.primary.color,
        content = colors.primary.onContainer,
        selected = colors.primary.onContainer
    ),
    tagKey = "own"
)

API

start

The bar at the bottom of a window or of a pane that says how things stand: a document's validity and size at its start, the caret's line and column and the text's encoding at its end. Its buttons keep its height, short as it is, and are pressed past it.

ParameterTypeDefaultWhat it is
startStatusBarScope.() -> Unitthe items at the bar's start.
modifierModifierModifierthe bar's modifier. The bar is as wide as it may be.
endStatusBarScope.() -> Unit{}the items at the bar's end, before the "…" button.
contentDescriptionString?nullwhat a screen reader calls the bar, or null for the theme's words for a status bar.
styleStatusBarStyle?nullthis call's own style: over every enclosing one and under the density. Only the fields it sets change, on every platform.
colorsStatusBarColors?nullthis call's own colours, where they are not the theme's.
tagKeyString?nullthe bar's automation key: it is StatusBar_<tagKey>, its items Item_<key> inside it and its "…" button More_items.

StatusBarStyle

PantrixStatusBar's geometry: how tall the bar is, the room at its two ends and the room between two items. A bar used by touch is taller; its buttons are pressed past it, up to the platform's touch target, rather than made taller.

ParameterTypeDefaultWhat it is
heightDpDp.UnspecifiedHow tall the bar is, under its line: 28 under a pointer, 32 on a phone and a tablet.
horizontalPaddingDpDp.UnspecifiedThe room at the bar's start and its end.
gapDpDp.UnspecifiedThe room between two items. A button is pressed in half of it on either side, where it is narrower than the touch target.

StatusBarColors

A PantrixStatusBar's own colours, where they are not the theme's.

ParameterTypeDefaultWhat it is
containerColorColor.UnspecifiedThe bar's fill: the theme's background, a step from the surface of the panes over it.
lineColorColor.UnspecifiedThe line over the bar: the theme's divider.
contentColorColor.UnspecifiedIts words, a button's among them: the theme's textSecondary, quieter than a pane's.
selectedColorColor.UnspecifiedThe words of a button that is selected, as one that shows a pane while the pane is shown: the theme's primary colour.

Accessibility