Compare commits

..

No commits in common. "1e23f68ba331b76acf11fb9766bfa3eae4dc8a80" and "14bf2f2f24eddb0323571d2bd76ea580bc974ee0" have entirely different histories.

2 changed files with 28 additions and 17 deletions

View File

@ -89,7 +89,6 @@
* **Search di kategori** - Cari catatan berdasarkan judul & isi (case-insensitive)
* **Search empty state** - Tampilkan pesan "Tidak ada hasil" saat search kosong
* **Gradle optimization** - Cleanup dependencies yang tidak diperlukan
* **Hilangkan Fitur Tahan Untuk Hapus**
---

View File

@ -52,7 +52,6 @@ import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.material.icons.filled.ContentCopy
import androidx.compose.material.icons.outlined.StarBorder
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.zIndex
@ -115,7 +114,7 @@ class MainActivity : ComponentActivity() {
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun NotesApp() {
val context = LocalContext.current
val context = androidx.compose.ui.platform.LocalContext.current
val dataStoreManager = remember { DataStoreManager(context) }
val scope = rememberCoroutineScope()
@ -156,7 +155,7 @@ fun NotesApp() {
// Simpan categories dengan debounce
LaunchedEffect(categories.size) {
if (categories.isNotEmpty()) {
delay(500)
kotlinx.coroutines.delay(500)
try {
dataStoreManager.saveCategories(categories)
} catch (e: Exception) {
@ -168,7 +167,7 @@ fun NotesApp() {
// Simpan notes dengan debounce
LaunchedEffect(notes.size) {
if (notes.isNotEmpty()) {
delay(500)
kotlinx.coroutines.delay(500)
try {
dataStoreManager.saveNotes(notes)
} catch (e: Exception) {
@ -312,13 +311,19 @@ fun NotesApp() {
fullScreenNote = note
showFullScreenNote = true
},
onNoteLongClick = { note ->
notes = notes.map {
if (it.id == note.id) it.copy(isArchived = true)
else it
}
},
onPinToggle = { note ->
notes = notes.map {
if (it.id == note.id) it.copy(isPinned = !it.isPinned)
else it
}
},
onCategoryDelete = { category ->
onCategoryLongClick = { category ->
// Delete kategori dan semua catatan di dalamnya
categories = categories.filter { it.id != category.id }
notes = notes.filter { it.categoryId != category.id }
@ -819,8 +824,9 @@ fun MainScreen(
searchQuery: String,
onCategoryClick: (Category) -> Unit,
onNoteClick: (Note) -> Unit,
onNoteLongClick: (Note) -> Unit,
onPinToggle: (Note) -> Unit,
onCategoryDelete: (Category) -> Unit
onCategoryLongClick: (Category) -> Unit
) {
Column(modifier = Modifier.fillMaxSize()) {
if (selectedCategory == null) {
@ -860,8 +866,10 @@ fun MainScreen(
category = category,
noteCount = notes.count { it.categoryId == category.id && !it.isDeleted && !it.isArchived },
onClick = { onCategoryClick(category) },
onLongClick = { onCategoryLongClick(category) },
onDelete = {
onCategoryDelete(category)
// Delete kategori dan semua catatan di dalamnya
onCategoryLongClick(category)
}
)
}
@ -898,7 +906,8 @@ fun MainScreen(
NoteCard(
note = note,
onClick = { onNoteClick(note) },
onPinClick = { onPinToggle(note) },
onLongClick = { onNoteLongClick(note) },
onPinClick = { onPinToggle(note) }
)
}
}
@ -913,6 +922,7 @@ fun CategoryCard(
category: Category,
noteCount: Int,
onClick: () -> Unit,
onLongClick: () -> Unit,
onDelete: () -> Unit = {}
) {
var showDeleteConfirm by remember { mutableStateOf(false) }
@ -921,9 +931,9 @@ fun CategoryCard(
if (showDeleteConfirm) {
AlertDialog(
onDismissRequest = { showDeleteConfirm = false },
title = { Text("Hapus Kategori?", color = Color.White) },
title = { Text("Hapus Kategori?") },
text = {
Text("Kategori '${category.name}' dan semua catatan di dalamnya akan dihapus. Tindakan ini tidak dapat dibatalkan.", color = Color.White)
Text("Kategori '$${category.name}' dan semua catatan di dalamnya akan dihapus. Tindakan ini tidak dapat dibatalkan.")
},
confirmButton = {
Button(
@ -947,15 +957,17 @@ fun CategoryCard(
) {
Text("Batal", color = Color.White)
}
},
containerColor = Color(0xFF1E293B)
}
)
}
Card(
modifier = Modifier
.fillMaxWidth()
.clickable(onClick = onClick),
.combinedClickable(
onClick = onClick,
onLongClick = onLongClick
),
shape = RoundedCornerShape(20.dp),
colors = CardDefaults.cardColors(containerColor = Color.Transparent),
elevation = CardDefaults.cardElevation(defaultElevation = 0.dp)
@ -997,9 +1009,7 @@ fun CategoryCard(
// Delete button di top-right corner
IconButton(
onClick = {
showDeleteConfirm = true
},
onClick = { showDeleteConfirm = true },
modifier = Modifier
.align(Alignment.TopEnd)
.size(40.dp)
@ -1020,6 +1030,7 @@ fun CategoryCard(
fun NoteCard(
note: Note,
onClick: () -> Unit,
onLongClick: () -> Unit,
onPinClick: () -> Unit
) {
val dateFormat = SimpleDateFormat("dd MMM, HH:mm", Locale("id", "ID"))
@ -1029,6 +1040,7 @@ fun NoteCard(
.fillMaxWidth()
.combinedClickable(
onClick = onClick,
onLongClick = onLongClick
),
shape = RoundedCornerShape(16.dp),
colors = CardDefaults.cardColors(