Skip to content

Commit

Permalink
Merge pull request #116 from imashnake0/coming-soon-re
Browse files Browse the repository at this point in the history
R class shenanigans and Coming Soon
  • Loading branch information
imashnake0 authored Jan 3, 2024
2 parents be9d9c4 + ff11a6a commit 7a62675
Show file tree
Hide file tree
Showing 13 changed files with 174 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.dimensionResource
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import com.imashnake.animite.R
import com.imashnake.animite.core.ui.LocalPaddings
import com.imashnake.animite.features.destinations.MediaPageDestination
import com.imashnake.animite.features.media.MediaPageArgs
import com.imashnake.animite.features.navigationbar.NavigationBar
Expand Down Expand Up @@ -107,9 +106,9 @@ fun MainScreen(modifier: Modifier = Modifier) {
modifier = Modifier
.align(Alignment.BottomEnd)
.padding(
start = dimensionResource(R.dimen.large_padding),
end = dimensionResource(R.dimen.large_padding),
bottom = dimensionResource(R.dimen.large_padding)
start = LocalPaddings.current.large,
end = LocalPaddings.current.large,
bottom = LocalPaddings.current.large
)
)

Expand Down
57 changes: 29 additions & 28 deletions app/src/main/java/com/imashnake/animite/features/home/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ import com.imashnake.animite.features.ui.MediaSmall
import com.imashnake.animite.features.ui.MediaSmallRow
import com.ramcosta.composedestinations.annotation.Destination
import com.ramcosta.composedestinations.navigation.DestinationsNavigator
import com.imashnake.animite.R as Res
import com.imashnake.animite.R
import com.imashnake.animite.core.ui.LocalPaddings

@Destination
@Composable
Expand All @@ -83,7 +84,7 @@ fun Home(
val scrollState = rememberScrollState()
TranslucentStatusBarLayout(
scrollState = scrollState,
distanceUntilAnimated = dimensionResource(Res.dimen.banner_height)
distanceUntilAnimated = dimensionResource(R.dimen.banner_height)
) {
Box(
modifier = Modifier
Expand All @@ -92,11 +93,11 @@ fun Home(
) {
Box {
Image(
painter = painterResource(Res.drawable.background),
painter = painterResource(R.drawable.background),
contentDescription = null,
modifier = Modifier
.fillMaxWidth()
.height(dimensionResource(Res.dimen.banner_height))
.height(dimensionResource(R.dimen.banner_height))
.bannerParallax(scrollState),
contentScale = ContentScale.Crop,
alignment = Alignment.TopCenter
Expand All @@ -115,7 +116,7 @@ fun Home(
)
)
.fillMaxWidth()
.height(dimensionResource(Res.dimen.banner_height))
.height(dimensionResource(R.dimen.banner_height))
) { }

Row(
Expand All @@ -124,13 +125,13 @@ fun Home(
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = stringResource(Res.string.okaeri),
text = stringResource(R.string.okaeri),
color = MaterialTheme.colorScheme.onSecondaryContainer,
style = MaterialTheme.typography.displayMedium,
modifier = Modifier
.padding(
start = dimensionResource(Res.dimen.large_padding),
bottom = dimensionResource(Res.dimen.medium_padding)
start = LocalPaddings.current.large,
bottom = LocalPaddings.current.medium
)
.landscapeCutoutPadding()
.weight(1f, fill = false),
Expand All @@ -140,8 +141,8 @@ fun Home(
MediaTypeSelector(
modifier = Modifier
.padding(
end = dimensionResource(Res.dimen.large_padding),
bottom = dimensionResource(Res.dimen.medium_padding)
end = LocalPaddings.current.large,
bottom = LocalPaddings.current.medium
)
.landscapeCutoutPadding(),
selectedOption = homeMediaType,
Expand All @@ -151,19 +152,19 @@ fun Home(
}

Column {
Spacer(Modifier.size(dimensionResource(Res.dimen.banner_height)))
Spacer(Modifier.size(dimensionResource(R.dimen.banner_height)))

Column(
modifier = Modifier
.background(MaterialTheme.colorScheme.background)
.padding(vertical = dimensionResource(Res.dimen.large_padding))
.padding(vertical = LocalPaddings.current.large)
// TODO: Move this one out of Home when we can pass modifiers in.
.padding(bottom = dimensionResource(Res.dimen.navigation_bar_height)),
verticalArrangement = Arrangement.spacedBy(dimensionResource(Res.dimen.large_padding))
.padding(bottom = dimensionResource(R.dimen.navigation_bar_height)),
verticalArrangement = Arrangement.spacedBy(LocalPaddings.current.large)
) {
HomeRow(
list = trendingList.data.orEmpty(),
title = stringResource(Res.string.trending_now),
title = stringResource(R.string.trending_now),
onItemClicked = {
navigator.navigate(
MediaPageDestination(
Expand All @@ -180,7 +181,7 @@ fun Home(

HomeRow(
list = popularList.data.orEmpty(),
title = stringResource(Res.string.popular_this_season),
title = stringResource(R.string.popular_this_season),
onItemClicked = {
navigator.navigate(
MediaPageDestination(
Expand All @@ -197,7 +198,7 @@ fun Home(

HomeRow(
list = upcomingList.data.orEmpty(),
title = stringResource(Res.string.upcoming_next_season),
title = stringResource(R.string.upcoming_next_season),
onItemClicked = {
navigator.navigate(
MediaPageDestination(
Expand All @@ -214,7 +215,7 @@ fun Home(

HomeRow(
list = allTimePopularList.data.orEmpty(),
title = stringResource(Res.string.all_time_popular),
title = stringResource(R.string.all_time_popular),
onItemClicked = {
navigator.navigate(
MediaPageDestination(
Expand Down Expand Up @@ -260,11 +261,11 @@ fun HomeRow(
text = title,
style = MaterialTheme.typography.titleMedium,
modifier = Modifier
.padding(start = dimensionResource(Res.dimen.large_padding))
.padding(start = LocalPaddings.current.large)
.landscapeCutoutPadding()
)

Spacer(Modifier.size(dimensionResource(Res.dimen.medium_padding)))
Spacer(Modifier.size(LocalPaddings.current.medium))

MediaSmallRow(
mediaList = list,
Expand All @@ -273,7 +274,7 @@ fun HomeRow(
image = media.coverImage,
label = media.title,
onClick = { onItemClicked(media) },
modifier = Modifier.width(dimensionResource(Res.dimen.media_card_width))
modifier = Modifier.width(dimensionResource(R.dimen.media_card_width))
)
}
)
Expand All @@ -297,8 +298,8 @@ private fun MediaTypeSelector(
// Indicator
Surface(
modifier = Modifier
.padding(dimensionResource(Res.dimen.media_type_selector_padding))
.size(dimensionResource(Res.dimen.media_type_choice_size))
.padding(dimensionResource(R.dimen.media_type_selector_padding))
.size(dimensionResource(R.dimen.media_type_choice_size))
.offset(
animateDpAsState(
targetValue = if (selectedOption.value == MediaType.ANIME) 0.dp else 40.dp,
Expand All @@ -311,9 +312,9 @@ private fun MediaTypeSelector(

Row(
modifier = Modifier
.height(dimensionResource(Res.dimen.media_type_selector_height))
.width(dimensionResource(Res.dimen.media_type_selector_width))
.padding(dimensionResource(Res.dimen.media_type_selector_padding)),
.height(dimensionResource(R.dimen.media_type_selector_height))
.width(dimensionResource(R.dimen.media_type_selector_width))
.padding(dimensionResource(R.dimen.media_type_selector_padding)),
horizontalArrangement = Arrangement.spacedBy(4.dp),
verticalAlignment = Alignment.CenterVertically
) {
Expand All @@ -325,13 +326,13 @@ private fun MediaTypeSelector(
selectedOption.value = mediaType
}
},
modifier = Modifier.requiredWidth(dimensionResource(Res.dimen.media_type_choice_size))
modifier = Modifier.requiredWidth(dimensionResource(R.dimen.media_type_choice_size))
) {
Icon(
imageVector = if (mediaType == MediaType.ANIME) {
Icons.Rounded.PlayArrow
} else {
ImageVector.vectorResource(id = Res.drawable.manga)
ImageVector.vectorResource(id = R.drawable.manga)
},
contentDescription = mediaType.name,
tint = if (selectedOption.value == mediaType) {
Expand Down
52 changes: 26 additions & 26 deletions app/src/main/java/com/imashnake/animite/features/media/MediaPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,21 @@ import com.imashnake.animite.R
import com.imashnake.animite.api.anilist.sanitize.media.Media
import com.imashnake.animite.core.extensions.bannerParallax
import com.imashnake.animite.core.extensions.landscapeCutoutPadding
import com.imashnake.animite.core.ui.LocalPaddings
import com.imashnake.animite.core.ui.NestedScrollableContent
import com.imashnake.animite.core.ui.TranslucentStatusBarLayout
import com.imashnake.animite.dev.internal.Constants
import com.imashnake.animite.features.ui.MediaSmall
import com.imashnake.animite.features.ui.MediaSmallRow
import com.ramcosta.composedestinations.annotation.Destination
import com.imashnake.animite.R as Res

@Destination(navArgsDelegate = MediaPageArgs::class)
@Composable
fun MediaPage(
viewModel: MediaPageViewModel = hiltViewModel()
) {
val scrollState = rememberScrollState()
val bannerHeight = dimensionResource(Res.dimen.banner_height)
val bannerHeight = dimensionResource(R.dimen.banner_height)

val media = viewModel.uiState

Expand Down Expand Up @@ -114,31 +114,31 @@ fun MediaPage(
.fillMaxHeight()
.padding(top = bannerHeight)
.background(MaterialTheme.colorScheme.background)
.padding(bottom = dimensionResource(Res.dimen.large_padding))
.padding(bottom = LocalPaddings.current.large)
.navigationBarsPadding(),
verticalArrangement = Arrangement.spacedBy(dimensionResource(Res.dimen.large_padding))
verticalArrangement = Arrangement.spacedBy(LocalPaddings.current.large)
) {
MediaDetails(
title = media.title.orEmpty(),
description = media.description.orEmpty(),
// TODO Can we do something about this Modifier chain?
modifier = Modifier
.padding(
start = dimensionResource(Res.dimen.large_padding)
+ dimensionResource(Res.dimen.media_card_width)
+ dimensionResource(Res.dimen.large_padding),
top = dimensionResource(Res.dimen.medium_padding),
end = dimensionResource(Res.dimen.large_padding)
start = LocalPaddings.current.large
+ dimensionResource(R.dimen.media_card_width)
+ LocalPaddings.current.large,
top = LocalPaddings.current.medium,
end = LocalPaddings.current.large
)
.landscapeCutoutPadding()
.height(
WindowInsets.statusBars
.asPaddingValues()
.calculateTopPadding()
+ dimensionResource(Res.dimen.media_card_top_padding)
+ dimensionResource(Res.dimen.media_card_height)
- dimensionResource(Res.dimen.banner_height)
- dimensionResource(Res.dimen.medium_padding)
+ dimensionResource(R.dimen.media_card_top_padding)
+ dimensionResource(R.dimen.media_card_height)
- dimensionResource(R.dimen.banner_height)
- LocalPaddings.current.medium
)
.fillMaxSize()
)
Expand All @@ -148,7 +148,7 @@ fun MediaPage(
rankings = media.ranks,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = dimensionResource(Res.dimen.large_padding))
.padding(horizontal = LocalPaddings.current.large)
.landscapeCutoutPadding()
)
}
Expand All @@ -157,13 +157,13 @@ fun MediaPage(
MediaGenres(
genres = media.genres,
contentPadding = PaddingValues(
start = dimensionResource(Res.dimen.large_padding) + if (
start = LocalPaddings.current.large + if (
LocalConfiguration.current.orientation == Configuration.ORIENTATION_LANDSCAPE
) {
WindowInsets.displayCutout.asPaddingValues()
.calculateLeftPadding(LayoutDirection.Ltr)
} else 0.dp,
end = dimensionResource(Res.dimen.large_padding)
end = LocalPaddings.current.large
),
color = Color(media.color ?: (0xFF152232).toInt()),
)
Expand All @@ -172,15 +172,15 @@ fun MediaPage(
if (!media.characters.isNullOrEmpty()) {
MediaCharacters(
characters = media.characters,
contentPadding = PaddingValues(horizontal = dimensionResource(Res.dimen.large_padding))
contentPadding = PaddingValues(horizontal = LocalPaddings.current.large)
)
}

if (media.trailer != null) {
MediaTrailer(
trailer = media.trailer,
modifier = Modifier
.padding(horizontal = dimensionResource(Res.dimen.large_padding))
.padding(horizontal = LocalPaddings.current.large)
.landscapeCutoutPadding()
)
}
Expand All @@ -190,17 +190,17 @@ fun MediaPage(
modifier = Modifier
.statusBarsPadding()
.padding(
top = dimensionResource(Res.dimen.media_card_top_padding),
start = dimensionResource(Res.dimen.large_padding),
end = dimensionResource(Res.dimen.large_padding)
top = dimensionResource(R.dimen.media_card_top_padding),
start = LocalPaddings.current.large,
end = LocalPaddings.current.large
)
.landscapeCutoutPadding()
) {
MediaSmall(
image = media.coverImage,
label = null,
onClick = {},
modifier = Modifier.width(dimensionResource(Res.dimen.media_card_width))
modifier = Modifier.width(dimensionResource(R.dimen.media_card_width))
)
}
}
Expand Down Expand Up @@ -330,7 +330,7 @@ fun MediaGenres(
) {
LazyRow(
horizontalArrangement = Arrangement.spacedBy(
dimensionResource(R.dimen.medium_padding)
LocalPaddings.current.medium
),
contentPadding = contentPadding,
modifier = modifier
Expand All @@ -343,7 +343,7 @@ fun MediaGenres(
color = MaterialTheme.colorScheme.onBackground,
style = MaterialTheme.typography.labelMedium,
modifier = Modifier.padding(
vertical = dimensionResource(R.dimen.small_padding)
vertical = LocalPaddings.current.small
)
)
},
Expand Down Expand Up @@ -374,7 +374,7 @@ fun MediaCharacters(
.landscapeCutoutPadding()
)

Spacer(Modifier.size(dimensionResource(R.dimen.medium_padding)))
Spacer(Modifier.size(LocalPaddings.current.medium))

MediaSmallRow(
mediaList = characters
Expand All @@ -401,7 +401,7 @@ fun MediaTrailer(
style = MaterialTheme.typography.titleMedium
)

Spacer(Modifier.size(dimensionResource(R.dimen.medium_padding)))
Spacer(Modifier.size(LocalPaddings.current.medium))

val context = LocalContext.current
Box(
Expand Down
Loading

0 comments on commit 7a62675

Please sign in to comment.