Skip to content

[UI] Destructive action confirmation dialogs and discard-changes guards (Phase 11) #436

@CRamsan

Description

@CRamsan

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: Boolean in 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

What type of task is this?

Development

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions