some fixes for Next MCU extra

This commit is contained in:
Owen LeJeune
2023-07-11 22:11:25 -04:00
parent 19f5ae426f
commit 8d74d6ee53
4 changed files with 116 additions and 96 deletions

View File

@@ -8,7 +8,7 @@ import org.koin.core.parameter.parametersOf
class NextMCUClient: KoinComponent { class NextMCUClient: KoinComponent {
companion object { companion object {
private const val BASE_URL = "https://www.whenisthenextmcufilm.com/" private const val BASE_URL = "https://dev.whenisthenextmcufilm.com/"
} }
private val client: Client by inject { parametersOf(BASE_URL) } private val client: Client by inject { parametersOf(BASE_URL) }

View File

@@ -7,6 +7,7 @@ import java.util.Date
class NextMCU( class NextMCU(
@SerializedName("days_until") val daysUntil: Int, @SerializedName("days_until") val daysUntil: Int,
@SerializedName("title") val title: String, @SerializedName("title") val title: String,
@SerializedName("id") val id: Int,
@SerializedName("overview") val overview: String, @SerializedName("overview") val overview: String,
@SerializedName("poster_url") val posterUrl: String?, @SerializedName("poster_url") val posterUrl: String?,
@SerializedName("release_date") val releaseDate: Date, @SerializedName("release_date") val releaseDate: Date,

View File

@@ -89,9 +89,11 @@ fun DetailHeader(
) )
rating?.let { rating?.let {
RatingView( if (it > 0f) {
progress = rating RatingView(
) progress = rating
)
}
} }
} }
} }

View File

