Skip to content

Commit 8a56932

Browse files
author
Mincheol Kim
authored
Merge pull request #65 from Nexters/fix/qa
Fix/qa
2 parents 173e097 + 3302cf7 commit 8a56932

File tree

14 files changed

+122
-76
lines changed

14 files changed

+122
-76
lines changed

Sticky/Assets.xcassets/close_small.imageset/Contents.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
{
22
"images" : [
33
{
4-
"filename" : "close_small.png",
4+
"filename" : "Subtract.svg",
55
"idiom" : "universal",
66
"scale" : "1x"
77
},
88
{
9-
"filename" : "close_small@2x.svg",
9+
"filename" : "Subtract-1.svg",
1010
"idiom" : "universal",
1111
"scale" : "2x"
1212
},
1313
{
14+
"filename" : "Subtract-2.svg",
1415
"idiom" : "universal",
1516
"scale" : "3x"
1617
}
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
-330 Bytes
Binary file not shown.

Sticky/Assets.xcassets/close_small.imageset/close_small@2x.svg

Lines changed: 0 additions & 3 deletions
This file was deleted.

Sticky/Components/EditText.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ struct EditText: View {
4545
}
4646
}, label: {
4747
Image("ic_close_small")
48+
.resizable()
49+
.scaledToFit()
50+
.frame(width: 20, height: 20)
4851
})
4952
}
5053
}

Sticky/Features/Banner/Components/Banner.swift

