Skip to content

Commit 5771d66

Browse files
authored
[Mod#1569] 솝탬프 파트에 pointsDecimal 필드 추가 (#1570)
* [FEAT#1569] 파트별 랭킹 정보 내 pointsDecimal 필드 추가 * [FEAT#1569] 파트별 랭킹 내 소수점 점수 표기 기능 구현 * [REFACTOR#1569] RankListItem 내 미사용 파라미터 isPartRanking 제거 * [REFACTOR#1569] PartRank 관련 데이터 모델 내 points 필드 제거
1 parent 22d1cc5 commit 5771d66

6 files changed

Lines changed: 63 additions & 24 deletions

File tree

data/soptamp/src/main/java/org/sopt/official/data/soptamp/remote/model/response/PartRankResponse.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ data class PartRankResponse(
3434
val part: String,
3535
@SerialName("rank")
3636
val rank: Int,
37-
@SerialName("points")
38-
val points: Int,
37+
@SerialName("pointsDecimal")
38+
val pointsDecimal: Double
3939
) {
4040
fun toDomain() = PartRank(
4141
part = part,
4242
rank = rank,
43-
points = points
43+
pointsDecimal = pointsDecimal
4444
)
4545
}

domain/soptamp/src/main/kotlin/org/sopt/official/domain/soptamp/model/PartRank.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ package org.sopt.official.domain.soptamp.model
2727
data class PartRank(
2828
val part: String,
2929
val rank: Int,
30-
val points: Int,
30+
val pointsDecimal: Double
3131
)

feature/soptamp/src/main/java/org/sopt/official/stamp/feature/ranking/RankListItem.kt

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ import org.sopt.official.common.util.noRippleClickable
4747
import org.sopt.official.stamp.feature.ranking.model.PartRankModel
4848
import org.sopt.official.stamp.feature.ranking.model.RankerUiModel
4949

50+
/**
51+
* 랭킹 UI 레이아웃
52+
* @param partItem 파트별 랭킹 아이템
53+
* @param rankerItem 개인별 랭킹 아이템
54+
* @param isMyRanking 사용자 본인의 랭킹 여부
55+
* */
5056
@Composable
5157
fun RankListItem(
5258
partItem: PartRankModel? = null,
@@ -76,14 +82,15 @@ fun RankListItem(
7682
var name = ""
7783
var description: String? = ""
7884
var scorePoint: Int = -1
85+
var scorePartRankPoint = 0.0
7986

8087
if (partItem != null) {
8188
with(partItem) {
8289
ranking = rank
8390
newRank = -1
8491
name = part
8592
description = null
86-
scorePoint = point
93+
scorePartRankPoint = pointDecimal
8794
}
8895
} else if (rankerItem != null) {
8996
with(rankerItem) {
@@ -131,12 +138,21 @@ fun RankListItem(
131138
}
132139
Spacer(modifier = Modifier.weight(0.04f))
133140
Box(
134-
modifier = Modifier.weight(0.4f),
141+
modifier = Modifier.weight(0.5f),
135142
) {
136-
RankScore(
137-
modifier = Modifier.align(Alignment.CenterEnd),
138-
score = scorePoint,
139-
)
143+
if (isPartRankItem) {
144+
// 파트 랭킹
145+
RankScore(
146+
modifier = Modifier.align(Alignment.CenterEnd),
147+
score = scorePartRankPoint,
148+
)
149+
} else {
150+
// 개인 랭킹
151+
RankScore(
152+
modifier = Modifier.align(Alignment.CenterEnd),
153+
score = scorePoint,
154+
)
155+
}
140156
}
141157
}
142158
}

feature/soptamp/src/main/java/org/sopt/official/stamp/feature/ranking/RankScore.kt

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525
package org.sopt.official.stamp.feature.ranking
2626

27+
import androidx.compose.foundation.layout.Column
2728
import androidx.compose.foundation.layout.Row
2829
import androidx.compose.material3.Text
2930
import androidx.compose.runtime.Composable
@@ -35,11 +36,30 @@ import androidx.compose.ui.unit.sp
3536
import org.sopt.official.designsystem.SoptTheme
3637
import org.sopt.official.stamp.designsystem.style.MontserratRegular
3738
import org.sopt.official.stamp.designsystem.style.PretendardMedium
39+
import java.util.Locale
3840

3941
@Composable
4042
fun RankScore(
4143
modifier: Modifier = Modifier,
4244
score: Int,
45+
) {
46+
RankScoreText(modifier = modifier, scoreText = score.toString())
47+
}
48+
49+
@Composable
50+
fun RankScore(
51+
modifier: Modifier = Modifier,
52+
score: Double,
53+
) {
54+
val formattedScore = String.format(Locale.getDefault(),"%.2f", score)
55+
56+
RankScoreText(modifier = modifier, scoreText = formattedScore)
57+
}
58+
59+
@Composable
60+
private fun RankScoreText(
61+
modifier: Modifier = Modifier,
62+
scoreText: String,
4363
) {
4464
val textColor = SoptTheme.colors.primary
4565

@@ -48,7 +68,7 @@ fun RankScore(
4868
verticalAlignment = Alignment.Bottom,
4969
) {
5070
Text(
51-
text = "$score",
71+
text = scoreText,
5272
fontFamily = MontserratRegular,
5373
fontSize = 30.sp,
5474
fontWeight = FontWeight.W400,
@@ -66,8 +86,11 @@ fun RankScore(
6686

6787
@Preview
6888
@Composable
69-
fun PreviewRankScore() {
89+
private fun PreviewRankScore() {
7090
SoptTheme {
71-
RankScore(score = 1000)
91+
Column {
92+
RankScore(score = 1000)
93+
RankScore(score = 350.12)
94+
}
7295
}
73-
}
96+
}

feature/soptamp/src/main/java/org/sopt/official/stamp/feature/ranking/model/PartRankModel.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ import org.sopt.official.domain.soptamp.model.PartRank
2929
data class PartRankModel(
3030
val rank: Int,
3131
val part: String,
32-
val point: Int,
32+
val pointDecimal: Double,
3333
)
3434

3535
internal fun List<PartRank>.toData(): List<PartRankModel> =
3636
this.map {
3737
PartRankModel(
3838
rank = it.rank,
3939
part = it.part,
40-
point = it.points,
40+
pointDecimal = it.pointsDecimal
4141
)
4242
}

feature/soptamp/src/main/java/org/sopt/official/stamp/feature/ranking/part/PartRankingScreen.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ fun PartRankingBar(
149149
modifier: Modifier = Modifier,
150150
) {
151151
val newRank =
152-
if (part.point != 0) {
152+
if (part.pointDecimal != 0.0) {
153153
part.rank
154154
} else {
155155
0
@@ -160,7 +160,7 @@ fun PartRankingBar(
160160
verticalArrangement = Arrangement.Bottom,
161161
horizontalAlignment = Alignment.CenterHorizontally,
162162
) {
163-
if (part.rank < 4 && part.point != 0) {
163+
if (part.rank < 4 && part.pointDecimal != 0.0) {
164164
TopRankBarOfRankText(rank = part.rank)
165165
}
166166
RankingBar(
@@ -195,32 +195,32 @@ fun PartRankingPreview() {
195195
PartRankModel(
196196
3,
197197
"기획",
198-
500,
198+
350.12
199199
),
200200
PartRankModel(
201201
4,
202202
"디자인",
203-
400,
203+
350.12
204204
),
205205
PartRankModel(
206206
6,
207207
"",
208-
100,
208+
350.12
209209
),
210210
PartRankModel(
211211
2,
212212
"아요",
213-
1000,
213+
350.12
214214
),
215215
PartRankModel(
216216
1,
217217
"안드",
218-
8000,
218+
350.12
219219
),
220220
PartRankModel(
221221
5,
222222
"서버",
223-
200,
223+
350.12
224224
),
225225
)
226226
SoptTheme {

0 commit comments

Comments
 (0)