Skip to content

Commit 7616a6b

Browse files
committed
[Add] 인덴트 4 적용
1 parent 73a7aff commit 7616a6b

File tree

143 files changed

+4012
-4166
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+4012
-4166
lines changed

.swiftformat

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--indent 4

EATSSUDesign/EATSSUDesign/Sources/DesignSystem/Button/ESButton.swift

+99-99
Original file line numberDiff line numberDiff line change
@@ -14,107 +14,107 @@ import SnapKit
1414
///
1515
/// Big & Small 사이즈를 제공합니다.
1616
public enum ButtonSize {
17-
/// 큰 사이즈 EATSSU 버튼입니다.
18-
case big
19-
20-
/// 작은 사이즈 EATSSU 버튼입니다.
21-
case small
17+
/// 큰 사이즈 EATSSU 버튼입니다.
18+
case big
19+
20+
/// 작은 사이즈 EATSSU 버튼입니다.
21+
case small
2222
}
2323

2424
/// EATSSU 앱에서 보편적으로 사용하는 버튼
2525
public final class ESButton: UIButton {
26-
private enum Size {
27-
static let height: CGFloat = 52.adjusted
28-
static let smallButtonWidth: CGFloat = 80.adjusted
29-
}
30-
31-
// MARK: - Properties
32-
33-
private var buttonSize: ButtonSize
34-
private var title: String
35-
36-
/*
37-
설명
38-
- isEnabled 프로퍼티는 UIView의 프로퍼티를 오버라이드했다.
39-
- 오버라이드한 프로퍼티는 public이나 open 접근제한자로 설정해야 한다.
40-
- 여기서는 final로 명시를 했지만, 만약 ESButton 클래스를 상속받는 클래스가 있다면 똑같이 오버라이드할 수 있도록 조건을 형성해야 한다.
41-
*/
42-
override public var isEnabled: Bool {
43-
didSet {
44-
self.setButtonState(as: self.isEnabled)
45-
}
46-
}
47-
48-
// MARK: - Initializer
49-
50-
/// EATSSU 버튼
51-
///
52-
/// - Parameters:
53-
/// - size: 큰 버튼과 작은 버튼을 선택합니다.
54-
/// - title: 버튼의 타이틀입니다.
55-
public init(size: ButtonSize, title: String) {
56-
self.title = title
57-
self.buttonSize = size
58-
59-
/// 설명
60-
/// 지정 이니셜라이저를 오버라이딩할 필요가 없는 상황이라 판단해서,
61-
/// 이니셜라이저를 직접 구현하고, 초기화가 끝나면 Swift 문법에 맞추어 슈퍼 클래스 이니셜라이저를 호출합니다.
62-
///
63-
/// super.init이 해당 클래스 초기화 코드 이후에 온 이유는 다음과 같다.
64-
/// 스위프트의 two - phase intializer에 따라서 서브 클래스의 이니셜라이저가 먼저 호출되고, 슈퍼 클래스의 이니셜라이저가 호출된다.
65-
/// 그래서 서버 클래스의 이니셜라이저 호출 간 초기화 사항들이 정상적으로 이루어지고, 슈퍼 클래스 이니셜라이저가 생성된다.
66-
67-
super.init(frame: .zero)
68-
69-
self.configureUI(size: size)
70-
}
71-
72-
@available(*, unavailable)
73-
required init?(coder: NSCoder) {
74-
fatalError("init(coder:) has not been implemented")
75-
}
76-
77-
// MARK: - Functions
78-
79-
override public func didMoveToSuperview() {
80-
super.didMoveToSuperview()
81-
self.setLayout(size: self.buttonSize)
82-
}
83-
84-
private func configureUI(size: ButtonSize) {
85-
self.layer.cornerRadius = 12.adjusted
86-
self.clipsToBounds = true
87-
self.backgroundColor = EATSSUDesignAsset.Colors.MainColor.primary.color
88-
self.titleLabel?.textColor = .white
89-
self.setTitle(self.title, for: .normal)
90-
91-
switch size {
92-
case .big:
93-
self.titleLabel?.font = .button1
94-
case .small:
95-
self.titleLabel?.font = .button2
96-
}
97-
}
98-
99-
private func setLayout(size: ButtonSize) {
100-
switch size {
101-
case .big:
102-
self.snp.makeConstraints {
103-
$0.height.equalTo(Size.height)
104-
}
105-
case .small:
106-
self.snp.makeConstraints {
107-
$0.height.equalTo(Size.height)
108-
$0.width.equalTo(Size.smallButtonWidth)
109-
}
110-
}
111-
}
112-
113-
private func setButtonState(as isEnabled: Bool) {
114-
if isEnabled {
115-
self.alpha = 1
116-
} else {
117-
self.alpha = 0.5
118-
}
119-
}
26+
private enum Size {
27+
static let height: CGFloat = 52.adjusted
28+
static let smallButtonWidth: CGFloat = 80.adjusted
29+
}
30+
31+
// MARK: - Properties
32+
33+
private var buttonSize: ButtonSize
34+
private var title: String
35+
36+
/*
37+
설명
38+
- isEnabled 프로퍼티는 UIView의 프로퍼티를 오버라이드했다.
39+
- 오버라이드한 프로퍼티는 public이나 open 접근제한자로 설정해야 한다.
40+
- 여기서는 final로 명시를 했지만, 만약 ESButton 클래스를 상속받는 클래스가 있다면 똑같이 오버라이드할 수 있도록 조건을 형성해야 한다.
41+
*/
42+
override public var isEnabled: Bool {
43+
didSet {
44+
setButtonState(as: isEnabled)
45+
}
46+
}
47+
48+
// MARK: - Initializer
49+
50+
/// EATSSU 버튼
51+
///
52+
/// - Parameters:
53+
/// - size: 큰 버튼과 작은 버튼을 선택합니다.
54+
/// - title: 버튼의 타이틀입니다.
55+
public init(size: ButtonSize, title: String) {
56+
self.title = title
57+
buttonSize = size
58+
59+
/// 설명
60+
/// 지정 이니셜라이저를 오버라이딩할 필요가 없는 상황이라 판단해서,
61+
/// 이니셜라이저를 직접 구현하고, 초기화가 끝나면 Swift 문법에 맞추어 슈퍼 클래스 이니셜라이저를 호출합니다.
62+
///
63+
/// super.init이 해당 클래스 초기화 코드 이후에 온 이유는 다음과 같다.
64+
/// 스위프트의 two - phase intializer에 따라서 서브 클래스의 이니셜라이저가 먼저 호출되고, 슈퍼 클래스의 이니셜라이저가 호출된다.
65+
/// 그래서 서버 클래스의 이니셜라이저 호출 간 초기화 사항들이 정상적으로 이루어지고, 슈퍼 클래스 이니셜라이저가 생성된다.
66+
67+
super.init(frame: .zero)
68+
69+
configureUI(size: size)
70+
}
71+
72+
@available(*, unavailable)
73+
required init?(coder _: NSCoder) {
74+
fatalError("init(coder:) has not been implemented")
75+
}
76+
77+
// MARK: - Functions
78+
79+
override public func didMoveToSuperview() {
80+
super.didMoveToSuperview()
81+
setLayout(size: buttonSize)
82+
}
83+
84+
private func configureUI(size: ButtonSize) {
85+
layer.cornerRadius = 12.adjusted
86+
clipsToBounds = true
87+
backgroundColor = EATSSUDesignAsset.Colors.MainColor.primary.color
88+
titleLabel?.textColor = .white
89+
setTitle(title, for: .normal)
90+
91+
switch size {
92+
case .big:
93+
titleLabel?.font = .button1
94+
case .small:
95+
titleLabel?.font = .button2
96+
}
97+
}
98+
99+
private func setLayout(size: ButtonSize) {
100+
switch size {
101+
case .big:
102+
snp.makeConstraints {
103+
$0.height.equalTo(Size.height)
104+
}
105+
case .small:
106+
snp.makeConstraints {
107+
$0.height.equalTo(Size.height)
108+
$0.width.equalTo(Size.smallButtonWidth)
109+
}
110+
}
111+
}
112+
113+
private func setButtonState(as isEnabled: Bool) {
114+
if isEnabled {
115+
alpha = 1
116+
} else {
117+
alpha = 0.5
118+
}
119+
}
120120
}

