Skip to content

Commit

Permalink
Merge pull request #43 from Nexters/feature/add-home-destination
Browse files Browse the repository at this point in the history
홈, 결과 상세 화면 동선 추가
  • Loading branch information
yxnsx authored Sep 20, 2023
2 parents a6803f9 + b7c1868 commit 7317e37
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 6 deletions.
2 changes: 2 additions & 0 deletions app/src/main/java/com/keyme/app/ui/KeymeApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ fun KeymeApp() {

dailyKeymeTestGraph(
navigateToTakeKeymeTest = { appState.navigate(TakeKeymeTestDestination, it) },
navigateToQuestionResult = { appState.navigate(KeymeQuestionResultDestination, it.questionId) },
nestedGraphs = {
keymeQuestionResultGraph(onBackClick = appState::onBackClick)
takeKeymeTestGraph(
onBackClick = appState::onBackClick,
onTestSolved = appState::onBackClick,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import androidx.navigation.navigation
import com.keyme.domain.entity.response.QuestionStatistic
import com.keyme.presentation.navigation.KeymeNavigationDestination

object DailyKeymeTestDestination : KeymeNavigationDestination {
Expand All @@ -19,14 +20,18 @@ object DailyKeymeTestDestination : KeymeNavigationDestination {

fun NavGraphBuilder.dailyKeymeTestGraph(
navigateToTakeKeymeTest: (testId: Int) -> Unit,
navigateToQuestionResult: (QuestionStatistic) -> Unit,
nestedGraphs: NavGraphBuilder.() -> Unit,
) {
navigation(
route = DailyKeymeTestDestination.route,
startDestination = DailyKeymeTestDestination.destination,
) {
composable(route = DailyKeymeTestDestination.destination) {
DailyKeymeTestRoute(navigateToTakeKeymeTest = navigateToTakeKeymeTest)
DailyKeymeTestRoute(
navigateToTakeKeymeTest = navigateToTakeKeymeTest,
navigateToQuestionResult = navigateToQuestionResult,
)
}
nestedGraphs()
}
Expand All @@ -36,6 +41,7 @@ fun NavGraphBuilder.dailyKeymeTestGraph(
fun DailyKeymeTestRoute(
dailyKeymeTestViewModel: DailyKeymeTestViewModel = hiltViewModel(),
navigateToTakeKeymeTest: (testId: Int) -> Unit,
navigateToQuestionResult: (QuestionStatistic) -> Unit,
) {
val myCharacter by dailyKeymeTestViewModel.myCharacterState.collectAsStateWithLifecycle()
val dailyKeymeTest by dailyKeymeTestViewModel.dailyKeymeTestState.collectAsStateWithLifecycle()
Expand All @@ -58,5 +64,6 @@ fun DailyKeymeTestRoute(
// todo api level 분기 필요
// Toast.makeText(context, "링크 복사 완료", Toast.LENGTH_SHORT).show()
},
onQuestionStatisticClick = navigateToQuestionResult,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import coil.compose.AsyncImage
import coil.request.ImageRequest
import com.keyme.domain.entity.member.Member
import com.keyme.domain.entity.response.Category
import com.keyme.domain.entity.response.QuestionStatistic
import com.keyme.domain.entity.response.Test
import com.keyme.domain.entity.response.TestStatistic
import com.keyme.presentation.designsystem.component.KeymeText
Expand All @@ -59,11 +60,17 @@ fun DailyKeymeTestScreen(
dailyKeymeTestStatistic: TestStatistic? = null,
onDailyKeymeTestClick: () -> Unit,
onShareClick: () -> Unit,
onQuestionStatisticClick: (QuestionStatistic) -> Unit,
) {
Box(modifier = Modifier.fillMaxSize()) {
// NOTE: 데일리 문제를 제공하는 대신 온보딩 문제를 계속 공유할 수 있게 하는 플로우로 수정 방향 생각중
if (dailyKeymeTestStatistic != null) {
DailyKeymeTestStatisticScreen(myCharacter, dailyKeymeTestStatistic, onShareClick)
DailyKeymeTestStatisticScreen(
myCharacter,
dailyKeymeTestStatistic,
onShareClick,
onQuestionStatisticClick,
)
}
// else {
// DailKeymeTestScreen(myCharacter, dailyKeymeTest, onDailyKeymeTestClick)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,24 @@ import com.keyme.presentation.R
import com.keyme.presentation.designsystem.component.KeymeText
import com.keyme.presentation.designsystem.component.KeymeTextType
import com.keyme.presentation.utils.ColorUtil
import com.keyme.presentation.utils.clickableRippleEffect

@Composable
fun DailyKeymeTestStatisticScreen(
myCharacter: Member,
dailyKeymeTestStatistic: TestStatistic,
onShareClick: () -> Unit,
onQuestionStatisticClick: (QuestionStatistic) -> Unit,
) {
Column(modifier = Modifier.fillMaxSize()) {
StatisticTextTitle(myCharacter = myCharacter)
Spacer(modifier = Modifier.height(96.dp))
StatisticList(modifier = Modifier.weight(1f), myCharacter, dailyKeymeTestStatistic)
StatisticList(
modifier = Modifier.weight(1f),
myCharacter,
dailyKeymeTestStatistic,
onQuestionStatisticClick,
)
ShareToFriendsButton(onClick = onShareClick)
}
}
Expand All @@ -66,6 +73,7 @@ private fun StatisticList(
modifier: Modifier = Modifier,
myCharacter: Member,
dailyKeymeTestStatistic: TestStatistic,
onClickItem: (QuestionStatistic) -> Unit,
) {
Column(
modifier = modifier
Expand Down Expand Up @@ -96,19 +104,28 @@ private fun StatisticList(
verticalArrangement = Arrangement.spacedBy(12.dp),
) {
items(dailyKeymeTestStatistic.questionsStatistics) {
QuestionStatisticItem(myCharacter = myCharacter, statistic = it)
QuestionStatisticItem(
myCharacter = myCharacter,
statistic = it,
onClick = { onClickItem(it) },
)
}
}
}
}

@Composable
private fun QuestionStatisticItem(myCharacter: Member, statistic: QuestionStatistic) {
private fun QuestionStatisticItem(
myCharacter: Member,
statistic: QuestionStatistic,
onClick: () -> Unit,
) {
Row(
modifier = Modifier
.fillMaxWidth()
.background(color = Color(0x0DFFFFFF), shape = RoundedCornerShape(size = 14.dp))
.padding(horizontal = 14.dp, vertical = 20.dp),
.padding(horizontal = 14.dp, vertical = 20.dp)
.clickableRippleEffect { onClick() },
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(12.dp),
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ private fun KeymeQuestionStatisticsInfo(
questionStatistic.category.name
},
keymeTextType = KeymeTextType.BODY_3_REGULAR,
color = Color.White,
)

Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,13 @@ private fun KeymeQuestionScoreItem(
modifier = Modifier.align(Alignment.Center),
text = "${score}",
keymeTextType = KeymeTextType.BODY_3_REGULAR,
color = Color.White,
)
KeymeText(
modifier = Modifier.align(Alignment.CenterEnd),
text = timeStamp.getUploadTimeString(),
keymeTextType = KeymeTextType.BODY_3_REGULAR,
color = Color(0x4DFFFFFF),
)
}
}

0 comments on commit 7317e37

Please sign in to comment.