|
|
@ -1,7 +1,10 @@
|
|
|
|
package eu.kanade.presentation.components
|
|
|
|
package eu.kanade.presentation.components
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.compose.foundation.ScrollState
|
|
|
|
|
|
|
|
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.foundation.rememberScrollState
|
|
|
|
import androidx.compose.material.icons.Icons
|
|
|
|
import androidx.compose.material.icons.Icons
|
|
|
|
import androidx.compose.material.icons.automirrored.outlined.ArrowRight
|
|
|
|
import androidx.compose.material.icons.automirrored.outlined.ArrowRight
|
|
|
|
import androidx.compose.material.icons.outlined.RadioButtonChecked
|
|
|
|
import androidx.compose.material.icons.outlined.RadioButtonChecked
|
|
|
@ -22,12 +25,17 @@ import tachiyomi.i18n.MR
|
|
|
|
import tachiyomi.presentation.core.i18n.stringResource
|
|
|
|
import tachiyomi.presentation.core.i18n.stringResource
|
|
|
|
import androidx.compose.material3.DropdownMenu as ComposeDropdownMenu
|
|
|
|
import androidx.compose.material3.DropdownMenu as ComposeDropdownMenu
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* DropdownMenu but overlaps anchor and has width constraints to better
|
|
|
|
|
|
|
|
* match non-Compose implementation.
|
|
|
|
|
|
|
|
*/
|
|
|
|
@Composable
|
|
|
|
@Composable
|
|
|
|
fun DropdownMenu(
|
|
|
|
fun DropdownMenu(
|
|
|
|
expanded: Boolean,
|
|
|
|
expanded: Boolean,
|
|
|
|
onDismissRequest: () -> Unit,
|
|
|
|
onDismissRequest: () -> Unit,
|
|
|
|
modifier: Modifier = Modifier,
|
|
|
|
modifier: Modifier = Modifier,
|
|
|
|
offset: DpOffset = DpOffset(8.dp, (-56).dp),
|
|
|
|
offset: DpOffset = DpOffset(8.dp, (-56).dp),
|
|
|
|
|
|
|
|
scrollState: ScrollState = rememberScrollState(),
|
|
|
|
properties: PopupProperties = PopupProperties(focusable = true),
|
|
|
|
properties: PopupProperties = PopupProperties(focusable = true),
|
|
|
|
content: @Composable ColumnScope.() -> Unit,
|
|
|
|
content: @Composable ColumnScope.() -> Unit,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
@ -36,6 +44,7 @@ fun DropdownMenu(
|
|
|
|
onDismissRequest = onDismissRequest,
|
|
|
|
onDismissRequest = onDismissRequest,
|
|
|
|
modifier = modifier.sizeIn(minWidth = 196.dp, maxWidth = 196.dp),
|
|
|
|
modifier = modifier.sizeIn(minWidth = 196.dp, maxWidth = 196.dp),
|
|
|
|
offset = offset,
|
|
|
|
offset = offset,
|
|
|
|
|
|
|
|
scrollState = scrollState,
|
|
|
|
properties = properties,
|
|
|
|
properties = properties,
|
|
|
|
content = content,
|
|
|
|
content = content,
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -45,6 +54,7 @@ fun DropdownMenu(
|
|
|
|
fun RadioMenuItem(
|
|
|
|
fun RadioMenuItem(
|
|
|
|
text: @Composable () -> Unit,
|
|
|
|
text: @Composable () -> Unit,
|
|
|
|
isChecked: Boolean,
|
|
|
|
isChecked: Boolean,
|
|
|
|
|
|
|
|
modifier: Modifier = Modifier,
|
|
|
|
onClick: () -> Unit,
|
|
|
|
onClick: () -> Unit,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
DropdownMenuItem(
|
|
|
|
DropdownMenuItem(
|
|
|
@ -64,6 +74,7 @@ fun RadioMenuItem(
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
modifier = modifier,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -71,25 +82,29 @@ fun RadioMenuItem(
|
|
|
|
fun NestedMenuItem(
|
|
|
|
fun NestedMenuItem(
|
|
|
|
text: @Composable () -> Unit,
|
|
|
|
text: @Composable () -> Unit,
|
|
|
|
children: @Composable ColumnScope.(() -> Unit) -> Unit,
|
|
|
|
children: @Composable ColumnScope.(() -> Unit) -> Unit,
|
|
|
|
|
|
|
|
modifier: Modifier = Modifier,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
var nestedExpanded by remember { mutableStateOf(false) }
|
|
|
|
var nestedExpanded by remember { mutableStateOf(false) }
|
|
|
|
val closeMenu = { nestedExpanded = false }
|
|
|
|
val closeMenu = { nestedExpanded = false }
|
|
|
|
|
|
|
|
|
|
|
|
DropdownMenuItem(
|
|
|
|
Box {
|
|
|
|
text = text,
|
|
|
|
DropdownMenuItem(
|
|
|
|
onClick = { nestedExpanded = true },
|
|
|
|
text = text,
|
|
|
|
trailingIcon = {
|
|
|
|
onClick = { nestedExpanded = true },
|
|
|
|
Icon(
|
|
|
|
trailingIcon = {
|
|
|
|
imageVector = Icons.AutoMirrored.Outlined.ArrowRight,
|
|
|
|
Icon(
|
|
|
|
contentDescription = null,
|
|
|
|
imageVector = Icons.AutoMirrored.Outlined.ArrowRight,
|
|
|
|
)
|
|
|
|
contentDescription = null,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
DropdownMenu(
|
|
|
|
DropdownMenu(
|
|
|
|
expanded = nestedExpanded,
|
|
|
|
expanded = nestedExpanded,
|
|
|
|
onDismissRequest = closeMenu,
|
|
|
|
onDismissRequest = closeMenu,
|
|
|
|
) {
|
|
|
|
modifier = modifier,
|
|
|
|
children(closeMenu)
|
|
|
|
) {
|
|
|
|
|
|
|
|
children(closeMenu)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|