Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat [#9] 커스텀 버튼 구현 #10

Merged
merged 11 commits into from
Jan 4, 2024
Prev Previous commit
Next Next commit
[Add/#9] Onboarding - OnboardingButton 추가
kim-seonwoo committed Jan 3, 2024
commit 85764cb16116872cf99088adf293159bfbe073b0
20 changes: 20 additions & 0 deletions HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
0B0035402B43D64D00DA140C /* HMHNavigationBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B00353F2B43D64D00DA140C /* HMHNavigationBar.swift */; };
0B2C2D3B2B443BE90023CCFA /* Image.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B2C2D3A2B443BE90023CCFA /* Image.swift */; };
0B2C2D3F2B4559E10023CCFA /* OnboardingButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B2C2D3E2B4559E10023CCFA /* OnboardingButton.swift */; };
0B50F9CB2B369813000C5046 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B50F9CA2B369813000C5046 /* AppDelegate.swift */; };
0B50F9CD2B369813000C5046 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B50F9CC2B369813000C5046 /* SceneDelegate.swift */; };
0B50F9CF2B369813000C5046 /* HomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B50F9CE2B369813000C5046 /* HomeViewController.swift */; };
@@ -60,6 +61,7 @@
/* Begin PBXFileReference section */
0B00353F2B43D64D00DA140C /* HMHNavigationBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHNavigationBar.swift; sourceTree = "<group>"; };
0B2C2D3A2B443BE90023CCFA /* Image.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Image.swift; sourceTree = "<group>"; };
0B2C2D3E2B4559E10023CCFA /* OnboardingButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingButton.swift; sourceTree = "<group>"; };
0B50F9C72B369813000C5046 /* HMH_iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HMH_iOS.app; sourceTree = BUILT_PRODUCTS_DIR; };
0B50F9CA2B369813000C5046 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
0B50F9CC2B369813000C5046 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
@@ -121,6 +123,22 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
0B2C2D3C2B4559AE0023CCFA /* Onboarding */ = {
isa = PBXGroup;
children = (
0B2C2D3D2B4559C90023CCFA /* Views */,
);
path = Onboarding;
sourceTree = "<group>";
};
0B2C2D3D2B4559C90023CCFA /* Views */ = {
isa = PBXGroup;
children = (
0B2C2D3E2B4559E10023CCFA /* OnboardingButton.swift */,
);
path = Views;
sourceTree = "<group>";
};
0B50F9BE2B369813000C5046 = {
isa = PBXGroup;
children = (
@@ -184,6 +202,7 @@
0B67CCE72B369BE300582D54 /* Presentation */ = {
isa = PBXGroup;
children = (
0B2C2D3C2B4559AE0023CCFA /* Onboarding */,
0B8A89A72B369DE600688BA6 /* Home */,
0B8A89A52B369DD500688BA6 /* Common */,
);
@@ -472,6 +491,7 @@
0B50F9CB2B369813000C5046 /* AppDelegate.swift in Sources */,
0B8A89C42B369FA000688BA6 /* F.swift in Sources */,
0B8A89B72B369F1100688BA6 /* C.swift in Sources */,
0B2C2D3F2B4559E10023CCFA /* OnboardingButton.swift in Sources */,
0B2C2D3B2B443BE90023CCFA /* Image.swift in Sources */,
0B8A89AD2B369E3B00688BA6 /* HomeCell.swift in Sources */,
0B8A89C62B369FA800688BA6 /* H.swift in Sources */,
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// OnboardingButton.swift
// HMH_iOS
//
// Created by Seonwoo Kim on 1/3/24.
//

import UIKit

import SnapKit
import Then

final class OnboardingButton: UIButton {
@frozen
enum OnboardingButtonType {
case enable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P5. 소소하지만 .. case naming 혹시 enabled는 어떠신가요? disabled와 맞추는 게 좋아보여서요!

case disabled
}

private var type: OnboardingButtonType = .enable

private let buttonTitleLabel = UILabel().then {
$0.textColor = .white
$0.font = UIFont.iosText3Semibold18
$0.isHidden = true
}

init(leftItem type: OnboardingButtonType, buttonText: String) {
super.init(frame: .zero)
self.type = type
buttonTitleLabel.text = buttonText

configureButton()
setUI()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

private func setUI() {
setHierarchy()
setConstraints()
}

private func setHierarchy() {
self.addSubview(buttonTitleLabel)
}

private func setConstraints() {
buttonTitleLabel.snp.makeConstraints {
$0.center.equalToSuperview()
}
}

private func configureButton() {
self.do {
$0.makeCornerRound(radius: 6.adjustedHeight)
$0.layer.cornerCurve = .continuous
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P4. 여기도 위와 마찬가지로 @frozen을 제거하고 switch문으로 바꾸는 건 어떠신가요 ?!

switch type {
case .enable:
self.do {
$0.backgroundColor = .purple
}
case .disabled:
self.do {
$0.backgroundColor = .gray
}
}
}

}