Lines changed: 49 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -24,59 +24,68 @@ struct Banner: View {
2424
badgeType: BadgeType.monthly,
2525
badges: self.badgeViewModel.monthly
2626
)
27-
let remainMonthlyBadge = (Int(nextMonthlyBadge.badgeValue) ?? 0) * 3600
28-
- challengeState.seconds
29-
if remainMonthlyBadge <= 0 {
30-
nextMonthlyBadge.updated = Date()
31-
nextMonthlyBadge.count += 1
32-
badgeViewModel.monthly = badgeViewModel.monthly
33-
badgeViewModel.badgeQueue.append(nextMonthlyBadge)
34-
} else {
35-
print("월간 배지 획득 남은 시간: \(remainMonthlyBadge)")
27+
var remainMonthlyBadge = 0
28+
if nextMonthlyBadge.badgeType != .unknown {
29+
remainMonthlyBadge = (Int(nextMonthlyBadge.badgeValue) ?? 0) * 3600
30+
- challengeState.seconds
31+
if remainMonthlyBadge <= 0 {
32+
nextMonthlyBadge.updated = Date()
33+
nextMonthlyBadge.count += 1
34+
badgeViewModel.monthly = badgeViewModel.monthly
35+
badgeViewModel.badgeQueue.append(nextMonthlyBadge)
36+
} else {
37+
print("월간 배지 획득 남은 시간: \(remainMonthlyBadge)")
38+
}
3639
}
3740

3841
let nextContiousBadge = nextBadge(
3942
badgeType: BadgeType.continuous,
4043
badges: self.badgeViewModel.continuous
4144
)
42-
// 연속 배지 획득까지 남은 seconds; 뱃지 필요한 시간 - 챌린지 시간
43-
var remainContinuousBadge = nextContiousBadge.badgeValue == "0.5" ? 12 * 3600 : (Int(nextContiousBadge.badgeValue) ?? 0) * 3600 * 24
44-
remainContinuousBadge -= challengeState.seconds
45-
if remainContinuousBadge <= 0 {
46-
nextContiousBadge.updated = Date()
47-
nextContiousBadge.count += 1
48-
badgeViewModel.continuous = badgeViewModel.continuous
49-
badgeViewModel.badgeQueue.append(nextContiousBadge)
50-
} else {
51-
print("연속 배지 획득 남은 시간: \(remainContinuousBadge)")
45+
var remainContinuousBadge = 0
46+
if nextContiousBadge.badgeType != .unknown {
47+
// 연속 배지 획득까지 남은 seconds; 뱃지 필요한 시간 - 챌린지 시간
48+
remainContinuousBadge = nextContiousBadge.badgeValue == "0.5" ? 12 * 3600 : (Int(nextContiousBadge.badgeValue) ?? 0) * 3600 * 24
49+
remainContinuousBadge -= challengeState.seconds
50+
if remainContinuousBadge <= 0 {
51+
nextContiousBadge.updated = Date()
52+
nextContiousBadge.count += 1
53+
badgeViewModel.continuous = badgeViewModel.continuous
54+
badgeViewModel.badgeQueue.append(nextContiousBadge)
55+
} else {
56+
print("연속 배지 획득 남은 시간: \(remainContinuousBadge)")
57+
}
5258
}
5359

5460
return ScrollView(.horizontal, showsIndicators: false) {
5561
HStack {
56-
Button(
57-
action: {
62+
if nextMonthlyBadge.badgeType != .unknown {
63+
Button(
64+
action: {
65+
self.bannerDetailPresented = true
66+
self.badgeViewModel.select = nextMonthlyBadge
67+
},
68+
label: {
69+
BannerItem(
70+
image: nextMonthlyBadge.image,
71+
title: nextMonthlyBadge.name,
72+
subtitle: "\(remainTime(remainMonthlyBadge)) 남음"
73+
)
74+
}
75+
)
76+
}
77+
if nextContiousBadge.badgeType != .unknown {
78+
Button(action: {
5879
self.bannerDetailPresented = true
59-
self.badgeViewModel.select = nextMonthlyBadge
60-
},
61-
label: {
80+
self.badgeViewModel.select = nextContiousBadge
81+
}, label: {
6282
BannerItem(
63-
image: nextMonthlyBadge.image,
64-
title: nextMonthlyBadge.name,
65-
subtitle: "\(remainTime(remainMonthlyBadge)) 남음"
83+
image: nextContiousBadge.image,
84+
title: nextContiousBadge.name,
85+
subtitle: "\(remainTime(remainContinuousBadge)) 남음"
6686
)
67-
}
68-
)
69-
70-
Button(action: {
71-
self.bannerDetailPresented = true
72-
self.badgeViewModel.select = nextContiousBadge
73-
}, label: {
74-
BannerItem(
75-
image: nextContiousBadge.image,
76-
title: nextContiousBadge.name,
77-
subtitle: "\(remainTime(remainContinuousBadge)) 남음"
78-
)
79-
})
87+
})
88+
}
8089

8190
Button(action: { self.mypagePresented = true }) {
8291
RoundedRectangle(cornerRadius: 20)

Sticky/Features/MyPage/Models/Badge.swift

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ class Badge: Codable, Hashable, Identifiable {
5757
.special:
5858
// 한 번이라도 획득했으면 무조건 활성화
5959
return count > 0
60+
case .unknown:
61+
return false
6062
}
6163
}
6264

@@ -69,6 +71,8 @@ class Badge: Codable, Hashable, Identifiable {
6971
return "\(badgeType)_\(badgeValue)\(active ? "" : "_locked")"
7072
case .level:
7173
return "level\(badgeValue)"
74+
case .unknown:
75+
return ""
7276
}
7377
}
7478

@@ -81,7 +85,8 @@ class Badge: Codable, Hashable, Identifiable {
8185
switch badgeType {
8286
case .continuous,
8387
.monthly,
84-
.special:
88+
.special,
89+
.unknown:
8590
if badgeType == BadgeType.continuous, badgeValue == "0.5" {
8691
return "12 Hours"
8792
}
@@ -99,8 +104,9 @@ class Badge: Codable, Hashable, Identifiable {
99104
case .continuous:
100105
return "이번 챌린지에서 집에서 보낸 시간\n\(name)을 달성하면 받을 수 있습니다."
101106
case .level,
102-
.special:
103-
return "준비 중입니다."
107+
.special,
108+
.unknown:
109+
return ""
104110
}
105111
}
106112

@@ -141,6 +147,7 @@ extension Date {
141147
- level: 레벨
142148
*/
143149
enum BadgeType: String, Codable {
150+
case unknown
144151
case special
145152
case monthly
146153
case continuous
@@ -150,6 +157,8 @@ enum BadgeType: String, Codable {
150157
extension BadgeType {
151158
func toString(value: String) -> String {
152159
switch self {
160+
case .unknown:
161+
return ""
153162
case .special:
154163
if value.trimmingCharacters(in: .whitespaces) == "welcome" {
155164
return "스티키에 오신걸 환영합니다!"
@@ -166,19 +175,21 @@ extension BadgeType {
166175

167176
var unit: String {
168177
switch self {
169-
case BadgeType.special:
178+
case .level,
179+
.special,
180+
.unknown:
170181
return ""
171-
case BadgeType.monthly:
182+
case .monthly:
172183
return "Hours"
173-
case BadgeType.continuous:
184+
case .continuous:
174185
return "Days"
175-
case BadgeType.level:
176-
return ""
177186
}
178187
}
179188

180189
var alias: String {
181190
switch self {
191+
case .unknown:
192+
return ""
182193
case .continuous:
183194
return "연속 달성 기록"
184195
case .monthly:

Sticky/Features/MyPage/Models/BadgeViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func nextBadge(
151151
return badges
152152
.filter { badge in !badge.active }
153153
.sorted { Double($0.badgeValue)! < Double($1.badgeValue)! }
154-
.first ?? Badge(badgeType: .special, badgeValue: "locked")
154+
.first ?? Badge(badgeType: .unknown, badgeValue: "")
155155
}
156156

157157
/// 이번달 여부 확인

0 commit comments

Comments
 (0)