EATSSUDesign/EATSSUDesign/Sources/DesignSystem/ReportButton/ESReportButton.swift

+85-85
Original file line numberDiff line numberDiff line change
@@ -13,89 +13,89 @@ import UIKit
1313
import SnapKit
1414

1515
public final class ESReportButton: UIButton {
16-
// MARK: - Properties
17-
18-
override public var isSelected: Bool {
19-
didSet {
20-
self.updateButtonAppearance()
21-
}
22-
}
23-
24-
// MARK: - Intializer
25-
26-
/// Swift 이니셜라이저 다형성, 지정 이니셜라이저, 편의 이니셜라이저 사용성에 관한 메모
27-
/// - 지정 연산자를 오버라이딩 하는지 여부에 따라서 설계할 수 있는 이니셜라이저가 다르다.
28-
29-
/// 지정 이니셜라이저 (Designated Intializer)를 오버라이딩 하는 경우 아래의 코드와 같은 형식으로 설계한다.
30-
/// self.init를 사용했다는 것이 중요하다.
31-
/// 해당 클래스 안에 지정 연산자를 오버라이딩 했기 때문에 super.init이 아니라 self.init을 사용해야 한다.
32-
33-
/*
34-
public convenience init(title: String) {
35-
self.init(frame: .zero)
36-
self.setProperties(title: title)
37-
}
38-
39-
override public init(frame: CGRect) {
40-
super.init(frame: frame)
41-
}
42-
*/
43-
44-
/// 지정 이니셜라이저 (Designated Intializer)를 오버라이딩 하지 않으면, 단순 호출만 하면 되는 것이기 때문에,
45-
/// 아래와 같이 코드를 설계한다.
46-
/// super.init을 사용했다는 것이 중요하다.
47-
/// 지정 이니셜라이저를 오버라이딩 하지 않았기 떄문에, 이니셜라이저를 직접 설계하고 super.init 지정 이니셜라이저를 호출하면 된다.
48-
49-
/// 회색 컬러의 ReportButton
50-
///
51-
/// - Parameter title: 버튼 타이틀
52-
public init(title: String) {
53-
super.init(frame: .zero)
54-
self.setProperties(title: title)
55-
self.setupButton()
56-
}
57-
58-
@available(*, unavailable)
59-
required init?(coder: NSCoder) {
60-
fatalError("init(coder:) has not been implemented")
61-
}
62-
63-
// MARK: - Methods
64-
65-
private func setProperties(title: String) {
66-
self.backgroundColor = .white
67-
68-
self.layer.borderWidth = 1
69-
self.layer.borderColor = EATSSUDesignAsset.Colors.GrayScaleColor.gray300.color.cgColor
70-
self.layer.cornerRadius = 10
71-
72-
self.setTitle(title, for: .normal)
73-
self.setTitleColor(.black, for: .normal)
74-
self.titleLabel?.font = EATSSUDesignFontFamily.Pretendard.medium.font(size: 14)
75-
self.contentHorizontalAlignment = UIControl.ContentHorizontalAlignment.left
76-
// TODO: Deprecated. UIButtonConfiguration 속성 사용할 경우 해당사항 적용안됨 / Configuration 속성으로 수정 필요
77-
self.titleEdgeInsets = UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 0)
78-
}
79-
80-
private func setupButton() {
81-
self.updateButtonAppearance()
82-
83-
self.addTarget(self, action: #selector(self.esReportButtonTapped), for: .touchUpInside)
84-
}
85-
86-
@objc
87-
private func esReportButtonTapped() {
88-
self.isSelected.toggle()
89-
self.updateButtonAppearance()
90-
}
91-
92-
private func updateButtonAppearance() {
93-
if self.isSelected {
94-
self.backgroundColor = EATSSUDesignAsset.Colors.MainColor.secondary.color
95-
self.layer.borderColor = EATSSUDesignAsset.Colors.MainColor.primary.color.cgColor
96-
} else {
97-
self.backgroundColor = .white
98-
self.layer.borderColor = EATSSUDesignAsset.Colors.GrayScaleColor.gray300.color.cgColor
99-
}
100-
}
16+
// MARK: - Properties
17+
18+
override public var isSelected: Bool {
19+
didSet {
20+
updateButtonAppearance()
21+
}
22+
}
23+
24+
// MARK: - Intializer
25+
26+
/// Swift 이니셜라이저 다형성, 지정 이니셜라이저, 편의 이니셜라이저 사용성에 관한 메모
27+
/// - 지정 연산자를 오버라이딩 하는지 여부에 따라서 설계할 수 있는 이니셜라이저가 다르다.
28+
29+
/// 지정 이니셜라이저 (Designated Intializer)를 오버라이딩 하는 경우 아래의 코드와 같은 형식으로 설계한다.
30+
/// self.init를 사용했다는 것이 중요하다.
31+
/// 해당 클래스 안에 지정 연산자를 오버라이딩 했기 때문에 super.init이 아니라 self.init을 사용해야 한다.
32+
33+
/*
34+
public convenience init(title: String) {
35+
self.init(frame: .zero)
36+
self.setProperties(title: title)
37+
}
38+
39+
override public init(frame: CGRect) {
40+
super.init(frame: frame)
41+
}
42+
*/
43+
44+
/// 지정 이니셜라이저 (Designated Intializer)를 오버라이딩 하지 않으면, 단순 호출만 하면 되는 것이기 때문에,
45+
/// 아래와 같이 코드를 설계한다.
46+
/// super.init을 사용했다는 것이 중요하다.
47+
/// 지정 이니셜라이저를 오버라이딩 하지 않았기 떄문에, 이니셜라이저를 직접 설계하고 super.init 지정 이니셜라이저를 호출하면 된다.
48+
49+
/// 회색 컬러의 ReportButton
50+
///
51+
/// - Parameter title: 버튼 타이틀
52+
public init(title: String) {
53+
super.init(frame: .zero)
54+
setProperties(title: title)
55+
setupButton()
56+
}
57+
58+
@available(*, unavailable)
59+
required init?(coder _: NSCoder) {
60+
fatalError("init(coder:) has not been implemented")
61+
}
62+
63+
// MARK: - Methods
64+
65+
private func setProperties(title: String) {
66+
backgroundColor = .white
67+
68+
layer.borderWidth = 1
69+
layer.borderColor = EATSSUDesignAsset.Colors.GrayScaleColor.gray300.color.cgColor
70+
layer.cornerRadius = 10
71+
72+
setTitle(title, for: .normal)
73+
setTitleColor(.black, for: .normal)
74+
titleLabel?.font = EATSSUDesignFontFamily.Pretendard.medium.font(size: 14)
75+
contentHorizontalAlignment = UIControl.ContentHorizontalAlignment.left
76+
// TODO: Deprecated. UIButtonConfiguration 속성 사용할 경우 해당사항 적용안됨 / Configuration 속성으로 수정 필요
77+
titleEdgeInsets = UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 0)
78+
}
79+
80+
private func setupButton() {
81+
updateButtonAppearance()
82+
83+
addTarget(self, action: #selector(esReportButtonTapped), for: .touchUpInside)
84+
}
85+
86+
@objc
87+
private func esReportButtonTapped() {
88+
isSelected.toggle()
89+
updateButtonAppearance()
90+
}
91+
92+
private func updateButtonAppearance() {
93+
if isSelected {
94+
backgroundColor = EATSSUDesignAsset.Colors.MainColor.secondary.color
95+
layer.borderColor = EATSSUDesignAsset.Colors.MainColor.primary.color.cgColor
96+
} else {
97+
backgroundColor = .white
98+
layer.borderColor = EATSSUDesignAsset.Colors.GrayScaleColor.gray300.color.cgColor
99+
}
100+
}
101101
}

0 commit comments

Comments
 (0)