diff --git a/app/src/main/java/com/example/notesai/MainActivity.kt b/app/src/main/java/com/example/notesai/MainActivity.kt index 0e02c39..22e92f2 100644 --- a/app/src/main/java/com/example/notesai/MainActivity.kt +++ b/app/src/main/java/com/example/notesai/MainActivity.kt @@ -52,6 +52,7 @@ import androidx.compose.ui.text.AnnotatedString import androidx.compose.material.icons.filled.ContentCopy import androidx.compose.material.icons.outlined.StarBorder import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.style.TextOverflow import kotlinx.coroutines.delay // Data Classes @@ -323,6 +324,15 @@ fun NotesApp() { notes = notes.filter { it.categoryId != category.id } } ) + "starred" -> StarredNotesScreen( + notes = notes, + onNoteClick = { note -> + fullScreenNote = note + showFullScreenNote = true + }, + onMenuClick = { drawerState = true }, + onBack = { currentScreen = "main" } + ) "ai" -> AIHelperScreen( categories = categories, notes = notes.filter { !it.isDeleted } @@ -1055,6 +1065,12 @@ fun DrawerMenu( isSelected = currentScreen == "main" ) { onItemClick("main") } + MenuItem( + icon = Icons.Default.Star, + text = "Berbintang", + isSelected = currentScreen == "starred" + ) { onItemClick("starred") } + MenuItem( icon = Icons.Default.Archive, text = "Arsip", @@ -2169,6 +2185,240 @@ fun TrashNoteCard( } } + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun StarredNotesScreen( + notes: List, + onNoteClick: (Note) -> Unit, + onMenuClick: () -> Unit, + onBack: () -> Unit +) { + val starredNotes = notes.filter { it.isPinned && !it.isArchived && !it.isDeleted } + + Scaffold( + containerColor = MaterialTheme.colorScheme.background, + topBar = { + TopAppBar( + title = { + Text( + "Berbintang", + style = MaterialTheme.typography.titleLarge, + fontWeight = FontWeight.Bold, + color = MaterialTheme.colorScheme.onBackground + ) + }, + navigationIcon = { + IconButton(onClick = onBack) { + Icon( + Icons.AutoMirrored.Filled.ArrowBack, + contentDescription = "Kembali", + tint = MaterialTheme.colorScheme.onBackground + ) + } + }, + actions = { + IconButton(onClick = onMenuClick) { + Icon( + Icons.Default.Menu, + contentDescription = "Menu", + tint = MaterialTheme.colorScheme.onBackground + ) + } + }, + colors = TopAppBarDefaults.topAppBarColors( + containerColor = Color.Transparent + ) + ) + } + ) { padding -> + if (starredNotes.isEmpty()) { + // Tampilan kosong + Box( + modifier = Modifier + .fillMaxSize() + .padding(padding), + contentAlignment = Alignment.Center + ) { + Column( + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.Center, + modifier = Modifier.padding(horizontal = 32.dp) + ) { + Icon( + Icons.Default.Star, + contentDescription = null, + tint = Color(0xFF64748B), + modifier = Modifier.size(80.dp) + ) + Spacer(modifier = Modifier.height(16.dp)) + Text( + "Belum Ada Catatan Berbintang", + style = MaterialTheme.typography.titleMedium, + color = Color(0xFF64748B), + fontWeight = FontWeight.SemiBold, + textAlign = TextAlign.Center + ) + Spacer(modifier = Modifier.height(8.dp)) + Text( + "Tandai catatan penting dengan bintang agar mudah ditemukan", + style = MaterialTheme.typography.bodyMedium, + color = Color(0xFF94A3B8), + textAlign = TextAlign.Center + ) + } + } + } else { + // Daftar catatan berbintang + LazyColumn( + modifier = Modifier + .fillMaxSize() + .padding(padding) + .padding(horizontal = 16.dp), + verticalArrangement = Arrangement.spacedBy(12.dp) + ) { + item { + Spacer(modifier = Modifier.height(8.dp)) + Text( + text = "${starredNotes.size} catatan berbintang", + style = MaterialTheme.typography.bodyMedium, + color = Color(0xFF64748B), + modifier = Modifier.padding(start = 4.dp, bottom = 4.dp) + ) + } + + items(starredNotes) { note -> + StarredNoteCard( + note = note, + onClick = { onNoteClick(note) } + ) + } + + item { + Spacer(modifier = Modifier.height(16.dp)) + } + } + } + } +} + +@Composable +fun StarredNoteCard( + note: Note, + onClick: () -> Unit +) { + val dateFormat = remember { SimpleDateFormat("dd MMM yyyy ยท HH:mm", Locale("id", "ID")) } + + Card( + modifier = Modifier + .fillMaxWidth() + .clickable(onClick = onClick), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surface + ), + shape = RoundedCornerShape(16.dp), + elevation = CardDefaults.cardElevation( + defaultElevation = 2.dp, + pressedElevation = 4.dp + ) + ) { + Column( + modifier = Modifier + .fillMaxWidth() + .padding(20.dp) + ) { + // Header dengan judul dan ikon bintang + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.SpaceBetween, + verticalAlignment = Alignment.Top + ) { + Text( + text = note.title, + style = MaterialTheme.typography.titleLarge, + fontWeight = FontWeight.Bold, + color = MaterialTheme.colorScheme.onSurface, + maxLines = 2, + overflow = TextOverflow.Ellipsis, + modifier = Modifier.weight(1f) + ) + + Spacer(modifier = Modifier.width(12.dp)) + + Box( + modifier = Modifier + .size(32.dp) + .background( + color = Color(0xFFFBBF24).copy(alpha = 0.15f), + shape = CircleShape + ), + contentAlignment = Alignment.Center + ) { + Icon( + Icons.Default.Star, + contentDescription = "Berbintang", + tint = Color(0xFFFBBF24), + modifier = Modifier.size(18.dp) + ) + } + } + + // Konten catatan + if (note.content.isNotBlank()) { + Spacer(modifier = Modifier.height(12.dp)) + Text( + text = note.content, + style = MaterialTheme.typography.bodyLarge, + color = Color(0xFF64748B), + maxLines = 4, + overflow = TextOverflow.Ellipsis, + lineHeight = 24.sp + ) + } + + // Footer dengan timestamp + Spacer(modifier = Modifier.height(16.dp)) + + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.SpaceBetween, + verticalAlignment = Alignment.CenterVertically + ) { + Row( + verticalAlignment = Alignment.CenterVertically + ) { + Icon( + Icons.Default.Schedule, + contentDescription = null, + tint = Color(0xFF94A3B8), + modifier = Modifier.size(14.dp) + ) + Spacer(modifier = Modifier.width(4.dp)) + Text( + text = dateFormat.format(Date(note.timestamp)), + style = MaterialTheme.typography.bodySmall, + color = Color(0xFF94A3B8) + ) + } + + // Badge indicator + Surface( + color = Color(0xFFA855F7).copy(alpha = 0.15f), + shape = RoundedCornerShape(8.dp) + ) { + Text( + text = "Penting", + style = MaterialTheme.typography.labelSmall, + color = Color(0xFFA855F7), + fontWeight = FontWeight.SemiBold, + modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp) + ) + } + } + } + } +} + @Composable fun EmptyState( icon: ImageVector,