Skip to content

Commit

Permalink
[Feat] 링 구현 #37
Browse files Browse the repository at this point in the history
  • Loading branch information
HELLOHIDI committed Nov 25, 2023
1 parent cf7b5d1 commit 0767d0b
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 8 deletions.
4 changes: 4 additions & 0 deletions SOPKATHON_33-iOS/SOPKATHON_33-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -103,6 +104,7 @@
D26AFFE92B12767B007B90DF /* MoyaAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoyaAPI.swift; sourceTree = "<group>"; };
D26AFFEB2B127B0F007B90DF /* BaseViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseViewController.swift; sourceTree = "<group>"; };
D26AFFED2B128915007B90DF /* GelationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GelationModel.swift; sourceTree = "<group>"; };
D26AFFEF2B1291DC007B90DF /* ProgressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressView.swift; sourceTree = "<group>"; };
D28379B82B0FBBEA00A1903B /* UIApplication+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIApplication+.swift"; sourceTree = "<group>"; };
D28379BA2B0FBBF500A1903B /* UIButton+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIButton+.swift"; sourceTree = "<group>"; };
D28379BC2B0FBC0400A1903B /* UICollectionReuseableView+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UICollectionReuseableView+.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -208,6 +210,7 @@
A19A1F5A2B1255CF0077ACEC /* ActivityStackView.swift */,
A19A1F5C2B1258490077ACEC /* ActivityStackViewItem.swift */,
A13161442B12749800883CB2 /* UserInfoChipView.swift */,
D26AFFEF2B1291DC007B90DF /* ProgressView.swift */,
);
path = View;
sourceTree = "<group>";
Expand Down Expand Up @@ -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 */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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))
Expand All @@ -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)
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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")
}
}



0 comments on commit 0767d0b

Please sign in to comment.