mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 15:50:16 +02:00
Fix card overlays showing, fix home page refresh indicator (#1178)
## Description - Always show card overlays (ie Movie vs TV Show) for discover/Seerr cards - Show card overlays (ie favorite and watched status) for search result cards - Restore showing home page refresh indicator ### Related issues Closes #1141 Closes https://github.com/damontecres/Wholphin/issues/702#issuecomment-4114775539 ### Testing Emulator ## Screenshots N/A, no new UIs, just adding existing ones ## AI or LLM usage None
This commit is contained in:
parent
762a5e6dcc
commit
7ccef6f802
7 changed files with 34 additions and 25 deletions
|
|
@ -16,7 +16,6 @@ import androidx.compose.foundation.layout.size
|
|||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.NonRestartableComposable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
|
|
@ -50,13 +49,12 @@ import com.github.damontecres.wholphin.ui.theme.WholphinTheme
|
|||
import kotlinx.coroutines.delay
|
||||
|
||||
@Composable
|
||||
@NonRestartableComposable
|
||||
fun DiscoverItemCard(
|
||||
item: DiscoverItem?,
|
||||
onClick: () -> Unit,
|
||||
onLongClick: () -> Unit,
|
||||
showOverlay: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
showOverlay: Boolean = true,
|
||||
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
|
||||
) {
|
||||
val focused by interactionSource.collectIsFocusedAsState()
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ fun EpisodeCard(
|
|||
modifier: Modifier = Modifier,
|
||||
imageHeight: Dp = Dp.Unspecified,
|
||||
imageWidth: Dp = Dp.Unspecified,
|
||||
showImageOverlay: Boolean = false,
|
||||
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
|
||||
) {
|
||||
val dto = item?.data
|
||||
|
|
@ -94,7 +95,7 @@ fun EpisodeCard(
|
|||
ItemCardImage(
|
||||
item = item,
|
||||
name = item?.name,
|
||||
showOverlay = false,
|
||||
showOverlay = showImageOverlay,
|
||||
favorite = dto?.userData?.isFavorite ?: false,
|
||||
watched = dto?.userData?.played ?: false,
|
||||
unwatchedCount = dto?.userData?.unplayedItemCount ?: -1,
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ fun DiscoverMovieDetailsContent(
|
|||
item = item,
|
||||
onClick = onClick,
|
||||
onLongClick = onLongClick,
|
||||
showOverlay = false,
|
||||
showOverlay = true,
|
||||
modifier = mod,
|
||||
)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -378,7 +378,7 @@ fun DiscoverSeriesDetailsContent(
|
|||
item = item,
|
||||
onClick = onClick,
|
||||
onLongClick = onLongClick,
|
||||
showOverlay = false,
|
||||
showOverlay = true,
|
||||
modifier = mod,
|
||||
)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -342,7 +342,7 @@ fun DiscoverRow(
|
|||
item = item,
|
||||
onClick = onClick,
|
||||
onLongClick = onLongClick,
|
||||
showOverlay = false,
|
||||
showOverlay = true,
|
||||
modifier =
|
||||
mod.onFocusChanged {
|
||||
if (it.isFocused) {
|
||||
|
|
|
|||
|
|
@ -85,7 +85,13 @@ class HomeViewModel
|
|||
val refresh =
|
||||
state.loadingState == LoadingState.Success && state.settings == settings
|
||||
Timber.v("refresh=$refresh, state.loadingState=${state.loadingState}")
|
||||
_state.update { it.copy(settings = settings) }
|
||||
_state.update {
|
||||
it.copy(
|
||||
loadingState = if (refresh) LoadingState.Success else LoadingState.Loading,
|
||||
refreshState = LoadingState.Loading,
|
||||
settings = settings,
|
||||
)
|
||||
}
|
||||
|
||||
val semaphore = Semaphore(4)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.github.damontecres.wholphin.ui.main
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.foundation.focusGroup
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
|
|
@ -32,7 +33,6 @@ import androidx.compose.ui.input.key.KeyEventType
|
|||
import androidx.compose.ui.input.key.key
|
||||
import androidx.compose.ui.input.key.onPreviewKeyEvent
|
||||
import androidx.compose.ui.input.key.type
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalFocusManager
|
||||
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
||||
import androidx.compose.ui.res.stringResource
|
||||
|
|
@ -232,7 +232,6 @@ fun SearchPage(
|
|||
modifier: Modifier = Modifier,
|
||||
viewModel: SearchViewModel = hiltViewModel(),
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val focusManager = LocalFocusManager.current
|
||||
val keyboardController = LocalSoftwareKeyboardController.current
|
||||
val movies by viewModel.movies.observeAsState(SearchResult.NoQuery)
|
||||
|
|
@ -377,7 +376,7 @@ fun SearchPage(
|
|||
}
|
||||
}
|
||||
searchResultRow(
|
||||
title = context.getString(R.string.movies),
|
||||
title = R.string.movies,
|
||||
result = movies,
|
||||
rowIndex = MOVIE_ROW,
|
||||
position = position,
|
||||
|
|
@ -387,7 +386,7 @@ fun SearchPage(
|
|||
modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
searchResultRow(
|
||||
title = context.getString(R.string.tv_shows),
|
||||
title = R.string.tv_shows,
|
||||
result = series,
|
||||
rowIndex = SERIES_ROW,
|
||||
position = position,
|
||||
|
|
@ -397,7 +396,7 @@ fun SearchPage(
|
|||
modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
searchResultRow(
|
||||
title = context.getString(R.string.episodes),
|
||||
title = R.string.episodes,
|
||||
result = episodes,
|
||||
rowIndex = EPISODE_ROW,
|
||||
position = position,
|
||||
|
|
@ -414,12 +413,13 @@ fun SearchPage(
|
|||
},
|
||||
onLongClick = onLongClick,
|
||||
imageHeight = 140.dp,
|
||||
showImageOverlay = true,
|
||||
modifier = mod.padding(horizontal = 8.dp),
|
||||
)
|
||||
},
|
||||
)
|
||||
searchResultRow(
|
||||
title = context.getString(R.string.albums),
|
||||
title = R.string.albums,
|
||||
result = albums,
|
||||
rowIndex = ALBUM_ROW,
|
||||
position = position,
|
||||
|
|
@ -437,12 +437,13 @@ fun SearchPage(
|
|||
onLongClick = onLongClick,
|
||||
imageHeight = Cards.heightEpisode,
|
||||
aspectRatio = AspectRatios.SQUARE,
|
||||
showImageOverlay = true,
|
||||
modifier = mod,
|
||||
)
|
||||
},
|
||||
)
|
||||
searchResultRow(
|
||||
title = context.getString(R.string.artists),
|
||||
title = R.string.artists,
|
||||
result = artists,
|
||||
rowIndex = COLLECTION_ROW,
|
||||
position = position,
|
||||
|
|
@ -460,12 +461,13 @@ fun SearchPage(
|
|||
onLongClick = onLongClick,
|
||||
imageHeight = Cards.heightEpisode,
|
||||
aspectRatio = AspectRatios.SQUARE,
|
||||
showImageOverlay = true,
|
||||
modifier = mod,
|
||||
)
|
||||
},
|
||||
)
|
||||
searchResultRow(
|
||||
title = context.getString(R.string.songs),
|
||||
title = R.string.songs,
|
||||
result = songs,
|
||||
rowIndex = SONG_ROW,
|
||||
position = position,
|
||||
|
|
@ -483,12 +485,13 @@ fun SearchPage(
|
|||
onLongClick = onLongClick,
|
||||
imageHeight = Cards.heightEpisode,
|
||||
aspectRatio = AspectRatios.SQUARE,
|
||||
showImageOverlay = true,
|
||||
modifier = mod,
|
||||
)
|
||||
},
|
||||
)
|
||||
searchResultRow(
|
||||
title = context.getString(R.string.collections),
|
||||
title = R.string.collections,
|
||||
result = collections,
|
||||
rowIndex = COLLECTION_ROW,
|
||||
position = position,
|
||||
|
|
@ -498,7 +501,7 @@ fun SearchPage(
|
|||
modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
searchResultRow(
|
||||
title = context.getString(R.string.discover),
|
||||
title = R.string.discover,
|
||||
result = seerrResults,
|
||||
rowIndex = SEERR_ROW,
|
||||
position = position,
|
||||
|
|
@ -525,7 +528,7 @@ fun SearchPage(
|
|||
}
|
||||
|
||||
fun LazyListScope.searchResultRow(
|
||||
title: String,
|
||||
@StringRes title: Int,
|
||||
result: SearchResult,
|
||||
rowIndex: Int,
|
||||
position: RowColumn,
|
||||
|
|
@ -549,6 +552,7 @@ fun LazyListScope.searchResultRow(
|
|||
},
|
||||
onLongClick = onLongClick,
|
||||
imageHeight = Cards.height2x3,
|
||||
showImageOverlay = true,
|
||||
modifier = mod,
|
||||
)
|
||||
},
|
||||
|
|
@ -557,7 +561,7 @@ fun LazyListScope.searchResultRow(
|
|||
when (val r = result) {
|
||||
is SearchResult.Error -> {
|
||||
SearchResultPlaceholder(
|
||||
title = title,
|
||||
title = stringResource(title),
|
||||
message = r.ex.localizedMessage ?: "Error occurred during search",
|
||||
messageColor = MaterialTheme.colorScheme.error,
|
||||
modifier = Modifier,
|
||||
|
|
@ -570,7 +574,7 @@ fun LazyListScope.searchResultRow(
|
|||
|
||||
SearchResult.Searching -> {
|
||||
SearchResultPlaceholder(
|
||||
title = title,
|
||||
title = stringResource(title),
|
||||
message = stringResource(R.string.searching),
|
||||
modifier = modifier,
|
||||
)
|
||||
|
|
@ -579,13 +583,13 @@ fun LazyListScope.searchResultRow(
|
|||
is SearchResult.Success -> {
|
||||
if (r.items.isEmpty()) {
|
||||
SearchResultPlaceholder(
|
||||
title = title,
|
||||
title = stringResource(title),
|
||||
message = stringResource(R.string.no_results),
|
||||
modifier = modifier,
|
||||
)
|
||||
} else {
|
||||
ItemRow(
|
||||
title = title,
|
||||
title = stringResource(title),
|
||||
items = r.items,
|
||||
onClickItem = onClickItem,
|
||||
onLongClickItem = { _, _ -> },
|
||||
|
|
@ -598,13 +602,13 @@ fun LazyListScope.searchResultRow(
|
|||
is SearchResult.SuccessSeerr -> {
|
||||
if (r.items.isEmpty()) {
|
||||
SearchResultPlaceholder(
|
||||
title = title,
|
||||
title = stringResource(title),
|
||||
message = stringResource(R.string.no_results),
|
||||
modifier = modifier,
|
||||
)
|
||||
} else {
|
||||
ItemRow(
|
||||
title = title,
|
||||
title = stringResource(title),
|
||||
items = r.items,
|
||||
onClickItem = { index, item ->
|
||||
onClickPosition.invoke(RowColumn(rowIndex, index))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue