-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] 한 눈에 보기 화면 Compose 마이그레이션 #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
444f0aa
36c48ae
7dbef25
add6924
a33a814
cf83cf9
6e5cb56
cf328e6
bd76738
b387fd2
f2713c9
d07a626
390a72c
db24df3
fe726a2
115ed91
ee2bcd5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| package com.daedan.festabook.presentation.placeMap.component | ||
|
|
||
| import androidx.compose.foundation.layout.Row | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.layout.size | ||
| import androidx.compose.material3.Card | ||
| import androidx.compose.material3.CardColors | ||
| import androidx.compose.material3.Icon | ||
| 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.graphics.Color | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.res.stringResource | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import com.daedan.festabook.presentation.placeMap.model.PlaceCategoryUiModel | ||
| import com.daedan.festabook.presentation.placeMap.model.getIconId | ||
| import com.daedan.festabook.presentation.placeMap.model.getLabelColor | ||
| import com.daedan.festabook.presentation.placeMap.model.getTextId | ||
| import com.daedan.festabook.presentation.theme.festabookShapes | ||
| import kotlin.math.roundToInt | ||
|
|
||
| @Composable | ||
| fun PlaceCategoryLabel( | ||
| category: PlaceCategoryUiModel, | ||
| modifier: Modifier = Modifier, | ||
| iconColor: Color = category.getLabelColor(), | ||
| ) { | ||
| Card( | ||
| shape = festabookShapes.radius1, | ||
| colors = | ||
| CardColors( | ||
| containerColor = getBackgroundColor(iconColor), | ||
| contentColor = Color.Unspecified, | ||
| disabledContainerColor = getBackgroundColor(iconColor), | ||
| disabledContentColor = Color.Unspecified, | ||
| ), | ||
| modifier = modifier, | ||
| ) { | ||
| Row( | ||
| modifier = Modifier.padding(horizontal = 4.dp, vertical = 2.dp), | ||
| verticalAlignment = Alignment.CenterVertically, | ||
| ) { | ||
| Icon( | ||
| painter = painterResource(category.getIconId()), | ||
| contentDescription = stringResource(category.getTextId()), | ||
| tint = iconColor, | ||
| modifier = Modifier.size(12.dp), | ||
| ) | ||
| Text( | ||
| modifier = Modifier.padding(start = 4.dp), | ||
| text = stringResource(category.getTextId()), | ||
| style = MaterialTheme.typography.labelMedium, | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private fun getBackgroundColor(color: Color): Color { | ||
| // 10% 투명도를 가지게 변경 | ||
| val alpha = (MAX_ALPHA * ALPHA_RATIO).roundToInt() | ||
| return color.copy(alpha = alpha / MAX_ALPHA.toFloat()) | ||
| } | ||
|
|
||
| private const val MAX_ALPHA = 255 | ||
| private const val ALPHA_RATIO = 0.10f | ||
|
|
||
| @Preview(showBackground = true) | ||
| @Composable | ||
| private fun PlaceCategoryLabelPreview() { | ||
| val category = PlaceCategoryUiModel.FOOD_TRUCK | ||
| PlaceCategoryLabel( | ||
| category = category, | ||
| iconColor = Color(0xFF00AB40), | ||
| ) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,16 +5,41 @@ import androidx.compose.foundation.layout.Column | |
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.layout.wrapContentSize | ||
| import androidx.compose.material3.ExperimentalMaterial3Api | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import com.daedan.festabook.domain.model.TimeTag | ||
| import com.daedan.festabook.presentation.placeMap.model.PlaceCategoryUiModel | ||
| import com.daedan.festabook.presentation.placeMap.model.PlaceUiModel | ||
| import com.daedan.festabook.presentation.placeMap.placeCategory.component.PlaceCategoryScreen | ||
| import com.daedan.festabook.presentation.placeMap.timeTagSpinner.component.TimeTagMenu | ||
| import com.daedan.festabook.presentation.theme.FestabookColor | ||
| import com.daedan.festabook.presentation.theme.FestabookTheme | ||
| import com.naver.maps.map.NaverMap | ||
|
|
||
| @OptIn(ExperimentalMaterial3Api::class) | ||
| @Composable | ||
| fun PlaceMapScreen( | ||
| timeTagTitle: String, | ||
| timeTags: List<TimeTag>, | ||
| places: List<PlaceUiModel>, | ||
| modifier: Modifier = Modifier, | ||
| onMapReady: (NaverMap) -> Unit = {}, | ||
| onPlaceClick: (PlaceUiModel) -> Unit = {}, | ||
| onTimeTagClick: (TimeTag) -> Unit = {}, | ||
| ) { | ||
| PlaceMapContent( | ||
| title = timeTagTitle, | ||
| timeTags = timeTags, | ||
| onMapReady = onMapReady, | ||
| onTimeTagClick = onTimeTagClick, | ||
| ) | ||
| } | ||
|
|
||
| @Composable | ||
| private fun PlaceMapContent( | ||
| timeTags: List<TimeTag>, | ||
| title: String, | ||
| onMapReady: (NaverMap) -> Unit, | ||
|
|
@@ -42,6 +67,35 @@ fun PlaceMapScreen( | |
| ).padding(horizontal = 24.dp), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 나중에 지도 전용 spacing을 만드는 것도 나쁘지 않을 것 같아용
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PlaceMapScreen에 통합할 때 만들겠습니다 ! |
||
| ) | ||
| } | ||
| PlaceCategoryScreen() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Preview(showBackground = true) | ||
| @Composable | ||
| private fun PlaceMapScreenPreview() { | ||
| FestabookTheme { | ||
| PlaceMapScreen( | ||
| timeTagTitle = "테스트", | ||
| timeTags = | ||
| listOf( | ||
| TimeTag(1, "테스트1"), | ||
| TimeTag(2, "테스트2"), | ||
| ), | ||
| places = | ||
| (0..100).map { | ||
| PlaceUiModel( | ||
| id = it.toLong(), | ||
| imageUrl = null, | ||
| title = "테스트테스트테스트테스트테스트테스트테스트테스트테스트테스트", | ||
| description = "테스트테스트테스트테스트테스트테스트테스트테스트테스트테스트테스트", | ||
| location = "테스트테스트테스트테스트테스트테스트테스트테스트테스트", | ||
| category = PlaceCategoryUiModel.BAR, | ||
| isBookmarked = true, | ||
| timeTagId = listOf(1), | ||
| ) | ||
| }, | ||
| ) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| package com.daedan.festabook.presentation.placeMap.model | ||
|
|
||
| import androidx.compose.ui.graphics.Color | ||
| import com.daedan.festabook.R | ||
| import com.daedan.festabook.domain.model.PlaceCategory | ||
| import com.daedan.festabook.presentation.placeMap.mapManager.internal.OverlayImageManager | ||
|
|
@@ -65,6 +66,14 @@ val PlaceCategoryUiModel.Companion.iconResources: List<Int> | |
| R.drawable.ic_extra_selected, | ||
| ) | ||
|
|
||
| fun PlaceCategoryUiModel.getLabelColor() = | ||
| when (this) { | ||
| PlaceCategoryUiModel.BOOTH -> Color(0xFF0094FF) | ||
| PlaceCategoryUiModel.FOOD_TRUCK -> Color(0xFF00AB40) | ||
| PlaceCategoryUiModel.BAR -> Color(0xFFFF9D00) | ||
| else -> Color.Unspecified | ||
|
Comment on lines
+71
to
+74
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 하드 코딩 해치워주세요..!!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 부분도 추후 전용 spacing을 만들 때 함께 해치우겠습니다..! |
||
| } | ||
|
|
||
| fun OverlayImageManager.getNormalIcon(category: PlaceCategoryUiModel): OverlayImage? = | ||
| when (category) { | ||
| PlaceCategoryUiModel.BOOTH -> getImage(R.drawable.ic_booth) | ||
|
|
||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PlaceMapScreen에서는 PlaceMapContent를 호출만 하고 있는데 screen이랑 content랑 따로 분리하신 이유가 있으실까용?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PlaceMapScreen은 추후 하위 Fragment를 제거한 후 사용될 컴포저블 함수입니다 !
지금은 크게 와닿지 않을 수 있지만 컴포저블 함수를 통합할 때, stateFlow 등으로 복잡해질 것 같아요.
해당 부분은 나중에 PlaceMapScreen을 사용하게 될 때 구조가 변경될 가능성이 높아, 가볍게만 봐주셔도 좋을 것 같습니다 !