@@ -17,9 +17,9 @@ import androidx.compose.foundation.interaction.MutableInteractionSource
1717import androidx.compose.foundation.interaction.collectIsPressedAsState
1818import androidx.compose.foundation.layout.Arrangement
1919import androidx.compose.foundation.layout.Box
20- import androidx.compose.foundation.layout.Column
2120import androidx.compose.foundation.layout.PaddingValues
2221import androidx.compose.foundation.layout.Row
22+ import androidx.compose.foundation.layout.Spacer
2323import androidx.compose.foundation.layout.WindowInsets
2424import androidx.compose.foundation.layout.asPaddingValues
2525import androidx.compose.foundation.layout.calculateEndPadding
@@ -56,10 +56,10 @@ import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
5656import androidx.compose.material3.FloatingActionButtonDefaults
5757import androidx.compose.material3.Icon
5858import androidx.compose.material3.IconButton
59+ import androidx.compose.material3.MaterialTheme
5960import androidx.compose.material3.Scaffold
6061import androidx.compose.material3.Surface
6162import androidx.compose.material3.Text
62- import androidx.compose.material3.TextButton
6363import androidx.compose.material3.TopAppBar
6464import androidx.compose.material3.rememberDrawerState
6565import androidx.compose.runtime.Composable
@@ -106,6 +106,7 @@ import com.yangdai.opennote.presentation.component.main.AdaptiveNoteCard
106106import com.yangdai.opennote.presentation.component.main.AdaptiveTopSearchbar
107107import com.yangdai.opennote.presentation.component.main.DrawerContent
108108import com.yangdai.opennote.presentation.component.main.Timeline
109+ import com.yangdai.opennote.presentation.component.note.IconButtonWithTooltip
109110import com.yangdai.opennote.presentation.event.DatabaseEvent
110111import com.yangdai.opennote.presentation.event.ListEvent
111112import com.yangdai.opennote.presentation.navigation.Screen
@@ -328,102 +329,65 @@ fun MainScreen(
328329 exit = slideOutVertically { fullHeight -> fullHeight }
329330 ) {
330331 BottomAppBar {
331- Row (
332- modifier = Modifier
333- .fillMaxSize()
334- .padding(horizontal = 16 .dp),
335- horizontalArrangement = Arrangement .SpaceBetween ,
336- verticalAlignment = Alignment .CenterVertically
337- ) {
338-
339- Row (
340- modifier = Modifier .fillMaxHeight(),
341- verticalAlignment = Alignment .CenterVertically
342- ) {
343- Checkbox (
344- checked = allNotesSelected,
345- onCheckedChange = { allNotesSelected = it }
346- )
332+ Row (verticalAlignment = Alignment .CenterVertically ) {
333+ Checkbox (
334+ checked = allNotesSelected,
335+ onCheckedChange = { allNotesSelected = it }
336+ )
347337
348- Text (text = stringResource(R .string.checked))
349- Text (text = selectedNotesSet.size.toString())
350- }
338+ Text (text = stringResource(R .string.checked))
339+ Text (text = selectedNotesSet.size.toString())
340+ }
351341
352- Row (
353- modifier = Modifier .fillMaxHeight(),
354- verticalAlignment = Alignment .CenterVertically
355- ) {
342+ Spacer (Modifier .weight(1f ))
356343
357- if (selectedNavDrawerIndex == 1 ) {
358- TextButton (onClick = {
359- viewModel.onListEvent(
360- ListEvent .RestoreNotes (selectedNotesSet)
361- )
362- initializeNoteSelection()
363- }) {
364- Column (horizontalAlignment = Alignment .CenterHorizontally ) {
365- Icon (
366- imageVector = Icons .Outlined .RestartAlt ,
367- contentDescription = " Restore"
368- )
369- Text (
370- text = stringResource(id = R .string.restore),
371- maxLines = 1 ,
372- overflow = TextOverflow .Ellipsis
373- )
374- }
375- }
376- } else {
377- TextButton (onClick = { isExportNotesDialogVisible = true }) {
378- Column (horizontalAlignment = Alignment .CenterHorizontally ) {
379- Icon (
380- imageVector = Icons .Outlined .Upload ,
381- contentDescription = " Export"
382- )
383- Text (
384- text = stringResource(id = R .string.export),
385- maxLines = 1 ,
386- overflow = TextOverflow .Ellipsis
387- )
388- }
389- }
344+ Row (verticalAlignment = Alignment .CenterVertically ) {
390345
391- TextButton (onClick = { isMoveToFolderDialogVisible = true }) {
392- Column (horizontalAlignment = Alignment .CenterHorizontally ) {
393- Icon (
394- imageVector = Icons .AutoMirrored .Outlined .DriveFileMove ,
395- contentDescription = " Move"
396- )
397- Text (
398- text = stringResource(id = R .string.move),
399- maxLines = 1 ,
400- overflow = TextOverflow .Ellipsis
401- )
402- }
403- }
404- }
405-
406- TextButton (onClick = {
346+ if (selectedNavDrawerIndex == 1 ) {
347+ IconButtonWithTooltip (
348+ imageVector = Icons .Outlined .RestartAlt ,
349+ tint = MaterialTheme .colorScheme.primary,
350+ contentDescription = stringResource(id = R .string.restore),
351+ shortCutDescription = stringResource(id = R .string.restore)
352+ ) {
407353 viewModel.onListEvent(
408- ListEvent .DeleteNotes (
409- selectedNotesSet,
410- selectedNavDrawerIndex != 1
411- )
354+ ListEvent .RestoreNotes (selectedNotesSet)
412355 )
413356 initializeNoteSelection()
414- }) {
415- Column (horizontalAlignment = Alignment .CenterHorizontally ) {
416- Icon (
417- imageVector = Icons .Outlined .Delete ,
418- contentDescription = " Delete"
419- )
420- Text (
421- text = stringResource(id = R .string.delete),
422- maxLines = 1 ,
423- overflow = TextOverflow .Ellipsis
424- )
425- }
426357 }
358+ } else {
359+ IconButtonWithTooltip (
360+ imageVector = Icons .Outlined .Upload ,
361+ tint = MaterialTheme .colorScheme.primary,
362+ contentDescription = stringResource(id = R .string.export),
363+ shortCutDescription = stringResource(id = R .string.export)
364+ ) {
365+ isExportNotesDialogVisible = true
366+ }
367+
368+ IconButtonWithTooltip (
369+ imageVector = Icons .AutoMirrored .Outlined .DriveFileMove ,
370+ tint = MaterialTheme .colorScheme.primary,
371+ contentDescription = stringResource(id = R .string.move),
372+ shortCutDescription = stringResource(id = R .string.move)
373+ ) {
374+ isMoveToFolderDialogVisible = true
375+ }
376+ }
377+
378+ IconButtonWithTooltip (
379+ imageVector = Icons .Outlined .Delete ,
380+ tint = MaterialTheme .colorScheme.primary,
381+ contentDescription = stringResource(id = R .string.delete),
382+ shortCutDescription = stringResource(id = R .string.delete)
383+ ) {
384+ viewModel.onListEvent(
385+ ListEvent .DeleteNotes (
386+ selectedNotesSet,
387+ selectedNavDrawerIndex != 1
388+ )
389+ )
390+ initializeNoteSelection()
427391 }
428392 }
429393 }
0 commit comments