feat: Add message info to NotificationEditor

This commit is contained in:
Myzel394 2023-10-24 12:50:58 +02:00
parent 37a8a9871e
commit 26f17869d6
No known key found for this signature in database
GPG Key ID: 50098FCA22080F0F
3 changed files with 15 additions and 3 deletions

View File

@ -40,6 +40,8 @@ import app.myzel394.alibi.db.NotificationSettings
import app.myzel394.alibi.ui.components.CustomRecordingNotificationsScreen.models.NotificationViewModel
import app.myzel394.alibi.ui.components.CustomRecordingNotificationsScreen.molecules.EditNotificationInput
import app.myzel394.alibi.ui.components.CustomRecordingNotificationsScreen.molecules.NotificationPresetsRoulette
import app.myzel394.alibi.ui.components.atoms.MessageBox
import app.myzel394.alibi.ui.components.atoms.MessageType
val HORIZONTAL_PADDING = 16.dp;
@ -109,6 +111,11 @@ fun NotificationEditor(
.padding(horizontal = HORIZONTAL_PADDING),
verticalArrangement = Arrangement.spacedBy(16.dp),
) {
MessageBox(
type = MessageType.SURFACE,
message = stringResource(R.string.ui_settings_customNotifications_edit_help)
)
EditNotificationInput(
modifier = Modifier
.fillMaxWidth()

View File

@ -29,17 +29,19 @@ fun MessageBox(
title: String? = null,
) {
val isDark = rememberIsInDarkMode()
val containerColor = when(type) {
val containerColor = when (type) {
MessageType.ERROR -> MaterialTheme.colorScheme.errorContainer
MessageType.INFO -> MaterialTheme.colorScheme.tertiaryContainer
MessageType.SUCCESS -> Color.Green.copy(alpha = 0.3f)
MessageType.WARNING -> Color.Yellow.copy(alpha = 0.3f)
MessageType.SURFACE -> MaterialTheme.colorScheme.surfaceVariant
}
val onContainerColor = when(type) {
val onContainerColor = when (type) {
MessageType.ERROR -> MaterialTheme.colorScheme.onError
MessageType.INFO -> MaterialTheme.colorScheme.onTertiaryContainer
MessageType.SUCCESS -> Color.Green
MessageType.WARNING -> Color.Yellow
MessageType.SURFACE -> MaterialTheme.colorScheme.onSurfaceVariant
}
val textColor = if (isDark) onContainerColor else MaterialTheme.colorScheme.onSurface
val backgroundColor = if (isDark) containerColor else onContainerColor
@ -53,9 +55,10 @@ fun MessageBox(
.then(modifier)
) {
Icon(
imageVector = when(type) {
imageVector = when (type) {
MessageType.ERROR -> Icons.Default.Error
MessageType.INFO -> Icons.Default.Info
MessageType.SURFACE -> Icons.Default.Info
MessageType.SUCCESS -> Icons.Default.Check
MessageType.WARNING -> Icons.Default.Warning
},
@ -84,6 +87,7 @@ fun MessageBox(
enum class MessageType {
ERROR,
INFO,
SURFACE,
SUCCESS,
WARNING,
}

View File

@ -87,4 +87,5 @@
<string name="ui_settings_customNotifications_preset_apply_label">Apply Preset \"%s\"</string>
<string name="ui_settings_customNotifications_showOngoing_label">Show Duration</string>
<string name="ui_settings_customNotifications_save_label">Update notification</string>
<string name="ui_settings_customNotifications_edit_help">This is a preview for your notification. You can edit the title and the message. At the bottom you can find some presets.</string>
</resources>