mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 15:50:16 +02:00
Add view option for hiding card titles (#422)
Adds a view option for grids to show/hide titles. It is enabled by default. Closes #403
This commit is contained in:
parent
f63a30d295
commit
2403a44c18
4 changed files with 45 additions and 30 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
package com.github.damontecres.wholphin.ui.cards
|
package com.github.damontecres.wholphin.ui.cards
|
||||||
|
|
||||||
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.animation.core.animateDpAsState
|
import androidx.compose.animation.core.animateDpAsState
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||||
|
|
@ -44,6 +45,7 @@ fun GridCard(
|
||||||
imageAspectRatio: Float = AspectRatios.TALL,
|
imageAspectRatio: Float = AspectRatios.TALL,
|
||||||
imageContentScale: ContentScale = ContentScale.Fit,
|
imageContentScale: ContentScale = ContentScale.Fit,
|
||||||
imageType: ViewOptionImageType = ViewOptionImageType.PRIMARY,
|
imageType: ViewOptionImageType = ViewOptionImageType.PRIMARY,
|
||||||
|
showTitle: Boolean = true,
|
||||||
) {
|
) {
|
||||||
val dto = item?.data
|
val dto = item?.data
|
||||||
val focused by interactionSource.collectIsFocusedAsState()
|
val focused by interactionSource.collectIsFocusedAsState()
|
||||||
|
|
@ -98,6 +100,7 @@ fun GridCard(
|
||||||
.background(MaterialTheme.colorScheme.surfaceVariant),
|
.background(MaterialTheme.colorScheme.surfaceVariant),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
AnimatedVisibility(showTitle) {
|
||||||
Column(
|
Column(
|
||||||
verticalArrangement = Arrangement.spacedBy(0.dp),
|
verticalArrangement = Arrangement.spacedBy(0.dp),
|
||||||
modifier =
|
modifier =
|
||||||
|
|
@ -128,4 +131,5 @@ fun GridCard(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -681,6 +681,10 @@ fun CollectionFolderGridContent(
|
||||||
letterPosition: suspend (Char) -> Int,
|
letterPosition: suspend (Char) -> Int,
|
||||||
sortOptions: List<ItemSortBy>,
|
sortOptions: List<ItemSortBy>,
|
||||||
playEnabled: Boolean,
|
playEnabled: Boolean,
|
||||||
|
getPossibleFilterValues: suspend (ItemFilterBy<*>) -> List<FilterValueOption>,
|
||||||
|
defaultViewOptions: ViewOptions,
|
||||||
|
onSaveViewOptions: (ViewOptions) -> Unit,
|
||||||
|
viewOptions: ViewOptions,
|
||||||
onClickPlayAll: (shuffle: Boolean) -> Unit,
|
onClickPlayAll: (shuffle: Boolean) -> Unit,
|
||||||
onClickPlay: (Int, BaseItem) -> Unit,
|
onClickPlay: (Int, BaseItem) -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
|
|
@ -689,10 +693,6 @@ fun CollectionFolderGridContent(
|
||||||
currentFilter: GetItemsFilter = GetItemsFilter(),
|
currentFilter: GetItemsFilter = GetItemsFilter(),
|
||||||
filterOptions: List<ItemFilterBy<*>> = listOf(),
|
filterOptions: List<ItemFilterBy<*>> = listOf(),
|
||||||
onFilterChange: (GetItemsFilter) -> Unit = {},
|
onFilterChange: (GetItemsFilter) -> Unit = {},
|
||||||
getPossibleFilterValues: suspend (ItemFilterBy<*>) -> List<FilterValueOption>,
|
|
||||||
defaultViewOptions: ViewOptions,
|
|
||||||
viewOptions: ViewOptions,
|
|
||||||
onSaveViewOptions: (ViewOptions) -> Unit,
|
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val title = item?.name ?: item?.data?.collectionType?.name ?: stringResource(R.string.collection)
|
val title = item?.name ?: item?.data?.collectionType?.name ?: stringResource(R.string.collection)
|
||||||
|
|
@ -837,6 +837,7 @@ fun CollectionFolderGridContent(
|
||||||
imageContentScale = viewOptions.contentScale.scale,
|
imageContentScale = viewOptions.contentScale.scale,
|
||||||
imageAspectRatio = viewOptions.aspectRatio.ratio,
|
imageAspectRatio = viewOptions.aspectRatio.ratio,
|
||||||
imageType = viewOptions.imageType,
|
imageType = viewOptions.imageType,
|
||||||
|
showTitle = viewOptions.showTitles,
|
||||||
modifier = mod,
|
modifier = mod,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,7 @@ data class ViewOptions(
|
||||||
val aspectRatio: AspectRatio = AspectRatio.TALL,
|
val aspectRatio: AspectRatio = AspectRatio.TALL,
|
||||||
val showDetails: Boolean = false,
|
val showDetails: Boolean = false,
|
||||||
val imageType: ViewOptionImageType = ViewOptionImageType.PRIMARY,
|
val imageType: ViewOptionImageType = ViewOptionImageType.PRIMARY,
|
||||||
|
val showTitles: Boolean = true,
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
val ViewOptionsColumns =
|
val ViewOptionsColumns =
|
||||||
|
|
@ -165,6 +166,13 @@ data class ViewOptions(
|
||||||
getter = { it.showDetails },
|
getter = { it.showDetails },
|
||||||
setter = { vo, value -> vo.copy(showDetails = value) },
|
setter = { vo, value -> vo.copy(showDetails = value) },
|
||||||
)
|
)
|
||||||
|
val ViewOptionsShowTitles =
|
||||||
|
AppSwitchPreference<ViewOptions>(
|
||||||
|
title = R.string.show_titles,
|
||||||
|
defaultValue = true,
|
||||||
|
getter = { it.showTitles },
|
||||||
|
setter = { vo, value -> vo.copy(showTitles = value) },
|
||||||
|
)
|
||||||
|
|
||||||
val ViewOptionsImageType =
|
val ViewOptionsImageType =
|
||||||
AppChoicePreference<ViewOptions, ViewOptionImageType>(
|
AppChoicePreference<ViewOptions, ViewOptionImageType>(
|
||||||
|
|
@ -194,6 +202,7 @@ data class ViewOptions(
|
||||||
ViewOptionsImageType,
|
ViewOptionsImageType,
|
||||||
ViewOptionsAspectRatio,
|
ViewOptionsAspectRatio,
|
||||||
ViewOptionsDetailHeader,
|
ViewOptionsDetailHeader,
|
||||||
|
ViewOptionsShowTitles,
|
||||||
ViewOptionsColumns,
|
ViewOptionsColumns,
|
||||||
ViewOptionsSpacing,
|
ViewOptionsSpacing,
|
||||||
ViewOptionsContentScale,
|
ViewOptionsContentScale,
|
||||||
|
|
|
||||||
|
|
@ -354,6 +354,7 @@
|
||||||
<string name="automatic">Automatic</string>
|
<string name="automatic">Automatic</string>
|
||||||
<string name="username_or_password">Use username/password</string>
|
<string name="username_or_password">Use username/password</string>
|
||||||
<string name="login">Login</string>
|
<string name="login">Login</string>
|
||||||
|
<string name="show_titles">Show titles</string>
|
||||||
|
|
||||||
<string-array name="theme_song_volume">
|
<string-array name="theme_song_volume">
|
||||||
<item>Disabled</item>
|
<item>Disabled</item>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue