Skip to content

Commit

Permalink
#171: ZatchButton 컴포넌트 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-muuu committed Feb 12, 2023
1 parent c1a6887 commit 3866d9c
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions Zatch/Global/Source/Component/Button/ZatchButton.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// ZatchButton.swift
// Zatch
//
// Created by 박소윤 on 2023/02/11.
//

import Foundation

extension ZatchComponent{

enum ZatchButtonConfiguration{
case height48
}

class ZatchButton: UIButton{

var offset: CGFloat{
config.offset
}

private let config: ZatchButtonConfiguration

init(title: String, configuration: ZatchButtonConfiguration){
self.config = configuration
super.init(frame: .zero)
self.setTitle(title, for: .normal)
initialize()
}

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

private func initialize(){
style()
layout()
}

private func style(){
self.layer.cornerRadius = config.height / 2
self.titleLabel?.setTypoStyleWithSingleLine(typoStyle: config.typo)
}

private func layout(){
self.snp.makeConstraints{
$0.height.equalTo(config.height)
}
}
}

}

extension ZatchComponent.ZatchButtonConfiguration{

var height: CGFloat{
switch self{
case .height48: return 48
}
}

var typo: TypoStyle{
switch self{
case .height48: return .bold18
}
}

var offset: CGFloat{
switch self{
case .height48: return 56
}
}
}

0 comments on commit 3866d9c

Please sign in to comment.