BrowseSourceToolbar: Match display mode dropdown to stable and change toolbar icon based on display mode (#8200)
* BrowseSourceToolbar: Match display mode dropdown to stable and change toolbar icon based on display mode * Review changes * Review changes 2 (cherry picked from commit 3d7e44726d799294e808ce44fa1f0c8e5ff42e7a) # Conflicts: # app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceToolbar.kt
This commit is contained in:
parent
6bcad5b13e
commit
2903e0d98e
@ -3,13 +3,12 @@ package eu.kanade.presentation.browse.components
|
|||||||
import androidx.compose.foundation.text.KeyboardActions
|
import androidx.compose.foundation.text.KeyboardActions
|
||||||
import androidx.compose.foundation.text.KeyboardOptions
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.ViewList
|
||||||
import androidx.compose.material.icons.filled.ViewModule
|
import androidx.compose.material.icons.filled.ViewModule
|
||||||
import androidx.compose.material.icons.outlined.Check
|
|
||||||
import androidx.compose.material.icons.outlined.Help
|
import androidx.compose.material.icons.outlined.Help
|
||||||
import androidx.compose.material.icons.outlined.Public
|
import androidx.compose.material.icons.outlined.Public
|
||||||
import androidx.compose.material.icons.outlined.Search
|
import androidx.compose.material.icons.outlined.Search
|
||||||
import androidx.compose.material.icons.outlined.Settings
|
import androidx.compose.material.icons.outlined.Settings
|
||||||
import androidx.compose.material3.DropdownMenuItem
|
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TopAppBarScrollBehavior
|
import androidx.compose.material3.TopAppBarScrollBehavior
|
||||||
@ -27,6 +26,7 @@ import eu.kanade.presentation.browse.BrowseSourceState
|
|||||||
import eu.kanade.presentation.components.AppBar
|
import eu.kanade.presentation.components.AppBar
|
||||||
import eu.kanade.presentation.components.AppBarActions
|
import eu.kanade.presentation.components.AppBarActions
|
||||||
import eu.kanade.presentation.components.DropdownMenu
|
import eu.kanade.presentation.components.DropdownMenu
|
||||||
|
import eu.kanade.presentation.components.RadioButton
|
||||||
import eu.kanade.presentation.components.SearchToolbar
|
import eu.kanade.presentation.components.SearchToolbar
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||||
@ -115,7 +115,7 @@ fun BrowseSourceRegularToolbar(
|
|||||||
// SY -->
|
// SY -->
|
||||||
AppBar.Action(
|
AppBar.Action(
|
||||||
title = stringResource(R.string.action_display_mode),
|
title = stringResource(R.string.action_display_mode),
|
||||||
icon = Icons.Filled.ViewModule,
|
icon = if (displayMode == LibraryDisplayMode.List) Icons.Filled.ViewList else Icons.Filled.ViewModule,
|
||||||
onClick = { selectingDisplayMode = true },
|
onClick = { selectingDisplayMode = true },
|
||||||
).takeIf { displayMode != null },
|
).takeIf { displayMode != null },
|
||||||
// SY <--
|
// SY <--
|
||||||
@ -149,41 +149,20 @@ fun BrowseSourceRegularToolbar(
|
|||||||
expanded = selectingDisplayMode,
|
expanded = selectingDisplayMode,
|
||||||
onDismissRequest = { selectingDisplayMode = false },
|
onDismissRequest = { selectingDisplayMode = false },
|
||||||
) {
|
) {
|
||||||
DropdownMenuItem(
|
RadioButton(
|
||||||
text = { Text(text = stringResource(R.string.action_display_comfortable_grid)) },
|
text = { Text(text = stringResource(R.string.action_display_comfortable_grid)) },
|
||||||
onClick = { onDisplayModeChange(LibraryDisplayMode.ComfortableGrid) },
|
onClick = { onDisplayModeChange(LibraryDisplayMode.ComfortableGrid) },
|
||||||
trailingIcon = {
|
isChecked = displayMode == LibraryDisplayMode.ComfortableGrid,
|
||||||
if (displayMode == LibraryDisplayMode.ComfortableGrid) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Outlined.Check,
|
|
||||||
contentDescription = "",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
DropdownMenuItem(
|
RadioButton(
|
||||||
text = { Text(text = stringResource(R.string.action_display_grid)) },
|
text = { Text(text = stringResource(R.string.action_display_grid)) },
|
||||||
onClick = { onDisplayModeChange(LibraryDisplayMode.CompactGrid) },
|
onClick = { onDisplayModeChange(LibraryDisplayMode.CompactGrid) },
|
||||||
trailingIcon = {
|
isChecked = displayMode == LibraryDisplayMode.CompactGrid,
|
||||||
if (displayMode == LibraryDisplayMode.CompactGrid) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Outlined.Check,
|
|
||||||
contentDescription = "",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
DropdownMenuItem(
|
RadioButton(
|
||||||
text = { Text(text = stringResource(R.string.action_display_list)) },
|
text = { Text(text = stringResource(R.string.action_display_list)) },
|
||||||
onClick = { onDisplayModeChange(LibraryDisplayMode.List) },
|
onClick = { onDisplayModeChange(LibraryDisplayMode.List) },
|
||||||
trailingIcon = {
|
isChecked = displayMode == LibraryDisplayMode.List,
|
||||||
if (displayMode == LibraryDisplayMode.List) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Outlined.Check,
|
|
||||||
contentDescription = "",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -2,6 +2,11 @@ package eu.kanade.presentation.components
|
|||||||
|
|
||||||
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.outlined.RadioButtonChecked
|
||||||
|
import androidx.compose.material.icons.outlined.RadioButtonUnchecked
|
||||||
|
import androidx.compose.material3.DropdownMenuItem
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.DpOffset
|
import androidx.compose.ui.unit.DpOffset
|
||||||
@ -26,3 +31,28 @@ fun DropdownMenu(
|
|||||||
content = content,
|
content = content,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun RadioButton(
|
||||||
|
text: @Composable () -> Unit,
|
||||||
|
onClick: () -> Unit,
|
||||||
|
isChecked: Boolean,
|
||||||
|
) {
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = text,
|
||||||
|
onClick = onClick,
|
||||||
|
trailingIcon = {
|
||||||
|
if (isChecked) {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Outlined.RadioButtonChecked,
|
||||||
|
contentDescription = "",
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Outlined.RadioButtonUnchecked,
|
||||||
|
contentDescription = "",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user