-
Notifications
You must be signed in to change notification settings - Fork 0
[UI] Destructive action confirmation dialogs and discard-changes guards (Phase 11) #436
Description
Phase 11 — Destructive Action Guards
Implement confirmation dialogs for all destructive actions and discard-changes guards on all form screens. This is split from #410 which covered the entire MVP Polish epic.
POL-05: Confirmation Dialogs for Destructive Actions
Define a reusable ConfirmationDialog composable:
@Composable
fun ConfirmationDialog(
title: String,
body: String,
confirmLabel: String,
onConfirm: () -> Unit,
onDismiss: () -> Unit,
isDestructive: Boolean = true,
)When isDestructive = true, confirm button uses MaterialTheme.colorScheme.error.
Apply to: Delete Unit, Delete Task, Remove Occupant, Cancel Invite, Leave Organization.
ViewModel pattern: manage pendingDestructiveAction: DestructiveAction? field — non-null triggers dialog; on confirm executes then clears; on dismiss clears without executing.
POL-06: Discard Changes Guard
All form screens must warn before losing unsaved changes.
Form screens requiring this guard: AddEditUnitScreen, AddEditTaskScreen, AddOccupantScreen, EditProfileScreen, AddPaymentRecordScreen, SubmitRequestScreen.
Implementation:
- Each form ViewModel exposes
isModified: Booleanin UIState — set to true when any field changes from its original value BackHandler(enabled = viewModel.isModified)intercepts back navigation- Dialog: title "Discard unsaved changes?", body "Your changes will be lost.", Discard (destructive) / Keep Editing (neutral)
- Top bar back arrow must also trigger this guard (not bypass it)
Dependencies
- All feature screens listed above must exist before guards can be applied
- [POLISH] Empty states, loading states, and confirmation dialogs across all screens (Phase 11) #410 — Accessibility and UI states (sister polish issue)
What type of task is this?
Development