toast
OCToast - A Custom Composable UI Component
The OCToast
composable is a customizable card view for displaying information. It can include a title, description, caption, button, and icons. The appearance of the card can be customized using different background colors and icon sizes.
Toast Color Options:
- ToastDefaultBackground
- ToastSuccessBackground
- ToastErrorBackground
Features
- Display informative toasts with a customizable title.
- Choose from different background colors, including default, success, and error.
- Option to add an icon with a description.
- Supports adding an optional action.
- Automatically adjusts margins for landscape mode.
How to use OCToast
-
Add the necessary imports:
import your.package.name.OCToast
-
Use the
OCToast
within your Composable:
OCToast(
iconDescription = "Description",
title = "One line message",
actionOnNewLine = false,
backgroundColor = ToastDefaultBackground,
action = {
TextButton(
onClick = { },
content = {
OCText(
text = "Button1",
style = OCTypography().buttonSemiBold.copy(
color = OCTheme.colors.toastDefaultAction,
),
)
},
modifier = Modifier.clearAndSetSemantics { contentDescription = "Button1" }
)
},
)
Parameters:
title
: Title of the toastbackgroundColor
: The background color of the toast. You can choose from the following options:- ToastDefaultBackground: Default background color.
- ToastSuccessBackground: Background color for success messages.
- ToastErrorBackground: Background color for error messages.
iconDescription
(String, optional): A description for an optional icon.action
: An optional composable lambda that represents an action button to be displayed in the toast. You can define custom actions to be performed when the user interacts with it.actionOnNewLine
(Boolean, optional): If set to true, the action button will be displayed on a new line below the title and icon, otherwise, it will be on the same line as the title.