From 9118cd2f855a96df7c59048944fb3efa0ba5a8e9 Mon Sep 17 00:00:00 2001 From: imashnake0 Date: Wed, 3 Jan 2024 00:48:03 -0500 Subject: [PATCH 1/7] R-class shenanigans and coming soon --- .../animite/features/MainActivity.kt | 8 +-- .../imashnake/animite/features/home/Home.kt | 57 ++++++++++--------- .../animite/features/media/MediaPage.kt | 52 ++++++++--------- .../features/searchbar/SearchFrontDrop.kt | 17 +++--- .../animite/features/ui/MediaSmall.kt | 23 ++++---- app/src/main/res/values/dimens.xml | 7 --- core/src/main/res/values/dimens.xml | 7 +++ .../animite/profile/ProfileScreen.kt | 19 ++++++- .../imashnake/animite/rslash/RSlashScreen.kt | 20 ++++++- 9 files changed, 123 insertions(+), 87 deletions(-) diff --git a/app/src/main/java/com/imashnake/animite/features/MainActivity.kt b/app/src/main/java/com/imashnake/animite/features/MainActivity.kt index f3852bad..9eecd220 100644 --- a/app/src/main/java/com/imashnake/animite/features/MainActivity.kt +++ b/app/src/main/java/com/imashnake/animite/features/MainActivity.kt @@ -27,7 +27,7 @@ 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.R as coreR import com.imashnake.animite.features.destinations.MediaPageDestination import com.imashnake.animite.features.media.MediaPageArgs import com.imashnake.animite.features.navigationbar.NavigationBar @@ -107,9 +107,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 = dimensionResource(coreR.dimen.large_padding), + end = dimensionResource(coreR.dimen.large_padding), + bottom = dimensionResource(coreR.dimen.large_padding) ) ) diff --git a/app/src/main/java/com/imashnake/animite/features/home/Home.kt b/app/src/main/java/com/imashnake/animite/features/home/Home.kt index acdb6755..193cf900 100644 --- a/app/src/main/java/com/imashnake/animite/features/home/Home.kt +++ b/app/src/main/java/com/imashnake/animite/features/home/Home.kt @@ -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.core.R as coreR +import com.imashnake.animite.R @Destination @Composable @@ -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 @@ -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 @@ -115,7 +116,7 @@ fun Home( ) ) .fillMaxWidth() - .height(dimensionResource(Res.dimen.banner_height)) + .height(dimensionResource(R.dimen.banner_height)) ) { } Row( @@ -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 = dimensionResource(coreR.dimen.large_padding), + bottom = dimensionResource(coreR.dimen.medium_padding) ) .landscapeCutoutPadding() .weight(1f, fill = false), @@ -140,8 +141,8 @@ fun Home( MediaTypeSelector( modifier = Modifier .padding( - end = dimensionResource(Res.dimen.large_padding), - bottom = dimensionResource(Res.dimen.medium_padding) + end = dimensionResource(coreR.dimen.large_padding), + bottom = dimensionResource(coreR.dimen.medium_padding) ) .landscapeCutoutPadding(), selectedOption = homeMediaType, @@ -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 = dimensionResource(coreR.dimen.large_padding)) // 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(dimensionResource(coreR.dimen.large_padding)) ) { HomeRow( list = trendingList.data.orEmpty(), - title = stringResource(Res.string.trending_now), + title = stringResource(R.string.trending_now), onItemClicked = { navigator.navigate( MediaPageDestination( @@ -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( @@ -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( @@ -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( @@ -260,11 +261,11 @@ fun HomeRow( text = title, style = MaterialTheme.typography.titleMedium, modifier = Modifier - .padding(start = dimensionResource(Res.dimen.large_padding)) + .padding(start = dimensionResource(coreR.dimen.large_padding)) .landscapeCutoutPadding() ) - Spacer(Modifier.size(dimensionResource(Res.dimen.medium_padding))) + Spacer(Modifier.size(dimensionResource(coreR.dimen.medium_padding))) MediaSmallRow( mediaList = list, @@ -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)) ) } ) @@ -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, @@ -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 ) { @@ -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) { diff --git a/app/src/main/java/com/imashnake/animite/features/media/MediaPage.kt b/app/src/main/java/com/imashnake/animite/features/media/MediaPage.kt index 2dc5c065..69e70685 100644 --- a/app/src/main/java/com/imashnake/animite/features/media/MediaPage.kt +++ b/app/src/main/java/com/imashnake/animite/features/media/MediaPage.kt @@ -66,6 +66,7 @@ import androidx.core.text.HtmlCompat import androidx.hilt.navigation.compose.hiltViewModel import coil.compose.AsyncImage import coil.request.ImageRequest +import com.imashnake.animite.core.R as coreR import com.imashnake.animite.R import com.imashnake.animite.api.anilist.sanitize.media.Media import com.imashnake.animite.core.extensions.bannerParallax @@ -76,7 +77,6 @@ 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 @@ -84,7 +84,7 @@ 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 @@ -114,9 +114,9 @@ fun MediaPage( .fillMaxHeight() .padding(top = bannerHeight) .background(MaterialTheme.colorScheme.background) - .padding(bottom = dimensionResource(Res.dimen.large_padding)) + .padding(bottom = dimensionResource(coreR.dimen.large_padding)) .navigationBarsPadding(), - verticalArrangement = Arrangement.spacedBy(dimensionResource(Res.dimen.large_padding)) + verticalArrangement = Arrangement.spacedBy(dimensionResource(coreR.dimen.large_padding)) ) { MediaDetails( title = media.title.orEmpty(), @@ -124,21 +124,21 @@ fun MediaPage( // 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 = dimensionResource(coreR.dimen.large_padding) + + dimensionResource(R.dimen.media_card_width) + + dimensionResource(coreR.dimen.large_padding), + top = dimensionResource(coreR.dimen.medium_padding), + end = dimensionResource(coreR.dimen.large_padding) ) .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) + - dimensionResource(coreR.dimen.medium_padding) ) .fillMaxSize() ) @@ -148,7 +148,7 @@ fun MediaPage( rankings = media.ranks, modifier = Modifier .fillMaxWidth() - .padding(horizontal = dimensionResource(Res.dimen.large_padding)) + .padding(horizontal = dimensionResource(coreR.dimen.large_padding)) .landscapeCutoutPadding() ) } @@ -157,13 +157,13 @@ fun MediaPage( MediaGenres( genres = media.genres, contentPadding = PaddingValues( - start = dimensionResource(Res.dimen.large_padding) + if ( + start = dimensionResource(coreR.dimen.large_padding) + if ( LocalConfiguration.current.orientation == Configuration.ORIENTATION_LANDSCAPE ) { WindowInsets.displayCutout.asPaddingValues() .calculateLeftPadding(LayoutDirection.Ltr) } else 0.dp, - end = dimensionResource(Res.dimen.large_padding) + end = dimensionResource(coreR.dimen.large_padding) ), color = Color(media.color ?: (0xFF152232).toInt()), ) @@ -172,7 +172,7 @@ fun MediaPage( if (!media.characters.isNullOrEmpty()) { MediaCharacters( characters = media.characters, - contentPadding = PaddingValues(horizontal = dimensionResource(Res.dimen.large_padding)) + contentPadding = PaddingValues(horizontal = dimensionResource(coreR.dimen.large_padding)) ) } @@ -180,7 +180,7 @@ fun MediaPage( MediaTrailer( trailer = media.trailer, modifier = Modifier - .padding(horizontal = dimensionResource(Res.dimen.large_padding)) + .padding(horizontal = dimensionResource(coreR.dimen.large_padding)) .landscapeCutoutPadding() ) } @@ -190,9 +190,9 @@ 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 = dimensionResource(coreR.dimen.large_padding), + end = dimensionResource(coreR.dimen.large_padding) ) .landscapeCutoutPadding() ) { @@ -200,7 +200,7 @@ fun MediaPage( image = media.coverImage, label = null, onClick = {}, - modifier = Modifier.width(dimensionResource(Res.dimen.media_card_width)) + modifier = Modifier.width(dimensionResource(R.dimen.media_card_width)) ) } } @@ -330,7 +330,7 @@ fun MediaGenres( ) { LazyRow( horizontalArrangement = Arrangement.spacedBy( - dimensionResource(R.dimen.medium_padding) + dimensionResource(coreR.dimen.medium_padding) ), contentPadding = contentPadding, modifier = modifier @@ -343,7 +343,7 @@ fun MediaGenres( color = MaterialTheme.colorScheme.onBackground, style = MaterialTheme.typography.labelMedium, modifier = Modifier.padding( - vertical = dimensionResource(R.dimen.small_padding) + vertical = dimensionResource(coreR.dimen.small_padding) ) ) }, @@ -374,7 +374,7 @@ fun MediaCharacters( .landscapeCutoutPadding() ) - Spacer(Modifier.size(dimensionResource(R.dimen.medium_padding))) + Spacer(Modifier.size(dimensionResource(coreR.dimen.medium_padding))) MediaSmallRow( mediaList = characters @@ -401,7 +401,7 @@ fun MediaTrailer( style = MaterialTheme.typography.titleMedium ) - Spacer(Modifier.size(dimensionResource(R.dimen.medium_padding))) + Spacer(Modifier.size(dimensionResource(coreR.dimen.medium_padding))) val context = LocalContext.current Box( diff --git a/app/src/main/java/com/imashnake/animite/features/searchbar/SearchFrontDrop.kt b/app/src/main/java/com/imashnake/animite/features/searchbar/SearchFrontDrop.kt index 0343fb3c..1ad8cadb 100644 --- a/app/src/main/java/com/imashnake/animite/features/searchbar/SearchFrontDrop.kt +++ b/app/src/main/java/com/imashnake/animite/features/searchbar/SearchFrontDrop.kt @@ -46,6 +46,7 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.lifecycle.viewmodel.compose.viewModel +import com.imashnake.animite.core.R as coreR import com.imashnake.animite.R import com.imashnake.animite.api.anilist.sanitize.search.Search import com.imashnake.animite.api.anilist.type.MediaType @@ -135,17 +136,17 @@ fun SearchList( LazyColumn( modifier = modifier, contentPadding = PaddingValues( - start = dimensionResource(R.dimen.large_padding), - end = dimensionResource(R.dimen.large_padding), - top = dimensionResource(R.dimen.large_padding) + start = dimensionResource(coreR.dimen.large_padding), + end = dimensionResource(coreR.dimen.large_padding), + top = dimensionResource(coreR.dimen.large_padding) + WindowInsets.statusBars.asPaddingValues().calculateTopPadding(), bottom = dimensionResource(R.dimen.search_bar_height) - + dimensionResource(R.dimen.large_padding) - + dimensionResource(R.dimen.large_padding) + + dimensionResource(coreR.dimen.large_padding) + + dimensionResource(coreR.dimen.large_padding) + dimensionResource(R.dimen.navigation_bar_height) + WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding() ), - verticalArrangement = Arrangement.spacedBy(dimensionResource(R.dimen.small_padding)) + verticalArrangement = Arrangement.spacedBy(dimensionResource(coreR.dimen.small_padding)) ) { items(searchList.size, key = { searchList[it].id }) { index -> SearchItem( @@ -175,7 +176,7 @@ private fun SearchItem( modifier = Modifier.width(dimensionResource(R.dimen.character_card_width)) ) - Column(Modifier.padding(horizontal = dimensionResource(R.dimen.small_padding))) { + Column(Modifier.padding(horizontal = dimensionResource(coreR.dimen.small_padding))) { Text( text = item.title.orEmpty(), color = MaterialTheme.colorScheme.onBackground, @@ -192,7 +193,7 @@ private fun SearchItem( ) } - Spacer(Modifier.size(dimensionResource(R.dimen.medium_padding))) + Spacer(Modifier.size(dimensionResource(coreR.dimen.medium_padding))) Text( text = item.studios.joinToString(), diff --git a/app/src/main/java/com/imashnake/animite/features/ui/MediaSmall.kt b/app/src/main/java/com/imashnake/animite/features/ui/MediaSmall.kt index a0d090f1..81c7846b 100644 --- a/app/src/main/java/com/imashnake/animite/features/ui/MediaSmall.kt +++ b/app/src/main/java/com/imashnake/animite/features/ui/MediaSmall.kt @@ -36,7 +36,8 @@ import coil.request.ImageRequest import com.imashnake.animite.api.anilist.MediaListQuery import com.imashnake.animite.api.anilist.type.MediaType import com.imashnake.animite.dev.internal.Constants.CROSSFADE_DURATION -import com.imashnake.animite.R as Res +import com.imashnake.animite.core.R as coreR +import com.imashnake.animite.R /** * A [LazyRow] of [MediaSmall]s. @@ -49,14 +50,14 @@ fun MediaSmallRow( content: @Composable (T) -> Unit ) { LazyRow( - horizontalArrangement = Arrangement.spacedBy(dimensionResource(Res.dimen.small_padding)), + horizontalArrangement = Arrangement.spacedBy(dimensionResource(coreR.dimen.small_padding)), contentPadding = PaddingValues( - start = dimensionResource(Res.dimen.large_padding) + if ( + start = dimensionResource(coreR.dimen.large_padding) + if ( LocalConfiguration.current.orientation == Configuration.ORIENTATION_LANDSCAPE ) { WindowInsets.displayCutout.asPaddingValues().calculateLeftPadding(LayoutDirection.Ltr) } else 0.dp, - end = dimensionResource(Res.dimen.large_padding) + end = dimensionResource(coreR.dimen.large_padding) ) ) { items(mediaList) { media -> @@ -85,7 +86,7 @@ fun MediaSmall( colors = CardDefaults.cardColors( containerColor = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.3f) ), - shape = RoundedCornerShape(dimensionResource(Res.dimen.media_card_corner_radius)) + shape = RoundedCornerShape(dimensionResource(R.dimen.media_card_corner_radius)) ) { AsyncImage( model = ImageRequest.Builder(LocalContext.current) @@ -97,7 +98,7 @@ fun MediaSmall( modifier = Modifier .fillMaxWidth() .aspectRatio(0.7f) - .clip(RoundedCornerShape(dimensionResource(Res.dimen.media_card_corner_radius))) + .clip(RoundedCornerShape(dimensionResource(R.dimen.media_card_corner_radius))) ) if (label != null) @@ -108,7 +109,7 @@ fun MediaSmall( style = MaterialTheme.typography.labelLarge, maxLines = 2, modifier = Modifier.padding( - vertical = dimensionResource(Res.dimen.media_card_text_padding_vertical) + vertical = dimensionResource(R.dimen.media_card_text_padding_vertical) ) ) @@ -125,8 +126,8 @@ fun MediaSmall( .align(Alignment.Center) .fillMaxWidth() .padding( - horizontal = dimensionResource(Res.dimen.media_card_text_padding_horizontal), - vertical = dimensionResource(Res.dimen.media_card_text_padding_vertical) + horizontal = dimensionResource(R.dimen.media_card_text_padding_horizontal), + vertical = dimensionResource(R.dimen.media_card_text_padding_vertical) ) ) } @@ -160,7 +161,7 @@ fun PreviewMediaSmallRow() { media.title?.english ?: media.title?.native ?: "", onClick = { }, - modifier = Modifier.width(dimensionResource(Res.dimen.media_card_width)) + modifier = Modifier.width(dimensionResource(R.dimen.media_card_width)) ) } ) @@ -175,6 +176,6 @@ fun PreviewMediaSmall() { label = "Sono Bisque Doll wa Koi wo Suru", onClick = { }, - modifier = Modifier.width(dimensionResource(Res.dimen.media_card_width)) + modifier = Modifier.width(dimensionResource(R.dimen.media_card_width)) ) } diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 71715e67..e07e6db8 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -1,12 +1,5 @@ - 0dp - 4dp - 4dp - 8dp - 16dp - 24dp - 18dp 16dp 10dp diff --git a/core/src/main/res/values/dimens.xml b/core/src/main/res/values/dimens.xml index ad19b7f3..3a928496 100644 --- a/core/src/main/res/values/dimens.xml +++ b/core/src/main/res/values/dimens.xml @@ -1,5 +1,12 @@ + 0dp + 4dp + 4dp + 8dp + 16dp + 24dp + 100dp 3dp diff --git a/profile/src/main/kotlin/com/imashnake/animite/profile/ProfileScreen.kt b/profile/src/main/kotlin/com/imashnake/animite/profile/ProfileScreen.kt index aac175a4..a52ce052 100644 --- a/profile/src/main/kotlin/com/imashnake/animite/profile/ProfileScreen.kt +++ b/profile/src/main/kotlin/com/imashnake/animite/profile/ProfileScreen.kt @@ -1,12 +1,17 @@ package com.imashnake.animite.profile import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.res.dimensionResource +import com.imashnake.animite.core.R as coreR import com.imashnake.animite.core.ui.ProgressIndicator import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.annotation.RootNavGraph @@ -21,6 +26,18 @@ fun ProfileScreen() { .fillMaxSize() .background(MaterialTheme.colorScheme.background) ) { - ProgressIndicator() + Column( + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.spacedBy( + dimensionResource(coreR.dimen.large_padding) + ) + ) { + Text( + text = "Coming Soon", + color = MaterialTheme.colorScheme.onSurfaceVariant, + style = MaterialTheme.typography.labelLarge + ) + ProgressIndicator() + } } } diff --git a/rslash/src/main/kotlin/com/imashnake/animite/rslash/RSlashScreen.kt b/rslash/src/main/kotlin/com/imashnake/animite/rslash/RSlashScreen.kt index 8cccfeab..65e887b3 100644 --- a/rslash/src/main/kotlin/com/imashnake/animite/rslash/RSlashScreen.kt +++ b/rslash/src/main/kotlin/com/imashnake/animite/rslash/RSlashScreen.kt @@ -1,17 +1,21 @@ package com.imashnake.animite.rslash import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.res.dimensionResource +import com.imashnake.animite.core.R as coreR import com.imashnake.animite.core.ui.ProgressIndicator import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.annotation.RootNavGraph -// TODO: Add transitions as we did for `Profile`. @RootNavGraph(start = true) @Destination(route = "rslash-screen") @Composable @@ -22,6 +26,18 @@ fun RSlashScreen() { .fillMaxSize() .background(MaterialTheme.colorScheme.background) ) { - ProgressIndicator() + Column( + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.spacedBy( + dimensionResource(coreR.dimen.tiny_padding) + ) + ) { + Text( + text = "Coming Soon", + color = MaterialTheme.colorScheme.onSurfaceVariant, + style = MaterialTheme.typography.labelLarge + ) + ProgressIndicator() + } } } From 26dcd5c6ef4c3befbed9d4b11540e853749d4169 Mon Sep 17 00:00:00 2001 From: imashnake0 Date: Wed, 3 Jan 2024 00:59:05 -0500 Subject: [PATCH 2/7] bruh --- .../main/kotlin/com/imashnake/animite/profile/ProfileScreen.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profile/src/main/kotlin/com/imashnake/animite/profile/ProfileScreen.kt b/profile/src/main/kotlin/com/imashnake/animite/profile/ProfileScreen.kt index a52ce052..18fd74ea 100644 --- a/profile/src/main/kotlin/com/imashnake/animite/profile/ProfileScreen.kt +++ b/profile/src/main/kotlin/com/imashnake/animite/profile/ProfileScreen.kt @@ -29,7 +29,7 @@ fun ProfileScreen() { Column( horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy( - dimensionResource(coreR.dimen.large_padding) + dimensionResource(coreR.dimen.tiny_padding) ) ) { Text( From 0c77ebdb03e06ce55fa31ebe82a3c099f45e6092 Mon Sep 17 00:00:00 2001 From: imashnake0 Date: Wed, 3 Jan 2024 01:04:08 -0500 Subject: [PATCH 3/7] No hard-coded strings --- core/src/main/res/values/strings.xml | 4 ++++ .../kotlin/com/imashnake/animite/profile/ProfileScreen.kt | 3 ++- .../main/kotlin/com/imashnake/animite/rslash/RSlashScreen.kt | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 core/src/main/res/values/strings.xml diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml new file mode 100644 index 00000000..18fb4866 --- /dev/null +++ b/core/src/main/res/values/strings.xml @@ -0,0 +1,4 @@ + + + Coming Soon + diff --git a/profile/src/main/kotlin/com/imashnake/animite/profile/ProfileScreen.kt b/profile/src/main/kotlin/com/imashnake/animite/profile/ProfileScreen.kt index 18fd74ea..abb48424 100644 --- a/profile/src/main/kotlin/com/imashnake/animite/profile/ProfileScreen.kt +++ b/profile/src/main/kotlin/com/imashnake/animite/profile/ProfileScreen.kt @@ -11,6 +11,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.dimensionResource +import androidx.compose.ui.res.stringResource import com.imashnake.animite.core.R as coreR import com.imashnake.animite.core.ui.ProgressIndicator import com.ramcosta.composedestinations.annotation.Destination @@ -33,7 +34,7 @@ fun ProfileScreen() { ) ) { Text( - text = "Coming Soon", + text = stringResource(coreR.string.coming_soon), color = MaterialTheme.colorScheme.onSurfaceVariant, style = MaterialTheme.typography.labelLarge ) diff --git a/rslash/src/main/kotlin/com/imashnake/animite/rslash/RSlashScreen.kt b/rslash/src/main/kotlin/com/imashnake/animite/rslash/RSlashScreen.kt index 65e887b3..39ec3bb6 100644 --- a/rslash/src/main/kotlin/com/imashnake/animite/rslash/RSlashScreen.kt +++ b/rslash/src/main/kotlin/com/imashnake/animite/rslash/RSlashScreen.kt @@ -11,6 +11,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.dimensionResource +import androidx.compose.ui.res.stringResource import com.imashnake.animite.core.R as coreR import com.imashnake.animite.core.ui.ProgressIndicator import com.ramcosta.composedestinations.annotation.Destination @@ -33,7 +34,7 @@ fun RSlashScreen() { ) ) { Text( - text = "Coming Soon", + text = stringResource(coreR.string.coming_soon), color = MaterialTheme.colorScheme.onSurfaceVariant, style = MaterialTheme.typography.labelLarge ) From 9bde7581bcc8373e1836d45c82860e15faff50cd Mon Sep 17 00:00:00 2001 From: imashnake0 Date: Wed, 3 Jan 2024 02:14:02 -0500 Subject: [PATCH 4/7] Fixed progress indicator cap --- .../com/imashnake/animite/core/ui/ProgressIndicator.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/src/main/kotlin/com/imashnake/animite/core/ui/ProgressIndicator.kt b/core/src/main/kotlin/com/imashnake/animite/core/ui/ProgressIndicator.kt index 04b77502..49979cf0 100644 --- a/core/src/main/kotlin/com/imashnake/animite/core/ui/ProgressIndicator.kt +++ b/core/src/main/kotlin/com/imashnake/animite/core/ui/ProgressIndicator.kt @@ -8,6 +8,7 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.StrokeCap import androidx.compose.ui.res.dimensionResource import com.imashnake.animite.core.R @@ -15,10 +16,8 @@ import com.imashnake.animite.core.R fun ProgressIndicator() { LinearProgressIndicator( modifier = Modifier - .clip(CircleShape) .width(dimensionResource(R.dimen.progress_indicator_width)) .height(dimensionResource(R.dimen.progress_indicator_height)), - color = MaterialTheme.colorScheme.background, - trackColor = MaterialTheme.colorScheme.primary + strokeCap = StrokeCap.Round ) } From 80a32973150d072c3f6b104b89c8cad2dc0db708 Mon Sep 17 00:00:00 2001 From: imashnake0 Date: Wed, 3 Jan 2024 02:17:21 -0500 Subject: [PATCH 5/7] Cleanup --- .../kotlin/com/imashnake/animite/core/ui/ProgressIndicator.kt | 3 --- 1 file changed, 3 deletions(-) diff --git a/core/src/main/kotlin/com/imashnake/animite/core/ui/ProgressIndicator.kt b/core/src/main/kotlin/com/imashnake/animite/core/ui/ProgressIndicator.kt index 49979cf0..fb784787 100644 --- a/core/src/main/kotlin/com/imashnake/animite/core/ui/ProgressIndicator.kt +++ b/core/src/main/kotlin/com/imashnake/animite/core/ui/ProgressIndicator.kt @@ -2,12 +2,9 @@ package com.imashnake.animite.core.ui import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.width -import androidx.compose.foundation.shape.CircleShape import androidx.compose.material3.LinearProgressIndicator -import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.StrokeCap import androidx.compose.ui.res.dimensionResource import com.imashnake.animite.core.R From c9d8319ce3112dbd391bc5b3eebe3a9e9a6bea1a Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Wed, 3 Jan 2024 20:27:13 +1300 Subject: [PATCH 6/7] Introduce Paddings --- .../imashnake/animite/features/theme/Theme.kt | 9 ++++- .../com/imashnake/animite/core/ui/Paddings.kt | 35 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 core/src/main/kotlin/com/imashnake/animite/core/ui/Paddings.kt diff --git a/app/src/main/java/com/imashnake/animite/features/theme/Theme.kt b/app/src/main/java/com/imashnake/animite/features/theme/Theme.kt index ba10def8..14f744e4 100644 --- a/app/src/main/java/com/imashnake/animite/features/theme/Theme.kt +++ b/app/src/main/java/com/imashnake/animite/features/theme/Theme.kt @@ -12,10 +12,16 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.Immutable import androidx.compose.ui.platform.LocalContext +import com.imashnake.animite.core.ui.LocalPaddings +import com.imashnake.animite.core.ui.Paddings +import com.imashnake.animite.core.ui.rememberDefaultPaddings import com.imashnake.animite.dev.ext.pastelize @Composable -fun AnimiteTheme(content: @Composable () -> Unit) { +fun AnimiteTheme( + paddings: Paddings = rememberDefaultPaddings(), + content: @Composable () -> Unit +) { val dynamicColor = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S val darkTheme = isSystemInDarkTheme() val animiteColorScheme = when { @@ -33,6 +39,7 @@ fun AnimiteTheme(content: @Composable () -> Unit) { ) { CompositionLocalProvider( LocalRippleTheme provides AnimiteRippleTheme, + LocalPaddings provides paddings, content = content ) } diff --git a/core/src/main/kotlin/com/imashnake/animite/core/ui/Paddings.kt b/core/src/main/kotlin/com/imashnake/animite/core/ui/Paddings.kt new file mode 100644 index 00000000..14ab809b --- /dev/null +++ b/core/src/main/kotlin/com/imashnake/animite/core/ui/Paddings.kt @@ -0,0 +1,35 @@ +package com.imashnake.animite.core.ui + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.runtime.staticCompositionLocalOf +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.dimensionResource +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp +import com.imashnake.animite.core.R + +data class Paddings( + val ultraTiny: Dp, + val tiny: Dp, + val small: Dp, + val medium: Dp, + val large: Dp +) { + companion object { + val ZERO = 0.dp + } +} + +val LocalPaddings = staticCompositionLocalOf { error("Paddings must be set!") } + +@Composable +fun rememberDefaultPaddings(): Paddings { + return Paddings( + ultraTiny = dimensionResource(R.dimen.ultra_tiny_padding), + tiny = dimensionResource(R.dimen.tiny_padding), + small = dimensionResource(R.dimen.small_padding), + medium = dimensionResource(R.dimen.medium_padding), + large = dimensionResource(R.dimen.large_padding) + ) +} From ff11a6a1f99c66d51abb90dd7f5707cfb63c9a81 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Wed, 3 Jan 2024 20:37:27 +1300 Subject: [PATCH 7/7] Migrate to Paddings --- .../animite/features/MainActivity.kt | 9 ++--- .../imashnake/animite/features/home/Home.kt | 18 ++++----- .../animite/features/media/MediaPage.kt | 38 +++++++++---------- .../features/searchbar/SearchFrontDrop.kt | 18 ++++----- .../animite/features/ui/MediaSmall.kt | 8 ++-- .../animite/profile/ProfileScreen.kt | 4 +- .../imashnake/animite/rslash/RSlashScreen.kt | 4 +- 7 files changed, 49 insertions(+), 50 deletions(-) diff --git a/app/src/main/java/com/imashnake/animite/features/MainActivity.kt b/app/src/main/java/com/imashnake/animite/features/MainActivity.kt index 9eecd220..31453bca 100644 --- a/app/src/main/java/com/imashnake/animite/features/MainActivity.kt +++ b/app/src/main/java/com/imashnake/animite/features/MainActivity.kt @@ -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.core.R as coreR +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 @@ -107,9 +106,9 @@ fun MainScreen(modifier: Modifier = Modifier) { modifier = Modifier .align(Alignment.BottomEnd) .padding( - start = dimensionResource(coreR.dimen.large_padding), - end = dimensionResource(coreR.dimen.large_padding), - bottom = dimensionResource(coreR.dimen.large_padding) + start = LocalPaddings.current.large, + end = LocalPaddings.current.large, + bottom = LocalPaddings.current.large ) ) diff --git a/app/src/main/java/com/imashnake/animite/features/home/Home.kt b/app/src/main/java/com/imashnake/animite/features/home/Home.kt index 193cf900..556f3ab2 100644 --- a/app/src/main/java/com/imashnake/animite/features/home/Home.kt +++ b/app/src/main/java/com/imashnake/animite/features/home/Home.kt @@ -58,8 +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.core.R as coreR import com.imashnake.animite.R +import com.imashnake.animite.core.ui.LocalPaddings @Destination @Composable @@ -130,8 +130,8 @@ fun Home( style = MaterialTheme.typography.displayMedium, modifier = Modifier .padding( - start = dimensionResource(coreR.dimen.large_padding), - bottom = dimensionResource(coreR.dimen.medium_padding) + start = LocalPaddings.current.large, + bottom = LocalPaddings.current.medium ) .landscapeCutoutPadding() .weight(1f, fill = false), @@ -141,8 +141,8 @@ fun Home( MediaTypeSelector( modifier = Modifier .padding( - end = dimensionResource(coreR.dimen.large_padding), - bottom = dimensionResource(coreR.dimen.medium_padding) + end = LocalPaddings.current.large, + bottom = LocalPaddings.current.medium ) .landscapeCutoutPadding(), selectedOption = homeMediaType, @@ -157,10 +157,10 @@ fun Home( Column( modifier = Modifier .background(MaterialTheme.colorScheme.background) - .padding(vertical = dimensionResource(coreR.dimen.large_padding)) + .padding(vertical = LocalPaddings.current.large) // TODO: Move this one out of Home when we can pass modifiers in. .padding(bottom = dimensionResource(R.dimen.navigation_bar_height)), - verticalArrangement = Arrangement.spacedBy(dimensionResource(coreR.dimen.large_padding)) + verticalArrangement = Arrangement.spacedBy(LocalPaddings.current.large) ) { HomeRow( list = trendingList.data.orEmpty(), @@ -261,11 +261,11 @@ fun HomeRow( text = title, style = MaterialTheme.typography.titleMedium, modifier = Modifier - .padding(start = dimensionResource(coreR.dimen.large_padding)) + .padding(start = LocalPaddings.current.large) .landscapeCutoutPadding() ) - Spacer(Modifier.size(dimensionResource(coreR.dimen.medium_padding))) + Spacer(Modifier.size(LocalPaddings.current.medium)) MediaSmallRow( mediaList = list, diff --git a/app/src/main/java/com/imashnake/animite/features/media/MediaPage.kt b/app/src/main/java/com/imashnake/animite/features/media/MediaPage.kt index 69e70685..83f2b692 100644 --- a/app/src/main/java/com/imashnake/animite/features/media/MediaPage.kt +++ b/app/src/main/java/com/imashnake/animite/features/media/MediaPage.kt @@ -66,11 +66,11 @@ import androidx.core.text.HtmlCompat import androidx.hilt.navigation.compose.hiltViewModel import coil.compose.AsyncImage import coil.request.ImageRequest -import com.imashnake.animite.core.R as coreR 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 @@ -114,9 +114,9 @@ fun MediaPage( .fillMaxHeight() .padding(top = bannerHeight) .background(MaterialTheme.colorScheme.background) - .padding(bottom = dimensionResource(coreR.dimen.large_padding)) + .padding(bottom = LocalPaddings.current.large) .navigationBarsPadding(), - verticalArrangement = Arrangement.spacedBy(dimensionResource(coreR.dimen.large_padding)) + verticalArrangement = Arrangement.spacedBy(LocalPaddings.current.large) ) { MediaDetails( title = media.title.orEmpty(), @@ -124,11 +124,11 @@ fun MediaPage( // TODO Can we do something about this Modifier chain? modifier = Modifier .padding( - start = dimensionResource(coreR.dimen.large_padding) + start = LocalPaddings.current.large + dimensionResource(R.dimen.media_card_width) - + dimensionResource(coreR.dimen.large_padding), - top = dimensionResource(coreR.dimen.medium_padding), - end = dimensionResource(coreR.dimen.large_padding) + + LocalPaddings.current.large, + top = LocalPaddings.current.medium, + end = LocalPaddings.current.large ) .landscapeCutoutPadding() .height( @@ -138,7 +138,7 @@ fun MediaPage( + dimensionResource(R.dimen.media_card_top_padding) + dimensionResource(R.dimen.media_card_height) - dimensionResource(R.dimen.banner_height) - - dimensionResource(coreR.dimen.medium_padding) + - LocalPaddings.current.medium ) .fillMaxSize() ) @@ -148,7 +148,7 @@ fun MediaPage( rankings = media.ranks, modifier = Modifier .fillMaxWidth() - .padding(horizontal = dimensionResource(coreR.dimen.large_padding)) + .padding(horizontal = LocalPaddings.current.large) .landscapeCutoutPadding() ) } @@ -157,13 +157,13 @@ fun MediaPage( MediaGenres( genres = media.genres, contentPadding = PaddingValues( - start = dimensionResource(coreR.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(coreR.dimen.large_padding) + end = LocalPaddings.current.large ), color = Color(media.color ?: (0xFF152232).toInt()), ) @@ -172,7 +172,7 @@ fun MediaPage( if (!media.characters.isNullOrEmpty()) { MediaCharacters( characters = media.characters, - contentPadding = PaddingValues(horizontal = dimensionResource(coreR.dimen.large_padding)) + contentPadding = PaddingValues(horizontal = LocalPaddings.current.large) ) } @@ -180,7 +180,7 @@ fun MediaPage( MediaTrailer( trailer = media.trailer, modifier = Modifier - .padding(horizontal = dimensionResource(coreR.dimen.large_padding)) + .padding(horizontal = LocalPaddings.current.large) .landscapeCutoutPadding() ) } @@ -191,8 +191,8 @@ fun MediaPage( .statusBarsPadding() .padding( top = dimensionResource(R.dimen.media_card_top_padding), - start = dimensionResource(coreR.dimen.large_padding), - end = dimensionResource(coreR.dimen.large_padding) + start = LocalPaddings.current.large, + end = LocalPaddings.current.large ) .landscapeCutoutPadding() ) { @@ -330,7 +330,7 @@ fun MediaGenres( ) { LazyRow( horizontalArrangement = Arrangement.spacedBy( - dimensionResource(coreR.dimen.medium_padding) + LocalPaddings.current.medium ), contentPadding = contentPadding, modifier = modifier @@ -343,7 +343,7 @@ fun MediaGenres( color = MaterialTheme.colorScheme.onBackground, style = MaterialTheme.typography.labelMedium, modifier = Modifier.padding( - vertical = dimensionResource(coreR.dimen.small_padding) + vertical = LocalPaddings.current.small ) ) }, @@ -374,7 +374,7 @@ fun MediaCharacters( .landscapeCutoutPadding() ) - Spacer(Modifier.size(dimensionResource(coreR.dimen.medium_padding))) + Spacer(Modifier.size(LocalPaddings.current.medium)) MediaSmallRow( mediaList = characters @@ -401,7 +401,7 @@ fun MediaTrailer( style = MaterialTheme.typography.titleMedium ) - Spacer(Modifier.size(dimensionResource(coreR.dimen.medium_padding))) + Spacer(Modifier.size(LocalPaddings.current.medium)) val context = LocalContext.current Box( diff --git a/app/src/main/java/com/imashnake/animite/features/searchbar/SearchFrontDrop.kt b/app/src/main/java/com/imashnake/animite/features/searchbar/SearchFrontDrop.kt index 1ad8cadb..5da9982d 100644 --- a/app/src/main/java/com/imashnake/animite/features/searchbar/SearchFrontDrop.kt +++ b/app/src/main/java/com/imashnake/animite/features/searchbar/SearchFrontDrop.kt @@ -46,11 +46,11 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.lifecycle.viewmodel.compose.viewModel -import com.imashnake.animite.core.R as coreR import com.imashnake.animite.R import com.imashnake.animite.api.anilist.sanitize.search.Search import com.imashnake.animite.api.anilist.type.MediaType import com.imashnake.animite.core.extensions.landscapeCutoutPadding +import com.imashnake.animite.core.ui.LocalPaddings import com.imashnake.animite.dev.internal.Constants import com.imashnake.animite.features.ui.MediaSmall @@ -136,17 +136,17 @@ fun SearchList( LazyColumn( modifier = modifier, contentPadding = PaddingValues( - start = dimensionResource(coreR.dimen.large_padding), - end = dimensionResource(coreR.dimen.large_padding), - top = dimensionResource(coreR.dimen.large_padding) + start = LocalPaddings.current.large, + end = LocalPaddings.current.large, + top = LocalPaddings.current.large + WindowInsets.statusBars.asPaddingValues().calculateTopPadding(), bottom = dimensionResource(R.dimen.search_bar_height) - + dimensionResource(coreR.dimen.large_padding) - + dimensionResource(coreR.dimen.large_padding) + + LocalPaddings.current.large + + LocalPaddings.current.large + dimensionResource(R.dimen.navigation_bar_height) + WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding() ), - verticalArrangement = Arrangement.spacedBy(dimensionResource(coreR.dimen.small_padding)) + verticalArrangement = Arrangement.spacedBy(LocalPaddings.current.small) ) { items(searchList.size, key = { searchList[it].id }) { index -> SearchItem( @@ -176,7 +176,7 @@ private fun SearchItem( modifier = Modifier.width(dimensionResource(R.dimen.character_card_width)) ) - Column(Modifier.padding(horizontal = dimensionResource(coreR.dimen.small_padding))) { + Column(Modifier.padding(horizontal = LocalPaddings.current.small)) { Text( text = item.title.orEmpty(), color = MaterialTheme.colorScheme.onBackground, @@ -193,7 +193,7 @@ private fun SearchItem( ) } - Spacer(Modifier.size(dimensionResource(coreR.dimen.medium_padding))) + Spacer(Modifier.size(LocalPaddings.current.medium)) Text( text = item.studios.joinToString(), diff --git a/app/src/main/java/com/imashnake/animite/features/ui/MediaSmall.kt b/app/src/main/java/com/imashnake/animite/features/ui/MediaSmall.kt index 81c7846b..288e7cb7 100644 --- a/app/src/main/java/com/imashnake/animite/features/ui/MediaSmall.kt +++ b/app/src/main/java/com/imashnake/animite/features/ui/MediaSmall.kt @@ -36,8 +36,8 @@ import coil.request.ImageRequest import com.imashnake.animite.api.anilist.MediaListQuery import com.imashnake.animite.api.anilist.type.MediaType import com.imashnake.animite.dev.internal.Constants.CROSSFADE_DURATION -import com.imashnake.animite.core.R as coreR import com.imashnake.animite.R +import com.imashnake.animite.core.ui.LocalPaddings /** * A [LazyRow] of [MediaSmall]s. @@ -50,14 +50,14 @@ fun MediaSmallRow( content: @Composable (T) -> Unit ) { LazyRow( - horizontalArrangement = Arrangement.spacedBy(dimensionResource(coreR.dimen.small_padding)), + horizontalArrangement = Arrangement.spacedBy(LocalPaddings.current.small), contentPadding = PaddingValues( - start = dimensionResource(coreR.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(coreR.dimen.large_padding) + end = LocalPaddings.current.large ) ) { items(mediaList) { media -> diff --git a/profile/src/main/kotlin/com/imashnake/animite/profile/ProfileScreen.kt b/profile/src/main/kotlin/com/imashnake/animite/profile/ProfileScreen.kt index abb48424..749cbcc5 100644 --- a/profile/src/main/kotlin/com/imashnake/animite/profile/ProfileScreen.kt +++ b/profile/src/main/kotlin/com/imashnake/animite/profile/ProfileScreen.kt @@ -10,9 +10,9 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.res.dimensionResource import androidx.compose.ui.res.stringResource import com.imashnake.animite.core.R as coreR +import com.imashnake.animite.core.ui.LocalPaddings import com.imashnake.animite.core.ui.ProgressIndicator import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.annotation.RootNavGraph @@ -30,7 +30,7 @@ fun ProfileScreen() { Column( horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy( - dimensionResource(coreR.dimen.tiny_padding) + LocalPaddings.current.tiny ) ) { Text( diff --git a/rslash/src/main/kotlin/com/imashnake/animite/rslash/RSlashScreen.kt b/rslash/src/main/kotlin/com/imashnake/animite/rslash/RSlashScreen.kt index 39ec3bb6..cd764e9c 100644 --- a/rslash/src/main/kotlin/com/imashnake/animite/rslash/RSlashScreen.kt +++ b/rslash/src/main/kotlin/com/imashnake/animite/rslash/RSlashScreen.kt @@ -10,8 +10,8 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.res.dimensionResource import androidx.compose.ui.res.stringResource +import com.imashnake.animite.core.ui.LocalPaddings import com.imashnake.animite.core.R as coreR import com.imashnake.animite.core.ui.ProgressIndicator import com.ramcosta.composedestinations.annotation.Destination @@ -30,7 +30,7 @@ fun RSlashScreen() { Column( horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy( - dimensionResource(coreR.dimen.tiny_padding) + LocalPaddings.current.tiny ) ) { Text(