diff --git a/app/src/main/java/com/example/notesai/MainActivity.kt b/app/src/main/java/com/example/notesai/MainActivity.kt index ef8f981..39d63f6 100644 --- a/app/src/main/java/com/example/notesai/MainActivity.kt +++ b/app/src/main/java/com/example/notesai/MainActivity.kt @@ -449,8 +449,83 @@ fun EditableFullScreenNoteView( ) { var title by remember { mutableStateOf(note.title) } var content by remember { mutableStateOf(note.content) } + var showArchiveDialog by remember { mutableStateOf(false) } + var showDeleteDialog by remember { mutableStateOf(false) } val dateFormat = remember { SimpleDateFormat("dd MMMM yyyy, HH:mm", Locale("id", "ID")) } + // Dialog Konfirmasi Arsip + if (showArchiveDialog) { + AlertDialog( + onDismissRequest = { showArchiveDialog = false }, + title = { + Text( + text = "Arsipkan Catatan?", + style = MaterialTheme.typography.titleLarge, + fontWeight = FontWeight.Bold + ) + }, + text = { + Text( + text = "Catatan ini akan dipindahkan ke arsip. Anda masih bisa mengaksesnya nanti.", + style = MaterialTheme.typography.bodyMedium + ) + }, + confirmButton = { + TextButton( + onClick = { + if (title.isNotBlank()) { + onSave(title, content) + } + onArchive() + showArchiveDialog = false + } + ) { + Text("Arsipkan", color = MaterialTheme.colorScheme.primary) + } + }, + dismissButton = { + TextButton(onClick = { showArchiveDialog = false }) { + Text("Batal", color = MaterialTheme.colorScheme.onSurface) + } + } + ) + } + + // Dialog Konfirmasi Hapus + if (showDeleteDialog) { + AlertDialog( + onDismissRequest = { showDeleteDialog = false }, + title = { + Text( + text = "Hapus Catatan?", + style = MaterialTheme.typography.titleLarge, + fontWeight = FontWeight.Bold + ) + }, + text = { + Text( + text = "Catatan ini akan dihapus permanen dan tidak bisa dikembalikan.", + style = MaterialTheme.typography.bodyMedium + ) + }, + confirmButton = { + TextButton( + onClick = { + onDelete() + showDeleteDialog = false + } + ) { + Text("Hapus", color = Color(0xFFEF4444)) + } + }, + dismissButton = { + TextButton(onClick = { showDeleteDialog = false }) { + Text("Batal", color = MaterialTheme.colorScheme.onSurface) + } + } + ) + } + Scaffold( containerColor = MaterialTheme.colorScheme.background, topBar = { @@ -479,15 +554,10 @@ fun EditableFullScreenNoteView( tint = if (note.isPinned) Color(0xFFFBBF24) else MaterialTheme.colorScheme.onSurface ) } - IconButton(onClick = { - if (title.isNotBlank()) { - onSave(title, content) - } - onArchive() - }) { + IconButton(onClick = { showArchiveDialog = true }) { Icon(Icons.Default.Archive, contentDescription = "Arsipkan", tint = MaterialTheme.colorScheme.onSurface) } - IconButton(onClick = onDelete) { + IconButton(onClick = { showDeleteDialog = true }) { Icon(Icons.Default.Delete, contentDescription = "Hapus", tint = MaterialTheme.colorScheme.onSurface) } },