mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 14:27:57 +01:00 
			
		
		
		
	Replace Cascade with our own somewhat janky implementation
This commit is contained in:
		| @@ -9,8 +9,8 @@ import androidx.compose.foundation.layout.PaddingValues | ||||
| import androidx.compose.foundation.layout.WindowInsets | ||||
| import androidx.compose.foundation.layout.WindowInsetsSides | ||||
| import androidx.compose.foundation.layout.asPaddingValues | ||||
| import androidx.compose.foundation.layout.navigationBars | ||||
| import androidx.compose.foundation.layout.only | ||||
| import androidx.compose.foundation.layout.safeContent | ||||
| import androidx.compose.runtime.Composable | ||||
| import androidx.compose.ui.unit.Dp | ||||
| import androidx.compose.ui.unit.dp | ||||
| @@ -82,12 +82,15 @@ fun AdaptiveSheet( | ||||
|     content: @Composable (PaddingValues) -> Unit, | ||||
| ) { | ||||
|     val isTabletUi = isTabletUi() | ||||
|     val contentPadding = if (isTabletUi) { | ||||
|         PaddingValues() | ||||
|     } else { | ||||
|         WindowInsets.safeContent.only(WindowInsetsSides.Bottom).asPaddingValues() | ||||
|     } | ||||
|  | ||||
|     Dialog( | ||||
|         onDismissRequest = onDismissRequest, | ||||
|         properties = DialogProperties( | ||||
|             usePlatformDefaultWidth = false, | ||||
|             decorFitsSystemWindows = false, | ||||
|         ), | ||||
|         properties = dialogProperties, | ||||
|     ) { | ||||
|         AdaptiveSheetImpl( | ||||
|             isTabletUi = isTabletUi, | ||||
| @@ -95,12 +98,12 @@ fun AdaptiveSheet( | ||||
|             enableSwipeDismiss = enableSwipeDismiss, | ||||
|             onDismissRequest = onDismissRequest, | ||||
|         ) { | ||||
|             val contentPadding = if (isTabletUi) { | ||||
|                 PaddingValues() | ||||
|             } else { | ||||
|                 WindowInsets.navigationBars.only(WindowInsetsSides.Bottom).asPaddingValues() | ||||
|             } | ||||
|             content(contentPadding) | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| private val dialogProperties = DialogProperties( | ||||
|     usePlatformDefaultWidth = false, | ||||
|     decorFitsSystemWindows = false, | ||||
| ) | ||||
|   | ||||
| @@ -1,15 +1,14 @@ | ||||
| package eu.kanade.presentation.components | ||||
|  | ||||
| import androidx.compose.foundation.layout.Box | ||||
| import androidx.compose.foundation.layout.ColumnScope | ||||
| import androidx.compose.foundation.layout.sizeIn | ||||
| import androidx.compose.material.icons.Icons | ||||
| import androidx.compose.material.icons.outlined.MoreVert | ||||
| import androidx.compose.material.icons.outlined.ArrowLeft | ||||
| import androidx.compose.material.icons.outlined.ArrowRight | ||||
| import androidx.compose.material.icons.outlined.RadioButtonChecked | ||||
| import androidx.compose.material.icons.outlined.RadioButtonUnchecked | ||||
| import androidx.compose.material3.DropdownMenuItem | ||||
| import androidx.compose.material3.Icon | ||||
| import androidx.compose.material3.IconButton | ||||
| import androidx.compose.material3.MaterialTheme | ||||
| import androidx.compose.runtime.Composable | ||||
| import androidx.compose.runtime.getValue | ||||
| @@ -17,13 +16,13 @@ import androidx.compose.runtime.mutableStateOf | ||||
| import androidx.compose.runtime.remember | ||||
| import androidx.compose.runtime.setValue | ||||
| import androidx.compose.ui.Modifier | ||||
| import androidx.compose.ui.platform.LocalLayoutDirection | ||||
| import androidx.compose.ui.res.stringResource | ||||
| import androidx.compose.ui.unit.DpOffset | ||||
| import androidx.compose.ui.unit.LayoutDirection | ||||
| import androidx.compose.ui.unit.dp | ||||
| import androidx.compose.ui.window.PopupProperties | ||||
| import eu.kanade.tachiyomi.R | ||||
| import me.saket.cascade.CascadeColumnScope | ||||
| import me.saket.cascade.CascadeDropdownMenu | ||||
| import androidx.compose.material3.DropdownMenu as ComposeDropdownMenu | ||||
|  | ||||
| @Composable | ||||
| @@ -72,25 +71,29 @@ fun RadioMenuItem( | ||||
| } | ||||
|  | ||||
| @Composable | ||||
| fun OverflowMenu( | ||||
|     content: @Composable CascadeColumnScope.(() -> Unit) -> Unit, | ||||
| fun NestedMenuItem( | ||||
|     text: @Composable () -> Unit, | ||||
|     children: @Composable ColumnScope.(() -> Unit) -> Unit, | ||||
| ) { | ||||
|     var moreExpanded by remember { mutableStateOf(false) } | ||||
|     val closeMenu = { moreExpanded = false } | ||||
|     var nestedExpanded by remember { mutableStateOf(false) } | ||||
|     val closeMenu = { nestedExpanded = false } | ||||
|     val isLtr = LocalLayoutDirection.current == LayoutDirection.Ltr | ||||
|  | ||||
|     Box { | ||||
|         IconButton(onClick = { moreExpanded = !moreExpanded }) { | ||||
|     DropdownMenuItem( | ||||
|         text = text, | ||||
|         onClick = { nestedExpanded = true }, | ||||
|         trailingIcon = { | ||||
|             Icon( | ||||
|                 imageVector = Icons.Outlined.MoreVert, | ||||
|                 contentDescription = stringResource(R.string.abc_action_menu_overflow_description), | ||||
|                 imageVector = if (isLtr) Icons.Outlined.ArrowRight else Icons.Outlined.ArrowLeft, | ||||
|                 contentDescription = null, | ||||
|             ) | ||||
|         } | ||||
|         CascadeDropdownMenu( | ||||
|             expanded = moreExpanded, | ||||
|             onDismissRequest = closeMenu, | ||||
|             offset = DpOffset(8.dp, (-56).dp), | ||||
|         ) { | ||||
|             content(closeMenu) | ||||
|         } | ||||
|         }, | ||||
|     ) | ||||
|  | ||||
|     DropdownMenu( | ||||
|         expanded = nestedExpanded, | ||||
|         onDismissRequest = closeMenu, | ||||
|     ) { | ||||
|         children(closeMenu) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| package eu.kanade.presentation.manga.components | ||||
|  | ||||
| import androidx.compose.foundation.layout.Box | ||||
| import androidx.compose.foundation.layout.Column | ||||
| import androidx.compose.material.icons.Icons | ||||
| import androidx.compose.material.icons.outlined.ArrowBack | ||||
| @@ -18,8 +17,10 @@ import androidx.compose.material3.TopAppBar | ||||
| import androidx.compose.material3.TopAppBarDefaults | ||||
| import androidx.compose.material3.surfaceColorAtElevation | ||||
| 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.draw.alpha | ||||
| import androidx.compose.ui.res.stringResource | ||||
| @@ -89,27 +90,28 @@ fun MangaToolbar( | ||||
|                         ), | ||||
|                     ) | ||||
|                 } else { | ||||
|                     var downloadExpanded by remember { mutableStateOf(false) } | ||||
|                     if (onClickDownload != null) { | ||||
|                         val (downloadExpanded, onDownloadExpanded) = remember { mutableStateOf(false) } | ||||
|                         Box { | ||||
|                             IconButton(onClick = { onDownloadExpanded(!downloadExpanded) }) { | ||||
|                                 Icon( | ||||
|                                     imageVector = Icons.Outlined.Download, | ||||
|                                     contentDescription = stringResource(R.string.manga_download), | ||||
|                                 ) | ||||
|                             } | ||||
|                             val onDismissRequest = { onDownloadExpanded(false) } | ||||
|                             DownloadDropdownMenu( | ||||
|                                 expanded = downloadExpanded, | ||||
|                                 onDismissRequest = onDismissRequest, | ||||
|                                 onDownloadClicked = onClickDownload, | ||||
|                             ) | ||||
|                         } | ||||
|                         val onDismissRequest = { downloadExpanded = false } | ||||
|                         DownloadDropdownMenu( | ||||
|                             expanded = downloadExpanded, | ||||
|                             onDismissRequest = onDismissRequest, | ||||
|                             onDownloadClicked = onClickDownload, | ||||
|                         ) | ||||
|                     } | ||||
|  | ||||
|                     val filterTint = if (hasFilters) MaterialTheme.colorScheme.active else LocalContentColor.current | ||||
|                     AppBarActions( | ||||
|                         actions = buildList { | ||||
|                             if (onClickDownload != null) { | ||||
|                                 add( | ||||
|                                     AppBar.Action( | ||||
|                                         title = stringResource(R.string.manga_download), | ||||
|                                         icon = Icons.Outlined.Download, | ||||
|                                         onClick = { downloadExpanded = !downloadExpanded }, | ||||
|                                     ), | ||||
|                                 ) | ||||
|                             } | ||||
|                             add( | ||||
|                                 AppBar.Action( | ||||
|                                     title = stringResource(R.string.action_filter), | ||||
|   | ||||
| @@ -12,6 +12,8 @@ import androidx.compose.foundation.layout.padding | ||||
| import androidx.compose.material.icons.Icons | ||||
| import androidx.compose.material.icons.filled.PlayArrow | ||||
| import androidx.compose.material.icons.outlined.Pause | ||||
| import androidx.compose.material.icons.outlined.Sort | ||||
| import androidx.compose.material3.DropdownMenuItem | ||||
| import androidx.compose.material3.Icon | ||||
| import androidx.compose.material3.MaterialTheme | ||||
| import androidx.compose.material3.Text | ||||
| @@ -47,7 +49,9 @@ import cafe.adriel.voyager.core.model.rememberScreenModel | ||||
| import cafe.adriel.voyager.navigator.LocalNavigator | ||||
| import cafe.adriel.voyager.navigator.currentOrThrow | ||||
| import eu.kanade.presentation.components.AppBar | ||||
| import eu.kanade.presentation.components.OverflowMenu | ||||
| import eu.kanade.presentation.components.AppBarActions | ||||
| import eu.kanade.presentation.components.DropdownMenu | ||||
| import eu.kanade.presentation.components.NestedMenuItem | ||||
| import eu.kanade.presentation.util.Screen | ||||
| import eu.kanade.tachiyomi.R | ||||
| import eu.kanade.tachiyomi.databinding.DownloadListBinding | ||||
| @@ -120,70 +124,77 @@ object DownloadQueueScreen : Screen() { | ||||
|                     navigateUp = navigator::pop, | ||||
|                     actions = { | ||||
|                         if (downloadList.isNotEmpty()) { | ||||
|                             OverflowMenu { closeMenu -> | ||||
|                                 DropdownMenuItem( | ||||
|                                     text = { Text(text = stringResource(R.string.action_reorganize_by)) }, | ||||
|                                     children = { | ||||
|                             var sortExpanded by remember { mutableStateOf(false) } | ||||
|                             val onDismissRequest = { sortExpanded = false } | ||||
|                             DropdownMenu( | ||||
|                                 expanded = sortExpanded, | ||||
|                                 onDismissRequest = onDismissRequest, | ||||
|                             ) { | ||||
|                                 NestedMenuItem( | ||||
|                                     text = { Text(text = stringResource(R.string.action_order_by_upload_date)) }, | ||||
|                                     children = { closeMenu -> | ||||
|                                         DropdownMenuItem( | ||||
|                                             text = { Text(text = stringResource(R.string.action_order_by_upload_date)) }, | ||||
|                                             children = { | ||||
|                                                 androidx.compose.material3.DropdownMenuItem( | ||||
|                                                     text = { Text(text = stringResource(R.string.action_newest)) }, | ||||
|                                                     onClick = { | ||||
|                                                         screenModel.reorderQueue( | ||||
|                                                             { it.download.chapter.dateUpload }, | ||||
|                                                             true, | ||||
|                                                         ) | ||||
|                                                         closeMenu() | ||||
|                                                     }, | ||||
|                                                 ) | ||||
|                                                 androidx.compose.material3.DropdownMenuItem( | ||||
|                                                     text = { Text(text = stringResource(R.string.action_oldest)) }, | ||||
|                                                     onClick = { | ||||
|                                                         screenModel.reorderQueue( | ||||
|                                                             { it.download.chapter.dateUpload }, | ||||
|                                                             false, | ||||
|                                                         ) | ||||
|                                                         closeMenu() | ||||
|                                                     }, | ||||
|                                             text = { Text(text = stringResource(R.string.action_newest)) }, | ||||
|                                             onClick = { | ||||
|                                                 screenModel.reorderQueue( | ||||
|                                                     { it.download.chapter.dateUpload }, | ||||
|                                                     true, | ||||
|                                                 ) | ||||
|                                                 closeMenu() | ||||
|                                             }, | ||||
|                                         ) | ||||
|                                         DropdownMenuItem( | ||||
|                                             text = { Text(text = stringResource(R.string.action_order_by_chapter_number)) }, | ||||
|                                             children = { | ||||
|                                                 androidx.compose.material3.DropdownMenuItem( | ||||
|                                                     text = { Text(text = stringResource(R.string.action_asc)) }, | ||||
|                                                     onClick = { | ||||
|                                                         screenModel.reorderQueue( | ||||
|                                                             { it.download.chapter.chapterNumber }, | ||||
|                                                             false, | ||||
|                                                         ) | ||||
|                                                         closeMenu() | ||||
|                                                     }, | ||||
|                                                 ) | ||||
|                                                 androidx.compose.material3.DropdownMenuItem( | ||||
|                                                     text = { Text(text = stringResource(R.string.action_desc)) }, | ||||
|                                                     onClick = { | ||||
|                                                         screenModel.reorderQueue( | ||||
|                                                             { it.download.chapter.chapterNumber }, | ||||
|                                                             true, | ||||
|                                                         ) | ||||
|                                                         closeMenu() | ||||
|                                                     }, | ||||
|                                             text = { Text(text = stringResource(R.string.action_oldest)) }, | ||||
|                                             onClick = { | ||||
|                                                 screenModel.reorderQueue( | ||||
|                                                     { it.download.chapter.dateUpload }, | ||||
|                                                     false, | ||||
|                                                 ) | ||||
|                                                 closeMenu() | ||||
|                                             }, | ||||
|                                         ) | ||||
|                                     }, | ||||
|                                 ) | ||||
|                                 androidx.compose.material3.DropdownMenuItem( | ||||
|                                     text = { Text(text = stringResource(R.string.action_cancel_all)) }, | ||||
|                                     onClick = { | ||||
|                                         screenModel.clearQueue() | ||||
|                                         closeMenu() | ||||
|                                 NestedMenuItem( | ||||
|                                     text = { Text(text = stringResource(R.string.action_order_by_chapter_number)) }, | ||||
|                                     children = { closeMenu -> | ||||
|                                         DropdownMenuItem( | ||||
|                                             text = { Text(text = stringResource(R.string.action_asc)) }, | ||||
|                                             onClick = { | ||||
|                                                 screenModel.reorderQueue( | ||||
|                                                     { it.download.chapter.chapterNumber }, | ||||
|                                                     false, | ||||
|                                                 ) | ||||
|                                                 closeMenu() | ||||
|                                             }, | ||||
|                                         ) | ||||
|                                         DropdownMenuItem( | ||||
|                                             text = { Text(text = stringResource(R.string.action_desc)) }, | ||||
|                                             onClick = { | ||||
|                                                 screenModel.reorderQueue( | ||||
|                                                     { it.download.chapter.chapterNumber }, | ||||
|                                                     true, | ||||
|                                                 ) | ||||
|                                                 closeMenu() | ||||
|                                             }, | ||||
|                                         ) | ||||
|                                     }, | ||||
|                                 ) | ||||
|                             } | ||||
|  | ||||
|                             AppBarActions( | ||||
|                                 listOf( | ||||
|                                     AppBar.Action( | ||||
|                                         title = stringResource(R.string.action_sort), | ||||
|                                         icon = Icons.Outlined.Sort, | ||||
|                                         onClick = { sortExpanded = true }, | ||||
|                                     ), | ||||
|                                     AppBar.OverflowAction( | ||||
|                                         title = stringResource(R.string.action_cancel_all), | ||||
|                                         onClick = { screenModel.clearQueue() }, | ||||
|                                     ), | ||||
|                                 ), | ||||
|                             ) | ||||
|                         } | ||||
|                     }, | ||||
|                     scrollBehavior = scrollBehavior, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user