Skip to content

Commit

Permalink
시험상세 페이지 챌린지(퀴즈)와 덕력고사 분기 처리 (#475)
Browse files Browse the repository at this point in the history
* feat: ExamData에 quiz 관련 property 추가

* feat: Detail Screen 덕퀴즈인지, 일반 시험인지에 따라 분기할 수 있도록 재정비

* feat: 현재 quiz 정보인지에 대한 상태 추가

* feat: 새로운 왕관 아이콘 추가

* feat: String Resource 추가

* feat: ExamDetail에 대한 컴포저블 분리, 추후 시험 메타데이터 제공할 수 있도록 TODO 작성

* refactor: lint 검출 사항 수정

* feat: ranking empty일 때 케이스 고려
  • Loading branch information
EvergreenTree97 authored May 12, 2023
1 parent 3327a14 commit fe0b511
Show file tree
Hide file tree
Showing 16 changed files with 754 additions and 399 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import team.duckie.app.android.data.exam.model.ImageChoiceData
import team.duckie.app.android.data.exam.model.ProblemData
import team.duckie.app.android.data.exam.model.ProfileExamData
import team.duckie.app.android.data.exam.model.QuestionData
import team.duckie.app.android.data.exam.model.QuizInfoResponse
import team.duckie.app.android.data.heart.mapper.toDomain
import team.duckie.app.android.data.tag.mapper.toDomain
import team.duckie.app.android.data.tag.model.TagData
Expand All @@ -42,6 +43,7 @@ import team.duckie.app.android.domain.exam.model.ImageChoiceModel
import team.duckie.app.android.domain.exam.model.Problem
import team.duckie.app.android.domain.exam.model.ProfileExam
import team.duckie.app.android.domain.exam.model.Question
import team.duckie.app.android.domain.quiz.model.QuizInfo
import team.duckie.app.android.util.kotlin.AllowCyclomaticComplexMethod
import team.duckie.app.android.util.kotlin.exception.duckieResponseFieldNpe
import team.duckie.app.android.util.kotlin.fastMap
Expand All @@ -66,6 +68,8 @@ internal fun ExamData.toDomain() = Exam(
status = status,
heart = heart?.toDomain(),
heartCount = heartCount,
quizs = quizs?.fastMap(QuizInfoResponse::toDomain)?.toImmutableList(),
perfectScoreImageUrl = perfectScoreImageUrl,
)

internal fun ExamsData.toDomain() = exams?.fastMap { examData -> examData.toDomain() }
Expand Down Expand Up @@ -243,3 +247,12 @@ internal fun ProfileExamData.toDomain() = ProfileExam(
heartCount = heartCount,
user = user?.toDomain(),
)

internal fun QuizInfoResponse.toDomain() = QuizInfo(
id = id ?: duckieResponseFieldNpe("${this::class.java.simpleName}.id"),
correctProblemCount = correctProblemCount
?: duckieResponseFieldNpe("${this::class.java.simpleName}.correctProblemCount"),
score = score ?: duckieResponseFieldNpe("${this::class.java.simpleName}.score"),
user = user?.toDomain() ?: duckieResponseFieldNpe("${this::class.java.simpleName}.user"),
time = time ?: duckieResponseFieldNpe("${this::class.java.simpleName}.time"),
)
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ data class ExamData(

@field:JsonProperty("heartCount")
val heartCount: Int? = null,

@field:JsonProperty("challenges")
val quizs: List<QuizInfoResponse>? = null,

@field:JsonProperty("perfectScoreImageUrl")
val perfectScoreImageUrl: String? = null,
)

data class ExamsData(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Designed and developed by Duckie Team, 2022
*
* Licensed under the MIT.
* Please see full license: https://github.com/duckie-team/duckie-android/blob/develop/LICENSE
*/

package team.duckie.app.android.data.exam.model

import com.fasterxml.jackson.annotation.JsonProperty
import team.duckie.app.android.data.user.model.UserResponse

data class QuizInfoResponse(
@JsonProperty("id")
val id: Int? = null,
@JsonProperty("correctProblemCount")
val correctProblemCount: Int? = null,
@JsonProperty("score")
val score: Int? = null,
@JsonProperty("time")
val time: Int? = null,
@JsonProperty("user")
val user: UserResponse? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.compose.runtime.Immutable
import kotlinx.collections.immutable.ImmutableList
import team.duckie.app.android.domain.category.model.Category
import team.duckie.app.android.domain.heart.model.Heart
import team.duckie.app.android.domain.quiz.model.QuizInfo
import team.duckie.app.android.domain.tag.model.Tag
import team.duckie.app.android.domain.user.model.User

Expand All @@ -35,6 +36,8 @@ data class Exam(
val status: String?,
val heart: Heart?,
val heartCount: Int?,
val quizs: ImmutableList<QuizInfo>?,
val perfectScoreImageUrl: String?,
) {
companion object {
/*
Expand All @@ -59,6 +62,8 @@ data class Exam(
status = null,
heart = null,
heartCount = null,
quizs = null,
perfectScoreImageUrl = null,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Designed and developed by Duckie Team, 2022
*
* Licensed under the MIT.
* Please see full license: https://github.com/duckie-team/duckie-android/blob/develop/LICENSE
*/

package team.duckie.app.android.domain.quiz.model

import androidx.compose.runtime.Immutable
import team.duckie.app.android.domain.user.model.User

@Immutable
data class QuizInfo(
val id: Int,
val correctProblemCount: Int,
val score: Int,
val user: User,
val time: Int,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Designed and developed by Duckie Team, 2022
*
* Licensed under the MIT.
* Please see full license: https://github.com/duckie-team/duckie-android/blob/develop/LICENSE
*/

package team.duckie.app.android.feature.ui.detail.common

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
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.unit.DpSize
import androidx.compose.ui.unit.dp
import team.duckie.app.android.feature.ui.detail.viewmodel.state.DetailState
import team.duckie.app.android.shared.ui.compose.Spacer
import team.duckie.quackquack.ui.R
import team.duckie.quackquack.ui.component.QuackDivider
import team.duckie.quackquack.ui.component.QuackImage
import team.duckie.quackquack.ui.component.QuackSmallButton
import team.duckie.quackquack.ui.component.QuackSmallButtonType

/** 상세 화면 최하단 Layout */
@Composable
internal fun DetailBottomLayout(
modifier: Modifier,
state: DetailState.Success,
onHeartClick: () -> Unit,
onChallengeClick: () -> Unit,
) {
Column(modifier = modifier) {
Spacer(space = 20.dp)
// 구분선
QuackDivider()
// 버튼 모음 Layout
// TODO(riflockle7): 추후 Layout 을 활용해 처리하기
Row(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp, vertical = 9.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
) {
// 좋아요 버튼
QuackImage(
src = if (state.isHeart) {
R.drawable.quack_ic_heart_filled_24
} else {
R.drawable.quack_ic_heart_24
},
size = DpSize(24.dp, 24.dp),
onClick = onHeartClick,
)

// 버튼
QuackSmallButton(
text = state.buttonTitle,
type = QuackSmallButtonType.Fill,
enabled = true,
onClick = onChallengeClick,
)
}
}
}
Loading

0 comments on commit fe0b511

Please sign in to comment.