Banner Component
A banner communicates a change or error within an app can or provide actions that the user can perform. Banners persist until they are deleted by the user or until the condition that caused the banner is resolved. The banner is shown below the Top Navigation and moves the content below down.
Usage 🔑
- Import the necessary components: Ensure you've imported the required Banner Composable and other necessary components at the top of your Kotlin file.
import androidx.compose.runtime.* import androidx.compose.ui.*
// ... other required imports
-
Use the OCBanner Composable: In your UI, you can then add the OCBanner composable:
@Composable fun yourComposable() {
// ... startOCBanner( modifier: Modifier = Modifier, icon = R.drawable.icon_banner_default, description = "This is a sample banner", bannerType = Default,
primaryActionTitle = "Action 1", secondaryActionTitle = "Action 2", primaryAction = , secondaryAction = )// ... rest of code
}
Parameters:
modifier: Modifier: Modifier for styling and layout. icon: Int? = null: A icon which is optional will appear on top left of banner component. Resizing of icon is disabled. description: String: The text to be displayed which contain necessary details or action to be performed. bannerType: OCBannerType: Specifies the type of the Banner whether it is Default or Error. Based on that will decide the background color, text color, icon color, and action button text color of that banner component. primaryActionTitle: String? = null : Text that is displayed on primary action button. secondaryActionTitle: String? = null : Text that is displayed on secondary action button. primaryAction: () -> Unit = : Callback function that is called on clicking TextButton with title primaryActionTitle and corresponding action is performed on clicking it. secondaryAction: () -> Unit = : Callback function that is called on clicking TextButton with title secondaryActionTitle and corresponding action is performed on clicking it.