### Install Orbit Compose Catalog via Homebrew Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/readme.md Install the Orbit Compose catalog app on macOS using Homebrew from the yasan-org tap. ```sh brew install --cask yasan-org/tap/orbit-compose-multiplatform-catalog ``` -------------------------------- ### UI testing with ProgressBarRangeInfo Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/10-progress-indicators/loading.md Set progress and read the state using semantic properties. The example sets a test tag and fetches ProgressBarRangeInfo to assert the current value. ```kotlin composeTestRule.setContent { LinearProgressIndicator( progress = 0.4f, modifier = Modifier.testTag("loader"), ) } val progressBarInfo = composeTestRule .onNodeWithTag("loader") .fetchSemanticsNode() .config[SemanticsProperties.ProgressBarRangeInfo] Assert.assertEquals(0.4f, progressBarInfo.current) ``` -------------------------------- ### Basic BadgeList usage with predefined item variants Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/03-information/badgelist.md Use BadgeList composable to wrap particular items. Each item takes an icon Painter and has a content slot. This example shows BadgeListSuccess and BadgeListInfo items. ```kotlin @Composable fun Example() { Column { BadgeList { BadgeListSuccess(Icons.Check) { Text("Your order is being processed right now.") } BadgeListInfo(Icons.Info) { Text("We will email you when there will be a progress.") } BadgeListInfo(Icons.Money) { Text("Additional credits were added to your account.") } } } } ``` -------------------------------- ### Use Orbit Components in Composable Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/readme.md Example of using Orbit components (ButtonPrimary, AlertCritical) inside a Composable function. ```kotlin @Composable fun MyScreen() { Column( verticalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.padding(16.dp) ) { val maxWidth = Modifier.fillMaxWidth() ButtonPrimary(onClick = {}, maxWidth) { Text("This is an Orbit primary button") } Spacer(modifier = Modifier.padding(4.dp)) AlertCritical( title = { Text("Alert title") }, content = { Text("Content description") }, actions = { ButtonPrimary(onClick = {}) { Text("Primary") } ButtonSecondary(onClick = {}) { Text("Secondary") } }, ) } } ``` -------------------------------- ### UI testing with CheckboxField Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/05-input/checkbox.md Example of UI testing using testTag and assertIsOn/assertIsOff to check the state. ```APIDOC ## UI testing with CheckboxField ### Description Example of UI testing using testTag and assertIsOn/assertIsOff to check the state. ### Example ```kotlin composeTestRule.setContent { var checked by remember { mutableStateOf(false) } CheckboxField( modifier = Modifier.testTag("checkbox"), checked = checked, onCheckedChange = { checked = !checked }, ) { Text("Label") } } val checkbox = composeTestRule.onNodeWithTag("checkbox") checkbox.assertIsOff() checkbox.performClick() checkbox.assertIsOn() ``` ``` -------------------------------- ### UI testing with testTag on BadgeListItemNeutral Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/03-information/badgelist.md Slotting API allows adding testTag to component parts. This example sets content with a BadgeListItemNeutral and asserts text content using composeTestRule. ```kotlin composeTestRule.setContent { BadgeList { BadgeListItemNeutral(Icons.Email) { Text("Email up to date!", Modifier.testTag("Email")) } } } composeTestRule.onNodeWithTag("Email").assertTextContains("Email up to date!") ``` -------------------------------- ### Customize BadgeListSmall spacing and content emphasis Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/03-information/badgelist.md Use BadgeListSmall with verticalArrangement and contentEmphasis parameters to customize item spacing and overall text color. This example uses ContentEmphasis.Minor. ```kotlin @Composable fun Example() { Column { BadgeListSmall( verticalArrangement = Arrangement.spacedBy(10.dp), contentEmphasis = ContentEmphasis.Minor, ) { BadgeListSuccess(Icons.Check) { Text("Your order is being processed right now.") } BadgeListInfo(Icons.Info) { Text("We will email you when there will be a progress.") } BadgeListInfo(Icons.Money) { Text("Additional credits were added to your account.") } } } } ``` -------------------------------- ### UI testing ButtonPrimary with testTag Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/01-action/button.md UI test example: Button merges nodes into one, exposing text and action. Pass a testTag via modifier to locate and interact with the button. ```kotlin var clicked = false composeTestRule.setContent { ButtonPrimary(onClick = { clicked = true }, Modifier.testTag("Button")) { Text("Update") } } composeTestRule.onNodeWithTag("Button").assertTextContains("Update") composeTestRule.onNodeWithTag("Button").performClick() Assert.assertEquals(true, clicked) ``` -------------------------------- ### Use OrbitTheme for Typography and Colors Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/readme.md Access OrbitTheme for typography and colors. Use ContentEmphasis.Minor for emphasis and OrbitTheme.typography.title1 for title style. ```kotlin Text("Title 1", emphasis = ContentEmphasis.Minor) Text("Big title in Title 1 style", style = OrbitTheme.typography.title1) Text("Check your typography styles!", color = OrbitTheme.colors.warning.normal) ``` -------------------------------- ### Card Usage with Title, Action, and Content Padding Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/02-structure/card.md Shows how to use Card with optional title and action slots, and how to modify contentPadding to combine with components like ListChoice that handle their own padding. ```kotlin @Composable fun Example() { Column { Card( title = { Text("Card title") }, action = { ButtonTextLinkPrimary("Action", onClick = {}) }, ) { Text("Content") } Card( title = { Text("Card title") }, contentPadding = PaddingValues(vertical = 12.dp), ) { Column { ListChoice( onClick = {}, icon = { Icon(Icons.AirplaneTakeoff, contentDescription = null) }, trailingIcon = { Icon(Icons.ChevronForward, contentDescription = null) }, ) { Text("Takeoff") } ListChoice( onClick = {}, icon = { Icon(Icons.AirplaneLanding, contentDescription = null) }, trailingIcon = { Icon(Icons.ChevronForward, contentDescription = null) }, ) { Text("Landing") } } } } } ``` -------------------------------- ### Record Paparazzi screenshots Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/contributing.md Run this Gradle task to generate new screenshots for UI components. ```bash ./gradlew :ui:recordPaparazziDebug ``` -------------------------------- ### Use Illustrations Object for Icons Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/readme.md Access illustrations via the Illustrations object, e.g., Illustrations.AppKiwi. ```kotlin Image(painter = Illustrations.AppKiwi, contentDescription = "app_kiwi") ``` -------------------------------- ### Verify Paparazzi screenshots Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/contributing.md Run this Gradle task to verify the implementation matches the recorded screenshots. ```bash ./gradlew :ui:verifyPaparazziDebug ``` -------------------------------- ### Card UI Testing with testTag Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/02-structure/card.md Demonstrates adding testTag to Card's title, action, and content slots for UI testing, and verifying text with composeTestRule assertions. ```kotlin composeTestRule.setContent { Card( title = { Text("Card title", Modifier.testTag("title")) }, action = { ButtonTextLinkPrimary("Action", onClick = {}, Modifier.testTag("action")) }, ) { Text("Content", Modifier.testTag("content")) } } composeTestRule.onNodeWithTag("title").assertTextEquals("Card title") composeTestRule.onNodeWithTag("action").assertTextEquals("Action") composeTestRule.onNodeWithTag("content").assertTextEquals("Content") ``` -------------------------------- ### UI testing with testTag on Alert action Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/03-information/alert.md Shows how to add a testTag to a component part using the slotting API, then perform a click on it in a compose test. ```kotlin composeTestRule.setContent { AlertSuccess( title = {}, content = { Text("Thank you for subscribing") }, actions = { ButtonPrimary(onClick = {}, Modifier.testTag("action")) { Text("Show content") } }, ) } composeTestRule.onNodeWithTag("action").performClick() ``` -------------------------------- ### Alert with title, content, and actions Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/03-information/alert.md Shows how to use AlertSuccess with title, content, and actions slots. Buttons are automatically re-colored to match the Alert color theme. The icon can be changed via the icon parameter accepting a Painter. ```kotlin @Composable fun Example() { Column { AlertSuccess( title = { Text("Thank you for subscribing") }, content = { Text("Your subscription was successfully activated. All premium content is now available in your account.") }, actions = { ButtonPrimary(onClick = {}) { Text("Show content") } ButtonSecondary(onClick = {}) { Text("Manage subscription") } }, ) AlertInfo( icon = Icons.Check, content = { Text("You information is up-to-date.") }, ) } } ``` -------------------------------- ### AlertInline with title and action Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/03-information/alert.md Shows how to use AlertInlineSuccess for quick and short messages. It requires a single action via the action slot. ```kotlin @Composable fun Example() { Column { AlertInlineSuccess( title = { Text("Password changed") }, action = { ButtonTextLinkPrimary("Account", onClick = { /* ... */ }) }, ) } } ``` -------------------------------- ### Basic SelectField usage with options and label Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/05-input/select.md Shows how to use SelectField with a list of options, a label, and an onOptionSelect callback. The value is stored in a mutable state. Note the typo 'remeber' in the original code. ```kotlin @Composable fun Example() { var selected by remeber { mutableStateOf("A") } SelectField( value = selected, options = remember { listOf("A", "B", "C") }, onOptionSelect = { selected = it }, label = { Text("Pick a letter") } ) { letter -> Text(letter) } } ``` -------------------------------- ### UI testing Collapse with testTags and semantics actions Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/07-interaction/collapse.md Slotting API allows adding testTag to component parts. Set content, assert initial state, expand via SemanticsActions.Expand, assert content displayed, then collapse and assert content gone. ```kotlin composeTestRule.setContent { var expanded by remember { mutableStateOf(false) } Collapse( expanded = expanded, onExpandClick = { expanded = it }, title = { Text(text = "Collapse title", modifier = Modifier.testTag("title")) }, content = { Text(text = "This is the collapsible content", modifier = Modifier.testTag("content")) }, modifier = Modifier.testTag("collapse"), ) } composeTestRule.onNodeWithTag("title", useUnmergedTree = true).assertIsDisplayed() composeTestRule.onNodeWithTag("content").assertDoesNotExist() composeTestRule.onNodeWithTag("collapse").performSemanticsAction(SemanticsActions.Expand) composeTestRule.onNodeWithTag("content").assertIsDisplayed() composeTestRule.onNodeWithTag("collapse").performSemanticsAction(SemanticsActions.Collapse) composeTestRule.onNodeWithTag("content").assertDoesNotExist() ``` -------------------------------- ### UI testing Tile with testTag Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/02-structure/tile.md Demonstrates adding testTag to Tile and its slots for UI testing. Asserts text on title and description nodes and performs a click on the tile. ```kotlin composeTestRule.setContent { Tile( title = { Text("Title", Modifier.testTag("title")) }, onClick = {}, modifier = Modifier.testTag("tile"), description = { Text("Description", Modifier.testTag("description")) }, ) } composeTestRule.onNodeWithTag("title").assertTextEquals("Title") composeTestRule.onNodeWithTag("description").assertTextEquals("Description") composeTestRule.onNodeWithTag("tile").performClick() ``` -------------------------------- ### Add Orbit Compose Dependencies to Gradle Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/readme.md Add the Orbit Compose dependencies to your Gradle file. Replace with the desired version. ```groovy implementation("glass.yasan.orbit:ui:") implementation("glass.yasan.orbit:icons:") implementation("glass.yasan.orbit:illustrations:") ``` -------------------------------- ### Basic TextField usage Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/05-input/inputfield.md Provides a label and handles value changes. The TextField is an atomic block of label, input, and info/error message. ```kotlin @Composable fun Example() { TextField( value = "...", onValueChange = { /* ... */ }, label = { Text("Full name") }, ) } ``` -------------------------------- ### UI Testing RadioField with testTag Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/05-input/radio.md Sets up a RadioField with a testTag and uses assertIsSelected/assertIsNotSelected to verify state changes after click. ```kotlin composeTestRule.setContent { var selected by remember { mutableStateOf(false) } RadioField( modifier = Modifier.testTag("radio"), selected = selected, onClick = { selected = !selected }, description = { Text("Description") }, ) { Text("Label") } } val radio = composeTestRule.onNodeWithTag("radio") radio.assertIsNotSelected() radio.performClick() radio.assertIsSelected() ``` -------------------------------- ### Coupon usage with and without onCopied callback Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/08-visuals/coupon.md Shows a Coupon component with code 'hxt3b81f' in two rows: one without copy functionality (onCopied = null) and one with a callback that shows a toast on long click. The code parameter is converted to uppercase and wrapped in a dashed border. ```kotlin @Composable fun Example() { Column { Row( horizontalArrangement = Arrangement.spacedBy(4.dp), ) { Text( text = "Your coupon:", modifier = Modifier.alignByBaseline(), ) Coupon( code = "hxt3b81f", onCopied = null, modifier = Modifier.alignByBaseline(), ) } Row( horizontalArrangement = Arrangement.spacedBy(4.dp), ) { Text( text = "Copy your coupon:", modifier = Modifier.alignByBaseline(), ) Coupon( code = "hxt3b81f", onCopied = { coroutineScope.launch { toastHostState.showToast("Copied to clipboard!") { Icons.Copy } } }, modifier = Modifier.alignByBaseline(), ) } } } ``` -------------------------------- ### UI testing SelectField with testTag and EditableText Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/05-input/select.md Demonstrates how to set up a Compose UI test for SelectField. It uses testTag on the field and options, clicks an option using the unmerged tree, and asserts the value via the EditableText semantic property. Includes a custom SemanticsMatcher to check the exact text. ```kotlin composeTestRule.setContent { var selected by remember { mutableStateOf("A") } SelectField( modifier = Modifier.testTag("select"), value = selected, options = listOf("A", "B", "C"), onOptionSelect = { selected = it }, label = { Text("Pick letter") }, ) { letter -> Text(letter, modifier = Modifier.testTag("option$letter")) } } val select = composeTestRule.onNodeWithTag("select") select.assert(hasEditTextExactly("A")) select.performClick() composeTestRule.onNodeWithTag("optionB", useUnmergedTree = true).performClick() select.assert(hasEditTextExactly("B")) private fun hasEditTextExactly(expected: String): SemanticsMatcher { val propertyName = SemanticsProperties.EditableText.name return SemanticsMatcher( "$propertyName = [$expected]", ) { node -> val actual = node.config.getOrNull(SemanticsProperties.EditableText) actual?.text == expected } } ``` -------------------------------- ### UI testing Stepper with semantic actions Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/07-interaction/stepper.md Set up a Stepper in a compose test rule and use semantic properties and custom actions to read and change the value. If the button is not active, the corresponding semantic action is not added; use fetchSemanticsNode() to check its presence. ```kotlin composeTestRule.setContent { var value by remember { mutableIntStateOf(0) } Stepper( modifier = Modifier.testTag("stepper"), value = value, onValueChange = { value = it }, ) } val stepper = composeTestRule.onNodeWithTag("stepper") assertFalse(stepper.fetchSemanticsNode().config.contains(StepperSemanticsActions.DecreaseValue)) assertTrue(stepper.fetchSemanticsNode().config.contains(StepperSemanticsActions.IncreaseValue)) stepper .assertTextEquals("0") .performSemanticsAction(StepperSemanticsActions.IncreaseValue) .assertTextEquals("1") .performSemanticsAction(StepperSemanticsActions.IncreaseValue) .assertTextEquals("2") .performSemanticsAction(StepperSemanticsActions.DecreaseValue) .assertTextEquals("1") assertTrue(stepper.fetchSemanticsNode().config.contains(StepperSemanticsActions.DecreaseValue)) assertTrue(stepper.fetchSemanticsNode().config.contains(StepperSemanticsActions.IncreaseValue)) ``` -------------------------------- ### Stepper composable with min and max values Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/07-interaction/stepper.md Use the Stepper composable with value and onValueChange callback. Optionally set minValue and maxValue boundaries. Set active to true to highlight the component in info color. ```kotlin @Composable fun Example() { var value by remember { mutableIntStateOf(0) } Stepper( modifier = Modifier.testTag("stepper"), value = value, onValueChange = { value = it }, active = value > 0, minValue = 0, maxValue = 10, ) } ``` -------------------------------- ### Badge Usage with content and icon slots Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/03-information/badge.md Shows how to use Badge variants with a trailing content slot and an optional icon slot. The component sizes and positions icon and content correctly together. ```kotlin @Composable fun Example() { Column { BadgeInfo { Text("Text") } BadgeSuccessSubtle( icon = { Icon(Icons.Check, "Ok") }, content = { Text("Added") } ) } } ``` -------------------------------- ### Basic TileGroup with multiple Tiles Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/02-structure/tilegroup.md Wraps multiple Tile components in a single elevated container. Use Modifier.padding(16.dp) for spacing. Each Tile requires a title and onClick; optional icon and description are supported. ```kotlin @Composable fun Example() { TileGroup( modifier = Modifier.padding(16.dp), ) { Tile( title = { Text("Title") }, onClick = {}, ) Tile( title = { Text("Title") }, onClick = {}, icon = { Icon(Icons.Airplane, contentDescription = null) }, description = { Text("Description") }, ) } } ``` -------------------------------- ### Basic Radio Usage Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/05-input/radio.md Simple radio component accepting a boolean state and a callback on change. ```kotlin @Composable fun Example() { Radio( selected = false, onClick = { /*...*/ }, ) } ``` -------------------------------- ### AlertInfo composable Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/03-information/alert.md Displays an informational alert with a title, content, and optional actions. The icon can be customized via the icon parameter. ```APIDOC ## AlertInfo composable ### Description Displays an informational alert with a title, content, and optional actions. The icon can be customized via the icon parameter. ### Parameters - **title** (Composable) - Required - Slot for the title text. - **content** (Composable) - Required - Slot for the description text. - **actions** (Composable) - Optional - Slot for action buttons (ButtonPrimary or ButtonSecondary). - **icon** (Painter) - Optional - Custom icon to replace the predefined one. - **suppressed** (Boolean) - Optional - If true, uses neutral background instead of tinted. ### Example ```kotlin @Composable fun Example() { AlertInfo( icon = Icons.Check, content = { Text("You information is up-to-date.") }, ) } ``` ``` -------------------------------- ### AlertInlineSuccess composable Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/03-information/alert.md Displays a compact success alert for short messages. Requires a single action. ```APIDOC ## AlertInlineSuccess composable ### Description Displays a compact success alert for short messages. Requires a single action. ### Parameters - **title** (Composable) - Required - Slot for the title text. - **action** (Composable) - Required - Slot for a single action button. - **suppressed** (Boolean) - Optional - If true, uses neutral background instead of tinted. ### Example ```kotlin @Composable fun Example() { AlertInlineSuccess( title = { Text("Password changed") }, action = { ButtonTextLinkPrimary("Account", onClick = { /* ... */ }) }, ) } ``` ``` -------------------------------- ### AlertSuccess composable Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/03-information/alert.md Displays a success alert with a title, content, and optional actions. The icon can be customized via the icon parameter. ```APIDOC ## AlertSuccess composable ### Description Displays a success alert with a title, content, and optional actions. The icon can be customized via the icon parameter. ### Parameters - **title** (Composable) - Required - Slot for the title text. - **content** (Composable) - Required - Slot for the description text. - **actions** (Composable) - Optional - Slot for action buttons (ButtonPrimary or ButtonSecondary). - **icon** (Painter) - Optional - Custom icon to replace the predefined one. - **suppressed** (Boolean) - Optional - If true, uses neutral background instead of tinted. ### Example ```kotlin @Composable fun Example() { AlertSuccess( title = { Text("Thank you for subscribing") }, content = { Text("Your subscription was successfully activated. All premium content is now available in your account.") }, actions = { ButtonPrimary(onClick = {}) { Text("Show content") } ButtonSecondary(onClick = {}) { Text("Manage subscription") } }, ) } ``` ``` -------------------------------- ### UI testing TextField with testTag Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/05-input/inputfield.md Slotting API allows adding testTag to component parts. The test sets content, asserts initial state, performs text replacement, and verifies the editable text. ```kotlin composeTestRule.setContent { var value by remember { mutableStateOf("") } TextField( modifier = Modifier.testTag("textfield"), value = value, onValueChange = { value = it }, info = { Text("Info") }, error = if (value.length > 3) { @Composable { Text("Error") } } else { null }, label = { Text("Label") }, placeholder = { Text("Placeholder") }, ) } val textField = composeTestRule.onNodeWithTag("textfield") textField.assert(hasEditTextExactly("")) textField.assertTextEquals("Label", "Placeholder", includeEditableText = false) textField.performTextReplacement("text") textField.assert(hasEditTextExactly("text")) private fun hasEditTextExactly(expected: String): SemanticsMatcher { val propertyName = SemanticsProperties.EditableText.name return SemanticsMatcher( "$propertyName = [$expected]", ) { node -> val actual = node.config.getOrNull(SemanticsProperties.EditableText) actual?.text == expected } } ``` -------------------------------- ### Tile variants with title, icon, description, and custom content Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/02-structure/tile.md Shows both Tile variants: one with title, icon, description, and trailingContent slots; the other with a custom content slot. trailingContent has RowScope context and defaults to a forward chevron icon. ```kotlin @Composable fun Example() { Column { Tile( title = { Text("Title") }, onClick = {}, icon = { Icon(Icons.Airplane, contentDescription = null) }, description = { Text("Description") }, trailingContent = { Text( text = "Action", modifier = Modifier.align(Alignment.Top), color = OrbitTheme.colors.primary.normal, style = OrbitTheme.typography.bodyNormalMedium, ) }, ) Tile( onClick = {}, ) { Text( text = "Custom content", modifier = Modifier.fillMaxWidth(), textAlign = TextAlign.Center, ) } } } ``` -------------------------------- ### CheckboxField with label and description Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/05-input/checkbox.md Creates a CheckboxField with additional description and label slots. The description is provided as a composable lambda and the label is the trailing content. ```kotlin @Composable fun Example() { CheckboxField( checked = false, onCheckedChange = {}, description = { Text("If selected, you will get the latest updates.") } ) { Text("Autoupdate") } } ``` -------------------------------- ### Basic Checkbox usage Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/05-input/checkbox.md Creates a simple Checkbox with a Boolean state and a callback. The checked parameter is set to false and onCheckedChange is an empty lambda. ```kotlin package test import androidx.compose.runtime.Composable @Composable fun Example() { Checkbox( checked = false, onCheckedChange = {}, ) } ``` -------------------------------- ### Basic Collapse composable with expanded state Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/07-interaction/collapse.md Use the Collapse composable with a boolean state for expanded and handle changes in onExpandClick. The title slot shows always-visible content, while the content slot holds collapsible content. ```kotlin @Composable fun Example() { var expanded by remember { mutableStateOf(false) } Collapse( expanded = expanded, onExpandClick = { expanded = it }, title = { Text(text = "Collapse title") }, content = { Text(text = "This is the collapsible content") }, ) } ``` -------------------------------- ### UI testing Coupon with testTag Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/08-visuals/coupon.md Sets a testTag 'coupon' on the Coupon component and asserts the displayed text equals 'HXT3B81F' (uppercase conversion). Use this to verify the component's properties in Compose UI tests. ```kotlin composeTestRule.setContent { Coupon( code = "hxt3b81f", onCopied = null, modifier = Modifier.testTag("coupon"), ) } composeTestRule.onNodeWithTag("coupon").assertTextEquals("HXT3B81F") ``` -------------------------------- ### UI testing CheckboxField with testTag Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/05-input/checkbox.md Sets up a Compose UI test for CheckboxField using a testTag. It asserts the initial off state, performs a click, and asserts the on state. ```kotlin composeTestRule.setContent { var checked by remember { mutableStateOf(false) } CheckboxField( modifier = Modifier.testTag("checkbox"), checked = checked, onCheckedChange = { checked = !checked }, ) { Text("Label") } } val checkbox = composeTestRule.onNodeWithTag("checkbox") checkbox.assertIsOff() checkbox.performClick() checkbox.assertIsOn() ``` -------------------------------- ### Convert Orbit Theme to Material 2 Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/02-foundation/04-color/theming.md Use this conversion function to make Material 2 similar to the Orbit Theme. It sets up MaterialTheme with converted colors, typography, and shapes, then wraps OrbitTheme inside. Requires Orbit Compose's lightColors, createTypography, and Shapes. ```kotlin import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import kiwi.orbit.compose.ui.OrbitTheme import kiwi.orbit.compose.ui.foundation.Colors import kiwi.orbit.compose.ui.foundation.Shapes import kiwi.orbit.compose.ui.foundation.Typography import kiwi.orbit.compose.ui.foundation.createTypography import kiwi.orbit.compose.ui.foundation.lightColors @Composable fun App() { // your Orbit Theme setup val colors = lightColors() val typography = remember { createTypography() } val shapes = remember { Shapes() } MaterialTheme( colors = colors.toMaterial2(), typography = typography.toMaterial2(), shapes = shapes.toMaterial2(), ) { OrbitTheme( colors = colors, typography = typography, shapes = shapes, ) { // ... } } } private fun Colors.toMaterial2(): androidx.compose.material.Colors = androidx.compose.material.Colors( primary = primary.normal, primaryVariant = primary.strong, secondary = info.normal, secondaryVariant = info.strong, background = surface.subtle, surface = surface.main, error = critical.normal, onPrimary = primary.onNormal, onSecondary = info.onNormal, onBackground = content.normal, onSurface = content.normal, onError = critical.onNormal, isLight = isLight, ) private fun Typography.toMaterial2(): androidx.compose.material.Typography = androidx.compose.material.Typography( defaultFontFamily = title1.fontFamily ?: FontFamily.Default, h1 = title1.copy(fontSize = 96.sp, lineHeight = TextUnit.Unspecified), h2 = title1.copy(fontSize = 60.sp, lineHeight = TextUnit.Unspecified), h3 = title1.copy(fontSize = 38.sp, lineHeight = TextUnit.Unspecified), h4 = title1, h5 = title2, h6 = title3, subtitle1 = title4, subtitle2 = title5, overline = title6, body1 = bodyNormal, body2 = bodySmall, button = title5, caption = bodySmall, ) private fun Shapes.toMaterial2(): androidx.compose.material.Shapes = androidx.compose.material.Shapes( small = small, medium = normal, large = large, ) ``` -------------------------------- ### RadioField with Label and Description Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/05-input/radio.md RadioField with additional slots for label and description, used in a group with state management. ```kotlin @Composable enum class TvShow { StarTrek, StarWars } fun Example() { var tvshow by remember { mutableStateOf(TvShow.StarTrek) } Column { RadioField( selected = tvshow == TvShow.StarTrek, onClick = { tvshow = TvShow.StarTrek }, description = { Text("Engage.") } ) { Text("StarTrek") } RadioField( selected = tvshow == TvShow.StarWars, onClick = { tvshow = TvShow.StarWars }, description = { Text("May the force be with you.") } ) { Text("StarWars") } } } ``` -------------------------------- ### ClickableField usage in Compose Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/05-input/inputfile.md Defines a clickable field with a value, click action, label, info text, and leading icon. The onClick lambda is required for user interaction. ```kotlin @Composable fun Example() { ClickableField( value = "Attach filed", onClick = { /* ... */ }, label = { Text("Attachment") }, info = { Text("Attach JPEG.") }, leadingIcon = { Icon(Icons.Attachment, contentDescription = null) }, ) } ``` -------------------------------- ### UI testing Slider with SetProgress semantics action Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/07-interaction/slider.md Set content with a Slider tagged "slider", then use performSemanticsAction(SemanticsActions.SetProgress) to set progress and read ProgressBarRangeInfo to assert the value. ```kotlin composeTestRule.setContent { var currentValue by rememberSaveable { mutableStateOf(0.0f) } Slider( value = currentValue, onValueChange = { currentValue = it }, modifier = Modifier.testTag("slider"), startLabel = {}, endLabel = {}, ) } composeTestRule.onNodeWithTag("slider") .performSemanticsAction(SemanticsActions.SetProgress) { it.invoke(0.5f) } val progressBarInfo = composeTestRule.onNodeWithTag("slider") .fetchSemanticsNode() .config[SemanticsProperties.ProgressBarRangeInfo] assertEquals(0.5f, progressBarInfo.current) ``` -------------------------------- ### BadgeListItemSuccess composable Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/03-information/badgelist.md A predefined badge list item variant for success messages. It takes an icon painter and has a content slot. ```APIDOC ## BadgeListItemSuccess composable ### Description A predefined badge list item variant for success messages. It takes an icon painter and has a content slot. ### Parameters - **icon** (Painter) - Required - The icon to display. - **content** (Composable) - Required - The text or content to display. - **iconContentDescription** (String?) - Optional - Content description for the icon. ### Usage Example ```kotlin BadgeListSuccess(Icons.Check) { Text("Your order is being processed right now.") } ``` ``` -------------------------------- ### Coupon composable Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/08-visuals/coupon.md A composable function that displays a coupon code in a dashed border. It accepts a code string and an optional onCopied callback to copy the code to clipboard on long click. ```APIDOC ## Coupon composable ### Description A composable function that displays a coupon code in a dashed border. It accepts a code string and an optional onCopied callback to copy the code to clipboard on long click. ### Parameters - **code** (String) - Required - The coupon code to display. It is converted to uppercase. - **onCopied** (callback?) - Optional - Callback invoked when the code is copied to clipboard on long click. Pass null to disable copying. - **modifier** (Modifier) - Optional - Modifier for layout and testing. ### Usage Example ```kotlin @Composable fun Example() { Column { Row( horizontalArrangement = Arrangement.spacedBy(4.dp), ) { Text( text = "Your coupon:", modifier = Modifier.alignByBaseline(), ) Coupon( code = "hxt3b81f", onCopied = null, modifier = Modifier.alignByBaseline(), ) } Row( horizontalArrangement = Arrangement.spacedBy(4.dp), ) { Text( text = "Copy your coupon:", modifier = Modifier.alignByBaseline(), ) Coupon( code = "hxt3b81f", onCopied = { coroutineScope.launch { toastHostState.showToast("Copied to clipboard!") { Icons.Copy } } }, modifier = Modifier.alignByBaseline(), ) } } } ``` ### UI Testing Add `testTag` to the component to test its properties. ```kotlin composeTestRule.setContent { Coupon( code = "hxt3b81f", onCopied = null, modifier = Modifier.testTag("coupon"), ) } composeTestRule.onNodeWithTag("coupon").assertTextEquals("HXT3B81F") ``` ### Customization `Coupon` appearance is not customizable. ``` -------------------------------- ### UI Testing Badge with testTag Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/03-information/badge.md Demonstrates adding a testTag to a Badge's content and asserting its text in a Compose UI test. The slotting API allows tagging specific component parts. ```kotlin composeTestRule.setContent { BadgeInfo { Text("Latest Update", Modifier.testTag("Badge")) } } composeTestRule.onNodeWithTag("Badge").assertTextContains("Latest Update") ``` -------------------------------- ### BadgeListItemInfo composable Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/03-information/badgelist.md A predefined badge list item variant for informational messages. It takes an icon painter and has a content slot. ```APIDOC ## BadgeListItemInfo composable ### Description A predefined badge list item variant for informational messages. It takes an icon painter and has a content slot. ### Parameters - **icon** (Painter) - Required - The icon to display. - **content** (Composable) - Required - The text or content to display. - **iconContentDescription** (String?) - Optional - Content description for the icon. ### Usage Example ```kotlin BadgeListInfo(Icons.Info) { Text("We will email you when there will be a progress.") } ``` ``` -------------------------------- ### Slider composable with state and callbacks Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/07-interaction/slider.md Use Slider with rememberSaveable state, onValueChange and onValueChangeFinished callbacks, steps, and start/end labels. Pass empty lambda to hide labels. ```kotlin @Composable fun Example() { val volumeValue by rememberSaveable { mutableStateOf(0.0f) } Slider( value = volumeValue, onValueChange = { volumeValue = it }, onValueChangeFinished = { /* process volumeValue */ }, steps = 20, startLabel = { Text("0") }, endLabel = { Text("100") }, ) } ``` -------------------------------- ### UI testing RangeSlider thumbs with SetProgress Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/07-interaction/slider.md For RangeSlider, fetch thumb nodes using hasParent(hasTestTag("slider")) and SemanticsMatcher.keyIsDefined(SemanticsActions.SetProgress), then set progress on each thumb and assert their ProgressBarRangeInfo values. ```kotlin composeTestRule.setContent { var currentValue by rememberSaveable { mutableStateOf(0.0f) } RangeSlider( value = currentValue, onValueChange = { currentValue = it }, modifier = Modifier.testTag("slider"), startLabel = {}, endLabel = {}, ) } val sliderThumbs = composeTestRule.onAllNodes( hasParent(hasTestTag("slider")) and SemanticsMatcher.keyIsDefined(SemanticsActions.SetProgress), ) val start = sliderThumbs[0] val end = sliderThumbs[1] start.performSemanticsAction(SemanticsActions.SetProgress) { it.invoke(0.5f) } end.performSemanticsAction(SemanticsActions.SetProgress) { it.invoke(0.8f) } val startProgressBarInfo = start .fetchSemanticsNode() .config[SemanticsProperties.ProgressBarRangeInfo] assertEquals(0.5f, startProgressBarInfo.current) val endProgressBarInfo = end .fetchSemanticsNode() .config[SemanticsProperties.ProgressBarRangeInfo] assertEquals(0.8f, endProgressBarInfo.current) ``` -------------------------------- ### BadgeListSmall composable Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/03-information/badgelist.md A smaller variant of BadgeList that also wraps badge list items. It supports customization of vertical arrangement and content emphasis. ```APIDOC ## BadgeListSmall composable ### Description A smaller variant of BadgeList that also wraps badge list items. It supports customization of vertical arrangement and content emphasis. ### Parameters - **content** (Composable) - Required - The slot for badge list items. - **verticalArrangement** (Arrangement.Vertical) - Optional - Custom spacing between items. - **contentEmphasis** (ContentEmphasis) - Optional - Overall text color emphasis. ### Usage Example ```kotlin @Composable fun Example() { Column { BadgeListSmall( verticalArrangement = Arrangement.spacedBy(10.dp), contentEmphasis = ContentEmphasis.Minor, ) { BadgeListSuccess(Icons.Check) { Text("Your order is being processed right now.") } BadgeListInfo(Icons.Info) { Text("We will email you when there will be a progress.") } BadgeListInfo(Icons.Money) { Text("Additional credits were added to your account.") } } } } ``` ``` -------------------------------- ### Stepper UI Testing Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/07-interaction/stepper.md Semantic properties and custom actions allow UI tests to read the stepper value and trigger increase/decrease actions. The presence of these actions depends on whether the corresponding button is active. ```APIDOC ## Stepper UI Testing ### Description Use semantic properties and custom actions to read the value and increase/decrease it. If the button is not active, the particular semantic action is not added; use `fetchSemanticsNode()` to check its presence. ### Request Example ```kotlin composeTestRule.setContent { var value by remember { mutableIntStateOf(0) } Stepper( modifier = Modifier.testTag("stepper"), value = value, onValueChange = { value = it }, ) } val stepper = composeTestRule.onNodeWithTag("stepper") assertFalse(stepper.fetchSemanticsNode().config.contains(StepperSemanticsActions.DecreaseValue)) assertTrue(stepper.fetchSemanticsNode().config.contains(StepperSemanticsActions.IncreaseValue)) stepper .assertTextEquals("0") .performSemanticsAction(StepperSemanticsActions.IncreaseValue) .assertTextEquals("1") .performSemanticsAction(StepperSemanticsActions.IncreaseValue) .assertTextEquals("2") .performSemanticsAction(StepperSemanticsActions.DecreaseValue) .assertTextEquals("1") assertTrue(stepper.fetchSemanticsNode().config.contains(StepperSemanticsActions.DecreaseValue)) assertTrue(stepper.fetchSemanticsNode().config.contains(StepperSemanticsActions.IncreaseValue)) ``` ``` -------------------------------- ### BadgeList composable Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/03-information/badgelist.md A composable function that wraps badge list items. It provides a slot for content and can be customized with vertical arrangement and content emphasis. ```APIDOC ## BadgeList composable ### Description A composable function that wraps badge list items. It provides a slot for content and can be customized with vertical arrangement and content emphasis. ### Parameters - **content** (Composable) - Required - The slot for badge list items. - **verticalArrangement** (Arrangement.Vertical) - Optional - Custom spacing between items. - **contentEmphasis** (ContentEmphasis) - Optional - Overall text color emphasis. ### Usage Example ```kotlin @Composable fun Example() { Column { BadgeList { BadgeListSuccess(Icons.Check) { Text("Your order is being processed right now.") } BadgeListInfo(Icons.Info) { Text("We will email you when there will be a progress.") } BadgeListInfo(Icons.Money) { Text("Additional credits were added to your account.") } } } } ``` ``` -------------------------------- ### BadgeInfo Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/03-information/badge.md A composable function that displays a badge with an info color variant. It uses a trailing content slot for text and an optional icon slot. ```APIDOC ## BadgeInfo ### Description A composable function that displays a badge with an info color variant. It uses a trailing content slot for text and an optional icon slot. ### Parameters #### Content Slot - **content** (Composable) - Required - The text content to display inside the badge. #### Icon Slot - **icon** (Composable) - Optional - An icon to display alongside the content. ### Example ```kotlin @Composable fun Example() { Column { BadgeInfo { Text("Text") } } } ``` ``` -------------------------------- ### Align multiple TextFields with LabelLastBaseLine Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/05-input/inputfield.md Use the LabelLastBaseLine alignment line to vertically align multiple text fields in a Row. ```kotlin @Composable import kiwi.orbit.compose.ui.controls.field.LabelLastBaseLine fun Example() { Row { TextField(Modifier.alignBy(LabelLastBaseLine), ...) TextField(Modifier.alignBy(LabelLastBaseLine), ...) } } ``` -------------------------------- ### BadgeInfoSubtle Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/03-information/badge.md A composable function that displays a badge with a subtle info color variant. It uses a trailing content slot for text and an optional icon slot. ```APIDOC ## BadgeInfoSubtle ### Description A composable function that displays a badge with a subtle info color variant. It uses a trailing content slot for text and an optional icon slot. ### Parameters #### Content Slot - **content** (Composable) - Required - The text content to display inside the badge. #### Icon Slot - **icon** (Composable) - Optional - An icon to display alongside the content. ``` -------------------------------- ### Checkbox composable Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/05-input/checkbox.md A simple checkbox that accepts a Boolean state and a callback on its change. ```APIDOC ## Checkbox composable ### Description A simple checkbox that accepts a Boolean state and a callback on its change. ### Parameters - **checked** (Boolean) - Required - The current state of the checkbox. - **onCheckedChange** (function) - Required - Callback invoked when the checkbox state changes. ### Example ```kotlin package test import androidx.compose.runtime.Composable @Composable fun Example() { Checkbox( checked = false, onCheckedChange = {}, ) } ``` ``` -------------------------------- ### BadgeListItemWarning composable Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/03-information/badgelist.md A predefined badge list item variant for warning messages. It takes an icon painter and has a content slot. ```APIDOC ## BadgeListItemWarning composable ### Description A predefined badge list item variant for warning messages. It takes an icon painter and has a content slot. ### Parameters - **icon** (Painter) - Required - The icon to display. - **content** (Composable) - Required - The text or content to display. - **iconContentDescription** (String?) - Optional - Content description for the icon. ### Usage Example ```kotlin BadgeListWarning(Icons.Warning) { Text("Warning message.") } ``` ``` -------------------------------- ### LinearProgressIndicator usage Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/10-progress-indicators/loading.md Use LinearProgressIndicator with a progress value. By default, progress changes are animated; pass a custom animation spec via progressAnimationSpec or use snap() to disable animation. ```kotlin @Composable fun Example(progress: Float) { LinearProgressIndicator( progress = progress, ) } ``` -------------------------------- ### BadgeSuccess Source: https://github.com/yasan-org/orbit-compose-multiplatform/blob/main/docs/03-components/03-information/badge.md A composable function that displays a badge with a success color variant. It uses a trailing content slot for text and an optional icon slot. ```APIDOC ## BadgeSuccess ### Description A composable function that displays a badge with a success color variant. It uses a trailing content slot for text and an optional icon slot. ### Parameters #### Content Slot - **content** (Composable) - Required - The text content to display inside the badge. #### Icon Slot - **icon** (Composable) - Optional - An icon to display alongside the content. ```