From b100fd014de8b58e8ba722ac9923a5ee66ca2393 Mon Sep 17 00:00:00 2001 From: s Date: Tue, 13 Feb 2024 14:04:19 +0900 Subject: [PATCH 01/30] =?UTF-8?q?=F0=9F=8D=97=20::=20[#171]=20Int=ED=98=95?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EB=A6=AC=ED=8E=99=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/TimerScene/View/TimerViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/View/TimerViewController.swift b/Projects/Features/HomeFeature/Sources/TimerScene/View/TimerViewController.swift index 2f84b3dd..9a4c706c 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/View/TimerViewController.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/View/TimerViewController.swift @@ -139,7 +139,7 @@ public class TimerViewController: BaseViewController { .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] timeString in DispatchQueue.main.async { [weak self] in - if self?.progressBarView.currentTimer() ?? 0.0 <= 0.0 { + if self?.progressBarView.currentTimer() ?? 0 <= 0 { self?.alaertView.moveViewDown() self?.progressBarView.stopTimer() self?.stopButton.isHidden = true From 518252cea63b0dd9873786db4e437c1308fb9db3 Mon Sep 17 00:00:00 2001 From: s Date: Tue, 13 Feb 2024 14:04:34 +0900 Subject: [PATCH 02/30] =?UTF-8?q?=F0=9F=8D=97=20::=20[#171]=20=ED=83=80?= =?UTF-8?q?=EC=9D=B4=EB=A8=B8=20Int=ED=98=95=EC=9C=BC=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Supporter/MinGymKit/MinGymKit.swift | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGymKit.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGymKit.swift index d35b2cfe..dbc2058c 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGymKit.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGymKit.swift @@ -3,17 +3,19 @@ import RxSwift public protocol TimerControl { var timeUpdate: Observable { get } + func setting(initialTime: Int) func start() func stop() func reset() - func presentTime() -> Double + func restart() + func presentTime() -> Int } open class MindGymTimerKit { public let mainTimer: TimerControl = MindGaGymKitTimer() - public func setting(count: Double) { - (mainTimer as? MindGaGymKitTimer)?.setting(count: count) + public func setting(time: Int) { + mainTimer.setting(initialTime: time) } public func startTimer() { @@ -29,11 +31,10 @@ open class MindGymTimerKit { } public func restartTimer() { - (mainTimer as? MindGaGymKitTimer)?.restart() + mainTimer.restart() } - public func presentTimer() -> Double { - let presentTime: Double = mainTimer.presentTime() - return presentTime + public func presentTimer() -> Int { + return mainTimer.presentTime() } } From 16392ce0fd5687e27b05dc885e0f37f07cf3c820 Mon Sep 17 00:00:00 2001 From: s Date: Tue, 13 Feb 2024 14:04:50 +0900 Subject: [PATCH 03/30] =?UTF-8?q?=F0=9F=8D=97=20::=20[#171]=20=ED=83=80?= =?UTF-8?q?=EC=9D=B4=EB=A8=B8=20Int=ED=98=95=EC=9C=BC=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MinGymKit/MinGaGymTimerKit.swift | 67 ++++++++++--------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGaGymTimerKit.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGaGymTimerKit.swift index 32e3f358..8ed4a91d 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGaGymTimerKit.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGaGymTimerKit.swift @@ -4,58 +4,63 @@ import RxSwift open class MindGaGymKitTimer: NSObject, TimerControl { - private var initCounter: Double = 0.0 - private var counter: Double = 0.0 + private var initTime: Int = 0 + private var time: Double = 0 private var timer: Timer? + private let timerSubject = PublishSubject() public var timeUpdate: Observable { return timerSubject.asObservable() } - public func setting(count: Double) { - initCounter = count - self.counter = count - let timeString = self.timeString(from: self.counter) - self.timerSubject.onNext(timeString) + public func setting(initialTime: Int) { + initTime = initialTime + time = Double(initialTime) + setTimerString() } public func start() { - timer = Timer.scheduledTimer(withTimeInterval: 0.035, repeats: true) { [weak self] _ in - guard let self = self else { return } - if self.counter <= 0 { - self.stop() - } else { - self.counter -= 0.035 - let timeString = self.timeString(from: self.counter) - self.timerSubject.onNext(timeString) - } - } + reduceTime() } - + public func stop() { timer?.invalidate() timer = nil } - + public func restart() { - counter = initCounter - let timeString = self.timeString(from: self.counter) - self.timerSubject.onNext(timeString) + time = Double(initTime) + setTimerString() } - + public func reset() { - counter = 0.0 - initCounter = 0.0 - let timeString = self.timeString(from: self.counter) - self.timerSubject.onNext(timeString) + time = 0 + initTime = 0 + setTimerString() + } + + public func setTimerString() { + let timeString = timerString(count: Int(time)) + timerSubject.onNext(timeString) + } + + public func presentTime() -> Int { + return time } - public func presentTime() -> Double { - return self.counter + private func reduceTime() { + timer = Timer.scheduledTimer(withTimeInterval: 0.001, repeats: true) { [self] _ in + if time <= 0 { + stop() + } else { + time -= 0.001 + setTimerString() + } + } } - private func timeString(from counter: Double) -> String { - let totalSeconds = Int(counter) + private func timerString(count: Int) -> String { + let totalSeconds: Int = count let hours: String = String(format: "%02d", totalSeconds / 3600) let minutes: String = String(format: "%02d", (totalSeconds % 3600) / 60) let seconds: String = String(format: "%02d", totalSeconds % 60) From c7c6a4755fe601338e2d0d005814538d3cf3f05a Mon Sep 17 00:00:00 2001 From: s Date: Tue, 13 Feb 2024 14:05:09 +0900 Subject: [PATCH 04/30] =?UTF-8?q?=F0=9F=8D=97=20::=20[#171]=20=ED=83=80?= =?UTF-8?q?=EC=9D=B4=EB=A8=B8=20Int=ED=98=95=EC=9C=BC=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TimerScene/Supporter/HomeTimerView.swift | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/HomeTimerView.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/HomeTimerView.swift index 02c2575a..7feb01e5 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/HomeTimerView.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/HomeTimerView.swift @@ -9,16 +9,16 @@ import DSKit public class HomeTimerView: UIView { - private var homeTimer = MindGymTimerKit() + public var homeTimer = MindGymTimerKit() private var radius: Double! private var colorCircle: UIColor! private var trackLayer: CAShapeLayer! private var circleShapeLayer: CAShapeLayer! - private var initTime: Double = 0.0 - private var cancelTime: Double = 0.0 - private var currentTime: Double = 0.0 + private var initTime: Int = 0 + private var cancelTime: Int = 0 + private var currentTime: Int = 0 let disposeBag = DisposeBag() @@ -96,8 +96,8 @@ public class HomeTimerView: UIView { } public func timerSetting(for seconds: Int) { - homeTimer.setting(count: Double(seconds)) - initTime = Double(seconds) + homeTimer.setting(time: seconds) + initTime = seconds circleShapeLayer.add(createCircleAnimation(), forKey: "key") stopTimer() cancelTime = initTime @@ -140,22 +140,22 @@ public class HomeTimerView: UIView { return } - timerMainTitle.text = setTimerTimeLabelText(from: homeTimer.presentTimer()) + timerMainTitle.text = setTimerTimeLabelText(count: homeTimer.presentTimer()) homeTimer.mainTimer.timeUpdate .observe(on: MainScheduler.instance) - .subscribe(onNext: { [weak self] timeString in + .subscribe(onNext: { [self] timeString in DispatchQueue.main.async { [self] in - self?.currentTime = self!.homeTimer.presentTimer() - self?.timerMainTitle.text = timeString + currentTime = homeTimer.presentTimer() + timerMainTitle.text = timeString } }) .disposed(by: disposeBag) } - private func setTimerTimeLabelText(from counter: Double) -> String { - let totalSeconds = Int(counter) + private func setTimerTimeLabelText(count: Int) -> String { + let totalSeconds = count let hours: String = String(format: "%02d", totalSeconds / 3600) let minutes: String = String(format: "%02d", (totalSeconds % 3600) / 60) let seconds: String = String(format: "%02d", totalSeconds % 60) @@ -178,7 +178,7 @@ public class HomeTimerView: UIView { formatter_time.dateFormat = "a h:mm" formatter_time.amSymbol = "오전" formatter_time.pmSymbol = "오후" - let current_time_string = formatter_time.string(from: Date().addingTimeInterval(initTime)) + let current_time_string = formatter_time.string(from: Date().addingTimeInterval(TimeInterval(initTime))) DispatchQueue.main.async { self.timerAlarmTitle.text = current_time_string } @@ -189,14 +189,14 @@ public class HomeTimerView: UIView { formatter_time.dateFormat = "a h:mm" formatter_time.amSymbol = "오전" formatter_time.pmSymbol = "오후" - let current_time_string = formatter_time.string(from: Date().addingTimeInterval(homeTimer.presentTimer())) + let current_time_string = formatter_time.string(from: Date().addingTimeInterval(TimeInterval(homeTimer.presentTimer()))) DispatchQueue.main.async { self.timerAlarmTitle.text = current_time_string } } public func startTimer() -> Bool { - if homeTimer.presentTimer() == 0.0 { + if homeTimer.presentTimer() <= 0 { return false } else { if circleShapeLayer.speed == 0 { @@ -220,8 +220,8 @@ public class HomeTimerView: UIView { } public func cancelTimer() { - cancelTime = 0.0 - homeTimer.setting(count: Double(0)) + cancelTime = 0 + homeTimer.setting(time: cancelTime) circleShapeLayer.add(createCircleAnimation(), forKey: "key") stopCricleAnimation() homeTimer.stopTimer() @@ -231,7 +231,7 @@ public class HomeTimerView: UIView { } public func restartTimer() { - homeTimer.setting(count: Double(initTime)) + homeTimer.setting(time: initTime) cancelTime = initTime circleShapeLayer.add(createCircleAnimation(), forKey: "key") stopCricleAnimation() @@ -240,7 +240,7 @@ public class HomeTimerView: UIView { setInitialTimeLabel() } - public func currentTimer() -> Double { + public func currentTimer() -> Int { return homeTimer.presentTimer() } From de49131ca2f5230618b0119b7c2c849f560b43f5 Mon Sep 17 00:00:00 2001 From: s Date: Tue, 13 Feb 2024 14:54:16 +0900 Subject: [PATCH 05/30] =?UTF-8?q?=E2=9A=93=EF=B8=8F=20::=20[#171]=20core?= =?UTF-8?q?=EC=97=90=20tokenManager=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/Domain/Project.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Projects/Domain/Project.swift b/Projects/Domain/Project.swift index 65ec23b0..2994132a 100644 --- a/Projects/Domain/Project.swift +++ b/Projects/Domain/Project.swift @@ -6,6 +6,7 @@ let project = Project.makeModule( name: "Domain", targets: [.unitTest, .dynamicFramework], internalDependencies: [ - .core + .core, + .Modules.tokenManager ] ) From bcd093a449ebf61ca89ee4a58b4b0bab03e355f2 Mon Sep 17 00:00:00 2001 From: s Date: Tue, 13 Feb 2024 15:08:42 +0900 Subject: [PATCH 06/30] =?UTF-8?q?=F0=9F=8D=97=20::=20[#171]=20Double=20?= =?UTF-8?q?=EC=9E=90=EB=A3=8C=ED=98=95=EC=9C=BC=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/TimerScene/View/TimerViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/View/TimerViewController.swift b/Projects/Features/HomeFeature/Sources/TimerScene/View/TimerViewController.swift index 9a4c706c..2f84b3dd 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/View/TimerViewController.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/View/TimerViewController.swift @@ -139,7 +139,7 @@ public class TimerViewController: BaseViewController { .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] timeString in DispatchQueue.main.async { [weak self] in - if self?.progressBarView.currentTimer() ?? 0 <= 0 { + if self?.progressBarView.currentTimer() ?? 0.0 <= 0.0 { self?.alaertView.moveViewDown() self?.progressBarView.stopTimer() self?.stopButton.isHidden = true From 931b73a7f9e7a4885912dd71cfaefe167d609270 Mon Sep 17 00:00:00 2001 From: s Date: Tue, 13 Feb 2024 15:09:07 +0900 Subject: [PATCH 07/30] =?UTF-8?q?=F0=9F=8D=97=20::=20[#171]=20Double=20?= =?UTF-8?q?=EC=9E=90=EB=A3=8C=ED=98=95=EC=9C=BC=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Supporter/MinGymKit/MinGymKit.swift | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGymKit.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGymKit.swift index dbc2058c..d35b2cfe 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGymKit.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGymKit.swift @@ -3,19 +3,17 @@ import RxSwift public protocol TimerControl { var timeUpdate: Observable { get } - func setting(initialTime: Int) func start() func stop() func reset() - func restart() - func presentTime() -> Int + func presentTime() -> Double } open class MindGymTimerKit { public let mainTimer: TimerControl = MindGaGymKitTimer() - public func setting(time: Int) { - mainTimer.setting(initialTime: time) + public func setting(count: Double) { + (mainTimer as? MindGaGymKitTimer)?.setting(count: count) } public func startTimer() { @@ -31,10 +29,11 @@ open class MindGymTimerKit { } public func restartTimer() { - mainTimer.restart() + (mainTimer as? MindGaGymKitTimer)?.restart() } - public func presentTimer() -> Int { - return mainTimer.presentTime() + public func presentTimer() -> Double { + let presentTime: Double = mainTimer.presentTime() + return presentTime } } From 09455c4f85fbc31ad23fe46da7bb319032f695fa Mon Sep 17 00:00:00 2001 From: s Date: Tue, 13 Feb 2024 15:10:47 +0900 Subject: [PATCH 08/30] =?UTF-8?q?=F0=9F=8D=97=20::=20[#171]=20=EB=A7=88?= =?UTF-8?q?=EC=9D=8C=EA=B0=80=EC=A7=90=20=ED=83=80=EC=9D=B4=EB=A8=B8=20?= =?UTF-8?q?=ED=82=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Double자료형으로 변경, 애니메이션과 UILabel 싱크 맞춤 --- .../MinGymKit/MinGaGymTimerKit.swift | 77 +++++++++++-------- 1 file changed, 46 insertions(+), 31 deletions(-) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGaGymTimerKit.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGaGymTimerKit.swift index 8ed4a91d..0c50e783 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGaGymTimerKit.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGaGymTimerKit.swift @@ -4,63 +4,79 @@ import RxSwift open class MindGaGymKitTimer: NSObject, TimerControl { - private var initTime: Int = 0 - private var time: Double = 0 + private var initCounter: Double = 0.0 + private var counter: Double = 0.0 private var timer: Timer? - private let timerSubject = PublishSubject() public var timeUpdate: Observable { return timerSubject.asObservable() } - public func setting(initialTime: Int) { - initTime = initialTime - time = Double(initialTime) - setTimerString() + public func setting(count: Double) { + initCounter = count + counter = count + setInitTimeString() } public func start() { - reduceTime() + timer = Timer.scheduledTimer(withTimeInterval: 0.001, repeats: true) { [self] _ in + if counter <= 0 { + stop() + } else { + counter -= 0.001 + setTimeString() + } + } } - + public func stop() { timer?.invalidate() timer = nil + setInitTimeString() } - + public func restart() { - time = Double(initTime) - setTimerString() + counter = initCounter + setInitTimeString() } - + public func reset() { - time = 0 - initTime = 0 - setTimerString() + counter = 0.0 + initCounter = 0.0 + setInitTimeString() } - public func setTimerString() { - let timeString = timerString(count: Int(time)) + public func presentTime() -> Double { + return self.counter + } + + public func setTimeString() { + let timeString = timeString(from: counter) timerSubject.onNext(timeString) } - public func presentTime() -> Int { - return time + public func setInitTimeString() { + let timeString = initTimeString(from: counter) + timerSubject.onNext(timeString) } - private func reduceTime() { - timer = Timer.scheduledTimer(withTimeInterval: 0.001, repeats: true) { [self] _ in - if time <= 0 { - stop() - } else { - time -= 0.001 - setTimerString() - } + private func timeString(from counter: Double) -> String { + let totalSeconds = Int(counter) + 1 + let hours: String = String(format: "%02d", totalSeconds / 3600) + let minutes: String = String(format: "%02d", (totalSeconds % 3600) / 60) + let seconds: String = String(format: "%02d", totalSeconds % 60) + + if totalSeconds / 3600 >= 1 { + return "\(hours) : \(minutes) : \(seconds)" + } else if totalSeconds / 60 >= 1 { + return "\(minutes) : \(seconds)" + } else { + return "00 : \(seconds)" } } - private func timerString(count: Int) -> String { - let totalSeconds: Int = count + private func initTimeString(from counter: Double) -> String { + let totalSeconds = Int(counter) let hours: String = String(format: "%02d", totalSeconds / 3600) let minutes: String = String(format: "%02d", (totalSeconds % 3600) / 60) let seconds: String = String(format: "%02d", totalSeconds % 60) @@ -74,4 +90,3 @@ open class MindGaGymKitTimer: NSObject, TimerControl { } } } - From 6962ebadfad62ac2b4b6b30d3e0add50508793fd Mon Sep 17 00:00:00 2001 From: s Date: Tue, 13 Feb 2024 15:12:21 +0900 Subject: [PATCH 09/30] =?UTF-8?q?=F0=9F=8D=97=20::=20[#171]=20Double?= =?UTF-8?q?=EC=9E=90=EB=A3=8C=ED=98=95=EC=9C=BC=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TimerScene/Supporter/HomeTimerView.swift | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/HomeTimerView.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/HomeTimerView.swift index 7feb01e5..bb3a530b 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/HomeTimerView.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/HomeTimerView.swift @@ -16,9 +16,9 @@ public class HomeTimerView: UIView { private var trackLayer: CAShapeLayer! private var circleShapeLayer: CAShapeLayer! - private var initTime: Int = 0 - private var cancelTime: Int = 0 - private var currentTime: Int = 0 + private var initTime: Double = 0.0 + private var cancelTime: Double = 0.0 + private var currentTime: Double = 0.0 let disposeBag = DisposeBag() @@ -96,8 +96,8 @@ public class HomeTimerView: UIView { } public func timerSetting(for seconds: Int) { - homeTimer.setting(time: seconds) - initTime = seconds + homeTimer.setting(count: Double(seconds)) + initTime = Double(seconds) circleShapeLayer.add(createCircleAnimation(), forKey: "key") stopTimer() cancelTime = initTime @@ -140,22 +140,22 @@ public class HomeTimerView: UIView { return } - timerMainTitle.text = setTimerTimeLabelText(count: homeTimer.presentTimer()) + timerMainTitle.text = setTimerTimeLabelText(from: homeTimer.presentTimer()) homeTimer.mainTimer.timeUpdate .observe(on: MainScheduler.instance) - .subscribe(onNext: { [self] timeString in + .subscribe(onNext: { [weak self] timeString in DispatchQueue.main.async { [self] in - currentTime = homeTimer.presentTimer() - timerMainTitle.text = timeString + self?.currentTime = self!.homeTimer.presentTimer() + self?.timerMainTitle.text = timeString } }) .disposed(by: disposeBag) } - private func setTimerTimeLabelText(count: Int) -> String { - let totalSeconds = count + private func setTimerTimeLabelText(from counter: Double) -> String { + let totalSeconds = Int(counter) let hours: String = String(format: "%02d", totalSeconds / 3600) let minutes: String = String(format: "%02d", (totalSeconds % 3600) / 60) let seconds: String = String(format: "%02d", totalSeconds % 60) @@ -178,7 +178,7 @@ public class HomeTimerView: UIView { formatter_time.dateFormat = "a h:mm" formatter_time.amSymbol = "오전" formatter_time.pmSymbol = "오후" - let current_time_string = formatter_time.string(from: Date().addingTimeInterval(TimeInterval(initTime))) + let current_time_string = formatter_time.string(from: Date().addingTimeInterval(initTime)) DispatchQueue.main.async { self.timerAlarmTitle.text = current_time_string } @@ -189,14 +189,14 @@ public class HomeTimerView: UIView { formatter_time.dateFormat = "a h:mm" formatter_time.amSymbol = "오전" formatter_time.pmSymbol = "오후" - let current_time_string = formatter_time.string(from: Date().addingTimeInterval(TimeInterval(homeTimer.presentTimer()))) + let current_time_string = formatter_time.string(from: Date().addingTimeInterval(homeTimer.presentTimer())) DispatchQueue.main.async { self.timerAlarmTitle.text = current_time_string } } public func startTimer() -> Bool { - if homeTimer.presentTimer() <= 0 { + if homeTimer.presentTimer() == 0.0 { return false } else { if circleShapeLayer.speed == 0 { @@ -220,8 +220,8 @@ public class HomeTimerView: UIView { } public func cancelTimer() { - cancelTime = 0 - homeTimer.setting(time: cancelTime) + cancelTime = 0.0 + homeTimer.setting(count: Double(0)) circleShapeLayer.add(createCircleAnimation(), forKey: "key") stopCricleAnimation() homeTimer.stopTimer() @@ -231,7 +231,7 @@ public class HomeTimerView: UIView { } public func restartTimer() { - homeTimer.setting(time: initTime) + homeTimer.setting(count: Double(initTime)) cancelTime = initTime circleShapeLayer.add(createCircleAnimation(), forKey: "key") stopCricleAnimation() @@ -240,7 +240,7 @@ public class HomeTimerView: UIView { setInitialTimeLabel() } - public func currentTimer() -> Int { + public func currentTimer() -> Double { return homeTimer.presentTimer() } From f07bb79349c2913e6b47010b1b928a7df67ada31 Mon Sep 17 00:00:00 2001 From: s Date: Tue, 13 Feb 2024 15:59:15 +0900 Subject: [PATCH 10/30] =?UTF-8?q?=F0=9F=8D=97=20::=20[#171]=20=ED=83=80?= =?UTF-8?q?=EC=9D=B4=EB=A8=B8=20=EC=A2=85=EB=A3=8C=20=EC=A1=B0=EA=B1=B4=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Supporter/MinGymKit/MinGaGymTimerKit.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGaGymTimerKit.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGaGymTimerKit.swift index 0c50e783..36f54bbf 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGaGymTimerKit.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGaGymTimerKit.swift @@ -20,8 +20,8 @@ open class MindGaGymKitTimer: NSObject, TimerControl { public func start() { timer = Timer.scheduledTimer(withTimeInterval: 0.001, repeats: true) { [self] _ in - if counter <= 0 { - stop() + if counter <= 0.001 { + timerStop() } else { counter -= 0.001 setTimeString() @@ -32,7 +32,12 @@ open class MindGaGymKitTimer: NSObject, TimerControl { public func stop() { timer?.invalidate() timer = nil + } + + public func timerStop() { setInitTimeString() + timer?.invalidate() + timer = nil } public func restart() { From f5b9cedb8baa0877483a1d3da590514931313fec Mon Sep 17 00:00:00 2001 From: s Date: Wed, 14 Feb 2024 14:08:39 +0900 Subject: [PATCH 11/30] =?UTF-8?q?=E2=9A=93=EF=B8=8F=20::=20[#171]=20?= =?UTF-8?q?=EB=A9=80=ED=8B=B0=20=ED=83=80=EC=9D=B4=EB=A8=B8=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Supporter/MinGymKit/MinGymKit.swift | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGymKit.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGymKit.swift index d35b2cfe..95133966 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGymKit.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGymKit.swift @@ -3,37 +3,48 @@ import RxSwift public protocol TimerControl { var timeUpdate: Observable { get } + func setting(settingTime: Double) func start() func stop() func reset() + func restart() func presentTime() -> Double } open class MindGymTimerKit { - public let mainTimer: TimerControl = MindGaGymKitTimer() - - public func setting(count: Double) { - (mainTimer as? MindGaGymKitTimer)?.setting(count: count) + public var timers: [TimerControl] = [] + + public func setTimer(index: Int, settingTime: Double) { + timers[index].setting(settingTime: settingTime) } - public func startTimer() { - mainTimer.start() + public func startTimer(index: Int) { + timers[index].start() } - public func stopTimer() { - mainTimer.stop() + public func stopTimer(index: Int) { + timers[index].stop() } - public func resetTimer() { - mainTimer.reset() + public func resetTimer(index: Int) { + timers[index].reset() } - public func restartTimer() { - (mainTimer as? MindGaGymKitTimer)?.restart() + public func restartTimer(index: Int) { + timers[index].restart() + } + + public func addRearTimer(time: Double) { + let newTimer = MindGaGymKitTimer() + newTimer.setting(settingTime: time) + timers.append(newTimer) } - public func presentTimer() -> Double { - let presentTime: Double = mainTimer.presentTime() - return presentTime + public func deleteTimer(index: Int) { + timers.remove(at: index) + } + + public func presentTime(index: Int) -> Double { + return timers[index].presentTime() } } From 42f6d05f50a7d8a04b0d6cdf2b8e8d1090871fc7 Mon Sep 17 00:00:00 2001 From: s Date: Wed, 14 Feb 2024 14:09:04 +0900 Subject: [PATCH 12/30] =?UTF-8?q?=F0=9F=8D=97=20::=20[#171]=20=EB=B3=80?= =?UTF-8?q?=EC=88=98=20=EC=9D=B4=EB=A6=84=20=EB=A6=AC=ED=8E=99=ED=86=A0?= =?UTF-8?q?=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MinGymKit/MinGaGymTimerKit.swift | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGaGymTimerKit.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGaGymTimerKit.swift index 36f54bbf..f3aab8b2 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGaGymTimerKit.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGaGymTimerKit.swift @@ -4,26 +4,26 @@ import RxSwift open class MindGaGymKitTimer: NSObject, TimerControl { - private var initCounter: Double = 0.0 - private var counter: Double = 0.0 + private var initialTime: Double = 0.0 + private var time: Double = 0.0 private var timer: Timer? private let timerSubject = PublishSubject() public var timeUpdate: Observable { return timerSubject.asObservable() } - public func setting(count: Double) { - initCounter = count - counter = count + public func setting(settingTime: Double) { + initialTime = settingTime + time = settingTime setInitTimeString() } public func start() { timer = Timer.scheduledTimer(withTimeInterval: 0.001, repeats: true) { [self] _ in - if counter <= 0.001 { + if time <= 0.001 { timerStop() } else { - counter -= 0.001 + time -= 0.001 setTimeString() } } @@ -41,27 +41,27 @@ open class MindGaGymKitTimer: NSObject, TimerControl { } public func restart() { - counter = initCounter + time = initialTime setInitTimeString() } public func reset() { - counter = 0.0 - initCounter = 0.0 + time = 0.0 + initialTime = 0.0 setInitTimeString() } public func presentTime() -> Double { - return self.counter + return time } public func setTimeString() { - let timeString = timeString(from: counter) + let timeString = timeString(from: time) timerSubject.onNext(timeString) } public func setInitTimeString() { - let timeString = initTimeString(from: counter) + let timeString = initTimeString(from: time) timerSubject.onNext(timeString) } From 2895c22b9f8091eafcc4caf42106253a2f83919d Mon Sep 17 00:00:00 2001 From: s Date: Wed, 14 Feb 2024 14:09:52 +0900 Subject: [PATCH 13/30] =?UTF-8?q?=E2=9A=93=EF=B8=8F=20::=20[#171]=20?= =?UTF-8?q?=EC=9D=B8=EB=8D=B1=EC=8A=A4=20data=20=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/TimerScene/Supporter/TimerModel.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerModel.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerModel.swift index 10b5caa7..ae1b431f 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerModel.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerModel.swift @@ -4,14 +4,14 @@ public class TimerModel { var isClicked: Bool } - private var _data: [Time] + private var data: [Time] var data: [Time] { - return _data + return data } init() { - _data = [ + data = [ Time(time: 60, isClicked: false), Time(time: 10, isClicked: false), Time(time: 4660, isClicked: false), @@ -22,6 +22,10 @@ public class TimerModel { } func updateData(at index: Int, with newValue: Time) { - _data[index] = newValue + data[index] = newValue + } + + public func getTime(at index: Int) -> Int { + return data[index].time } } From 2007f32d3a322a23e71c8142b11fca033a38a6e0 Mon Sep 17 00:00:00 2001 From: s Date: Wed, 14 Feb 2024 19:20:50 +0900 Subject: [PATCH 14/30] =?UTF-8?q?=F0=9F=8D=97=20::=20[#171]=20collectionVi?= =?UTF-8?q?ew=20=ED=8C=8C=EC=9D=BC=20=EA=B5=AC=EC=A1=B0=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{ => CollectionViewCell}/TimerCollectionViewCell.swift | 0 .../{ => CollectionViewCell}/TimerHeaderCollectionViewCell.swift | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename Projects/Features/HomeFeature/Sources/TimerScene/Supporter/{ => CollectionViewCell}/TimerCollectionViewCell.swift (100%) rename Projects/Features/HomeFeature/Sources/TimerScene/Supporter/{ => CollectionViewCell}/TimerHeaderCollectionViewCell.swift (100%) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerCollectionViewCell.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/CollectionViewCell/TimerCollectionViewCell.swift similarity index 100% rename from Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerCollectionViewCell.swift rename to Projects/Features/HomeFeature/Sources/TimerScene/Supporter/CollectionViewCell/TimerCollectionViewCell.swift diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerHeaderCollectionViewCell.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/CollectionViewCell/TimerHeaderCollectionViewCell.swift similarity index 100% rename from Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerHeaderCollectionViewCell.swift rename to Projects/Features/HomeFeature/Sources/TimerScene/Supporter/CollectionViewCell/TimerHeaderCollectionViewCell.swift From e40a223254255b38789659c4757b46282131dff0 Mon Sep 17 00:00:00 2001 From: s Date: Wed, 14 Feb 2024 19:21:09 +0900 Subject: [PATCH 15/30] =?UTF-8?q?=F0=9F=8D=97=20::=20[#171]=20=EC=83=81?= =?UTF-8?q?=EB=8B=A8=20view=20=ED=8C=8C=EC=9D=BC=20=EA=B5=AC=EC=A1=B0=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TimerScene/Supporter/{ => NavView}/TimerAlarmAlertView.swift | 0 .../TimerScene/Supporter/{ => NavView}/TimerEditView.swift | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename Projects/Features/HomeFeature/Sources/TimerScene/Supporter/{ => NavView}/TimerAlarmAlertView.swift (100%) rename Projects/Features/HomeFeature/Sources/TimerScene/Supporter/{ => NavView}/TimerEditView.swift (100%) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerAlarmAlertView.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/NavView/TimerAlarmAlertView.swift similarity index 100% rename from Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerAlarmAlertView.swift rename to Projects/Features/HomeFeature/Sources/TimerScene/Supporter/NavView/TimerAlarmAlertView.swift diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerEditView.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/NavView/TimerEditView.swift similarity index 100% rename from Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerEditView.swift rename to Projects/Features/HomeFeature/Sources/TimerScene/Supporter/NavView/TimerEditView.swift From 479d22c3c8c2a895f7a82719e74ad93398ce72f3 Mon Sep 17 00:00:00 2001 From: s Date: Wed, 14 Feb 2024 19:21:46 +0900 Subject: [PATCH 16/30] =?UTF-8?q?=F0=9F=8D=97=20::=20[#171]=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EC=A4=91=EB=B3=B5=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TimerScene/Supporter/TimerModel.swift | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerModel.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerModel.swift index ae1b431f..aff79add 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerModel.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerModel.swift @@ -1,31 +1,32 @@ +import Foundation + public class TimerModel { public struct Time { - var time: Int + var time: Double var isClicked: Bool } - - private var data: [Time] - + private var privateData: [Time] + var data: [Time] { - return data + return privateData } - + init() { - data = [ - Time(time: 60, isClicked: false), - Time(time: 10, isClicked: false), - Time(time: 4660, isClicked: false), - Time(time: 3600, isClicked: false), - Time(time: 700, isClicked: false), - Time(time: 5, isClicked: false), + privateData = [ + Time(time: 60.0, isClicked: true), + Time(time: 10.0, isClicked: false), + Time(time: 4660.0, isClicked: false), + Time(time: 3600.0, isClicked: false), + Time(time: 700.0, isClicked: false), + Time(time: 5.0, isClicked: false), ] } - + func updateData(at index: Int, with newValue: Time) { - data[index] = newValue + privateData[index] = newValue } - public func getTime(at index: Int) -> Int { - return data[index].time + public func getTime(at index: Int) -> Double { + return privateData[index].time } } From 6da27e6d992531b634964b7364f42ab0b90afa8c Mon Sep 17 00:00:00 2001 From: s Date: Wed, 14 Feb 2024 19:23:51 +0900 Subject: [PATCH 17/30] =?UTF-8?q?=E2=9A=93=EF=B8=8F=20::=20[#171]=20?= =?UTF-8?q?=EC=9E=84=EC=8B=9C=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/TimerScene/Supporter/MinGymKit/MinGymKit.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGymKit.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGymKit.swift index 95133966..963c4450 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGymKit.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGymKit.swift @@ -14,6 +14,13 @@ public protocol TimerControl { open class MindGymTimerKit { public var timers: [TimerControl] = [] + public init() { + let initialTimes: [Double] = [60.0, 10.0, 4660.0, 3600.0, 700.0, 5.0] + for time in initialTimes { + addRearTimer(time: time) + } + } + public func setTimer(index: Int, settingTime: Double) { timers[index].setting(settingTime: settingTime) } From 839d186bcd2e4070a02ad96bce52f3b9f3e0b6c8 Mon Sep 17 00:00:00 2001 From: s Date: Wed, 14 Feb 2024 19:24:11 +0900 Subject: [PATCH 18/30] =?UTF-8?q?=F0=9F=8D=97=20::=20[#171]=20homeTimerVie?= =?UTF-8?q?w=20=EC=88=98=EC=A0=95=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TimerScene/Supporter/HomeTimerView.swift | 64 +++++++++++-------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/HomeTimerView.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/HomeTimerView.swift index bb3a530b..83d6ad61 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/HomeTimerView.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/HomeTimerView.swift @@ -20,7 +20,9 @@ public class HomeTimerView: UIView { private var cancelTime: Double = 0.0 private var currentTime: Double = 0.0 - let disposeBag = DisposeBag() + private var timerIndex: Int = 0 + + var disposeBag = DisposeBag() private var timerInitTitle = UILabel().then { $0.text = "" @@ -36,6 +38,10 @@ public class HomeTimerView: UIView { $0.textColor = .black } + private let alarmImage = UIImageView().then { + $0.image = DSKitAsset.Assets.homeTimerBell.image + } + private var timerAlarmTitle = UILabel().then { $0.text = "" $0.textAlignment = .center @@ -71,7 +77,7 @@ public class HomeTimerView: UIView { } private func layout() { - addSubviews([timerInitTitle, timerMainTitle, timerAlarmTitle]) + addSubviews([timerInitTitle, timerMainTitle, alarmImage, timerAlarmTitle]) timerInitTitle.snp.makeConstraints { $0.centerX.equalToSuperview() @@ -95,12 +101,15 @@ public class HomeTimerView: UIView { } } - public func timerSetting(for seconds: Int) { - homeTimer.setting(count: Double(seconds)) - initTime = Double(seconds) - circleShapeLayer.add(createCircleAnimation(), forKey: "key") - stopTimer() + let timerModel = TimerModel() + + public func timerSetting(for index: Int) { + initTime = timerModel.getTime(at: index) cancelTime = initTime + timerIndex = index + homeTimer.setTimer(index: index, settingTime: initTime) + circleShapeLayer.add(createCircleAnimation(), forKey: "key") + stopCricleAnimation() setInitialTimeLabel() setTimerTimeLabel() setInitAlarmTimeLabel() @@ -140,18 +149,23 @@ public class HomeTimerView: UIView { return } - timerMainTitle.text = setTimerTimeLabelText(from: homeTimer.presentTimer()) - - homeTimer.mainTimer.timeUpdate + timerMainTitle.text = setTimerTimeLabelText(from: homeTimer.presentTime(index: timerIndex)) + + // 이전 구독을 해제합니다. + disposeBag = DisposeBag() + + let currentTimer = homeTimer.timers[timerIndex] + currentTimer.timeUpdate .observe(on: MainScheduler.instance) - .subscribe(onNext: { [weak self] timeString in + .subscribe(onNext: { [self] timeString in DispatchQueue.main.async { [self] in - self?.currentTime = self!.homeTimer.presentTimer() - self?.timerMainTitle.text = timeString + currentTime = homeTimer.presentTime(index: timerIndex) + timerMainTitle.text = timeString } }) .disposed(by: disposeBag) } + private func setTimerTimeLabelText(from counter: Double) -> String { @@ -189,23 +203,23 @@ public class HomeTimerView: UIView { formatter_time.dateFormat = "a h:mm" formatter_time.amSymbol = "오전" formatter_time.pmSymbol = "오후" - let current_time_string = formatter_time.string(from: Date().addingTimeInterval(homeTimer.presentTimer())) + let current_time_string = formatter_time.string(from: Date().addingTimeInterval(currentTime)) DispatchQueue.main.async { self.timerAlarmTitle.text = current_time_string } } public func startTimer() -> Bool { - if homeTimer.presentTimer() == 0.0 { + if currentTime == 0.0 { return false } else { if circleShapeLayer.speed == 0 { restartCricleAnimation() - homeTimer.startTimer() + homeTimer.startTimer(index: timerIndex) setAlarmTimeLabel() } else { circleShapeLayer.add(createCircleAnimation(), forKey: "key") - homeTimer.startTimer() + homeTimer.startTimer(index: timerIndex) setAlarmTimeLabel() } circleShapeLayer.strokeColor = colorCircle.cgColor @@ -216,32 +230,32 @@ public class HomeTimerView: UIView { public func stopTimer() { circleShapeLayer.strokeColor = DSKitAsset.Colors.gray400.color.cgColor stopCricleAnimation() - homeTimer.stopTimer() + homeTimer.stopTimer(index: timerIndex) } public func cancelTimer() { cancelTime = 0.0 - homeTimer.setting(count: Double(0)) + homeTimer.setTimer(index: timerIndex, settingTime: 0.0) circleShapeLayer.add(createCircleAnimation(), forKey: "key") stopCricleAnimation() - homeTimer.stopTimer() + homeTimer.stopTimer(index: timerIndex) stopTimer() setInitAlarmTimeLabel() setInitialTimeLabel() } public func restartTimer() { - homeTimer.setting(count: Double(initTime)) + homeTimer.setTimer(index: timerIndex, settingTime: initTime) cancelTime = initTime circleShapeLayer.add(createCircleAnimation(), forKey: "key") stopCricleAnimation() - homeTimer.stopTimer() + homeTimer.stopTimer(index: timerIndex) setAlarmTimeLabel() setInitialTimeLabel() } - public func currentTimer() -> Double { - return homeTimer.presentTimer() + public func currentTimer(index: Int) -> Double { + return homeTimer.presentTime(index: index) } private func setCircleLayer() -> CAShapeLayer { @@ -294,7 +308,7 @@ public class HomeTimerView: UIView { strokeAnimation.toValue = 0 strokeAnimation.fromValue = 1 - strokeAnimation.duration = CFTimeInterval(homeTimer.presentTimer()) + strokeAnimation.duration = CFTimeInterval(homeTimer.presentTime(index: timerIndex)) strokeAnimation.isRemovedOnCompletion = true circleShapeLayer.strokeEnd = 0 return strokeAnimation From 23e6809573d9eba8f8febea49ba8c844141ad8f5 Mon Sep 17 00:00:00 2001 From: s Date: Wed, 14 Feb 2024 19:50:33 +0900 Subject: [PATCH 19/30] =?UTF-8?q?=E2=9A=93=EF=B8=8F=20::=20[#171]=20?= =?UTF-8?q?=ED=83=80=EC=9D=B4=EB=A8=B8=20=EC=B6=94=EA=B0=80=20view=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/TimerScene/Supporter/AddTimerView.swift | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Projects/Features/HomeFeature/Sources/TimerScene/Supporter/AddTimerView.swift diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/AddTimerView.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/AddTimerView.swift new file mode 100644 index 00000000..18fe1214 --- /dev/null +++ b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/AddTimerView.swift @@ -0,0 +1,9 @@ +// +// addTimerView.swift +// HomeFeature +// +// Created by 이은호 on 2/14/24. +// Copyright © 2024 MaeumGaGym-iOS. All rights reserved. +// + +import Foundation From 1d6d0d251996be3ba0a94d5972032bea460fbe74 Mon Sep 17 00:00:00 2001 From: s Date: Thu, 15 Feb 2024 15:01:40 +0900 Subject: [PATCH 20/30] =?UTF-8?q?=E2=9A=93=EF=B8=8F=20::=20[#171]=20?= =?UTF-8?q?=ED=83=80=EC=9D=B4=EB=A8=B8=20=ED=94=BC=EC=BB=A4=20View=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/TimerScene/Supporter/TimerPickerView.swift | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerPickerView.swift diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerPickerView.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerPickerView.swift new file mode 100644 index 00000000..1b589abf --- /dev/null +++ b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerPickerView.swift @@ -0,0 +1,9 @@ +// +// TimerPickerView.swift +// HomeFeature +// +// Created by 이은호 on 2/15/24. +// Copyright © 2024 MaeumGaGym-iOS. All rights reserved. +// + +import Foundation From dc6d34aa34c4d37c7cc3dd6ee8677f9e460ac75c Mon Sep 17 00:00:00 2001 From: s Date: Thu, 15 Feb 2024 15:01:56 +0900 Subject: [PATCH 21/30] =?UTF-8?q?=E2=9A=93=EF=B8=8F=20::=20[#171]=20?= =?UTF-8?q?=ED=83=80=EC=9D=B4=EB=A8=B8=20=EC=B6=94=EA=B0=80=20View?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TimerScene/Supporter/AddTimerView.swift | 64 ++++++++++++++++--- 1 file changed, 56 insertions(+), 8 deletions(-) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/AddTimerView.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/AddTimerView.swift index 18fe1214..0306be94 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/AddTimerView.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/AddTimerView.swift @@ -1,9 +1,57 @@ -// -// addTimerView.swift -// HomeFeature -// -// Created by 이은호 on 2/14/24. -// Copyright © 2024 MaeumGaGym-iOS. All rights reserved. -// +import UIKit -import Foundation +import SnapKit +import Then + +import Core +import DSKit + +public class AddTimerView: BaseView { + + private var containerView = UIView().then { + $0.backgroundColor = UIColor.black.withAlphaComponent(0.4) + } + + private let timerAddBackView = UIView().then { + $0.backgroundColor = .white + $0.layer.cornerRadius = 20.0 + } + + private let addTimerLabel = UILabel().then { + $0.text = "타이머 추가" + $0.font = UIFont.Pretendard.titleMedium + $0.textAlignment = .left + $0.textColor = .black + } + + private let timerPickerView = TimerPickerView() + + public override func layout() { + addSubviews([containerView]) + containerView.addSubviews([timerAddBackView]) + timerAddBackView.addSubviews([addTimerLabel, timerPickerView]) + + containerView.snp.makeConstraints { + $0.edges.equalToSuperview() + } + + timerAddBackView.snp.makeConstraints { + $0.leading.trailing.equalToSuperview() + $0.bottom.equalTo(containerView.safeAreaLayoutGuide) + $0.top.equalTo(containerView.snp.centerY).offset(-62.0) + } + + addTimerLabel.snp.makeConstraints { + $0.top.equalToSuperview().offset(24.0) + $0.leading.trailing.equalToSuperview().inset(20.0) + $0.height.equalTo(32.0) + } + + timerPickerView.snp.makeConstraints { + $0.leading.trailing.equalToSuperview().inset(20.0) + $0.top.equalToSuperview().offset(80.0) + $0.bottom.equalToSuperview().offset(-74.0) + } + + } +} From 9bda47a2ab7ab074cec9e36f4d3475d28675ae7b Mon Sep 17 00:00:00 2001 From: s Date: Thu, 15 Feb 2024 15:02:24 +0900 Subject: [PATCH 22/30] =?UTF-8?q?=E2=9A=93=EF=B8=8F=20::=20[#171]=20?= =?UTF-8?q?=ED=83=80=EC=9D=B4=EB=A8=B8=20=ED=94=BC=EC=BB=A4=20view=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Supporter/TimerPickerView.swift | 187 +++++++++++++++++- 1 file changed, 178 insertions(+), 9 deletions(-) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerPickerView.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerPickerView.swift index 1b589abf..af50320e 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerPickerView.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerPickerView.swift @@ -1,9 +1,178 @@ -// -// TimerPickerView.swift -// HomeFeature -// -// Created by 이은호 on 2/15/24. -// Copyright © 2024 MaeumGaGym-iOS. All rights reserved. -// - -import Foundation +import UIKit + +import SnapKit +import Then + +import Core +import DSKit + +public class TimerPickerView: BaseView { + private var pickerWidth: Double = 75.0 + public var isFirstLoad: Bool? + + public var pickerSelectValue = 0 + + + private let hourValues: [Int] = [00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23] + + private let minuteValues: [Int] = [00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59] + + private let secondValues: [Int] = [00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59] + + + private var rotationAngle: CGFloat! = -90 * (.pi/180) + + lazy var pickerView = UIPickerView().then { + $0.transform = CGAffineTransform(rotationAngle: 0) + } + + private lazy var titleLabel = UILabel().then { + $0.textAlignment = .center + $0.font = UIFont.Pretendard.light + $0.textColor = .black + } + + lazy var pickerSetLabel = UILabel() + + public override init(frame: CGRect) { + super.init(frame: frame) + } + + required public init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + public override func layout() { + addSubviews([pickerView]) + + pickerView.snp.makeConstraints { + $0.leading.trailing.equalToSuperview().inset(43.5) + $0.top.equalToSuperview().offset(14.0) + $0.bottom.equalToSuperview().inset(10.0) + } + + } + + public override func attribute() { + pickerView.delegate = self + pickerView.dataSource = self + + if #available(iOS 14.0, *) { + pickerView.preferredDatePickerStyle = .inline + } + } + +} + +extension TimerPickerView: UIPickerViewDelegate { + public func numberOfComponents(in pickerView: UIPickerView) -> Int { + return 3 + } + + public func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { + switch component { + case 0: + return "\(hourValues[row])" + case 1: + return "\(minuteValues[row])" + case 2: + return "\(secondValues[row])" + default: + return "" + } + } + + public func pickerView(_ pickerView: UIPickerView, + rowHeightForComponent component: Int + ) -> CGFloat { + return 48.0 + } + + public func pickerView(_ pickerView: UIPickerView, + viewForRow row: Int, + forComponent component: Int, + reusing view: UIView? + ) -> UIView { + + let pickerRow = UIView() + pickerRow.frame = CGRect(x: 0, y: 0, width: pickerWidth, height: 128.0) + + lazy var rowLabel = UILabel().then { + $0.textColor = .black + $0.font = UIFont.Pretendard.light + $0.textAlignment = .center + $0.layer.masksToBounds = true + $0.backgroundColor = .white + } + + pickerRow.addSubview(rowLabel) + rowLabel.snp.makeConstraints { + $0.center.equalTo(pickerRow.snp.center) // 레이블을 UIView의 중앙에 위치시킴 + $0.width.equalTo(pickerRow.snp.width) + $0.height.equalTo(48) // 레이블의 높이를 48로 설정 + } + + switch component { + case 0: + rowLabel.text = "\(hourValues[row])" + case 1: + rowLabel.text = "\(minuteValues[row])" + case 2: + rowLabel.text = "\(secondValues[row])" + default: + rowLabel.text = "" + } + + + pickerRow.transform = CGAffineTransform(rotationAngle: 0) + + guard let myBool = isFirstLoad else { + return pickerRow + } + + guard !myBool else { + return pickerRow + } + + guard let selectView = pickerView.view(forRow: pickerSelectValue, forComponent: component) else { + return pickerRow + } + + let selectLabel = selectView.subviews[0] as! UILabel + selectLabel.textColor = .black + selectLabel.font = UIFont.Pretendard.light + return pickerRow + } + + public func pickerView(_ pickerView: UIPickerView, widthForComponent component: Int) -> CGFloat { + switch component { + case 0: + return pickerWidth + 38.5 + case 1: + return pickerWidth + 38.5 + case 2: + return pickerWidth + default: + return 0 + } + } + +} + +extension TimerPickerView: UIPickerViewDataSource { + + public func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { + switch component { + case 0: + return hourValues.count + case 1: + return minuteValues.count + case 2: + return secondValues.count + default: + return 0 + } + } + + +} From fc4efac0529cc0f717de6ae4333b70a808cbbff4 Mon Sep 17 00:00:00 2001 From: s Date: Thu, 15 Feb 2024 15:02:58 +0900 Subject: [PATCH 23/30] =?UTF-8?q?=F0=9F=8D=97=20::=20[#171]=20=ED=99=88=20?= =?UTF-8?q?=ED=83=80=EC=9D=B4=EB=A8=B8=20view?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/TimerScene/Supporter/HomeTimerView.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/HomeTimerView.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/HomeTimerView.swift index 83d6ad61..717103f0 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/HomeTimerView.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/HomeTimerView.swift @@ -103,13 +103,19 @@ public class HomeTimerView: UIView { let timerModel = TimerModel() + public func timerChange(for index: Int) { + initTime = timerModel.getTime(at: index) + cancelTime = initTime + timerIndex = index + homeTimer.setTimer(index: index, settingTime: homeTimer.presentTime(index: index)) + + } + public func timerSetting(for index: Int) { initTime = timerModel.getTime(at: index) cancelTime = initTime timerIndex = index - homeTimer.setTimer(index: index, settingTime: initTime) - circleShapeLayer.add(createCircleAnimation(), forKey: "key") - stopCricleAnimation() + homeTimer.setTimer(index: index, settingTime: homeTimer.presentTime(index: index)) setInitialTimeLabel() setTimerTimeLabel() setInitAlarmTimeLabel() From 555a34ed91547898fa3f724ebd64fa7782606bff Mon Sep 17 00:00:00 2001 From: s Date: Thu, 15 Feb 2024 15:03:38 +0900 Subject: [PATCH 24/30] =?UTF-8?q?=F0=9F=8D=97=20::=20[#171]=20=ED=83=80?= =?UTF-8?q?=EC=9D=B4=EB=A8=B8=20=EC=BD=9C=EB=A0=89=EC=85=98=20=EB=B7=B0=20?= =?UTF-8?q?cell=20=EB=A6=AC=ED=8E=99=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TimerCollectionViewCell.swift | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/CollectionViewCell/TimerCollectionViewCell.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/CollectionViewCell/TimerCollectionViewCell.swift index 5d68afa6..59060d87 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/CollectionViewCell/TimerCollectionViewCell.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/CollectionViewCell/TimerCollectionViewCell.swift @@ -24,7 +24,7 @@ public class TimerCollectionViewCell: UICollectionViewCell { $0.isHidden = true } - private var exerciseNameLabel = UILabel().then { + private var timeLabel = UILabel().then { $0.font = UIFont.Pretendard.bodyMedium $0.backgroundColor = DSKitAsset.Colors.gray50.color $0.layer.masksToBounds = true @@ -35,7 +35,7 @@ public class TimerCollectionViewCell: UICollectionViewCell { } public func setup(time: Double) { - exerciseNameLabel.text = setTimerTimeLabelText(from: time) + timeLabel.text = setTimerTimeLabelText(from: time) layout() } @@ -54,7 +54,7 @@ public class TimerCollectionViewCell: UICollectionViewCell { } private func layout() { - addSubviews([exerciseNameLabel, checkImage, unCheckView]) + addSubviews([timeLabel, checkImage, unCheckView]) checkImage.snp.makeConstraints { $0.top.leading.equalToSuperview().offset(6.0) @@ -66,22 +66,22 @@ public class TimerCollectionViewCell: UICollectionViewCell { $0.width.height.equalTo(22.0) } - exerciseNameLabel.snp.makeConstraints { + timeLabel.snp.makeConstraints { $0.top.bottom.trailing.leading.equalToSuperview().inset(10.0) $0.width.height.equalTo(100.0) } } public func cellUnClicked() { - exerciseNameLabel.layer.borderColor = DSKitAsset.Colors.gray50.color.cgColor - exerciseNameLabel.layer.borderWidth = 2 - exerciseNameLabel.backgroundColor = DSKitAsset.Colors.gray50.color + timeLabel.layer.borderColor = DSKitAsset.Colors.gray50.color.cgColor + timeLabel.layer.borderWidth = 2 + timeLabel.backgroundColor = DSKitAsset.Colors.gray50.color } public func cellClicked() { - exerciseNameLabel.layer.borderColor = DSKitAsset.Colors.blue500.color.cgColor - exerciseNameLabel.layer.borderWidth = 2 - exerciseNameLabel.backgroundColor = .white + timeLabel.layer.borderColor = DSKitAsset.Colors.blue500.color.cgColor + timeLabel.layer.borderWidth = 2 + timeLabel.backgroundColor = .white } public func cellChoosing() { From caa4ff8223c80c6eac0c8c7c16ae793295abcd1f Mon Sep 17 00:00:00 2001 From: s Date: Thu, 15 Feb 2024 15:04:04 +0900 Subject: [PATCH 25/30] =?UTF-8?q?=F0=9F=8D=97=20::=20[#171]=20=ED=83=80?= =?UTF-8?q?=EC=9D=B4=EB=A8=B8=20VC=20=EC=88=98=EC=A0=95=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TimerScene/View/TimerViewController.swift | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/View/TimerViewController.swift b/Projects/Features/HomeFeature/Sources/TimerScene/View/TimerViewController.swift index 2f84b3dd..c3fc244f 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/View/TimerViewController.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/View/TimerViewController.swift @@ -14,6 +14,7 @@ import HomeFeatureInterface public class TimerViewController: BaseViewController { private var timerData = TimerModel.init() + private var currentTimerIndex: Int = 0 private var alaertView = TimerAlarmAlertView() @@ -31,6 +32,8 @@ public class TimerViewController: BaseViewController { private var editView = TimerEditView() + private var testView = AddTimerView() + lazy var progressBarView = HomeTimerView(center: view.center, radius: 175.0, color: DSKitAsset.Colors.blue500.color) private let closeButton = MGTimerButton(type: .close) @@ -61,13 +64,13 @@ public class TimerViewController: BaseViewController { public override func attribute() { view.backgroundColor = .white - progressBarView.timerSetting(for: 3601) + progressBarView.timerSetting(for: 0) buttonTap() } public override func layout() { - view.addSubviews([navBeforeButton, navAddButton, navEditButton, editView, progressBarView, closeButton, stopButton, startButton, restartButton, timerCollectionView, alaertView]) + view.addSubviews([navBeforeButton, navAddButton, navEditButton, editView, progressBarView, closeButton, stopButton, startButton, restartButton, timerCollectionView, alaertView, testView]) navBeforeButton.snp.makeConstraints { $0.top.equalToSuperview().offset(61.0) @@ -131,19 +134,23 @@ public class TimerViewController: BaseViewController { $0.leading.trailing.equalToSuperview().inset(20.0) $0.height.equalTo(152.0) } + + testView.snp.makeConstraints { + $0.edges.equalToSuperview() + } } private func buttonTap() { - progressBarView.homeTimer.mainTimer.timeUpdate + progressBarView.homeTimer.timers[0].timeUpdate .observe(on: MainScheduler.instance) - .subscribe(onNext: { [weak self] timeString in - DispatchQueue.main.async { [weak self] in - if self?.progressBarView.currentTimer() ?? 0.0 <= 0.0 { - self?.alaertView.moveViewDown() - self?.progressBarView.stopTimer() - self?.stopButton.isHidden = true - self?.startButton.isHidden = false + .subscribe(onNext: { [self] timeString in + DispatchQueue.main.async { [self] in + if progressBarView.currentTimer(index: currentTimerIndex) <= 0.0 { + alaertView.moveViewDown() + progressBarView.stopTimer() + stopButton.isHidden = true + startButton.isHidden = false } } }) @@ -243,8 +250,8 @@ extension TimerViewController: UICollectionViewDataSource { return false } - let time = timerData.data[indexPath.row - 1].time - progressBarView.timerSetting(for: time) + progressBarView.timerSetting(for: indexPath.row - 1) + currentTimerIndex = indexPath.row - 1 stopButton.isHidden = true startButton.isHidden = false From 75e91dde38697c8110395e1f3603b7b1fb6e8de3 Mon Sep 17 00:00:00 2001 From: s Date: Thu, 15 Feb 2024 15:07:56 +0900 Subject: [PATCH 26/30] =?UTF-8?q?=F0=9F=8D=97=20::=20[#171]=20conflict=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TimerScene/Supporter/{NavView => }/TimerAlarmAlertView.swift | 0 .../{CollectionViewCell => }/TimerCollectionViewCell.swift | 0 .../TimerScene/Supporter/{NavView => }/TimerEditView.swift | 0 .../{CollectionViewCell => }/TimerHeaderCollectionViewCell.swift | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename Projects/Features/HomeFeature/Sources/TimerScene/Supporter/{NavView => }/TimerAlarmAlertView.swift (100%) rename Projects/Features/HomeFeature/Sources/TimerScene/Supporter/{CollectionViewCell => }/TimerCollectionViewCell.swift (100%) rename Projects/Features/HomeFeature/Sources/TimerScene/Supporter/{NavView => }/TimerEditView.swift (100%) rename Projects/Features/HomeFeature/Sources/TimerScene/Supporter/{CollectionViewCell => }/TimerHeaderCollectionViewCell.swift (100%) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/NavView/TimerAlarmAlertView.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerAlarmAlertView.swift similarity index 100% rename from Projects/Features/HomeFeature/Sources/TimerScene/Supporter/NavView/TimerAlarmAlertView.swift rename to Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerAlarmAlertView.swift diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/CollectionViewCell/TimerCollectionViewCell.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerCollectionViewCell.swift similarity index 100% rename from Projects/Features/HomeFeature/Sources/TimerScene/Supporter/CollectionViewCell/TimerCollectionViewCell.swift rename to Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerCollectionViewCell.swift diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/NavView/TimerEditView.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerEditView.swift similarity index 100% rename from Projects/Features/HomeFeature/Sources/TimerScene/Supporter/NavView/TimerEditView.swift rename to Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerEditView.swift diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/CollectionViewCell/TimerHeaderCollectionViewCell.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerHeaderCollectionViewCell.swift similarity index 100% rename from Projects/Features/HomeFeature/Sources/TimerScene/Supporter/CollectionViewCell/TimerHeaderCollectionViewCell.swift rename to Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerHeaderCollectionViewCell.swift From 5e154c3f8fbe90332ed062e1076e4db81225248f Mon Sep 17 00:00:00 2001 From: s Date: Thu, 15 Feb 2024 15:09:33 +0900 Subject: [PATCH 27/30] =?UTF-8?q?=F0=9F=8D=97=20::=20[#171]=20conflict=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/TimerScene/View/TimerViewController.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/View/TimerViewController.swift b/Projects/Features/HomeFeature/Sources/TimerScene/View/TimerViewController.swift index c3fc244f..a86ac534 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/View/TimerViewController.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/View/TimerViewController.swift @@ -10,7 +10,6 @@ import Core import HomeFeatureInterface - public class TimerViewController: BaseViewController { private var timerData = TimerModel.init() From 031cd979b079924bee400b3181606afae19f5cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=80=ED=98=B8?= <127753071+Eunho0922@users.noreply.github.com> Date: Thu, 15 Feb 2024 15:19:27 +0900 Subject: [PATCH 28/30] =?UTF-8?q?=F0=9F=8D=97=20::=20[#171]=20conflict=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TimerScene/Supporter/HomeTimerView.swift | 167 ++++++++---------- 1 file changed, 73 insertions(+), 94 deletions(-) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/HomeTimerView.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/HomeTimerView.swift index 717103f0..58a71a98 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/HomeTimerView.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/HomeTimerView.swift @@ -8,47 +8,41 @@ import Then import DSKit public class HomeTimerView: UIView { - + public var homeTimer = MindGymTimerKit() - + private var radius: Double! private var colorCircle: UIColor! private var trackLayer: CAShapeLayer! private var circleShapeLayer: CAShapeLayer! - + private var initTime: Double = 0.0 private var cancelTime: Double = 0.0 private var currentTime: Double = 0.0 - - private var timerIndex: Int = 0 - - var disposeBag = DisposeBag() - + + let disposeBag = DisposeBag() + private var timerInitTitle = UILabel().then { $0.text = "" $0.textAlignment = .center $0.font = UIFont.Pretendard.bodyLarge $0.textColor = .black } - + private var timerMainTitle = UILabel().then { $0.text = "" $0.textAlignment = .center $0.font = UIFont.monospacedDigitSystemFont(ofSize: UIFont.Pretendard.light.pointSize, weight: .light) $0.textColor = .black } - - private let alarmImage = UIImageView().then { - $0.image = DSKitAsset.Assets.homeTimerBell.image - } - + private var timerAlarmTitle = UILabel().then { $0.text = "" $0.textAlignment = .center $0.font = UIFont.Pretendard.bodyMedium $0.textColor = DSKitAsset.Colors.gray400.color } - + public init( center: CGPoint, radius: Double, @@ -58,41 +52,41 @@ public class HomeTimerView: UIView { origin: CGPoint(x: center.x - CGFloat(radius), y: center.y - CGFloat(radius)), size: CGSize(width: radius * 2, height: radius * 2)) ) - + self.colorCircle = color self.radius = radius self.backgroundColor = .clear - + self.trackLayer = setTrackLayer() self.layer.addSublayer(trackLayer) - + self.circleShapeLayer = setCircleLayer() self.layer.addSublayer(circleShapeLayer) - + layout() } - + required public init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } - + private func layout() { - addSubviews([timerInitTitle, timerMainTitle, alarmImage, timerAlarmTitle]) - + addSubviews([timerInitTitle, timerMainTitle, timerAlarmTitle]) + timerInitTitle.snp.makeConstraints { $0.centerX.equalToSuperview() $0.height.equalTo(24.0) $0.width.equalToSuperview() $0.top.equalToSuperview().offset(89.0) } - + timerMainTitle.snp.makeConstraints { $0.centerX.equalToSuperview() $0.height.equalTo(64.0) $0.width.equalToSuperview() $0.top.equalTo(timerInitTitle.snp.bottom).offset(32.0) } - + timerAlarmTitle.snp.makeConstraints { $0.centerX.equalToSuperview() $0.height.equalTo(20.0) @@ -100,27 +94,18 @@ public class HomeTimerView: UIView { $0.top.equalTo(timerMainTitle.snp.bottom).offset(32.0) } } - - let timerModel = TimerModel() - - public func timerChange(for index: Int) { - initTime = timerModel.getTime(at: index) - cancelTime = initTime - timerIndex = index - homeTimer.setTimer(index: index, settingTime: homeTimer.presentTime(index: index)) - - } - - public func timerSetting(for index: Int) { - initTime = timerModel.getTime(at: index) + + public func timerSetting(for seconds: Int) { + homeTimer.setting(count: Double(seconds)) + initTime = Double(seconds) + circleShapeLayer.add(createCircleAnimation(), forKey: "key") + stopTimer() cancelTime = initTime - timerIndex = index - homeTimer.setTimer(index: index, settingTime: homeTimer.presentTime(index: index)) setInitialTimeLabel() setTimerTimeLabel() setInitAlarmTimeLabel() } - + private func setInitialTimeLabel() { if cancelTime == 0 { timerInitTitle.text = "0분" @@ -131,7 +116,7 @@ public class HomeTimerView: UIView { time[0] = initTimeInt / 3600 time[1] = (initTimeInt % 3600) / 60 time[2] = initTimeInt % 60 - + if time[0] > 0 && time[1] > 0 && time[2] > 0 { timerInitTitle.text = "\(time[0])시간 \(time[1])분 \(time[2])초" } else if time[0] > 0 && time[2] > 0 { @@ -140,7 +125,7 @@ public class HomeTimerView: UIView { timerInitTitle.text = "\(time[0])시간 \(time[1])분" } else if time[0] > 0 { timerInitTitle.text = "\(time[0])시간" - } else if time[1] > 0 && time[2] > 0{ + } else if time[1] > 0 && time[2] > 0 { timerInitTitle.text = "\(time[1])분 \(time[2])초" } else if time[1] > 0 { timerInitTitle.text = "\(time[1])분" @@ -148,32 +133,26 @@ public class HomeTimerView: UIView { timerInitTitle.text = "\(time[2])초" } } - + private func setTimerTimeLabel() { if cancelTime == 0 { timerMainTitle.text = "00 : 00" return } - - timerMainTitle.text = setTimerTimeLabelText(from: homeTimer.presentTime(index: timerIndex)) - // 이전 구독을 해제합니다. - disposeBag = DisposeBag() + timerMainTitle.text = setTimerTimeLabelText(from: homeTimer.presentTimer()) - let currentTimer = homeTimer.timers[timerIndex] - currentTimer.timeUpdate + homeTimer.mainTimer.timeUpdate .observe(on: MainScheduler.instance) - .subscribe(onNext: { [self] timeString in + .subscribe(onNext: { [weak self] timeString in DispatchQueue.main.async { [self] in - currentTime = homeTimer.presentTime(index: timerIndex) - timerMainTitle.text = timeString + self?.currentTime = self!.homeTimer.presentTimer() + self?.timerMainTitle.text = timeString } }) .disposed(by: disposeBag) } - - private func setTimerTimeLabelText(from counter: Double) -> String { let totalSeconds = Int(counter) let hours: String = String(format: "%02d", totalSeconds / 3600) @@ -188,44 +167,44 @@ public class HomeTimerView: UIView { return "00 : \(seconds)" } } - + private func setInitAlarmTimeLabel() { if cancelTime == 0 { timerAlarmTitle.text = "" return } - let formatter_time = DateFormatter() - formatter_time.dateFormat = "a h:mm" - formatter_time.amSymbol = "오전" - formatter_time.pmSymbol = "오후" - let current_time_string = formatter_time.string(from: Date().addingTimeInterval(initTime)) - DispatchQueue.main.async { - self.timerAlarmTitle.text = current_time_string - } +// let formatter_time = DateFormatter() +// formatter_time.dateFormat = "a h:mm" +// formatter_time.amSymbol = "오전" +// formatter_time.pmSymbol = "오후" +// let current_time_string = formatter_time.string(from: Date().addingTimeInterval(initTime)) +// DispatchQueue.main.async { +// self.timerAlarmTitle.text = current_time_string +// } } - + private func setAlarmTimeLabel() { - let formatter_time = DateFormatter() - formatter_time.dateFormat = "a h:mm" - formatter_time.amSymbol = "오전" - formatter_time.pmSymbol = "오후" - let current_time_string = formatter_time.string(from: Date().addingTimeInterval(currentTime)) - DispatchQueue.main.async { - self.timerAlarmTitle.text = current_time_string - } +// let formatter_time = DateFormatter() +// formatter_time.dateFormat = "a h:mm" +// formatter_time.amSymbol = "오전" +// formatter_time.pmSymbol = "오후" +// let current_time_string = formatter_time.string(from: Date().addingTimeInterval(homeTimer.presentTimer())) +// DispatchQueue.main.async { +// self.timerAlarmTitle.text = current_time_string +// } } - + public func startTimer() -> Bool { - if currentTime == 0.0 { + if homeTimer.presentTimer() == 0.0 { return false } else { if circleShapeLayer.speed == 0 { restartCricleAnimation() - homeTimer.startTimer(index: timerIndex) + homeTimer.startTimer() setAlarmTimeLabel() } else { circleShapeLayer.add(createCircleAnimation(), forKey: "key") - homeTimer.startTimer(index: timerIndex) + homeTimer.startTimer() setAlarmTimeLabel() } circleShapeLayer.strokeColor = colorCircle.cgColor @@ -236,32 +215,32 @@ public class HomeTimerView: UIView { public func stopTimer() { circleShapeLayer.strokeColor = DSKitAsset.Colors.gray400.color.cgColor stopCricleAnimation() - homeTimer.stopTimer(index: timerIndex) + homeTimer.stopTimer() } - + public func cancelTimer() { cancelTime = 0.0 - homeTimer.setTimer(index: timerIndex, settingTime: 0.0) + homeTimer.setting(count: Double(0)) circleShapeLayer.add(createCircleAnimation(), forKey: "key") stopCricleAnimation() - homeTimer.stopTimer(index: timerIndex) + homeTimer.stopTimer() stopTimer() setInitAlarmTimeLabel() setInitialTimeLabel() } - + public func restartTimer() { - homeTimer.setTimer(index: timerIndex, settingTime: initTime) + homeTimer.setting(count: Double(initTime)) cancelTime = initTime circleShapeLayer.add(createCircleAnimation(), forKey: "key") stopCricleAnimation() - homeTimer.stopTimer(index: timerIndex) + homeTimer.stopTimer() setAlarmTimeLabel() setInitialTimeLabel() } - - public func currentTimer(index: Int) -> Double { - return homeTimer.presentTime(index: index) + + public func currentTimer() -> Double { + return homeTimer.presentTimer() } private func setCircleLayer() -> CAShapeLayer { @@ -274,7 +253,7 @@ public class HomeTimerView: UIView { } return circleLayer } - + private func setTrackLayer() -> CAShapeLayer { let trackLayer = CAShapeLayer().then { $0.path = setCirclePath() @@ -285,13 +264,13 @@ public class HomeTimerView: UIView { } return trackLayer } - + private func stopCricleAnimation() { let pausedTime = circleShapeLayer.convertTime(CACurrentMediaTime(), from: nil) circleShapeLayer.speed = 0 circleShapeLayer.timeOffset = pausedTime } - + private func restartCricleAnimation() { let pausedTime = circleShapeLayer.timeOffset circleShapeLayer.speed = 1.0 @@ -300,7 +279,7 @@ public class HomeTimerView: UIView { let timeSincePause = circleShapeLayer.convertTime(CACurrentMediaTime(), from: nil) - pausedTime circleShapeLayer.beginTime = timeSincePause } - + private func setCirclePath() -> CGPath { UIBezierPath(arcCenter: CGPoint(x: radius, y: radius), radius: CGFloat(radius), @@ -308,13 +287,13 @@ public class HomeTimerView: UIView { endAngle: 2 * CGFloat.pi - CGFloat.pi / 2, clockwise: true).cgPath } - + private func createCircleAnimation() -> CABasicAnimation { let strokeAnimation = CABasicAnimation(keyPath: #keyPath(CAShapeLayer.strokeEnd)) - + strokeAnimation.toValue = 0 strokeAnimation.fromValue = 1 - strokeAnimation.duration = CFTimeInterval(homeTimer.presentTime(index: timerIndex)) + strokeAnimation.duration = CFTimeInterval(homeTimer.presentTimer()) strokeAnimation.isRemovedOnCompletion = true circleShapeLayer.strokeEnd = 0 return strokeAnimation From e65609b34c4bbce25ab1fd10b61b0f2b6b8c0261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=80=ED=98=B8?= <127753071+Eunho0922@users.noreply.github.com> Date: Thu, 15 Feb 2024 15:24:09 +0900 Subject: [PATCH 29/30] =?UTF-8?q?=F0=9F=8D=97=20::=20[#171]=20conflict=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MinGymKit/MinGaGymTimerKit.swift | 76 ++++++------------- .../Supporter/MinGymKit/MinGymKit.swift | 48 ++++-------- .../Supporter/TimerCollectionViewCell.swift | 51 ++++++------- .../TimerScene/Supporter/TimerModel.swift | 35 ++++----- 4 files changed, 79 insertions(+), 131 deletions(-) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGaGymTimerKit.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGaGymTimerKit.swift index f3aab8b2..11cd934a 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGaGymTimerKit.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGaGymTimerKit.swift @@ -3,28 +3,31 @@ import UIKit import RxSwift open class MindGaGymKitTimer: NSObject, TimerControl { - - private var initialTime: Double = 0.0 - private var time: Double = 0.0 + + private var initCounter: Double = 0.0 + private var counter: Double = 0.0 private var timer: Timer? private let timerSubject = PublishSubject() public var timeUpdate: Observable { return timerSubject.asObservable() } - public func setting(settingTime: Double) { - initialTime = settingTime - time = settingTime - setInitTimeString() + public func setting(count: Double) { + initCounter = count + self.counter = count + let timeString = self.timeString(from: self.counter) + self.timerSubject.onNext(timeString) } public func start() { - timer = Timer.scheduledTimer(withTimeInterval: 0.001, repeats: true) { [self] _ in - if time <= 0.001 { - timerStop() + timer = Timer.scheduledTimer(withTimeInterval: 0.035, repeats: true) { [weak self] _ in + guard let self = self else { return } + if self.counter <= 0 { + self.stop() } else { - time -= 0.001 - setTimeString() + self.counter -= 0.035 + let timeString = self.timeString(from: self.counter) + self.timerSubject.onNext(timeString) } } } @@ -33,54 +36,25 @@ open class MindGaGymKitTimer: NSObject, TimerControl { timer?.invalidate() timer = nil } - - public func timerStop() { - setInitTimeString() - timer?.invalidate() - timer = nil - } public func restart() { - time = initialTime - setInitTimeString() + counter = initCounter + let timeString = self.timeString(from: self.counter) + self.timerSubject.onNext(timeString) } public func reset() { - time = 0.0 - initialTime = 0.0 - setInitTimeString() + counter = 0.0 + initCounter = 0.0 + let timeString = self.timeString(from: self.counter) + self.timerSubject.onNext(timeString) } - + public func presentTime() -> Double { - return time + return self.counter } - - public func setTimeString() { - let timeString = timeString(from: time) - timerSubject.onNext(timeString) - } - - public func setInitTimeString() { - let timeString = initTimeString(from: time) - timerSubject.onNext(timeString) - } - - private func timeString(from counter: Double) -> String { - let totalSeconds = Int(counter) + 1 - let hours: String = String(format: "%02d", totalSeconds / 3600) - let minutes: String = String(format: "%02d", (totalSeconds % 3600) / 60) - let seconds: String = String(format: "%02d", totalSeconds % 60) - if totalSeconds / 3600 >= 1 { - return "\(hours) : \(minutes) : \(seconds)" - } else if totalSeconds / 60 >= 1 { - return "\(minutes) : \(seconds)" - } else { - return "00 : \(seconds)" - } - } - - private func initTimeString(from counter: Double) -> String { + private func timeString(from counter: Double) -> String { let totalSeconds = Int(counter) let hours: String = String(format: "%02d", totalSeconds / 3600) let minutes: String = String(format: "%02d", (totalSeconds % 3600) / 60) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGymKit.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGymKit.swift index 963c4450..b4dab795 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGymKit.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/MinGymKit/MinGymKit.swift @@ -3,55 +3,37 @@ import RxSwift public protocol TimerControl { var timeUpdate: Observable { get } - func setting(settingTime: Double) func start() func stop() func reset() - func restart() func presentTime() -> Double } open class MindGymTimerKit { - public var timers: [TimerControl] = [] - - public init() { - let initialTimes: [Double] = [60.0, 10.0, 4660.0, 3600.0, 700.0, 5.0] - for time in initialTimes { - addRearTimer(time: time) - } - } - - public func setTimer(index: Int, settingTime: Double) { - timers[index].setting(settingTime: settingTime) - } + public let mainTimer: TimerControl = MindGaGymKitTimer() - public func startTimer(index: Int) { - timers[index].start() + public func setting(count: Double) { + (mainTimer as? MindGaGymKitTimer)?.setting(count: count) } - public func stopTimer(index: Int) { - timers[index].stop() + public func startTimer() { + mainTimer.start() } - public func resetTimer(index: Int) { - timers[index].reset() + public func stopTimer() { + mainTimer.stop() } - public func restartTimer(index: Int) { - timers[index].restart() + public func resetTimer() { + mainTimer.reset() } - - public func addRearTimer(time: Double) { - let newTimer = MindGaGymKitTimer() - newTimer.setting(settingTime: time) - timers.append(newTimer) - } - - public func deleteTimer(index: Int) { - timers.remove(at: index) + + public func restartTimer() { + (mainTimer as? MindGaGymKitTimer)?.restart() } - public func presentTime(index: Int) -> Double { - return timers[index].presentTime() + public func presentTimer() -> Double { + let presentTime: Double = mainTimer.presentTime() + return presentTime } } diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerCollectionViewCell.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerCollectionViewCell.swift index 59060d87..b0aeec81 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerCollectionViewCell.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerCollectionViewCell.swift @@ -7,24 +7,24 @@ import DSKit import Core public class TimerCollectionViewCell: UICollectionViewCell { - + static let identifier: String = "TimerCollectionViewCell" - + private var containerView = UIView() - + private var checkImage = UIImageView().then { $0.image = DSKitAsset.Assets.yesCheck.image $0.isHidden = true } - + private var unCheckView = UIView().then { $0.layer.cornerRadius = 11.0 $0.layer.borderColor = DSKitAsset.Colors.gray300.color.cgColor $0.layer.borderWidth = 2 $0.isHidden = true } - - private var timeLabel = UILabel().then { + + private var exerciseNameLabel = UILabel().then { $0.font = UIFont.Pretendard.bodyMedium $0.backgroundColor = DSKitAsset.Colors.gray50.color $0.layer.masksToBounds = true @@ -33,13 +33,12 @@ public class TimerCollectionViewCell: UICollectionViewCell { $0.numberOfLines = 1 $0.layer.cornerRadius = 50.0 } - + public func setup(time: Double) { - timeLabel.text = setTimerTimeLabelText(from: time) + exerciseNameLabel.text = setTimerTimeLabelText(from: time) layout() - } - + private func setTimerTimeLabelText(from counter: Double) -> String { let hours: String = String(format: "%02d", Int(counter / 3600)) let minutes: String = String(format: "%02d", Int((counter.truncatingRemainder(dividingBy: 3600)) / 60)) @@ -52,46 +51,44 @@ public class TimerCollectionViewCell: UICollectionViewCell { return "00 : \(seconds)" } } - + private func layout() { - addSubviews([timeLabel, checkImage, unCheckView]) - + addSubviews([exerciseNameLabel, checkImage, unCheckView]) checkImage.snp.makeConstraints { $0.top.leading.equalToSuperview().offset(6.0) $0.width.height.equalTo(22.0) } - + unCheckView.snp.makeConstraints { $0.top.leading.equalToSuperview().offset(6.0) $0.width.height.equalTo(22.0) } - - timeLabel.snp.makeConstraints { + + exerciseNameLabel.snp.makeConstraints { $0.top.bottom.trailing.leading.equalToSuperview().inset(10.0) $0.width.height.equalTo(100.0) } } - + public func cellUnClicked() { - timeLabel.layer.borderColor = DSKitAsset.Colors.gray50.color.cgColor - timeLabel.layer.borderWidth = 2 - timeLabel.backgroundColor = DSKitAsset.Colors.gray50.color + exerciseNameLabel.layer.borderColor = DSKitAsset.Colors.gray50.color.cgColor + exerciseNameLabel.layer.borderWidth = 2 + exerciseNameLabel.backgroundColor = DSKitAsset.Colors.gray50.color } - + public func cellClicked() { - timeLabel.layer.borderColor = DSKitAsset.Colors.blue500.color.cgColor - timeLabel.layer.borderWidth = 2 - timeLabel.backgroundColor = .white + exerciseNameLabel.layer.borderColor = DSKitAsset.Colors.blue500.color.cgColor + exerciseNameLabel.layer.borderWidth = 2 + exerciseNameLabel.backgroundColor = .white } - + public func cellChoosing() { unCheckView.isHidden = true checkImage.isHidden = false } - + public func cellChoosed() { unCheckView.isHidden = false checkImage.isHidden = true } } - diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerModel.swift b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerModel.swift index aff79add..cad681de 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerModel.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/Supporter/TimerModel.swift @@ -1,32 +1,27 @@ -import Foundation - public class TimerModel { public struct Time { - var time: Double + var time: Int var isClicked: Bool } - private var privateData: [Time] - + + private var _data: [Time] + var data: [Time] { - return privateData + return _data } - + init() { - privateData = [ - Time(time: 60.0, isClicked: true), - Time(time: 10.0, isClicked: false), - Time(time: 4660.0, isClicked: false), - Time(time: 3600.0, isClicked: false), - Time(time: 700.0, isClicked: false), - Time(time: 5.0, isClicked: false), + _data = [ + Time(time: 60, isClicked: false), + Time(time: 10, isClicked: false), + Time(time: 4660, isClicked: false), + Time(time: 3600, isClicked: false), + Time(time: 700, isClicked: false), + Time(time: 5, isClicked: false) ] } - + func updateData(at index: Int, with newValue: Time) { - privateData[index] = newValue - } - - public func getTime(at index: Int) -> Double { - return privateData[index].time + _data[index] = newValue } } From d4b7815c5ec5ec8dfbb623677632fc11afcae878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=80=ED=98=B8?= <127753071+Eunho0922@users.noreply.github.com> Date: Thu, 15 Feb 2024 15:26:49 +0900 Subject: [PATCH 30/30] =?UTF-8?q?=F0=9F=8D=97=20::=20[#171]=20conflict=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TimerScene/View/TimerViewController.swift | 128 +++++++++--------- 1 file changed, 65 insertions(+), 63 deletions(-) diff --git a/Projects/Features/HomeFeature/Sources/TimerScene/View/TimerViewController.swift b/Projects/Features/HomeFeature/Sources/TimerScene/View/TimerViewController.swift index a86ac534..5903bc14 100644 --- a/Projects/Features/HomeFeature/Sources/TimerScene/View/TimerViewController.swift +++ b/Projects/Features/HomeFeature/Sources/TimerScene/View/TimerViewController.swift @@ -11,155 +11,158 @@ import Core import HomeFeatureInterface public class TimerViewController: BaseViewController { - + private var timerData = TimerModel.init() - private var currentTimerIndex: Int = 0 - + private var alaertView = TimerAlarmAlertView() - + private var navBeforeButton = UIButton().then { $0.setImage(DSKitAsset.Assets.timerNavLeft.image, for: .normal) } - + private var navAddButton = UIButton().then { $0.setImage(DSKitAsset.Assets.timerNavPlus.image, for: .normal) } - + private var navEditButton = UIButton().then { $0.setImage(DSKitAsset.Assets.timerNavDots.image, for: .normal) } - + private var editView = TimerEditView() - - private var testView = AddTimerView() - + lazy var progressBarView = HomeTimerView(center: view.center, radius: 175.0, color: DSKitAsset.Colors.blue500.color) - + private let closeButton = MGTimerButton(type: .close) private let stopButton = MGTimerButton(type: .stop, radius: 40.0) private let startButton = MGTimerButton(type: .start, radius: 40.0) private let restartButton = MGTimerButton(type: .restart) - + private lazy var collectionViewLayout = UICollectionViewFlowLayout().then { $0.scrollDirection = .horizontal $0.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) } - - private lazy var timerCollectionView = UICollectionView(frame: .zero, collectionViewLayout: self.collectionViewLayout).then { - $0.register(TimerHeaderCollectionViewCell.self, forCellWithReuseIdentifier: TimerHeaderCollectionViewCell.identifier) - $0.register(TimerCollectionViewCell.self, forCellWithReuseIdentifier: TimerCollectionViewCell.identifier) + + private lazy var timerCollectionView = UICollectionView(frame: .zero, + collectionViewLayout: self.collectionViewLayout + ).then { + $0.register(TimerHeaderCollectionViewCell.self, + forCellWithReuseIdentifier: TimerHeaderCollectionViewCell.identifier) + $0.register(TimerCollectionViewCell.self, + forCellWithReuseIdentifier: TimerCollectionViewCell.identifier) $0.translatesAutoresizingMaskIntoConstraints = false $0.showsHorizontalScrollIndicator = false $0.showsVerticalScrollIndicator = false $0.dataSource = self $0.delegate = self } - + public override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() alaertView.initializeViewPosition() } - + public override func attribute() { view.backgroundColor = .white - - progressBarView.timerSetting(for: 0) - + + progressBarView.timerSetting(for: 3601) + buttonTap() } - + public override func layout() { - view.addSubviews([navBeforeButton, navAddButton, navEditButton, editView, progressBarView, closeButton, stopButton, startButton, restartButton, timerCollectionView, alaertView, testView]) - + view.addSubviews([navBeforeButton, + navAddButton, + navEditButton, + editView, + progressBarView, + closeButton, + stopButton, + startButton, + restartButton, + timerCollectionView, + alaertView]) + navBeforeButton.snp.makeConstraints { $0.top.equalToSuperview().offset(61.0) $0.leading.equalToSuperview().offset(20.0) $0.width.height.equalTo(32.0) } - + navEditButton.snp.makeConstraints { $0.top.equalToSuperview().offset(61.0) $0.trailing.equalToSuperview().offset(-20.0) $0.width.height.equalTo(32.0) } - + navAddButton.snp.makeConstraints { $0.top.equalToSuperview().offset(61.0) $0.trailing.equalTo(navEditButton.snp.leading).offset(-12.0) $0.width.height.equalTo(32.0) } - + editView.snp.makeConstraints { $0.edges.equalToSuperview() } - + progressBarView.snp.makeConstraints { $0.top.equalToSuperview().offset(141.0) $0.centerX.equalToSuperview() $0.width.height.equalTo(350.0) } - + timerCollectionView.snp.makeConstraints { $0.top.equalTo(progressBarView.snp.bottom).offset(49.5) $0.leading.trailing.equalToSuperview() $0.height.equalTo(120.0) } - + closeButton.snp.makeConstraints { $0.top.equalTo(progressBarView.snp.bottom).offset(225.0) $0.leading.equalToSuperview().offset(83.0) } - + stopButton.snp.makeConstraints { $0.top.equalTo(progressBarView.snp.bottom).offset(219.0) $0.leading.equalTo(closeButton.snp.trailing).offset(24.0) - } - + startButton.snp.makeConstraints { $0.top.equalTo(progressBarView.snp.bottom).offset(219.0) $0.leading.equalTo(closeButton.snp.trailing).offset(24.0) - } - + restartButton.snp.makeConstraints { $0.top.equalTo(progressBarView.snp.bottom).offset(225.0) $0.trailing.equalToSuperview().offset(-83.0) - } - + alaertView.snp.makeConstraints { $0.top.equalToSuperview().offset(77.0) $0.leading.trailing.equalToSuperview().inset(20.0) $0.height.equalTo(152.0) } - - testView.snp.makeConstraints { - $0.edges.equalToSuperview() - } } - + private func buttonTap() { - - progressBarView.homeTimer.timers[0].timeUpdate + progressBarView.homeTimer.mainTimer.timeUpdate .observe(on: MainScheduler.instance) - .subscribe(onNext: { [self] timeString in - DispatchQueue.main.async { [self] in - if progressBarView.currentTimer(index: currentTimerIndex) <= 0.0 { - alaertView.moveViewDown() - progressBarView.stopTimer() - stopButton.isHidden = true - startButton.isHidden = false + .subscribe(onNext: { [weak self] timeString in + DispatchQueue.main.async { [weak self] in + if self?.progressBarView.currentTimer() ?? 0.0 <= 0.0 { + self?.alaertView.moveViewDown() + self?.progressBarView.stopTimer() + self?.stopButton.isHidden = true + self?.startButton.isHidden = false } } }) .disposed(by: disposeBag) - + navEditButton.rx.tap .subscribe(onNext: { [self] in editView.showView() }).disposed(by: disposeBag) - + startButton.rx.tap .subscribe(onNext: { [self] in if progressBarView.startTimer() { @@ -168,7 +171,7 @@ public class TimerViewController: BaseViewController { } }) .disposed(by: disposeBag) - + stopButton.rx.tap .subscribe(onNext: { [self] in progressBarView.stopTimer() @@ -176,7 +179,7 @@ public class TimerViewController: BaseViewController { startButton.isHidden = false }) .disposed(by: disposeBag) - + restartButton.rx.tap .subscribe(onNext: { [self] in progressBarView.restartTimer() @@ -185,7 +188,7 @@ public class TimerViewController: BaseViewController { startButton.isHidden = false } }).disposed(by: disposeBag) - + closeButton.rx.tap .subscribe(onNext: { [self] in progressBarView.cancelTimer() @@ -243,23 +246,22 @@ extension TimerViewController: UICollectionViewDataSource { } return cell ?? UICollectionViewCell() } - + public func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool { if indexPath.row == 0 { return false } - - progressBarView.timerSetting(for: indexPath.row - 1) - currentTimerIndex = indexPath.row - 1 - + + let time = timerData.data[indexPath.row - 1].time + progressBarView.timerSetting(for: time) + stopButton.isHidden = true startButton.isHidden = false - + return true } } - extension TimerViewController: UICollectionViewDelegate { public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { for index in 0..