Penyesuaian fitur Filter/Pencarian
This commit is contained in:
parent
9715d958ae
commit
4caea5c83e
@ -258,10 +258,13 @@ fun NotesApp() {
|
||||
selectedCategory = null
|
||||
},
|
||||
onMenuClick = { drawerState = !drawerState },
|
||||
onSearchClick = { showSearch = !showSearch },
|
||||
onSearchClick = {
|
||||
showSearch = !showSearch
|
||||
if (!showSearch) searchQuery = "" // Reset search saat close
|
||||
},
|
||||
searchQuery = searchQuery,
|
||||
onSearchQueryChange = { searchQuery = it },
|
||||
showSearch = showSearch && currentScreen == "main"
|
||||
showSearch = showSearch // AKTIFKAN UNTUK SEMUA SCREEN
|
||||
)
|
||||
}
|
||||
},
|
||||
@ -426,6 +429,7 @@ fun NotesApp() {
|
||||
"trash" -> TrashScreen(
|
||||
notes = notes.filter { it.isDeleted },
|
||||
categories = categories,
|
||||
searchQuery = searchQuery, // TAMBAHKAN INI
|
||||
onRestoreNote = { note ->
|
||||
notes = notes.map {
|
||||
if (it.id == note.id) it.copy(isDeleted = false, isArchived = false)
|
||||
@ -454,6 +458,7 @@ fun NotesApp() {
|
||||
"starred" -> StarredNotesScreen(
|
||||
notes = notes,
|
||||
categories = categories.filter { !it.isDeleted },
|
||||
searchQuery = searchQuery, // TAMBAHKAN INI
|
||||
onNoteClick = { note ->
|
||||
fullScreenNote = note
|
||||
showFullScreenNote = true
|
||||
@ -469,6 +474,7 @@ fun NotesApp() {
|
||||
"archive" -> ArchiveScreen(
|
||||
notes = notes.filter { it.isArchived && !it.isDeleted },
|
||||
categories = categories.filter { !it.isDeleted },
|
||||
searchQuery = searchQuery,
|
||||
onRestore = { note ->
|
||||
notes = notes.map {
|
||||
if (it.id == note.id) it.copy(isArchived = false)
|
||||
@ -566,8 +572,8 @@ fun NotesApp() {
|
||||
currentScreen = screen
|
||||
selectedCategory = null
|
||||
drawerState = false
|
||||
showSearch = false
|
||||
searchQuery = ""
|
||||
showSearch = false // TUTUP SEARCH
|
||||
searchQuery = "" // RESET SEARCH QUERY
|
||||
},
|
||||
onThemeToggle = {
|
||||
isDarkTheme = !isDarkTheme
|
||||
|
||||
@ -4,27 +4,13 @@ import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Archive
|
||||
import androidx.compose.material.icons.filled.Clear
|
||||
import androidx.compose.material.icons.filled.Search
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.OutlinedTextFieldDefaults
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.example.notesai.data.model.Note
|
||||
import com.example.notesai.data.model.Category
|
||||
@ -35,12 +21,11 @@ import com.example.notesai.presentation.screens.archive.components.ArchiveNoteCa
|
||||
fun ArchiveScreen(
|
||||
notes: List<Note>,
|
||||
categories: List<Category>,
|
||||
searchQuery: String = "", // Tambahkan parameter ini
|
||||
onRestore: (Note) -> Unit,
|
||||
onDelete: (Note) -> Unit
|
||||
) {
|
||||
var searchQuery by remember { mutableStateOf("") }
|
||||
|
||||
// Filter berdasarkan search query
|
||||
// Filter berdasarkan search query dari ModernTopBar
|
||||
val filteredNotes = if (searchQuery.isBlank()) {
|
||||
notes
|
||||
} else {
|
||||
@ -53,50 +38,6 @@ fun ArchiveScreen(
|
||||
}
|
||||
|
||||
Column(modifier = Modifier.fillMaxSize()) {
|
||||
// Search Bar
|
||||
OutlinedTextField(
|
||||
value = searchQuery,
|
||||
onValueChange = { searchQuery = it },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 12.dp),
|
||||
placeholder = {
|
||||
Text(
|
||||
"Cari catatan arsip...",
|
||||
color = Color(0xFF64748B)
|
||||
)
|
||||
},
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
Icons.Default.Search,
|
||||
contentDescription = null,
|
||||
tint = Color(0xFF64748B)
|
||||
)
|
||||
},
|
||||
trailingIcon = {
|
||||
if (searchQuery.isNotEmpty()) {
|
||||
IconButton(onClick = { searchQuery = "" }) {
|
||||
Icon(
|
||||
Icons.Default.Clear,
|
||||
contentDescription = "Clear",
|
||||
tint = Color(0xFF64748B)
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
colors = OutlinedTextFieldDefaults.colors(
|
||||
focusedContainerColor = Color(0xFF1E293B),
|
||||
unfocusedContainerColor = Color(0xFF1E293B),
|
||||
focusedBorderColor = Color(0xFF6366F1),
|
||||
unfocusedBorderColor = Color(0xFF334155),
|
||||
focusedTextColor = Color.White,
|
||||
unfocusedTextColor = Color.White,
|
||||
cursorColor = Color(0xFF6366F1)
|
||||
),
|
||||
singleLine = true
|
||||
)
|
||||
|
||||
// Content
|
||||
if (filteredNotes.isEmpty()) {
|
||||
if (searchQuery.isNotEmpty()) {
|
||||
@ -117,6 +58,7 @@ fun ArchiveScreen(
|
||||
contentPadding = PaddingValues(
|
||||
start = 16.dp,
|
||||
end = 16.dp,
|
||||
top = 8.dp,
|
||||
bottom = 100.dp
|
||||
),
|
||||
verticalArrangement = Arrangement.spacedBy(12.dp)
|
||||
|
||||
@ -3,32 +3,15 @@ package com.example.notesai.presentation.screens.starred
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Clear
|
||||
import androidx.compose.material.icons.filled.Search
|
||||
import androidx.compose.material.icons.filled.Star
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.OutlinedTextFieldDefaults
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.example.notesai.presentation.components.EmptyState
|
||||
import com.example.notesai.presentation.screens.starred.components.StarredNoteCard
|
||||
@ -40,16 +23,15 @@ import com.example.notesai.data.model.Category
|
||||
fun StarredNotesScreen(
|
||||
notes: List<Note>,
|
||||
categories: List<Category>,
|
||||
searchQuery: String = "", // Tambahkan parameter ini
|
||||
onNoteClick: (Note) -> Unit,
|
||||
onUnpin: (Note) -> Unit
|
||||
) {
|
||||
var searchQuery by remember { mutableStateOf("") }
|
||||
|
||||
val starredNotes = notes
|
||||
.filter { it.isPinned && !it.isArchived && !it.isDeleted }
|
||||
.sortedByDescending { it.timestamp }
|
||||
|
||||
// Filter berdasarkan search query
|
||||
// Filter berdasarkan search query dari ModernTopBar
|
||||
val filteredNotes = if (searchQuery.isBlank()) {
|
||||
starredNotes
|
||||
} else {
|
||||
@ -61,50 +43,6 @@ fun StarredNotesScreen(
|
||||
}
|
||||
|
||||
Column(modifier = Modifier.fillMaxSize()) {
|
||||
// Search Bar
|
||||
OutlinedTextField(
|
||||
value = searchQuery,
|
||||
onValueChange = { searchQuery = it },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 12.dp),
|
||||
placeholder = {
|
||||
Text(
|
||||
"Cari catatan berbintang...",
|
||||
color = Color(0xFF64748B)
|
||||
)
|
||||
},
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
Icons.Default.Search,
|
||||
contentDescription = null,
|
||||
tint = Color(0xFF64748B)
|
||||
)
|
||||
},
|
||||
trailingIcon = {
|
||||
if (searchQuery.isNotEmpty()) {
|
||||
IconButton(onClick = { searchQuery = "" }) {
|
||||
Icon(
|
||||
Icons.Default.Clear,
|
||||
contentDescription = "Clear",
|
||||
tint = Color(0xFF64748B)
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
colors = OutlinedTextFieldDefaults.colors(
|
||||
focusedContainerColor = Color(0xFF1E293B),
|
||||
unfocusedContainerColor = Color(0xFF1E293B),
|
||||
focusedBorderColor = Color(0xFF6366F1),
|
||||
unfocusedBorderColor = Color(0xFF334155),
|
||||
focusedTextColor = Color.White,
|
||||
unfocusedTextColor = Color.White,
|
||||
cursorColor = Color(0xFF6366F1)
|
||||
),
|
||||
singleLine = true
|
||||
)
|
||||
|
||||
// Content
|
||||
if (filteredNotes.isEmpty()) {
|
||||
if (searchQuery.isNotEmpty()) {
|
||||
@ -125,6 +63,7 @@ fun StarredNotesScreen(
|
||||
contentPadding = PaddingValues(
|
||||
start = 16.dp,
|
||||
end = 16.dp,
|
||||
top = 8.dp,
|
||||
bottom = 100.dp
|
||||
),
|
||||
verticalArrangement = Arrangement.spacedBy(12.dp)
|
||||
|
||||
@ -4,26 +4,15 @@ import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Clear
|
||||
import androidx.compose.material.icons.filled.Delete
|
||||
import androidx.compose.material.icons.filled.Search
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.OutlinedTextFieldDefaults
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
@ -38,18 +27,17 @@ import com.example.notesai.data.model.Category
|
||||
fun TrashScreen(
|
||||
notes: List<Note>,
|
||||
categories: List<Category>,
|
||||
searchQuery: String = "", // Tambahkan parameter ini
|
||||
onRestoreNote: (Note) -> Unit,
|
||||
onDeleteNotePermanent: (Note) -> Unit,
|
||||
onRestoreCategory: (Category) -> Unit,
|
||||
onDeleteCategoryPermanent: (Category) -> Unit
|
||||
) {
|
||||
var searchQuery by remember { mutableStateOf("") }
|
||||
|
||||
// Filter kategori dan note yang dihapus
|
||||
val deletedCategories = categories.filter { it.isDeleted }
|
||||
val deletedNotes = notes.filter { it.isDeleted }
|
||||
|
||||
// Filter berdasarkan search query
|
||||
// Filter berdasarkan search query dari ModernTopBar
|
||||
val filteredCategories = if (searchQuery.isBlank()) {
|
||||
deletedCategories
|
||||
} else {
|
||||
@ -70,50 +58,6 @@ fun TrashScreen(
|
||||
}
|
||||
|
||||
Column(modifier = Modifier.fillMaxSize()) {
|
||||
// Search Bar
|
||||
OutlinedTextField(
|
||||
value = searchQuery,
|
||||
onValueChange = { searchQuery = it },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 12.dp),
|
||||
placeholder = {
|
||||
Text(
|
||||
"Cari di sampah...",
|
||||
color = Color(0xFF64748B)
|
||||
)
|
||||
},
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
Icons.Default.Search,
|
||||
contentDescription = null,
|
||||
tint = Color(0xFF64748B)
|
||||
)
|
||||
},
|
||||
trailingIcon = {
|
||||
if (searchQuery.isNotEmpty()) {
|
||||
IconButton(onClick = { searchQuery = "" }) {
|
||||
Icon(
|
||||
Icons.Default.Clear,
|
||||
contentDescription = "Clear",
|
||||
tint = Color(0xFF64748B)
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
colors = OutlinedTextFieldDefaults.colors(
|
||||
focusedContainerColor = Color(0xFF1E293B),
|
||||
unfocusedContainerColor = Color(0xFF1E293B),
|
||||
focusedBorderColor = Color(0xFF6366F1),
|
||||
unfocusedBorderColor = Color(0xFF334155),
|
||||
focusedTextColor = Color.White,
|
||||
unfocusedTextColor = Color.White,
|
||||
cursorColor = Color(0xFF6366F1)
|
||||
),
|
||||
singleLine = true
|
||||
)
|
||||
|
||||
// Content
|
||||
if (filteredCategories.isEmpty() && filteredNotes.isEmpty()) {
|
||||
if (searchQuery.isNotEmpty()) {
|
||||
@ -134,6 +78,7 @@ fun TrashScreen(
|
||||
contentPadding = PaddingValues(
|
||||
start = 16.dp,
|
||||
end = 16.dp,
|
||||
top = 8.dp,
|
||||
bottom = 100.dp
|
||||
),
|
||||
verticalArrangement = Arrangement.spacedBy(12.dp)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user