Skip to content
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

[refactor] BbangZipDetail 뷰 코드 정리 #99

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ class BbangZipDetailContract {
sealed interface BbangZipDetailEvent : BaseContract.Event {
data object Initialize : BbangZipDetailEvent

data object OnClickBackBtn : BbangZipDetailEvent
data object OnBackIconClick : BbangZipDetailEvent
}

sealed interface BbangZipDetailReduce : BaseContract.Reduce {
data class UpdateMyBbangZipList(val bbangZipList: List<BbangZip>) : BbangZipDetailReduce
}

sealed interface BbangZipDetailSideEffect : BaseContract.SideEffect {
data object PopBackStack : BbangZipDetailSideEffect
data object NavigateToBack : BbangZipDetailSideEffect
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.android.bbangzip.presentation.component.indicator.BbangZipLoadingIndi

@Composable
fun BbangZipDetailRoute(
popBackStack: () -> Unit,
navigateToBack: () -> Unit,
modifier: Modifier = Modifier,
viewModel: BbangZipDetailViewModel = hiltViewModel(),
) {
Expand All @@ -23,7 +23,7 @@ fun BbangZipDetailRoute(
LaunchedEffect(viewModel.uiSideEffect) {
viewModel.uiSideEffect.collectLatest { effect ->
when (effect) {
is BbangZipDetailContract.BbangZipDetailSideEffect.PopBackStack -> popBackStack()
is BbangZipDetailContract.BbangZipDetailSideEffect.NavigateToBack -> navigateToBack()
}
}
}
Expand All @@ -34,7 +34,7 @@ fun BbangZipDetailRoute(
modifier = modifier,
state = state,
pagerState = pagerState,
popBackStack = popBackStack,
popBackStack = navigateToBack,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p4 : popBackStack 바꿔주세요!

)

else -> BbangZipLoadingIndicator()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.PagerState
import androidx.compose.foundation.shape.CircleShape
Expand Down Expand Up @@ -42,6 +40,7 @@ import org.android.bbangzip.R
import org.android.bbangzip.presentation.component.chip.BbangZipChip
import org.android.bbangzip.presentation.component.topbar.BbangZipBaseTopBar
import org.android.bbangzip.presentation.model.BbangZip
import org.android.bbangzip.presentation.util.graphic.Gap
import org.android.bbangzip.ui.theme.BbangZipTheme
import timber.log.Timber

Expand Down Expand Up @@ -132,37 +131,28 @@ private fun BbangZipPager(

BbangZipPagerIndicator(
pagerState = pagerState,
modifier = Modifier.align(Alignment.BottomCenter).padding(bottom = 24.dp),
modifier =
Modifier
.align(Alignment.BottomCenter)
.padding(bottom = 24.dp),
)
}
}

Column(
modifier =
Modifier.fillMaxWidth()
Modifier
.fillMaxWidth()
.padding(top = 24.dp),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Row(
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically,
) {
BbangZipChip(
backgroundColor = BbangZipTheme.colors.statusPositive_3D3730,
text = "Lv " + bbangZipList[page].level,
)

Spacer(modifier = Modifier.width(8.dp))

Text(
text = bbangZipList[page].name,
style = BbangZipTheme.typography.body1Bold,
color = BbangZipTheme.colors.labelNormal_282119,
)
}
BbangZipLevelTitle(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p5 : 컴포넌트화 좋네요~

bbangZipList = bbangZipList,
page = page,
)

if (!bbangZipList[page].isLocked) {
Spacer(modifier = Modifier.height(78.dp))
Gap(height = 78)

Text(
text = bbangZipList[page].description,
Expand All @@ -171,7 +161,7 @@ private fun BbangZipPager(
textAlign = TextAlign.Center,
)
} else {
Spacer(modifier = Modifier.height(62.dp))
Gap(height = 62)

Box(
modifier = Modifier.fillMaxWidth(),
Expand All @@ -181,7 +171,11 @@ private fun BbangZipPager(
imageVector = ImageVector.vectorResource(R.drawable.ic_lock_default_28),
contentDescription = null,
tint = BbangZipTheme.colors.lineStrong_68645E_52,
modifier = Modifier.height(70.dp).aspectRatio(0.714f).alpha(0.2f),
modifier =
Modifier
.height(70.dp)
.aspectRatio(0.714f)
.alpha(0.2f),
)

Text(
Expand All @@ -197,6 +191,32 @@ private fun BbangZipPager(
}
}

@Composable
private fun BbangZipLevelTitle(
bbangZipList: List<BbangZip>,
page: Int,
modifier: Modifier = Modifier,
) {
Row(
modifier = modifier,
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically,
) {
BbangZipChip(
backgroundColor = BbangZipTheme.colors.statusPositive_3D3730,
text = stringResource(R.string.my_bbangzip_level) + bbangZipList[page].level,
)

Gap(width = 8)

Text(
text = bbangZipList[page].name,
style = BbangZipTheme.typography.body1Bold,
color = BbangZipTheme.colors.labelNormal_282119,
)
}
}

@Composable
private fun BbangZipPagerIndicator(
pagerState: PagerState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class BbangZipDetailViewModel
override fun handleEvent(event: BbangZipDetailContract.BbangZipDetailEvent) {
when (event) {
is BbangZipDetailContract.BbangZipDetailEvent.Initialize -> launch { initDataLoad() }
is BbangZipDetailContract.BbangZipDetailEvent.OnClickBackBtn -> setSideEffect(BbangZipDetailContract.BbangZipDetailSideEffect.PopBackStack)
is BbangZipDetailContract.BbangZipDetailEvent.OnBackIconClick -> setSideEffect(BbangZipDetailContract.BbangZipDetailSideEffect.NavigateToBack)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ fun NavController.navigateBbangZipDetail() {
}

fun NavGraphBuilder.bbangZipDetailNavGraph(
popBackStack: () -> Unit,
navigateToBack: () -> Unit,
) {
composable<BbangZipDetailRoute> {
BbangZipDetailRoute(
popBackStack = popBackStack,
navigateToBack = navigateToBack,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fun MainNavHost(
)

bbangZipDetailNavGraph(
popBackStack = { navigator.popBackStackIfNotSubject() },
navigateToBack = { navigator.popBackStackIfNotSubject() },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p5 : 저희 navigatToBack = navigator::popbackStackIfNotSubject
같은 참조함수 형식으로 바꾸는건 어떤가요?

)

myBadgeCategoryNavGraph(
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
<string name="my_withdraw">계정 탈퇴</string>
<string name="my_bbangzip">내 제과제빵점</string>
<string name="my_bbangzip_lock">열심히 포인트를 모아서\n멋진 빵집을 차려봐요!</string>
<string name="my_bbangzip_level">LV </string>

<!-- component- bottom sheet -->
<string name="logout_title">로그아웃 하시겠어요?</string>
Expand Down