@@ -377,7 +377,7 @@ private fun MediaViewContent(
mediaItem?.productionCompanies?.firstOrNull { it.name == "Marvel Studios" } != null mediaItem?.productionCompanies?.firstOrNull { it.name == "Marvel Studios" } != null
&& preferences.showNextMcuProduction && preferences.showNextMcuProduction
) { ) {
NextMcuProjectCard(appNavController = appNavController) NextMcuProjectCard(itemId = itemId, appNavController = appNavController)
} }
if (windowSize != WindowSizeClass.Expanded) { if (windowSize != WindowSizeClass.Expanded) {
@@ -472,11 +472,13 @@ private fun MiscDetails(
.wrapContentHeight() .wrapContentHeight()
) { ) {
Text(text = year, color = MaterialTheme.colorScheme.onBackground) Text(text = year, color = MaterialTheme.colorScheme.onBackground)
Text( if (runtime != "0m") {
text = runtime, Text(
color = MaterialTheme.colorScheme.onBackground, text = runtime,
modifier = Modifier.padding(start = 12.dp) color = MaterialTheme.colorScheme.onBackground,
) modifier = Modifier.padding(start = 12.dp)
)
}
Text( Text(
text = contentRating, text = contentRating,
color = MaterialTheme.colorScheme.onBackground, color = MaterialTheme.colorScheme.onBackground,
@@ -870,40 +872,42 @@ fun SimilarContentCard(
val pagingItems = similarContent?.collectAsLazyPagingItems() val pagingItems = similarContent?.collectAsLazyPagingItems()
pagingItems?.let { pagingItems?.let {
ContentCard( if (it.itemCount > 0) {
modifier = modifier, ContentCard(
title = stringResource(id = R.string.recommended_label) modifier = modifier,
) { title = stringResource(id = R.string.recommended_label)
LazyRow(
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
.padding(vertical = 16.dp),
horizontalArrangement = Arrangement.spacedBy(4.dp)
) { ) {
item { LazyRow(
Spacer(modifier = Modifier.width(8.dp)) modifier = Modifier
} .fillMaxWidth()
lazyPagingItems(pagingItems) { item -> .wrapContentHeight()
item?.let { .padding(vertical = 16.dp),
TwoLineImageTextCard( horizontalArrangement = Arrangement.spacedBy(4.dp)
title = item.title, ) {
modifier = Modifier item {
.width(124.dp) Spacer(modifier = Modifier.width(8.dp))
.wrapContentHeight(), }
imageUrl = TmdbUtils.getFullPosterPath(item), lazyPagingItems(pagingItems) { item ->
onItemClicked = { item?.let {
appNavController.navigate( TwoLineImageTextCard(
AppNavItem.DetailView.withArgs(mediaType, item.id) title = item.title,
) modifier = Modifier
}, .width(124.dp)
placeholder = Icons.Filled.Movie, .wrapContentHeight(),
hideSubtitle = true imageUrl = TmdbUtils.getFullPosterPath(item),
) onItemClicked = {
appNavController.navigate(
AppNavItem.DetailView.withArgs(mediaType, item.id)
)
},
placeholder = Icons.Filled.Movie,
hideSubtitle = true
)
}
}
item {
Spacer(modifier = Modifier.width(8.dp))
} }
}
item {
Spacer(modifier = Modifier.width(8.dp))
} }
} }
} }
@@ -1099,6 +1103,7 @@ private fun WatchProviderContainer(
@Composable @Composable
private fun NextMcuProjectCard( private fun NextMcuProjectCard(
itemId: Int,
appNavController: NavController, appNavController: NavController,
modifier: Modifier = Modifier modifier: Modifier = Modifier
) { ) {
@@ -1110,70 +1115,82 @@ private fun NextMcuProjectCard(
val nextMcuProject = remember { viewModel.nextMcuProject } val nextMcuProject = remember { viewModel.nextMcuProject }
Card( if (nextMcuProject.value?.id != itemId) {
shape = RoundedCornerShape(10.dp), Card(
elevation = CardDefaults.cardElevation(defaultElevation = 10.dp), shape = RoundedCornerShape(10.dp),
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant), elevation = CardDefaults.cardElevation(defaultElevation = 10.dp),
modifier = modifier.then(Modifier colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant),
.fillMaxWidth() modifier = modifier.then(Modifier
) .fillMaxWidth()
) { .clickable {
Box( nextMcuProject.value?.let {
modifier = Modifier.height(250.dp) appNavController.navigate(
AppNavItem.DetailView.withArgs(
it.type,
it.id
)
)
}
}
)
) { ) {
val model = ImageRequest.Builder(LocalContext.current) Box(
.data(nextMcuProject.value?.posterUrl) modifier = Modifier.height(250.dp)
.diskCacheKey(nextMcuProject.value?.title)
.networkCachePolicy(CachePolicy.ENABLED)
.memoryCachePolicy(CachePolicy.ENABLED)
.build()
Column(
modifier = Modifier.padding(all = 8.dp),
verticalArrangement = Arrangement.spacedBy(6.dp)
) { ) {
Text( val model = ImageRequest.Builder(LocalContext.current)
text = stringResource(R.string.next_in_the_mcu_title), .data(nextMcuProject.value?.posterUrl)
style = MaterialTheme.typography.headlineSmall, .diskCacheKey(nextMcuProject.value?.title)
fontWeight = FontWeight.W700, .networkCachePolicy(CachePolicy.ENABLED)
modifier = Modifier.padding(start = 2.dp) .memoryCachePolicy(CachePolicy.ENABLED)
) .build()
Row( Column(
horizontalArrangement = Arrangement.spacedBy(12.dp) modifier = Modifier.padding(all = 8.dp),
verticalArrangement = Arrangement.spacedBy(6.dp)
) { ) {
AsyncImage( Text(
model = model, text = stringResource(R.string.next_in_the_mcu_title),
modifier = Modifier style = MaterialTheme.typography.headlineSmall,
.aspectRatio(0.7f) fontWeight = FontWeight.W700,
.clip(RoundedCornerShape(10.dp)), modifier = Modifier.padding(start = 2.dp)
contentDescription = nextMcuProject.value?.title
) )
Column( Row(
verticalArrangement = Arrangement.spacedBy(6.dp) horizontalArrangement = Arrangement.spacedBy(12.dp)
) { ) {
Text( AsyncImage(
text = nextMcuProject.value?.title ?: "", model = model,
style = MaterialTheme.typography.headlineSmall, modifier = Modifier
fontWeight = FontWeight.W600 .aspectRatio(0.7f)
.clip(RoundedCornerShape(10.dp)),
contentDescription = nextMcuProject.value?.title
) )
val releaseDate = Column(
nextMcuProject.value?.releaseDate?.format(DateFormat.MMMM_dd) ?: "" verticalArrangement = Arrangement.spacedBy(6.dp)
val daysLeft = stringResource( ) {
id = R.string.days_left, Text(
nextMcuProject.value?.daysUntil ?: -1 text = nextMcuProject.value?.title ?: "",
) style = MaterialTheme.typography.headlineSmall,
Text( fontWeight = FontWeight.W600
text = "$releaseDate$daysLeft", )
fontStyle = FontStyle.Italic
)
Text( val releaseDate =
text = nextMcuProject.value?.overview ?: "", nextMcuProject.value?.releaseDate?.format(DateFormat.MMMM_dd) ?: ""
overflow = TextOverflow.Ellipsis val daysLeft = stringResource(
) id = R.string.days_left,
nextMcuProject.value?.daysUntil ?: -1
)
Text(
text = "$releaseDate$daysLeft",
fontStyle = FontStyle.Italic
)
Text(
text = nextMcuProject.value?.overview ?: "",
overflow = TextOverflow.Ellipsis
)
}
} }
} }
} }