Skip to content

Commit

Permalink
Merge pull request #150 from TeamHY2/Fix/#149-RankingNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
Seokki-Kwon authored Jan 16, 2025
2 parents 190338a + 523e2bf commit ce84d1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions HongikYeolgong2/Presentation/Ranking/Component/RankingCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ import SwiftUI

struct RankingCell: View {
let departmentRankInfo: RankingDepartment
let offset: Int

var isStudyTimeLessThanZero: Bool {
departmentRankInfo.studyDurationOfWeek <= 0
}

var body: some View {
VStack(spacing: 0) {
HStack(spacing: 0) {
HStack(spacing: 14.adjustToScreenWidth) {
Text("\(departmentRankInfo.currentRank)")
Text(isStudyTimeLessThanZero ? "-" : "\(departmentRankInfo.currentRank)")
.font(.pretendard(size: 16, weight: .regular))
.foregroundStyle(setFontColor)

Expand Down Expand Up @@ -55,7 +60,7 @@ extension RankingCell {
}

private var setBackground: some View {
switch departmentRankInfo.currentRank {
switch offset {
case 1:
return Image(.rankingBox1)
.resizable()
Expand All @@ -76,7 +81,7 @@ extension RankingCell {
}

private var setFontColor: Color {
switch departmentRankInfo.currentRank {
switch offset {
case 1:
.gray600
case 2:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ struct RankingListView: View {
var body: some View {
ScrollView(showsIndicators: false) {
LazyVStack(spacing: 16) {
ForEach(departmentRankings, id: \.self) { rankingInfo in
RankingCell(departmentRankInfo: rankingInfo)
ForEach(Array(departmentRankings.enumerated()), id: \.self.offset) { (offset, rankingInfo) in
RankingCell(departmentRankInfo: rankingInfo, offset: offset + 1)
}
}
.padding(.horizontal, 32.adjustToScreenWidth)
Expand Down

0 comments on commit ce84d1e

Please sign in to comment.