From 0767d0bf0ecd303085fd50c0b4c1d9a5e2f5bf31 Mon Sep 17 00:00:00 2001 From: HELLOHIDI Date: Sun, 26 Nov 2023 05:43:59 +0900 Subject: [PATCH] =?UTF-8?q?[Feat]=20=EB=A7=81=20=EA=B5=AC=ED=98=84=20#37?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project.pbxproj | 4 ++ .../Main/MainViewController.swift | 4 ++ .../Main/View/ActivityCardView.swift | 30 ++++++--- .../Presentation/Main/View/ProgressView.swift | 65 +++++++++++++++++++ 4 files changed, 95 insertions(+), 8 deletions(-) create mode 100644 SOPKATHON_33-iOS/SOPKATHON_33-iOS/Presentation/Main/View/ProgressView.swift diff --git a/SOPKATHON_33-iOS/SOPKATHON_33-iOS.xcodeproj/project.pbxproj b/SOPKATHON_33-iOS/SOPKATHON_33-iOS.xcodeproj/project.pbxproj index 56e5792..3c83b6f 100644 --- a/SOPKATHON_33-iOS/SOPKATHON_33-iOS.xcodeproj/project.pbxproj +++ b/SOPKATHON_33-iOS/SOPKATHON_33-iOS.xcodeproj/project.pbxproj @@ -32,6 +32,7 @@ D26AFFEA2B12767B007B90DF /* MoyaAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = D26AFFE92B12767B007B90DF /* MoyaAPI.swift */; }; D26AFFEC2B127B0F007B90DF /* BaseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D26AFFEB2B127B0F007B90DF /* BaseViewController.swift */; }; D26AFFEE2B128915007B90DF /* GelationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D26AFFED2B128915007B90DF /* GelationModel.swift */; }; + D26AFFF02B1291DC007B90DF /* ProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D26AFFEF2B1291DC007B90DF /* ProgressView.swift */; }; D28379A12B0FB83A00A1903B /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = D28379A02B0FB83A00A1903B /* SnapKit */; }; D28379A42B0FB84300A1903B /* Then in Frameworks */ = {isa = PBXBuildFile; productRef = D28379A32B0FB84300A1903B /* Then */; }; D28379A72B0FB86500A1903B /* Moya in Frameworks */ = {isa = PBXBuildFile; productRef = D28379A62B0FB86500A1903B /* Moya */; }; @@ -103,6 +104,7 @@ D26AFFE92B12767B007B90DF /* MoyaAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoyaAPI.swift; sourceTree = ""; }; D26AFFEB2B127B0F007B90DF /* BaseViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseViewController.swift; sourceTree = ""; }; D26AFFED2B128915007B90DF /* GelationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GelationModel.swift; sourceTree = ""; }; + D26AFFEF2B1291DC007B90DF /* ProgressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressView.swift; sourceTree = ""; }; D28379B82B0FBBEA00A1903B /* UIApplication+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIApplication+.swift"; sourceTree = ""; }; D28379BA2B0FBBF500A1903B /* UIButton+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIButton+.swift"; sourceTree = ""; }; D28379BC2B0FBC0400A1903B /* UICollectionReuseableView+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UICollectionReuseableView+.swift"; sourceTree = ""; }; @@ -208,6 +210,7 @@ A19A1F5A2B1255CF0077ACEC /* ActivityStackView.swift */, A19A1F5C2B1258490077ACEC /* ActivityStackViewItem.swift */, A13161442B12749800883CB2 /* UserInfoChipView.swift */, + D26AFFEF2B1291DC007B90DF /* ProgressView.swift */, ); path = View; sourceTree = ""; @@ -595,6 +598,7 @@ D26AFFEE2B128915007B90DF /* GelationModel.swift in Sources */, D28379BF2B0FBC0F00A1903B /* UICollectionViewCell++.swift in Sources */, D28379D12B0FBC7600A1903B /* UIViewController+.swift in Sources */, + D26AFFF02B1291DC007B90DF /* ProgressView.swift in Sources */, D28379CD2B0FBC5F00A1903B /* UITextField+.swift in Sources */, D206CADC2B0FB748007ECC1B /* ViewController.swift in Sources */, D28379C72B0FBC4100A1903B /* UIStackView+.swift in Sources */, diff --git a/SOPKATHON_33-iOS/SOPKATHON_33-iOS/Presentation/Main/MainViewController.swift b/SOPKATHON_33-iOS/SOPKATHON_33-iOS/Presentation/Main/MainViewController.swift index e5cdef9..1ea0fe4 100644 --- a/SOPKATHON_33-iOS/SOPKATHON_33-iOS/Presentation/Main/MainViewController.swift +++ b/SOPKATHON_33-iOS/SOPKATHON_33-iOS/Presentation/Main/MainViewController.swift @@ -24,6 +24,10 @@ final class MainViewController: BaseViewController { self.setHierachy() self.setLayout() requestMainData() + activityCardView.progressView1.progressAnimation(duration: 1, value: 0.9) + activityCardView.progressView2.progressAnimation(duration: 1, value: 0.5) + activityCardView.progressView3.progressAnimation(duration: 1, value: 0.6) + } private func setHierachy() { diff --git a/SOPKATHON_33-iOS/SOPKATHON_33-iOS/Presentation/Main/View/ActivityCardView.swift b/SOPKATHON_33-iOS/SOPKATHON_33-iOS/Presentation/Main/View/ActivityCardView.swift index 76ce199..50c17b9 100644 --- a/SOPKATHON_33-iOS/SOPKATHON_33-iOS/Presentation/Main/View/ActivityCardView.swift +++ b/SOPKATHON_33-iOS/SOPKATHON_33-iOS/Presentation/Main/View/ActivityCardView.swift @@ -6,12 +6,15 @@ // import UIKit +import SnapKit final class ActivityCardView: UIView { //MARK: - set Properties - private let ringImageView = UIImageView() + let progressView1 = ProgressView(frame: .init(origin: .zero, size: .init(width: 187,height: 187))) + let progressView2 = ProgressView(frame: .init(origin: .zero, size: .init(width: 145,height: 145))) + let progressView3 = ProgressView(frame: .init(origin: .zero, size: .init(width: 105,height: 105))) let activityStackView = ActivityStackView() private let divisionLine = UIView() private let showDetailButton = UIButton() @@ -39,9 +42,6 @@ final class ActivityCardView: UIView { $0.layer.cornerRadius = 8 } - ringImageView.do { - $0.image = UIImage(named: "ring") - } divisionLine.do { $0.setBorder(borderWidth: 1, borderColor: UIColor(red: 0.914, green: 0.922, blue: 0.929, alpha: 1)) @@ -57,7 +57,9 @@ final class ActivityCardView: UIView { //MARK: - set Hierachy private func setHierachy() { - self.addSubviews(ringImageView, + self.addSubviews(progressView1, + progressView2, + progressView3, activityStackView, divisionLine, showDetailButton) @@ -71,9 +73,21 @@ final class ActivityCardView: UIView { $0.height.equalTo(405.adjusted) } - ringImageView.snp.makeConstraints { - $0.top.equalToSuperview().inset(34.adjusted) - $0.centerX.equalToSuperview() + progressView1.snp.makeConstraints { + $0.top.equalToSuperview().offset(34) + $0.leading.equalToSuperview().offset(74) + $0.width.height.equalTo(187) + } + progressView2.snp.makeConstraints { + $0.top.equalTo(progressView1).offset(21) + $0.leading.equalToSuperview().offset(95) + $0.width.height.equalTo(145) + } + + progressView3.snp.makeConstraints { + $0.top.equalTo(progressView2).offset(21) + $0.leading.equalToSuperview().offset(115) + $0.width.height.equalTo(105) } activityStackView.snp.makeConstraints { diff --git a/SOPKATHON_33-iOS/SOPKATHON_33-iOS/Presentation/Main/View/ProgressView.swift b/SOPKATHON_33-iOS/SOPKATHON_33-iOS/Presentation/Main/View/ProgressView.swift new file mode 100644 index 0000000..4b413f7 --- /dev/null +++ b/SOPKATHON_33-iOS/SOPKATHON_33-iOS/Presentation/Main/View/ProgressView.swift @@ -0,0 +1,65 @@ +// +// ProgressView.swift +// SOPKATHON_33-iOS +// +// Created by 류희재 on 2023/11/26. +// + +import UIKit + +class ProgressView: UIView { + private var circleLayer = CAShapeLayer() + private var progressLayer = CAShapeLayer() + private var startPoint = CGFloat(-0.5 * Double.pi) + private var endPoint = CGFloat(1.5 * Double.pi) + + override func draw(_ rect: CGRect) { + createCircularPath() + } + + func createCircularPath() { + self.backgroundColor = .white + let circularPath = UIBezierPath(arcCenter: .init( + x: self.frame.width / 2.0, + y: self.frame.height / 2.0), + radius: (frame.size.height - 10) / 2.0 , + startAngle: startPoint, + endAngle: endPoint, + clockwise: true + ) + circleLayer.path = circularPath.cgPath + circleLayer.fillColor = UIColor.clear.cgColor + circleLayer.lineCap = .round + circleLayer.lineWidth = 15 + circleLayer.strokeStart = 0 + circleLayer.strokeEnd = 1.0 + circleLayer.strokeColor = UIColor.black.withAlphaComponent(0.4).cgColor + layer.addSublayer(circleLayer) + + progressLayer.path = circularPath.cgPath + progressLayer.fillColor = UIColor.clear.cgColor + progressLayer.lineCap = .round + progressLayer.lineWidth = 15 + progressLayer.strokeStart = 0.0 +// progressLayer.strokeEnd = 0.5 + + progressLayer.strokeColor = UIColor.red.cgColor + layer.addSublayer(progressLayer) + } + + func progressAnimation(duration: TimeInterval, value: Double) { + // created circularProgressAnimation with keyPath + + let circularProgressAnimation = CABasicAnimation(keyPath: "strokeEnd") + // set the end time + circularProgressAnimation.duration = duration + circularProgressAnimation.fromValue = 0 + circularProgressAnimation.toValue = value + circularProgressAnimation.fillMode = .forwards + circularProgressAnimation.isRemovedOnCompletion = false + progressLayer.add(circularProgressAnimation, forKey: "progressAnim") + } +} + + +