mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Replace Cascade with our own somewhat janky implementation
This commit is contained in:
parent
44609c494c
commit
5ca7c39751
7 changed files with 118 additions and 102 deletions
|
@ -237,7 +237,6 @@ dependencies {
|
||||||
implementation(libs.bundles.richtext)
|
implementation(libs.bundles.richtext)
|
||||||
implementation(libs.aboutLibraries.compose)
|
implementation(libs.aboutLibraries.compose)
|
||||||
implementation(libs.bundles.voyager)
|
implementation(libs.bundles.voyager)
|
||||||
implementation(libs.compose.cascade)
|
|
||||||
implementation(libs.compose.materialmotion)
|
implementation(libs.compose.materialmotion)
|
||||||
implementation(libs.compose.simpleicons)
|
implementation(libs.compose.simpleicons)
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@ import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.WindowInsets
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
import androidx.compose.foundation.layout.WindowInsetsSides
|
import androidx.compose.foundation.layout.WindowInsetsSides
|
||||||
import androidx.compose.foundation.layout.asPaddingValues
|
import androidx.compose.foundation.layout.asPaddingValues
|
||||||
import androidx.compose.foundation.layout.navigationBars
|
|
||||||
import androidx.compose.foundation.layout.only
|
import androidx.compose.foundation.layout.only
|
||||||
|
import androidx.compose.foundation.layout.safeContent
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
@ -82,12 +82,15 @@ fun AdaptiveSheet(
|
||||||
content: @Composable (PaddingValues) -> Unit,
|
content: @Composable (PaddingValues) -> Unit,
|
||||||
) {
|
) {
|
||||||
val isTabletUi = isTabletUi()
|
val isTabletUi = isTabletUi()
|
||||||
|
val contentPadding = if (isTabletUi) {
|
||||||
|
PaddingValues()
|
||||||
|
} else {
|
||||||
|
WindowInsets.safeContent.only(WindowInsetsSides.Bottom).asPaddingValues()
|
||||||
|
}
|
||||||
|
|
||||||
Dialog(
|
Dialog(
|
||||||
onDismissRequest = onDismissRequest,
|
onDismissRequest = onDismissRequest,
|
||||||
properties = DialogProperties(
|
properties = dialogProperties,
|
||||||
usePlatformDefaultWidth = false,
|
|
||||||
decorFitsSystemWindows = false,
|
|
||||||
),
|
|
||||||
) {
|
) {
|
||||||
AdaptiveSheetImpl(
|
AdaptiveSheetImpl(
|
||||||
isTabletUi = isTabletUi,
|
isTabletUi = isTabletUi,
|
||||||
|
@ -95,12 +98,12 @@ fun AdaptiveSheet(
|
||||||
enableSwipeDismiss = enableSwipeDismiss,
|
enableSwipeDismiss = enableSwipeDismiss,
|
||||||
onDismissRequest = onDismissRequest,
|
onDismissRequest = onDismissRequest,
|
||||||
) {
|
) {
|
||||||
val contentPadding = if (isTabletUi) {
|
|
||||||
PaddingValues()
|
|
||||||
} else {
|
|
||||||
WindowInsets.navigationBars.only(WindowInsetsSides.Bottom).asPaddingValues()
|
|
||||||
}
|
|
||||||
content(contentPadding)
|
content(contentPadding)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val dialogProperties = DialogProperties(
|
||||||
|
usePlatformDefaultWidth = false,
|
||||||
|
decorFitsSystemWindows = false,
|
||||||
|
)
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
package eu.kanade.presentation.components
|
package eu.kanade.presentation.components
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Box
|
|
||||||
import androidx.compose.foundation.layout.ColumnScope
|
import androidx.compose.foundation.layout.ColumnScope
|
||||||
import androidx.compose.foundation.layout.sizeIn
|
import androidx.compose.foundation.layout.sizeIn
|
||||||
import androidx.compose.material.icons.Icons
|
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.RadioButtonChecked
|
||||||
import androidx.compose.material.icons.outlined.RadioButtonUnchecked
|
import androidx.compose.material.icons.outlined.RadioButtonUnchecked
|
||||||
import androidx.compose.material3.DropdownMenuItem
|
import androidx.compose.material3.DropdownMenuItem
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
|
@ -17,13 +16,13 @@ import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.platform.LocalLayoutDirection
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.DpOffset
|
import androidx.compose.ui.unit.DpOffset
|
||||||
|
import androidx.compose.ui.unit.LayoutDirection
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.window.PopupProperties
|
import androidx.compose.ui.window.PopupProperties
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import me.saket.cascade.CascadeColumnScope
|
|
||||||
import me.saket.cascade.CascadeDropdownMenu
|
|
||||||
import androidx.compose.material3.DropdownMenu as ComposeDropdownMenu
|
import androidx.compose.material3.DropdownMenu as ComposeDropdownMenu
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
@ -72,25 +71,29 @@ fun RadioMenuItem(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun OverflowMenu(
|
fun NestedMenuItem(
|
||||||
content: @Composable CascadeColumnScope.(() -> Unit) -> Unit,
|
text: @Composable () -> Unit,
|
||||||
|
children: @Composable ColumnScope.(() -> Unit) -> Unit,
|
||||||
) {
|
) {
|
||||||
var moreExpanded by remember { mutableStateOf(false) }
|
var nestedExpanded by remember { mutableStateOf(false) }
|
||||||
val closeMenu = { moreExpanded = false }
|
val closeMenu = { nestedExpanded = false }
|
||||||
|
val isLtr = LocalLayoutDirection.current == LayoutDirection.Ltr
|
||||||
|
|
||||||
Box {
|
DropdownMenuItem(
|
||||||
IconButton(onClick = { moreExpanded = !moreExpanded }) {
|
text = text,
|
||||||
|
onClick = { nestedExpanded = true },
|
||||||
|
trailingIcon = {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Outlined.MoreVert,
|
imageVector = if (isLtr) Icons.Outlined.ArrowRight else Icons.Outlined.ArrowLeft,
|
||||||
contentDescription = stringResource(R.string.abc_action_menu_overflow_description),
|
contentDescription = null,
|
||||||
)
|
)
|
||||||
}
|
},
|
||||||
CascadeDropdownMenu(
|
)
|
||||||
expanded = moreExpanded,
|
|
||||||
|
DropdownMenu(
|
||||||
|
expanded = nestedExpanded,
|
||||||
onDismissRequest = closeMenu,
|
onDismissRequest = closeMenu,
|
||||||
offset = DpOffset(8.dp, (-56).dp),
|
|
||||||
) {
|
) {
|
||||||
content(closeMenu)
|
children(closeMenu)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package eu.kanade.presentation.manga.components
|
package eu.kanade.presentation.manga.components
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Box
|
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.outlined.ArrowBack
|
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.TopAppBarDefaults
|
||||||
import androidx.compose.material3.surfaceColorAtElevation
|
import androidx.compose.material3.surfaceColorAtElevation
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.alpha
|
import androidx.compose.ui.draw.alpha
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
@ -89,27 +90,28 @@ fun MangaToolbar(
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
var downloadExpanded by remember { mutableStateOf(false) }
|
||||||
if (onClickDownload != null) {
|
if (onClickDownload != null) {
|
||||||
val (downloadExpanded, onDownloadExpanded) = remember { mutableStateOf(false) }
|
val onDismissRequest = { downloadExpanded = false }
|
||||||
Box {
|
|
||||||
IconButton(onClick = { onDownloadExpanded(!downloadExpanded) }) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Outlined.Download,
|
|
||||||
contentDescription = stringResource(R.string.manga_download),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
val onDismissRequest = { onDownloadExpanded(false) }
|
|
||||||
DownloadDropdownMenu(
|
DownloadDropdownMenu(
|
||||||
expanded = downloadExpanded,
|
expanded = downloadExpanded,
|
||||||
onDismissRequest = onDismissRequest,
|
onDismissRequest = onDismissRequest,
|
||||||
onDownloadClicked = onClickDownload,
|
onDownloadClicked = onClickDownload,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
val filterTint = if (hasFilters) MaterialTheme.colorScheme.active else LocalContentColor.current
|
val filterTint = if (hasFilters) MaterialTheme.colorScheme.active else LocalContentColor.current
|
||||||
AppBarActions(
|
AppBarActions(
|
||||||
actions = buildList {
|
actions = buildList {
|
||||||
|
if (onClickDownload != null) {
|
||||||
|
add(
|
||||||
|
AppBar.Action(
|
||||||
|
title = stringResource(R.string.manga_download),
|
||||||
|
icon = Icons.Outlined.Download,
|
||||||
|
onClick = { downloadExpanded = !downloadExpanded },
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
add(
|
add(
|
||||||
AppBar.Action(
|
AppBar.Action(
|
||||||
title = stringResource(R.string.action_filter),
|
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.Icons
|
||||||
import androidx.compose.material.icons.filled.PlayArrow
|
import androidx.compose.material.icons.filled.PlayArrow
|
||||||
import androidx.compose.material.icons.outlined.Pause
|
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.Icon
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
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.LocalNavigator
|
||||||
import cafe.adriel.voyager.navigator.currentOrThrow
|
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||||
import eu.kanade.presentation.components.AppBar
|
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.presentation.util.Screen
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.databinding.DownloadListBinding
|
import eu.kanade.tachiyomi.databinding.DownloadListBinding
|
||||||
|
@ -120,14 +124,16 @@ object DownloadQueueScreen : Screen() {
|
||||||
navigateUp = navigator::pop,
|
navigateUp = navigator::pop,
|
||||||
actions = {
|
actions = {
|
||||||
if (downloadList.isNotEmpty()) {
|
if (downloadList.isNotEmpty()) {
|
||||||
OverflowMenu { closeMenu ->
|
var sortExpanded by remember { mutableStateOf(false) }
|
||||||
DropdownMenuItem(
|
val onDismissRequest = { sortExpanded = false }
|
||||||
text = { Text(text = stringResource(R.string.action_reorganize_by)) },
|
DropdownMenu(
|
||||||
children = {
|
expanded = sortExpanded,
|
||||||
DropdownMenuItem(
|
onDismissRequest = onDismissRequest,
|
||||||
|
) {
|
||||||
|
NestedMenuItem(
|
||||||
text = { Text(text = stringResource(R.string.action_order_by_upload_date)) },
|
text = { Text(text = stringResource(R.string.action_order_by_upload_date)) },
|
||||||
children = {
|
children = { closeMenu ->
|
||||||
androidx.compose.material3.DropdownMenuItem(
|
DropdownMenuItem(
|
||||||
text = { Text(text = stringResource(R.string.action_newest)) },
|
text = { Text(text = stringResource(R.string.action_newest)) },
|
||||||
onClick = {
|
onClick = {
|
||||||
screenModel.reorderQueue(
|
screenModel.reorderQueue(
|
||||||
|
@ -137,7 +143,7 @@ object DownloadQueueScreen : Screen() {
|
||||||
closeMenu()
|
closeMenu()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
androidx.compose.material3.DropdownMenuItem(
|
DropdownMenuItem(
|
||||||
text = { Text(text = stringResource(R.string.action_oldest)) },
|
text = { Text(text = stringResource(R.string.action_oldest)) },
|
||||||
onClick = {
|
onClick = {
|
||||||
screenModel.reorderQueue(
|
screenModel.reorderQueue(
|
||||||
|
@ -149,10 +155,10 @@ object DownloadQueueScreen : Screen() {
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
DropdownMenuItem(
|
NestedMenuItem(
|
||||||
text = { Text(text = stringResource(R.string.action_order_by_chapter_number)) },
|
text = { Text(text = stringResource(R.string.action_order_by_chapter_number)) },
|
||||||
children = {
|
children = { closeMenu ->
|
||||||
androidx.compose.material3.DropdownMenuItem(
|
DropdownMenuItem(
|
||||||
text = { Text(text = stringResource(R.string.action_asc)) },
|
text = { Text(text = stringResource(R.string.action_asc)) },
|
||||||
onClick = {
|
onClick = {
|
||||||
screenModel.reorderQueue(
|
screenModel.reorderQueue(
|
||||||
|
@ -162,7 +168,7 @@ object DownloadQueueScreen : Screen() {
|
||||||
closeMenu()
|
closeMenu()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
androidx.compose.material3.DropdownMenuItem(
|
DropdownMenuItem(
|
||||||
text = { Text(text = stringResource(R.string.action_desc)) },
|
text = { Text(text = stringResource(R.string.action_desc)) },
|
||||||
onClick = {
|
onClick = {
|
||||||
screenModel.reorderQueue(
|
screenModel.reorderQueue(
|
||||||
|
@ -174,16 +180,21 @@ object DownloadQueueScreen : Screen() {
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
},
|
|
||||||
)
|
|
||||||
androidx.compose.material3.DropdownMenuItem(
|
|
||||||
text = { Text(text = stringResource(R.string.action_cancel_all)) },
|
|
||||||
onClick = {
|
|
||||||
screenModel.clearQueue()
|
|
||||||
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,
|
scrollBehavior = scrollBehavior,
|
||||||
|
|
|
@ -60,7 +60,6 @@ flexible-adapter-ui = "com.github.arkon.FlexibleAdapter:flexible-adapter-ui:c801
|
||||||
photoview = "com.github.chrisbanes:PhotoView:2.3.0"
|
photoview = "com.github.chrisbanes:PhotoView:2.3.0"
|
||||||
directionalviewpager = "com.github.tachiyomiorg:DirectionalViewPager:1.0.0"
|
directionalviewpager = "com.github.tachiyomiorg:DirectionalViewPager:1.0.0"
|
||||||
insetter = "dev.chrisbanes.insetter:insetter:0.6.1"
|
insetter = "dev.chrisbanes.insetter:insetter:0.6.1"
|
||||||
compose-cascade = "me.saket.cascade:cascade-compose:2.0.0-rc02"
|
|
||||||
compose-materialmotion = "io.github.fornewid:material-motion-compose-core:0.12.3"
|
compose-materialmotion = "io.github.fornewid:material-motion-compose-core:0.12.3"
|
||||||
compose-simpleicons = "br.com.devsrsouza.compose.icons.android:simple-icons:1.0.0"
|
compose-simpleicons = "br.com.devsrsouza.compose.icons.android:simple-icons:1.0.0"
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,6 @@
|
||||||
<string name="action_cancel_all">Cancel all</string>
|
<string name="action_cancel_all">Cancel all</string>
|
||||||
<string name="cancel_all_for_series">Cancel all for this series</string>
|
<string name="cancel_all_for_series">Cancel all for this series</string>
|
||||||
<string name="action_sort">Sort</string>
|
<string name="action_sort">Sort</string>
|
||||||
<string name="action_reorganize_by">Reorder</string>
|
|
||||||
<string name="action_order_by_upload_date">By upload date</string>
|
<string name="action_order_by_upload_date">By upload date</string>
|
||||||
<string name="action_order_by_chapter_number">By chapter number</string>
|
<string name="action_order_by_chapter_number">By chapter number</string>
|
||||||
<string name="action_newest">Newest</string>
|
<string name="action_newest">Newest</string>
|
||||||
|
|
Loading…
Reference in a new issue