Add email notification preference for task completion
- Add emailTaskCompleted field to NotificationPreference model - Add email preference toggle to notification settings UI (iOS & Android) - Add localized strings for email notifications section - Update ViewModel to support email preference updates 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -390,6 +390,11 @@
|
||||
<string name="notifications_warranty_expiring">Warranty Expiring</string>
|
||||
<string name="notifications_warranty_expiring_desc">Reminders for expiring warranties</string>
|
||||
|
||||
<!-- Email Notifications -->
|
||||
<string name="notifications_email_section">Email Notifications</string>
|
||||
<string name="notifications_email_task_completed">Task Completed Email</string>
|
||||
<string name="notifications_email_task_completed_desc">Receive email when a task is completed</string>
|
||||
|
||||
<!-- Common -->
|
||||
<string name="common_save">Save</string>
|
||||
<string name="common_cancel">Cancel</string>
|
||||
|
||||
@@ -40,7 +40,10 @@ data class NotificationPreference(
|
||||
@SerialName("residence_shared")
|
||||
val residenceShared: Boolean = true,
|
||||
@SerialName("warranty_expiring")
|
||||
val warrantyExpiring: Boolean = true
|
||||
val warrantyExpiring: Boolean = true,
|
||||
// Email preferences
|
||||
@SerialName("email_task_completed")
|
||||
val emailTaskCompleted: Boolean = true
|
||||
)
|
||||
|
||||
@Serializable
|
||||
@@ -56,7 +59,10 @@ data class UpdateNotificationPreferencesRequest(
|
||||
@SerialName("residence_shared")
|
||||
val residenceShared: Boolean? = null,
|
||||
@SerialName("warranty_expiring")
|
||||
val warrantyExpiring: Boolean? = null
|
||||
val warrantyExpiring: Boolean? = null,
|
||||
// Email preferences
|
||||
@SerialName("email_task_completed")
|
||||
val emailTaskCompleted: Boolean? = null
|
||||
)
|
||||
|
||||
@Serializable
|
||||
|
||||
@@ -35,6 +35,7 @@ fun NotificationPreferencesScreen(
|
||||
var taskAssigned by remember { mutableStateOf(true) }
|
||||
var residenceShared by remember { mutableStateOf(true) }
|
||||
var warrantyExpiring by remember { mutableStateOf(true) }
|
||||
var emailTaskCompleted by remember { mutableStateOf(true) }
|
||||
|
||||
// Load preferences on first render
|
||||
LaunchedEffect(Unit) {
|
||||
@@ -51,6 +52,7 @@ fun NotificationPreferencesScreen(
|
||||
taskAssigned = prefs.taskAssigned
|
||||
residenceShared = prefs.residenceShared
|
||||
warrantyExpiring = prefs.warrantyExpiring
|
||||
emailTaskCompleted = prefs.emailTaskCompleted
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,6 +296,36 @@ fun NotificationPreferencesScreen(
|
||||
}
|
||||
}
|
||||
|
||||
// Email Notifications Section
|
||||
Text(
|
||||
stringResource(Res.string.notifications_email_section),
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
modifier = Modifier.padding(top = AppSpacing.md)
|
||||
)
|
||||
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
shape = RoundedCornerShape(AppRadius.md),
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceVariant
|
||||
)
|
||||
) {
|
||||
Column {
|
||||
NotificationToggle(
|
||||
title = stringResource(Res.string.notifications_email_task_completed),
|
||||
description = stringResource(Res.string.notifications_email_task_completed_desc),
|
||||
icon = Icons.Default.Email,
|
||||
iconTint = MaterialTheme.colorScheme.primary,
|
||||
checked = emailTaskCompleted,
|
||||
onCheckedChange = {
|
||||
emailTaskCompleted = it
|
||||
viewModel.updatePreference(emailTaskCompleted = it)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(AppSpacing.xl))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,8 @@ class NotificationPreferencesViewModel : ViewModel() {
|
||||
taskCompleted: Boolean? = null,
|
||||
taskAssigned: Boolean? = null,
|
||||
residenceShared: Boolean? = null,
|
||||
warrantyExpiring: Boolean? = null
|
||||
warrantyExpiring: Boolean? = null,
|
||||
emailTaskCompleted: Boolean? = null
|
||||
) {
|
||||
viewModelScope.launch {
|
||||
_updateState.value = ApiResult.Loading
|
||||
@@ -46,7 +47,8 @@ class NotificationPreferencesViewModel : ViewModel() {
|
||||
taskCompleted = taskCompleted,
|
||||
taskAssigned = taskAssigned,
|
||||
residenceShared = residenceShared,
|
||||
warrantyExpiring = warrantyExpiring
|
||||
warrantyExpiring = warrantyExpiring,
|
||||
emailTaskCompleted = emailTaskCompleted
|
||||
)
|
||||
val result = APILayer.updateNotificationPreferences(request)
|
||||
_updateState.value = when (result) {
|
||||
|
||||
Reference in New Issue
Block a user