in hot-reload-devtools/src/main/kotlin/org/jetbrains/compose/devtools/widgets/DtNotificationCard.kt [44:115]
fun DtNotificationCard(notification: UINotification) {
var showDetails by remember { mutableStateOf(false) }
val scope = rememberEvasCoroutineScope()
Column(
modifier = Modifier
.background(DtColors.applicationBackground)
.dtBorder()
.clip(DtShapes.RoundedCornerShape)
.padding(DtPadding.smallElementPadding)
.heightIn(max = DtSizes.maxNotificationCardHeight)
.tag(Tag.NotificationCard),
verticalArrangement = Arrangement.spacedBy(DtPadding.smallElementPadding),
) {
Row {
Row(horizontalArrangement = Arrangement.spacedBy(DtPadding.tinyElementPadding)) {
DtNotificationIcon(notification)
DtHeader2(notification.title, modifier = Modifier.tag(Tag.NotificationTitle))
}
Spacer(Modifier.weight(1f))
Row(horizontalArrangement = Arrangement.spacedBy(DtPadding.tinyElementPadding)) {
DtCopyToClipboardButton(
modifier = Modifier.size(DtSizes.iconSize),
) {
buildString {
appendLine(notification.message)
append(notification.details.joinToString("\n"))
}
}
if (notification.details.isNotEmpty()) {
DtIconButton(
onClick = { showDetails = !showDetails },
tooltip = "Show details",
modifier = Modifier.size(DtSizes.iconSize),
tag = Tag.NotificationExpandButton,
) {
DtImage(
image = DtImages.Image.EXPAND_ICON,
tint = Color.White,
)
}
}
if (notification.isDisposableFromUI) {
DtIconButton(
onClick = { scope.launch { UINotificationDisposeEvent(notification.id).emit() } },
tooltip = "Clean the warning",
modifier = Modifier.size(DtSizes.iconSize),
tag = Tag.NotificationCleanButton,
) {
DtImage(
image = DtImages.Image.CLOSE_ICON,
tint = Color.White,
)
}
}
}
}
DtCode(notification.message, modifier = Modifier.tag(Tag.NotificationMessage))
if (showDetails) {
DtConsole(
logs = notification.details,
scrollToBottom = false,
animateBorder = false,
)
}
}
}