@@ -24,17 +24,12 @@ import androidx.compose.foundation.shape.RoundedCornerShape
2424import androidx.compose.material.icons.Icons
2525import androidx.compose.material.icons.rounded.Star
2626import androidx.compose.material.icons.rounded.StarBorder
27- import androidx.compose.material3.AlertDialog
2827import androidx.compose.material3.Card
2928import androidx.compose.material3.CardDefaults
30- import androidx.compose.material3.DropdownMenu
31- import androidx.compose.material3.DropdownMenuItem
3229import androidx.compose.material3.FilterChip
3330import androidx.compose.material3.Icon
3431import androidx.compose.material3.IconButton
3532import androidx.compose.material3.MaterialTheme
36- import androidx.compose.material3.MenuDefaults
37- import androidx.compose.material3.OutlinedButton
3833import androidx.compose.material3.SwipeToDismissBox
3934import androidx.compose.material3.SwipeToDismissBoxDefaults
4035import androidx.compose.material3.SwipeToDismissBoxValue
@@ -64,8 +59,6 @@ import com.yogeshpaliyal.deepr.Tags
6459import compose.icons.TablerIcons
6560import compose.icons.tablericons.DotsVertical
6661import compose.icons.tablericons.Edit
67- import compose.icons.tablericons.Note
68- import compose.icons.tablericons.Refresh
6962import compose.icons.tablericons.Trash
7063import kotlinx.coroutines.launch
7164import java.text.DateFormat
@@ -103,6 +96,10 @@ sealed class MenuItem(
10396 class Delete (
10497 item : GetLinksAndTags ,
10598 ) : MenuItem(item)
99+
100+ class MoreOptionsBottomSheet (
101+ item : GetLinksAndTags ,
102+ ) : MenuItem(item)
106103}
107104
108105@Composable
@@ -132,36 +129,13 @@ fun DeeprItem(
132129 isThumbnailEnable : Boolean ,
133130 modifier : Modifier = Modifier ,
134131) {
135- var expanded by remember { mutableStateOf(false ) }
136- var selectedNote by remember { mutableStateOf<String ?>(null ) }
137132 var tagsExpanded by remember { mutableStateOf(false ) }
138133 val context = LocalContext .current
139134 val selectedTags =
140135 remember(account.tagsNames) { account.tagsNames?.split(" ," )?.toMutableList() }
141136
142137 val linkCopied = stringResource(R .string.link_copied)
143138
144- selectedNote?.let {
145- AlertDialog (
146- {
147- selectedNote = null
148- },
149- title = {
150- Text (" Note" )
151- },
152- text = {
153- Text (it)
154- },
155- confirmButton = {
156- OutlinedButton ({
157- selectedNote = null
158- }) {
159- Text (" Okay" )
160- }
161- },
162- )
163- }
164-
165139 val dismissState =
166140 rememberSwipeToDismissBoxState(
167141 initialValue = SwipeToDismissBoxValue .Settled ,
@@ -342,103 +316,12 @@ fun DeeprItem(
342316 )
343317 }
344318
345- IconButton (onClick = { expanded = true }) {
319+ IconButton (onClick = { onItemClick( MenuItem . MoreOptionsBottomSheet (account)) }) {
346320 Icon (
347321 TablerIcons .DotsVertical ,
348322 contentDescription = stringResource(R .string.more_options),
349323 )
350324 }
351-
352- DropdownMenu (
353- expanded = expanded,
354- onDismissRequest = { expanded = false },
355- ) {
356- if (account.notes.isNotEmpty()) {
357- DropdownMenuItem (
358- text = { Text (stringResource(R .string.view_note)) },
359- onClick = {
360- expanded = false
361- selectedNote = account.notes
362- },
363- leadingIcon = {
364- Icon (
365- TablerIcons .Note ,
366- contentDescription = stringResource(R .string.view_note),
367- )
368- },
369- )
370- }
371-
372- // Display last opened time
373- if (account.lastOpenedAt != null ) {
374- DropdownMenuItem (
375- text = {
376- Text (
377- stringResource(
378- R .string.last_opened,
379- formatDateTime(account.lastOpenedAt),
380- ),
381- style = MaterialTheme .typography.bodySmall,
382- color = MaterialTheme .colorScheme.onSurfaceVariant,
383- )
384- },
385- onClick = { },
386- enabled = false ,
387- )
388- }
389- ShortcutMenuItem (account, {
390- onItemClick(MenuItem .Shortcut (it))
391- expanded = false
392- })
393- ShowQRCodeMenuItem (account, {
394- onItemClick(MenuItem .ShowQrCode (it))
395- expanded = false
396- })
397- DropdownMenuItem (
398- text = { Text (stringResource(R .string.reset_opened_count)) },
399- onClick = {
400- onItemClick(MenuItem .ResetCounter (account))
401- expanded = false
402- },
403- leadingIcon = {
404- Icon (
405- TablerIcons .Refresh ,
406- contentDescription = stringResource(R .string.reset_opened_count),
407- )
408- },
409- )
410- DropdownMenuItem (
411- text = { Text (stringResource(R .string.edit)) },
412- onClick = {
413- onItemClick(MenuItem .Edit (account))
414- expanded = false
415- },
416- leadingIcon = {
417- Icon (
418- TablerIcons .Edit ,
419- contentDescription = stringResource(R .string.edit),
420- )
421- },
422- )
423- DropdownMenuItem (
424- text = { Text (stringResource(R .string.delete)) },
425- onClick = {
426- onItemClick(MenuItem .Delete (account))
427- expanded = false
428- },
429- leadingIcon = {
430- Icon (
431- TablerIcons .Trash ,
432- contentDescription = stringResource(R .string.delete),
433- )
434- },
435- colors =
436- MenuDefaults .itemColors(
437- textColor = MaterialTheme .colorScheme.error,
438- leadingIconColor = MaterialTheme .colorScheme.error,
439- ),
440- )
441- }
442325 }
443326
444327 Text (
@@ -495,7 +378,7 @@ fun DeeprItem(
495378 }
496379}
497380
498- private fun formatDateTime (dateTimeString : String ): String {
381+ fun formatDateTime (dateTimeString : String ): String {
499382 try {
500383 val dbFormatter = SimpleDateFormat (" yyyy-MM-dd HH:mm:ss" , Locale .getDefault())
501384 dbFormatter.timeZone = TimeZone .getTimeZone(" UTC" )
0 commit comments