Skip to content

Commit b1821d6

Browse files
committed
[Fix] #63 - 1차 버그 수정
1 parent 649e367 commit b1821d6

File tree

6 files changed

+44
-19
lines changed

6 files changed

+44
-19
lines changed

Motivoo-iOS/Motivoo-iOS/Feature/Home/ViewControllers/HomeViewController.swift

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ final class HomeViewController: BaseViewController {
1919
private var mateGoalStep: Int = 0
2020
private var guideURL = String()
2121
/// 나중에 인증 완료 API 들어오면 바인딩
22-
private var isMissionCompleted: Bool = true
22+
private var isMissionCompleted: Bool = false {
23+
didSet {
24+
if isMissionCompleted {
25+
homeView.configureCheckButtonStyle(state: .checkCompleted)
26+
}
27+
}
28+
}
2329
private var isStepCountCompleted: Bool = false {
2430
didSet {
2531
if isStepCountCompleted && isMateStepCountCompleted {
@@ -69,10 +75,14 @@ final class HomeViewController: BaseViewController {
6975
if mateGoalStep > 0 && mateGoalStep <= tempMateStep {
7076
self.isMateStepCountCompleted = true
7177
}
78+
7279
DispatchQueue.main.async {
73-
self.homeView.homeCircularProgressView.setParentProgress(currentStep: self.tempMateStep, finalStep: self.mateGoalStep , withAnimation: true)
80+
self.homeView.homeCircularProgressView.setParentProgress(currentStep: self.tempMateStep,
81+
finalStep: self.mateGoalStep,
82+
withAnimation: true)
7483
self.homeView.homeStepCountView.parentWalkCountLabel.text = "\(self.tempMateStep)"
7584
}
85+
7686
}
7787
}
7888
}
@@ -91,7 +101,9 @@ final class HomeViewController: BaseViewController {
91101

92102
override func viewDidLoad() {
93103
super.viewDidLoad()
94-
StepCountManager.shared.startCheckStepCount()
104+
if !StepCountManager.shared.isStepCountStarted {
105+
StepCountManager.shared.startCheckStepCount()
106+
}
95107
configureStepCount()
96108
}
97109

@@ -104,9 +116,7 @@ final class HomeViewController: BaseViewController {
104116
requestPatchHome()
105117
requestPostMission()
106118
configureMissionTapGesture()
107-
if isMissionCompleted {
108-
homeView.configureCheckButtonStyle(state: .checkCompleted)
109-
}
119+
110120
}
111121

112122
// MARK: - Override Functions
@@ -149,9 +159,10 @@ final class HomeViewController: BaseViewController {
149159
@objc
150160
private func firstMissionViewDidTapped() {
151161
if !homeView.isMissionSelected {
152-
homeView.configureMissionSelectedView(isSelected: !homeView.isMissionSelected)
153162
requestPostMissionChoice(param: HomeChoiceMissionRequest(missionID: firstMissionData.missionID))
163+
homeView.configureMissionSelectedView(isSelected: !homeView.isMissionSelected)
154164
homeView.pickMissionLabel.text = firstMissionData.missionContent
165+
homeView.dateLabel.text = "오늘의 운동"
155166
}
156167
}
157168

@@ -161,8 +172,7 @@ final class HomeViewController: BaseViewController {
161172
homeView.configureMissionSelectedView(isSelected: !homeView.isMissionSelected)
162173
requestPostMissionChoice(param: HomeChoiceMissionRequest(missionID: secondMissionData.missionID))
163174
homeView.pickMissionLabel.text = secondMissionData.missionContent
164-
165-
175+
homeView.dateLabel.text = "오늘의 운동"
166176
}
167177
}
168178

@@ -234,7 +244,7 @@ final class HomeViewController: BaseViewController {
234244
///비활성화 된 상태에서, 화면 밖으로 나가지 않고 즉시 걸음수 충족 및 인증 완료를 확인하기 위한 처리.
235245
///화면으로부터 나간 후, 다시 들어왔을 때는 서버에서 isMissionCompleted 값을 준다.
236246
private func judgeButtonStyle(goal goalStep: Int, now currentStep: Int) {
237-
if goalStep >= 0 && goalStep >= currentStep {
247+
if goalStep > 0 && goalStep >= currentStep {
238248
homeView.configureCheckButtonStyle(state: .unCompleted)
239249
} else { /// 목표 걸음수를 채웠을 때의 두 가지 경우.
240250
self.isStepCountCompleted = true
@@ -314,21 +324,19 @@ extension HomeViewController {
314324
self.mateGoalStep = result.opponentUserGoalStepCount
315325
self.isStepCountCompleted = result.isStepCountCompleted
316326
self.isMissionCompleted = result.isMissionImgCompleted
317-
327+
if result.isMissionImgCompleted {
328+
self.homeView.configureCheckButtonStyle(state: .checkCompleted)
329+
}
318330

319331
/// 목표 걸음 수 너무 높아서 따로 넣어서 사용 중
320332
// self.goalStep = 700
321333
// self.mateGoalStep = 1000
322334

323335
if result.userType == "자녀" {
324336
self.homeView.homeStepCountView.parentWalkLabel.text = "부모님 걸음"
325-
self.homeView.homeCircularProgressView.myProgressLayer.strokeColor = UIColor.blue400.cgColor
326-
self.homeView.homeCircularProgressView.parentProgressLayer.strokeColor = UIColor.gray600.cgColor
327337

328338
} else if result.userType == "부모" {
329339
self.homeView.homeStepCountView.parentWalkLabel.text = "자녀 걸음"
330-
self.homeView.homeCircularProgressView.myProgressLayer.strokeColor = UIColor.gray600.cgColor
331-
self.homeView.homeCircularProgressView.parentProgressLayer.strokeColor = UIColor.blue400.cgColor
332340
}
333341
}
334342
}
@@ -349,6 +357,7 @@ extension HomeViewController {
349357
missionContent: String(),
350358
missionIconURL: String())
351359
} else {
360+
self.homeView.dateLabel.text = "오늘의 운동"
352361
self.guideURL = result.todayMission?.missionDescription ?? ""
353362
}
354363
}

Motivoo-iOS/Motivoo-iOS/Feature/Home/Views/Main/HomeMissionView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ final class HomeMissionView: BaseView {
4646
missionLabel.do {
4747
$0.font = .body6
4848
$0.textColor = .black
49-
$0.addLineHeight(lineHeight: 23.68.adjusted)
49+
$0.setLineSpacing(lineSpacing: 1.24.adjusted)
5050
$0.numberOfLines = 3
5151
}
5252

Motivoo-iOS/Motivoo-iOS/Feature/Home/Views/Main/HomeView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ final class HomeView: BaseView {
3131

3232
// MARK: - UI Components
3333

34-
private var dateLabel = UILabel()
34+
var dateLabel = UILabel()
3535
var pickMissionLabel = UILabel()
3636
var firstMissionView = HomeMissionView()
3737
var secondMissionView = HomeMissionView()
@@ -61,6 +61,7 @@ final class HomeView: BaseView {
6161
$0.font = .heading4
6262
$0.numberOfLines = 2
6363
$0.textColor = .black
64+
$0.setLineSpacing(lineSpacing: 1.17.adjusted)
6465
}
6566

6667
missionStackView.do {

Motivoo-iOS/Motivoo-iOS/Feature/Home/Views/Prove/HomeProveView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ final class HomeProveView: BaseView {
4545
$0.font = .heading3
4646
$0.textColor = .black
4747
$0.numberOfLines = 2
48-
$0.addLineHeight(lineHeight: 33.6.adjusted)
48+
$0.setLineSpacing(lineSpacing: 1.17.adjusted)
4949
}
5050

5151
subtitleLabel.do {

Motivoo-iOS/Motivoo-iOS/Global/Extension/UILabel+.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,17 @@ extension UILabel {
2424
self.attributedText = attrString
2525
}
2626
}
27+
28+
public func setLineSpacing(lineSpacing: CGFloat) {
29+
if let text = self.text {
30+
let attributedStr = NSMutableAttributedString(string: text)
31+
let style = NSMutableParagraphStyle()
32+
style.lineSpacing = lineSpacing
33+
attributedStr.addAttribute(
34+
NSAttributedString.Key.paragraphStyle,
35+
value: style,
36+
range: NSRange(location: 0, length: attributedStr.length))
37+
self.attributedText = attributedStr
38+
}
39+
}
2740
}

Motivoo-iOS/Motivoo-iOS/Global/SupportingFiles/StepCountManager.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ final class StepCountManager {
2727

2828
var db: DatabaseReference!
2929
private var timer: Timer? = nil
30-
30+
var isStepCountStarted = false
3131
var pedoMeter = CMPedometer()
3232
var uid: Int?
3333
var mid: Int?
@@ -80,13 +80,15 @@ final class StepCountManager {
8080
repeats: true)
8181
}
8282
print("타이머 시작")
83+
isStepCountStarted = true
8384
}
8485

8586
private func stopTimer() {
8687
timer?.invalidate()
8788
timer = nil
8889
db.removeAllObservers()
8990
db = nil
91+
isStepCountStarted = false
9092
print("타이머 멈춤")
9193
}
9294

0 commit comments

Comments
 (0)