From 50827cc5c7dc47f821604cfc46d6103e1c13cf2b Mon Sep 17 00:00:00 2001 From: hyejin12-ju Date: Mon, 23 Sep 2024 23:53:10 +0900 Subject: [PATCH 1/5] =?UTF-8?q?[fix]=20=EC=B6=A9=EB=8F=8C=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/team/ppac/detail/DetailScreen.kt | 57 ++++++++++++--- .../ppac/detail/component/DetailContent.kt | 72 ++++++++----------- 2 files changed, 77 insertions(+), 52 deletions(-) diff --git a/feature/detail/src/main/java/team/ppac/detail/DetailScreen.kt b/feature/detail/src/main/java/team/ppac/detail/DetailScreen.kt index 182af08e..ccde500a 100644 --- a/feature/detail/src/main/java/team/ppac/detail/DetailScreen.kt +++ b/feature/detail/src/main/java/team/ppac/detail/DetailScreen.kt @@ -3,18 +3,23 @@ package team.ppac.detail import android.graphics.Bitmap import android.os.Build import androidx.compose.foundation.background +import androidx.compose.foundation.border import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.BlurEffect import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp import coil.compose.AsyncImage import coil.request.CachePolicy import coil.request.ImageRequest @@ -22,6 +27,7 @@ import kotlinx.collections.immutable.persistentListOf import team.ppac.designsystem.FarmemeTheme import team.ppac.designsystem.component.scaffold.FarmemeScaffold import team.ppac.designsystem.component.toolbar.FarmemeBackToolBar +import team.ppac.designsystem.foundation.FarmemeRadius import team.ppac.detail.component.DetailBottomBar import team.ppac.detail.component.DetailContent import team.ppac.detail.model.DetailMemeUiModel @@ -39,6 +45,10 @@ internal fun DetailScreen( saveBitmap: (bitmap: Bitmap) -> Unit, onHashTagsClick: () -> Unit, ) { + val configuration = LocalConfiguration.current + val screenWidthPx = configuration.screenWidthDp.dp + val screenHeightPx = configuration.screenHeightDp.dp + FarmemeScaffold( modifier = modifier, topBar = { @@ -94,14 +104,45 @@ internal fun DetailScreen( .fillMaxSize(), contentAlignment = Alignment.Center ) { - DetailContent( - uiModel = uiState.detailMemeUiModel, - isLoading = uiState.isLoading, - saveBitmap = saveBitmap, - onClickFunnyButton = onClickFunnyButton, - onReactionButtonPositioned = onReactionButtonPosition, - onHashTagsClick = onHashTagsClick - ) + Box( + modifier = modifier + .border( + width = 2.dp, + color = FarmemeTheme.borderColor.primary, + shape = FarmemeRadius.Radius20.shape, + ) + .clip(FarmemeRadius.Radius20.shape) + .background(FarmemeTheme.backgroundColor.white), + ) { + if (screenHeightPx < 640.dp) { + Box( + modifier = Modifier.padding(10.dp), + contentAlignment = Alignment.BottomCenter + ) { + DetailContent( + uiModel = uiState.detailMemeUiModel, + isLoading = uiState.isLoading, + saveBitmap = saveBitmap, + onClickFunnyButton = onClickFunnyButton, + onReactionButtonPositioned = onReactionButtonPosition, + onHashTagsClick = onHashTagsClick, + ) + } + } else { + Column( + modifier = Modifier.padding(10.dp), + ) { + DetailContent( + uiModel = uiState.detailMemeUiModel, + isLoading = uiState.isLoading, + saveBitmap = saveBitmap, + onClickFunnyButton = onClickFunnyButton, + onReactionButtonPositioned = onReactionButtonPosition, + onHashTagsClick = onHashTagsClick + ) + } + } + } } } } diff --git a/feature/detail/src/main/java/team/ppac/detail/component/DetailContent.kt b/feature/detail/src/main/java/team/ppac/detail/component/DetailContent.kt index 03cc660d..abfe591f 100644 --- a/feature/detail/src/main/java/team/ppac/detail/component/DetailContent.kt +++ b/feature/detail/src/main/java/team/ppac/detail/component/DetailContent.kt @@ -5,7 +5,6 @@ import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut import androidx.compose.foundation.background -import androidx.compose.foundation.border import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -65,51 +64,36 @@ internal fun DetailContent( onReactionButtonPositioned: (Offset) -> Unit, onHashTagsClick: () -> Unit, ) { - Box( - modifier = modifier - .border( - width = 2.dp, - color = FarmemeTheme.borderColor.primary, - shape = FarmemeRadius.Radius20.shape, - ) - .clip(FarmemeRadius.Radius20.shape) - .background(FarmemeTheme.backgroundColor.white), + DetailImage( + imageUrl = uiModel.imageUrl, + isLoading = isLoading, + saveBitmap = saveBitmap, + ) + Column( + modifier = Modifier + .padding(horizontal = 10.dp) + .padding(top = 20.dp, bottom = 10.dp), + horizontalAlignment = Alignment.CenterHorizontally ) { - Column( - modifier = Modifier.padding(10.dp), - ) { - DetailImage( - imageUrl = uiModel.imageUrl, + DetailHashTags( + name = uiModel.name, + sourceDescription = uiModel.sourceDescription, + hashTags = uiModel.hashTags, + isLoading = isLoading, + onHashTagsClick = onHashTagsClick + ) + DetailFunnyButton( + modifier = Modifier.mapTextSkeletonModifierIfNeed( isLoading = isLoading, - saveBitmap = saveBitmap, - ) - Column( - modifier = Modifier - .padding(horizontal = 10.dp) - .padding(top = 20.dp, bottom = 10.dp), - horizontalAlignment = Alignment.CenterHorizontally, - ) { - DetailHashTags( - name = uiModel.name, - sourceDescription = uiModel.sourceDescription, - hashTags = uiModel.hashTags, - isLoading = isLoading, - onHashTagsClick = onHashTagsClick - ) - DetailFunnyButton( - modifier = Modifier.mapTextSkeletonModifierIfNeed( - isLoading = isLoading, - height = 46.dp, - shape = FarmemeRadius.Radius10.shape, - ), - reactionCount = uiModel.reactionCount, - isReaction = uiModel.isReaction, - isLoading = isLoading, - onClickFunnyButton = onClickFunnyButton, - onReactionButtonPositioned = onReactionButtonPositioned, - ) - } - } + height = 46.dp, + shape = FarmemeRadius.Radius10.shape, + ), + reactionCount = uiModel.reactionCount, + isReaction = uiModel.isReaction, + isLoading = isLoading, + onClickFunnyButton = onClickFunnyButton, + onReactionButtonPositioned = onReactionButtonPositioned + ) } } From d5d5ddc3e7fc72b978079e7b6dd3e056e39b1888 Mon Sep 17 00:00:00 2001 From: hyejin12-ju Date: Thu, 19 Sep 2024 22:16:08 +0900 Subject: [PATCH 2/5] =?UTF-8?q?[QA]=20=ED=95=B4=EC=83=81=EB=8F=84=EC=97=90?= =?UTF-8?q?=20=EB=94=B0=EB=9D=BC=20text=20color,=20image=20=EC=82=AC?= =?UTF-8?q?=EC=9D=B4=EC=A6=88=20=EB=B0=8F=20=EA=B7=B8=EB=9D=BC=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=EC=85=98=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/team/ppac/detail/DetailScreen.kt | 12 ++-- .../ppac/detail/component/DetailContent.kt | 67 ++++++++++++++----- .../team/ppac/detail/util/DetailScreenSize.kt | 26 +++++++ 3 files changed, 83 insertions(+), 22 deletions(-) create mode 100644 feature/detail/src/main/java/team/ppac/detail/util/DetailScreenSize.kt diff --git a/feature/detail/src/main/java/team/ppac/detail/DetailScreen.kt b/feature/detail/src/main/java/team/ppac/detail/DetailScreen.kt index ccde500a..582bdee4 100644 --- a/feature/detail/src/main/java/team/ppac/detail/DetailScreen.kt +++ b/feature/detail/src/main/java/team/ppac/detail/DetailScreen.kt @@ -33,6 +33,7 @@ import team.ppac.detail.component.DetailContent import team.ppac.detail.model.DetailMemeUiModel import team.ppac.detail.mvi.DetailIntent import team.ppac.detail.mvi.DetailUiState +import team.ppac.detail.util.DetailScreenSize @Composable internal fun DetailScreen( @@ -46,9 +47,8 @@ internal fun DetailScreen( onHashTagsClick: () -> Unit, ) { val configuration = LocalConfiguration.current - val screenWidthPx = configuration.screenWidthDp.dp - val screenHeightPx = configuration.screenHeightDp.dp - + val currentDetailScreenSize = + DetailScreenSize.from(configuration.screenWidthDp.dp, configuration.screenHeightDp.dp) FarmemeScaffold( modifier = modifier, topBar = { @@ -114,7 +114,7 @@ internal fun DetailScreen( .clip(FarmemeRadius.Radius20.shape) .background(FarmemeTheme.backgroundColor.white), ) { - if (screenHeightPx < 640.dp) { + if (currentDetailScreenSize == DetailScreenSize.SMALL) { Box( modifier = Modifier.padding(10.dp), contentAlignment = Alignment.BottomCenter @@ -126,6 +126,7 @@ internal fun DetailScreen( onClickFunnyButton = onClickFunnyButton, onReactionButtonPositioned = onReactionButtonPosition, onHashTagsClick = onHashTagsClick, + currentDetailScreenSize = currentDetailScreenSize ) } } else { @@ -138,7 +139,8 @@ internal fun DetailScreen( saveBitmap = saveBitmap, onClickFunnyButton = onClickFunnyButton, onReactionButtonPositioned = onReactionButtonPosition, - onHashTagsClick = onHashTagsClick + onHashTagsClick = onHashTagsClick, + currentDetailScreenSize = currentDetailScreenSize ) } } diff --git a/feature/detail/src/main/java/team/ppac/detail/component/DetailContent.kt b/feature/detail/src/main/java/team/ppac/detail/component/DetailContent.kt index abfe591f..14cd9e7a 100644 --- a/feature/detail/src/main/java/team/ppac/detail/component/DetailContent.kt +++ b/feature/detail/src/main/java/team/ppac/detail/component/DetailContent.kt @@ -23,6 +23,9 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.graphics.Brush +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.layout.boundsInWindow import androidx.compose.ui.layout.onGloballyPositioned @@ -53,6 +56,8 @@ import team.ppac.designsystem.util.extension.noRippleClickable import team.ppac.designsystem.util.extension.rippleClickable import team.ppac.detail.model.DetailMemeUiModel import team.ppac.detail.mvi.DetailUiState +import team.ppac.detail.util.DetailScreenSize +import team.ppac.detail.util.toImageSize @Composable internal fun DetailContent( @@ -63,12 +68,31 @@ internal fun DetailContent( onClickFunnyButton: () -> Unit, onReactionButtonPositioned: (Offset) -> Unit, onHashTagsClick: () -> Unit, + currentDetailScreenSize: DetailScreenSize ) { - DetailImage( - imageUrl = uiModel.imageUrl, - isLoading = isLoading, - saveBitmap = saveBitmap, - ) + Box { + DetailImage( + imageUrl = uiModel.imageUrl, + isLoading = isLoading, + saveBitmap = saveBitmap, + currentDetailScreenSize = currentDetailScreenSize + ) + if (currentDetailScreenSize == DetailScreenSize.SMALL) { + Box( + modifier = Modifier + .matchParentSize() + .graphicsLayer(alpha = 0.80f) + .clip(FarmemeRadius.Radius10.shape) + .background( + brush = Brush.verticalGradient( + colors = listOf(Color.Transparent, FarmemeTheme.iconColor.secondary), + startY = 320f, + endY = 1000f + ) + ) + ) + } + } Column( modifier = Modifier .padding(horizontal = 10.dp) @@ -80,7 +104,8 @@ internal fun DetailContent( sourceDescription = uiModel.sourceDescription, hashTags = uiModel.hashTags, isLoading = isLoading, - onHashTagsClick = onHashTagsClick + onHashTagsClick = onHashTagsClick, + currentDetailScreenSize = currentDetailScreenSize, ) DetailFunnyButton( modifier = Modifier.mapTextSkeletonModifierIfNeed( @@ -92,7 +117,8 @@ internal fun DetailContent( isReaction = uiModel.isReaction, isLoading = isLoading, onClickFunnyButton = onClickFunnyButton, - onReactionButtonPositioned = onReactionButtonPositioned + onReactionButtonPositioned = onReactionButtonPositioned, + currentDetailScreenSize = currentDetailScreenSize, ) } } @@ -128,7 +154,9 @@ private fun DetailImage( imageUrl: String, isLoading: Boolean, saveBitmap: (Bitmap) -> Unit, + currentDetailScreenSize: DetailScreenSize, ) { + val (widthDp, heightDp) = currentDetailScreenSize.toImageSize() Box( modifier = Modifier.clip(FarmemeRadius.Radius10.shape) ) { @@ -144,12 +172,12 @@ private fun DetailImage( contentScale = ContentScale.Fit, modifier = Modifier .background(FarmemeTheme.backgroundColor.black) - .width(330.dp) - .height(352.dp) + .width(widthDp) + .height(heightDp) .mapImageSkeletonModifierIfNeed( isLoading = isLoading, - width = 330.dp, - height = 352.dp + width = widthDp, + height = heightDp, ), onSuccess = { saveBitmap(it.result.drawable.toBitmap()) } ) @@ -164,6 +192,7 @@ internal fun DetailHashTags( hashTags: ImmutableList, isLoading: Boolean, onHashTagsClick: () -> Unit, + currentDetailScreenSize: DetailScreenSize ) { Text( modifier = Modifier.mapTextSkeletonModifierIfNeed( @@ -172,7 +201,7 @@ internal fun DetailHashTags( shape = FarmemeRadius.Radius4.shape, ), text = name.truncateDisplayedString(16), - color = FarmemeTheme.textColor.primary, + color = if (currentDetailScreenSize == DetailScreenSize.SMALL) FarmemeTheme.textColor.inverse else FarmemeTheme.textColor.primary, style = FarmemeTheme.typography.heading.large.semibold, overflow = TextOverflow.Ellipsis ) @@ -184,7 +213,8 @@ internal fun DetailHashTags( shape = FarmemeRadius.Radius4.shape, ), hashTags = hashTags.truncateDisplayedList(6), - onHashTagsClick = onHashTagsClick + onHashTagsClick = onHashTagsClick, + currentDetailScreenSize = currentDetailScreenSize ) if (sourceDescription.isNotEmpty()) { Spacer(modifier = Modifier.height(11.dp)) @@ -209,23 +239,25 @@ internal fun DetailTags( modifier: Modifier, hashTags: List, onHashTagsClick: () -> Unit, + currentDetailScreenSize: DetailScreenSize, ) { Text( modifier = modifier.noRippleClickable(onClick = onHashTagsClick), text = hashTags.joinToString(" ") { "#$it" }, - color = FarmemeTheme.textColor.tertiary, + color = if (currentDetailScreenSize == DetailScreenSize.SMALL) FarmemeTheme.textColor.disabled else FarmemeTheme.textColor.tertiary, style = FarmemeTheme.typography.body.large.medium, ) } @Composable -fun DetailFunnyButton( +private fun DetailFunnyButton( modifier: Modifier = Modifier, reactionCount: Int, isReaction: Boolean, isLoading: Boolean, onClickFunnyButton: () -> Unit, onReactionButtonPositioned: (Offset) -> Unit, + currentDetailScreenSize: DetailScreenSize, ) { val lottieComposition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.lol_move_effect)) val coroutineScope = rememberCoroutineScope() @@ -235,7 +267,7 @@ fun DetailFunnyButton( .fillMaxWidth() .height(46.dp) .clip(FarmemeRadius.Radius10.shape) - .background(color = FarmemeTheme.skeletonColor.primary) + .background(color = if (currentDetailScreenSize == DetailScreenSize.SMALL) FarmemeTheme.backgroundColor.white else FarmemeTheme.skeletonColor.primary) .rippleClickable( rippleColor = FarmemeTheme.skeletonColor.secondary, onClick = { @@ -312,6 +344,7 @@ fun PreviewDetailContent() { onClickFunnyButton = {}, onReactionButtonPositioned = { _ -> }, isLoading = false, - onHashTagsClick = {} + onHashTagsClick = {}, + currentDetailScreenSize = DetailScreenSize.MEDIUM ) } \ No newline at end of file diff --git a/feature/detail/src/main/java/team/ppac/detail/util/DetailScreenSize.kt b/feature/detail/src/main/java/team/ppac/detail/util/DetailScreenSize.kt new file mode 100644 index 00000000..b85998c4 --- /dev/null +++ b/feature/detail/src/main/java/team/ppac/detail/util/DetailScreenSize.kt @@ -0,0 +1,26 @@ +package team.ppac.detail.util + +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp + +internal enum class DetailScreenSize(val width: Dp, val height: Dp) { + SMALL(360.dp, 640.dp), + MEDIUM(360.dp, 800.dp), + LARGE(430.dp, 932.dp); + + companion object { + fun from(width: Dp, height: Dp): DetailScreenSize { + return entries.find { screenSize -> + height <= screenSize.height + } ?: LARGE + } + } +} + +internal fun DetailScreenSize.toImageSize(): Pair { + return when (this) { + DetailScreenSize.SMALL -> Pair(300.dp, 320.dp) + DetailScreenSize.MEDIUM -> Pair(330.dp, 352.dp) + DetailScreenSize.LARGE -> Pair(366.dp, 390.dp) + } +} \ No newline at end of file From dbbd0895322857af525c2394c6f444fdf99b3895 Mon Sep 17 00:00:00 2001 From: hyejin12-ju Date: Thu, 19 Sep 2024 22:26:55 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[Refactor]=20preview=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EA=B3=B5=ED=86=B5=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/team/ppac/detail/DetailScreen.kt | 18 ++---------------- .../ppac/detail/component/DetailContent.kt | 2 +- .../java/team/ppac/detail/mvi/DetailUiState.kt | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/feature/detail/src/main/java/team/ppac/detail/DetailScreen.kt b/feature/detail/src/main/java/team/ppac/detail/DetailScreen.kt index 582bdee4..758451cb 100644 --- a/feature/detail/src/main/java/team/ppac/detail/DetailScreen.kt +++ b/feature/detail/src/main/java/team/ppac/detail/DetailScreen.kt @@ -23,16 +23,15 @@ import androidx.compose.ui.unit.dp import coil.compose.AsyncImage import coil.request.CachePolicy import coil.request.ImageRequest -import kotlinx.collections.immutable.persistentListOf import team.ppac.designsystem.FarmemeTheme import team.ppac.designsystem.component.scaffold.FarmemeScaffold import team.ppac.designsystem.component.toolbar.FarmemeBackToolBar import team.ppac.designsystem.foundation.FarmemeRadius import team.ppac.detail.component.DetailBottomBar import team.ppac.detail.component.DetailContent -import team.ppac.detail.model.DetailMemeUiModel import team.ppac.detail.mvi.DetailIntent import team.ppac.detail.mvi.DetailUiState +import team.ppac.detail.mvi.DetailUiState.Companion.PREVIEW_STATE import team.ppac.detail.util.DetailScreenSize @Composable @@ -153,20 +152,7 @@ internal fun DetailScreen( @Composable fun PreviewDetailScreen() { DetailScreen( - uiState = DetailUiState( - memeId = "", - detailMemeUiModel = DetailMemeUiModel( - imageUrl = "", - name = "나는 공부를 찢어", - hashTags = persistentListOf("공부", "학생", "시험기간", "힘듦", "피곤"), - sourceDescription = "출처에 대한 내용이 들어갑니다.", - isSavedMeme = false, - reactionCount = 0, - isReaction = false, - ), - isError = false, - isLoading = false, - ), + uiState = PREVIEW_STATE, onClickFunnyButton = {}, onReactionButtonPosition = { _ -> }, onClickBackButton = {}, diff --git a/feature/detail/src/main/java/team/ppac/detail/component/DetailContent.kt b/feature/detail/src/main/java/team/ppac/detail/component/DetailContent.kt index 14cd9e7a..a5fc07e6 100644 --- a/feature/detail/src/main/java/team/ppac/detail/component/DetailContent.kt +++ b/feature/detail/src/main/java/team/ppac/detail/component/DetailContent.kt @@ -339,7 +339,7 @@ private fun DetailFunnyButton( fun PreviewDetailContent() { DetailContent( modifier = Modifier, - uiModel = DetailUiState.INITIAL_STATE.detailMemeUiModel, + uiModel = DetailUiState.PREVIEW_STATE.detailMemeUiModel, saveBitmap = {}, onClickFunnyButton = {}, onReactionButtonPositioned = { _ -> }, diff --git a/feature/detail/src/main/java/team/ppac/detail/mvi/DetailUiState.kt b/feature/detail/src/main/java/team/ppac/detail/mvi/DetailUiState.kt index 34b1accf..e5373a0c 100644 --- a/feature/detail/src/main/java/team/ppac/detail/mvi/DetailUiState.kt +++ b/feature/detail/src/main/java/team/ppac/detail/mvi/DetailUiState.kt @@ -26,6 +26,21 @@ data class DetailUiState( isError = false, isLoading = false, ) + + val PREVIEW_STATE = DetailUiState( + memeId = "", + detailMemeUiModel = DetailMemeUiModel( + imageUrl = "", + name = "나는 공부를 찢어", + hashTags = persistentListOf("공부", "학생", "시험기간", "힘듦", "피곤"), + sourceDescription = "출처에 대한 내용이 들어갑니다.", + isSavedMeme = false, + reactionCount = 0, + isReaction = false, + ), + isError = false, + isLoading = false, + ) } } From a3b8815f6d95a1a0b3bfecdb6362e18dd7c48c83 Mon Sep 17 00:00:00 2001 From: hyejin12-ju Date: Thu, 19 Sep 2024 22:50:33 +0900 Subject: [PATCH 4/5] =?UTF-8?q?[Refactor]=20DetailScreenSize=20=EB=9D=BC?= =?UTF-8?q?=EC=9A=B0=ED=84=B0=EB=A1=9C=20=ED=98=B8=EC=9D=B4=EC=8A=A4?= =?UTF-8?q?=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../detail/src/main/java/team/ppac/detail/DetailRoute.kt | 9 +++++++-- .../src/main/java/team/ppac/detail/DetailScreen.kt | 8 +++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/feature/detail/src/main/java/team/ppac/detail/DetailRoute.kt b/feature/detail/src/main/java/team/ppac/detail/DetailRoute.kt index 20cbac3e..12d00b9c 100644 --- a/feature/detail/src/main/java/team/ppac/detail/DetailRoute.kt +++ b/feature/detail/src/main/java/team/ppac/detail/DetailRoute.kt @@ -13,6 +13,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.dp @@ -36,6 +37,7 @@ import team.ppac.common.android.util.shareOneLink import team.ppac.designsystem.R import team.ppac.detail.mvi.DetailIntent import team.ppac.detail.mvi.DetailSideEffect +import team.ppac.detail.util.DetailScreenSize import kotlin.math.roundToInt @Composable @@ -46,7 +48,10 @@ internal fun DetailRoute( navigateToBack: () -> Unit, ) { val context = LocalContext.current + val configuration = LocalConfiguration.current + val currentDetailScreenSize = + DetailScreenSize.from(configuration.screenWidthDp.dp, configuration.screenHeightDp.dp) val lottieComposition by rememberLottieComposition( LottieCompositionSpec.RawRes(R.raw.lol_rising_effect) ) @@ -59,7 +64,6 @@ internal fun DetailRoute( val saveBitmap: (Bitmap) -> Unit = { bitmap = it } - BaseComposable(viewModel = viewModel) { uiState -> ComposableLifecycle { _, event -> when (event) { @@ -183,7 +187,8 @@ internal fun DetailRoute( }, onClickButtonButtons = viewModel::intent, saveBitmap = saveBitmap, - onHashTagsClick = { viewModel.intent(DetailIntent.ClickHashtags) } + onHashTagsClick = { viewModel.intent(DetailIntent.ClickHashtags) }, + currentDetailScreenSize = currentDetailScreenSize, ) LottieAnimation( modifier = Modifier diff --git a/feature/detail/src/main/java/team/ppac/detail/DetailScreen.kt b/feature/detail/src/main/java/team/ppac/detail/DetailScreen.kt index 758451cb..65006e49 100644 --- a/feature/detail/src/main/java/team/ppac/detail/DetailScreen.kt +++ b/feature/detail/src/main/java/team/ppac/detail/DetailScreen.kt @@ -16,7 +16,6 @@ import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.BlurEffect import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.layout.ContentScale -import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp @@ -44,10 +43,8 @@ internal fun DetailScreen( onClickButtonButtons: (DetailIntent.ClickBottomButton) -> Unit, saveBitmap: (bitmap: Bitmap) -> Unit, onHashTagsClick: () -> Unit, + currentDetailScreenSize: DetailScreenSize, ) { - val configuration = LocalConfiguration.current - val currentDetailScreenSize = - DetailScreenSize.from(configuration.screenWidthDp.dp, configuration.screenHeightDp.dp) FarmemeScaffold( modifier = modifier, topBar = { @@ -158,6 +155,7 @@ fun PreviewDetailScreen() { onClickBackButton = {}, onClickButtonButtons = {}, saveBitmap = {}, - onHashTagsClick = {} + onHashTagsClick = {}, + currentDetailScreenSize = DetailScreenSize.MEDIUM ) } \ No newline at end of file From 9a0eec2f7a17ac7e46f67ca5ea2b45c8569b6a31 Mon Sep 17 00:00:00 2001 From: hyejin12-ju Date: Fri, 27 Sep 2024 00:20:42 +0900 Subject: [PATCH 5/5] =?UTF-8?q?[Refactor]=20=EB=A6=AC=EB=B7=B0=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../detail/src/main/java/team/ppac/detail/DetailScreen.kt | 2 +- .../main/java/team/ppac/detail/component/DetailContent.kt | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/feature/detail/src/main/java/team/ppac/detail/DetailScreen.kt b/feature/detail/src/main/java/team/ppac/detail/DetailScreen.kt index 65006e49..788bac5d 100644 --- a/feature/detail/src/main/java/team/ppac/detail/DetailScreen.kt +++ b/feature/detail/src/main/java/team/ppac/detail/DetailScreen.kt @@ -147,7 +147,7 @@ internal fun DetailScreen( @Preview @Composable -fun PreviewDetailScreen() { +private fun PreviewDetailScreen() { DetailScreen( uiState = PREVIEW_STATE, onClickFunnyButton = {}, diff --git a/feature/detail/src/main/java/team/ppac/detail/component/DetailContent.kt b/feature/detail/src/main/java/team/ppac/detail/component/DetailContent.kt index a5fc07e6..31138c70 100644 --- a/feature/detail/src/main/java/team/ppac/detail/component/DetailContent.kt +++ b/feature/detail/src/main/java/team/ppac/detail/component/DetailContent.kt @@ -194,6 +194,7 @@ internal fun DetailHashTags( onHashTagsClick: () -> Unit, currentDetailScreenSize: DetailScreenSize ) { + val textColor = if (currentDetailScreenSize == DetailScreenSize.SMALL) FarmemeTheme.textColor.inverse else FarmemeTheme.textColor.primary Text( modifier = Modifier.mapTextSkeletonModifierIfNeed( isLoading = isLoading, @@ -201,7 +202,7 @@ internal fun DetailHashTags( shape = FarmemeRadius.Radius4.shape, ), text = name.truncateDisplayedString(16), - color = if (currentDetailScreenSize == DetailScreenSize.SMALL) FarmemeTheme.textColor.inverse else FarmemeTheme.textColor.primary, + color = textColor, style = FarmemeTheme.typography.heading.large.semibold, overflow = TextOverflow.Ellipsis ) @@ -336,7 +337,7 @@ private fun DetailFunnyButton( @Composable @Preview(showBackground = true) -fun PreviewDetailContent() { +private fun PreviewDetailContent() { DetailContent( modifier = Modifier, uiModel = DetailUiState.PREVIEW_STATE.detailMemeUiModel,