This repository has been archived by the owner on Dec 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#195] ๐๏ธ ์์ ํ์นธ์ฉ ์๋ ๊ณต๋ฐฑ๋ค์ ์ญ์
- Loading branch information
1 parent
7632171
commit f0dbdec
Showing
1 changed file
with
90 additions
and
90 deletions.
There are no files selected for viewing
180 changes: 90 additions & 90 deletions
180
iOS/Sources/Presentation/Scene/Main/NewClub/View/NewClubStepView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,93 @@ | ||
import UIKit | ||
import SnapKit | ||
import SnapKit | ||
|
||
final class NewClubStepView: UIView { | ||
private let levelLabel = UILabel().then { | ||
$0.font = UIFont(font: GCMSFontFamily.Inter.medium, size: 16) | ||
} | ||
private let titleLabel = UILabel().then { | ||
$0.font = UIFont(font: GCMSFontFamily.Inter.bold, size: 12) | ||
} | ||
private let underBar = UIView().then { | ||
$0.backgroundColor = GCMSAsset.Colors.gcmsGray5.color | ||
$0.layer.cornerRadius = 2 | ||
} | ||
private let shape = CAShapeLayer() | ||
final class NewClubStepView: UIView { | ||
private let levelLabel = UILabel().then { | ||
$0.font = UIFont(font: GCMSFontFamily.Inter.medium, size: 16) | ||
} | ||
private let titleLabel = UILabel().then { | ||
$0.font = UIFont(font: GCMSFontFamily.Inter.bold, size: 12) | ||
} | ||
private let underBar = UIView().then { | ||
$0.backgroundColor = GCMSAsset.Colors.gcmsGray5.color | ||
$0.layer.cornerRadius = 2 | ||
} | ||
private let shape = CAShapeLayer() | ||
|
||
var selectedBackgroundColor = GCMSAsset.Colors.gcmsMainColor.color | ||
var unSelectedBackgroundColor = GCMSAsset.Colors.gcmsGray4.color | ||
var selectedLevelTintColor = GCMSAsset.Colors.gcmsGray1.color | ||
var unSelectedLevelTintColor = GCMSAsset.Colors.gcmsGray5.color | ||
var selectedTitleLabelTintColor = GCMSAsset.Colors.gcmsMainColor.color | ||
var unSelectedTitleLabelTintColor = GCMSAsset.Colors.gcmsGray4.color | ||
var isSelected: Bool = false { | ||
didSet { update() } | ||
} | ||
|
||
init( | ||
level: Int, | ||
title: String | ||
) { | ||
super.init(frame: .zero) | ||
addView() | ||
setLayout() | ||
configure() | ||
self.levelLabel.text = "\(level)" | ||
self.titleLabel.text = title | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
override func draw(_ rect: CGRect) { | ||
super.draw(rect) | ||
drawPath(rect: rect) | ||
} | ||
|
||
} | ||
|
||
var selectedBackgroundColor = GCMSAsset.Colors.gcmsMainColor.color | ||
var unSelectedBackgroundColor = GCMSAsset.Colors.gcmsGray4.color | ||
var selectedLevelTintColor = GCMSAsset.Colors.gcmsGray1.color | ||
var unSelectedLevelTintColor = GCMSAsset.Colors.gcmsGray5.color | ||
var selectedTitleLabelTintColor = GCMSAsset.Colors.gcmsMainColor.color | ||
var unSelectedTitleLabelTintColor = GCMSAsset.Colors.gcmsGray4.color | ||
var isSelected: Bool = false { | ||
didSet { update() } | ||
} | ||
|
||
init( | ||
level: Int, | ||
title: String | ||
) { | ||
super.init(frame: .zero) | ||
addView() | ||
setLayout() | ||
configure() | ||
self.levelLabel.text = "\(level)" | ||
self.titleLabel.text = title | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
override func draw(_ rect: CGRect) { | ||
super.draw(rect) | ||
drawPath(rect: rect) | ||
} | ||
|
||
} | ||
|
||
private extension NewClubStepView { | ||
func drawPath(rect: CGRect) { | ||
let path = UIBezierPath() | ||
path.move(to: CGPoint(x: rect.width/2, y: rect.maxY + 5)) | ||
path.addLine(to: CGPoint(x: rect.width/2 - 4, y: rect.maxY)) | ||
path.addLine(to: CGPoint(x: rect.width/2 + 4, y: rect.maxY)) | ||
path.close() | ||
|
||
shape.fillColor = isSelected ? selectedBackgroundColor.cgColor : unSelectedBackgroundColor.cgColor | ||
shape.path = path.cgPath | ||
self.layer.addSublayer(shape) | ||
} | ||
func addView() { | ||
addSubViews(levelLabel, titleLabel, underBar) | ||
} | ||
func setLayout() { | ||
levelLabel.snp.makeConstraints { | ||
$0.center.equalToSuperview() | ||
} | ||
titleLabel.snp.makeConstraints { | ||
$0.centerX.equalToSuperview() | ||
$0.top.equalTo(self.snp.bottom).offset(20) | ||
} | ||
underBar.snp.makeConstraints { | ||
$0.centerX.equalToSuperview() | ||
$0.top.equalTo(self.snp.bottom).offset(10) | ||
$0.height.equalTo(3) | ||
$0.width.equalTo(11) | ||
} | ||
} | ||
func configure() { | ||
levelLabel.textColor = isSelected ? selectedLevelTintColor : unSelectedLevelTintColor | ||
titleLabel.textColor = isSelected ? selectedTitleLabelTintColor : unSelectedTitleLabelTintColor | ||
backgroundColor = isSelected ? selectedBackgroundColor : unSelectedBackgroundColor | ||
underBar.isHidden = !isSelected | ||
} | ||
func update() { | ||
shape.fillColor = isSelected ? selectedBackgroundColor.cgColor : unSelectedBackgroundColor.cgColor | ||
levelLabel.textColor = isSelected ? selectedLevelTintColor : unSelectedLevelTintColor | ||
titleLabel.textColor = isSelected ? selectedTitleLabelTintColor : unSelectedTitleLabelTintColor | ||
backgroundColor = isSelected ? selectedBackgroundColor : unSelectedBackgroundColor | ||
underBar.isHidden = !isSelected | ||
} | ||
} | ||
private extension NewClubStepView { | ||
func drawPath(rect: CGRect) { | ||
let path = UIBezierPath() | ||
path.move(to: CGPoint(x: rect.width/2, y: rect.maxY + 5)) | ||
path.addLine(to: CGPoint(x: rect.width/2 - 4, y: rect.maxY)) | ||
path.addLine(to: CGPoint(x: rect.width/2 + 4, y: rect.maxY)) | ||
path.close() | ||
|
||
shape.fillColor = isSelected ? selectedBackgroundColor.cgColor : unSelectedBackgroundColor.cgColor | ||
shape.path = path.cgPath | ||
self.layer.addSublayer(shape) | ||
} | ||
func addView() { | ||
addSubViews(levelLabel, titleLabel, underBar) | ||
} | ||
func setLayout() { | ||
levelLabel.snp.makeConstraints { | ||
$0.center.equalToSuperview() | ||
} | ||
titleLabel.snp.makeConstraints { | ||
$0.centerX.equalToSuperview() | ||
$0.top.equalTo(self.snp.bottom).offset(20) | ||
} | ||
underBar.snp.makeConstraints { | ||
$0.centerX.equalToSuperview() | ||
$0.top.equalTo(self.snp.bottom).offset(10) | ||
$0.height.equalTo(3) | ||
$0.width.equalTo(11) | ||
} | ||
} | ||
func configure() { | ||
levelLabel.textColor = isSelected ? selectedLevelTintColor : unSelectedLevelTintColor | ||
titleLabel.textColor = isSelected ? selectedTitleLabelTintColor : unSelectedTitleLabelTintColor | ||
backgroundColor = isSelected ? selectedBackgroundColor : unSelectedBackgroundColor | ||
underBar.isHidden = !isSelected | ||
} | ||
func update() { | ||
shape.fillColor = isSelected ? selectedBackgroundColor.cgColor : unSelectedBackgroundColor.cgColor | ||
levelLabel.textColor = isSelected ? selectedLevelTintColor : unSelectedLevelTintColor | ||
titleLabel.textColor = isSelected ? selectedTitleLabelTintColor : unSelectedTitleLabelTintColor | ||
backgroundColor = isSelected ? selectedBackgroundColor : unSelectedBackgroundColor | ||
underBar.isHidden = !isSelected | ||
} | ||
} |