InlineMessage
Inline Message is use to displays highly contextual, non-interruptive messages inline with content.
Note: if you are looking for a version with a actions look for the Composable with InlineMessageActions.
Parameters
string to be display as main message.
Modifier to be applied to the InlineMessage.
optional string to be display at the top of the InlineMessage. title will not display when style is set to InlineMessageStyle.Subtle.
InlineMessageVariant defines the semantic meaning of the message.
resources object to query the image file from.
defines the visual accentuation of the InlineMessage, with InlineMessageStyle.Subtle the title will is removed and the surface flattened.
InlineMessageVisibility enum that handles visibility state of the component
DismissParams if provided, the component will display a close button in the top, close interaction need to be handle trough visibility and DismissParams.onDismissRequest.
See also
Samples
import androidx.compose.foundation.background
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import net.ikea.skapa.foundation.*
import net.ikea.skapa.ui.components.Button
import net.ikea.skapa.ui.components.ButtonVariant
import net.ikea.skapa.ui.components.DismissParams
import net.ikea.skapa.ui.components.InlineMessage
import net.ikea.skapa.ui.components.InlineMessageStyle
import net.ikea.skapa.ui.components.InlineMessageVariant
import net.ikea.skapa.ui.components.InlineMessageVisibility
fun main() {
//sampleStart
var showInlineMessage by remember { mutableStateOf(InlineMessageVisibility.Visible) }
var loading by remember { mutableStateOf(false) }
val scope = rememberCoroutineScope()
SkapaTheme2(darkTheme = isSystemInDarkTheme()) {
with(SkapaSpacing) {
Column(
modifier = Modifier.padding(horizontal = space125)
) {
Box(
modifier = Modifier
.background(SkapaTheme.colors.neutral3)
.height(space1000)
.fillMaxWidth()
)
Spacer(modifier = Modifier.height(space100))
InlineMessage(
title = "Upload failed",
body = "Check your internet connection and try please again.",
variant = InlineMessageVariant.Negative,
style = InlineMessageStyle.Emphasised,
modifier = Modifier.padding(bottom = space150),
dismissible = DismissParams(
onDismissRequest = {
showInlineMessage = InlineMessageVisibility.Hidden
},
dismissButtonContentDescription = "Close"
)
)
Button(
label = "Upload Image",
modifier = Modifier
.fillMaxWidth()
.padding(bottom = space150),
loading = loading,
variant = ButtonVariant.Emphasised
) {
loading = true
scope.launch {
delay(3000L)
loading = false
showInlineMessage = InlineMessageVisibility.Visible
}
}
}
}
}
//sampleEnd
}Inline Message is use to displays highly contextual, non-interruptive messages inline with content.
Parameters
string to be display as main message.
InlineMessageActions to be added to the component, first and second action type is InlineMessageActionParams.
Modifier to be applied to the InlineMessage.
optional string to be display at the top of the InlineMessage.
InlineMessageVariant defines the semantic meaning of the message.
resources object to query the image file from.
InlineMessageVisibility enum that handles visibility state of the component
DismissParams if provided, the component will display a close button in the top, close interaction need to be handle trough visibility and DismissParams.onDismissRequest.
See also
Samples
import androidx.compose.foundation.background
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import net.ikea.skapa.foundation.*
import net.ikea.skapa.ui.components.Button
import net.ikea.skapa.ui.components.ButtonVariant
import net.ikea.skapa.ui.components.DismissParams
import net.ikea.skapa.ui.components.InlineMessage
import net.ikea.skapa.ui.components.InlineMessageStyle
import net.ikea.skapa.ui.components.InlineMessageVariant
import net.ikea.skapa.ui.components.InlineMessageVisibility
fun main() {
//sampleStart
var showInlineMessage by remember { mutableStateOf(InlineMessageVisibility.Visible) }
var loading by remember { mutableStateOf(false) }
val scope = rememberCoroutineScope()
SkapaTheme2(darkTheme = isSystemInDarkTheme()) {
with(SkapaSpacing) {
Column(
modifier = Modifier.padding(horizontal = space125)
) {
Box(
modifier = Modifier
.background(SkapaTheme.colors.neutral3)
.height(space1000)
.fillMaxWidth()
)
Spacer(modifier = Modifier.height(space100))
InlineMessage(
title = "Upload failed",
body = "Check your internet connection and try please again.",
variant = InlineMessageVariant.Negative,
style = InlineMessageStyle.Emphasised,
modifier = Modifier.padding(bottom = space150),
dismissible = DismissParams(
onDismissRequest = {
showInlineMessage = InlineMessageVisibility.Hidden
},
dismissButtonContentDescription = "Close"
)
)
Button(
label = "Upload Image",
modifier = Modifier
.fillMaxWidth()
.padding(bottom = space150),
loading = loading,
variant = ButtonVariant.Emphasised
) {
loading = true
scope.launch {
delay(3000L)
loading = false
showInlineMessage = InlineMessageVisibility.Visible
}
}
}
}
}
//sampleEnd
}