-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [#19] Switch 코드 변경 * Chip * [#8] chipViewController 생성 * [#8] ViewDidLoad 삭제 * [#8] SnapKit으로 정리, icon추가 * [#8] icon추가, 주석 정리 * [#8] icon 색상 지정 * ChipViewController SnapKit 문법 수정 * [#8] rebase conflict 및 package 에러 해결 * [#18] HandyDivider 생성 (#22) * [#13] HandyFab 생성 * [#18] HandyDivider 생성 * [#13] 1차 코드 리뷰 반영 * [#18] 불필요 height, Vertical Divider 삭제 * Chip * [#8] chipViewController 생성 * [#8] ViewDidLoad 삭제 * [#8] SnapKit으로 정리, icon추가 * [#8] icon추가, 주석 정리 * [#8] icon 색상 지정 * ChipViewController SnapKit 문법 수정 * [#8] rebase conflict 및 package 에러 해결 * [#18] HandyDivider 생성 * [#18] 불필요 height, Vertical Divider 삭제 * [#18] rebase conflict 해결 * [#18] package.resolved 업로드 --------- Co-authored-by: wjdalswl <109158284+wjdalswl@users.noreply.github.com> Co-authored-by: LeeJoEun-01 <joeun1005@naver.com> * [#6] HandyCheckBox 생성 * [#6] HandyCheckBox 테스트 추가 * [#6] checkBox ConfigurationButton으로 변경 * [#6] HandyRadioButton 추가 * [#6] HandyCheckBox 생성 * [#6] testViewController 수정 * [#6] checkBox, radioButton tintColor 커스텀 추가 * [#6]NON_ISSUE conflict resolve * [#19] Switch 코드 변경 * [#19] 코드리뷰 반영 * [#24] Snackbar Info 타입 제작 * [#24] Handy 기본 아이콘 24개 추가 * [#24] Snackbar Error 타입 제작 * [#24] Radius 단위 CGFloat로 변환 * [#24] Error 타입 레이아웃 수정 및 버튼 액션 추가 * [#24] Snackbar Swipe Gesture 추가 * [#24] 코드리뷰 반영 * [#24] 코드리뷰 반영 2 * [#19] Switch 코드 변경 * [#19] 코드리뷰 반영 --------- Co-authored-by: jysuhr <jun0.suhr@gmail.com> Co-authored-by: jysuhr <162943584+jysuhr@users.noreply.github.com> Co-authored-by: wjdalswl <109158284+wjdalswl@users.noreply.github.com> Co-authored-by: hyeonju <shj040201@naver.com>
- Loading branch information
1 parent
80cf82c
commit a80d94f
Showing
6 changed files
with
169 additions
and
2 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
Handy/Handy-Storybook/Atom/HansySwitchViewController.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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// HansySwitchViewController.swift | ||
// Handy-Storybook | ||
// | ||
// Created by 이조은 on 9/18/24. | ||
// | ||
|
||
import Handy | ||
import UIKit | ||
|
||
final class HansySwitchViewController: BaseViewController { | ||
|
||
private let switch1: HandySwitch = { | ||
let uiSwitch = HandySwitch() | ||
uiSwitch.size = .large | ||
return uiSwitch | ||
}() | ||
|
||
private let switch2: HandySwitch = { | ||
let uiSwitch = HandySwitch() | ||
uiSwitch.size = .medium | ||
uiSwitch.isOn = true | ||
return uiSwitch | ||
}() | ||
|
||
private let switch3: HandySwitch = { | ||
let uiSwitch = HandySwitch() | ||
uiSwitch.size = .small | ||
uiSwitch.isDisabled = true | ||
return uiSwitch | ||
}() | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
self.view.backgroundColor = .white | ||
} | ||
|
||
override func setViewHierarchies() { | ||
self.view.addSubview(switch1) | ||
self.view.addSubview(switch2) | ||
self.view.addSubview(switch3) | ||
} | ||
|
||
override func setViewLayouts() { | ||
switch1.snp.makeConstraints { | ||
$0.top.equalToSuperview().inset(100) | ||
$0.leading.equalToSuperview().inset(20) | ||
} | ||
switch2.snp.makeConstraints { | ||
$0.top.equalTo(switch1.snp.bottom).offset(36) // -4 | ||
$0.leading.equalToSuperview().inset(13) // -7 | ||
} | ||
switch3.snp.makeConstraints { | ||
$0.top.equalTo(switch2.snp.bottom).offset(28) // -12 | ||
$0.leading.equalToSuperview().inset(8) // -12 | ||
} | ||
} | ||
} |
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
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
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
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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// | ||
// HandySwitch.swift | ||
// Handy | ||
// | ||
// Created by 이조은 on 9/18/24. | ||
// | ||
|
||
import UIKit | ||
|
||
final public class HandySwitch: UISwitch { | ||
|
||
// MARK: - 외부에서 지정할 수 있는 속성 | ||
@Invalidating(.layout, .display) public var isDisabled: Bool = false | ||
|
||
@Invalidating(.display) public var size: SwitchSize = .medium { | ||
didSet { | ||
updateSwitchSize() // size가 변경될 때 크기 변경 | ||
} | ||
} | ||
|
||
public override var isOn: Bool { | ||
didSet { setNeedsDisplay() } | ||
} | ||
|
||
// MARK: - 외부에서 접근할 수 있는 enum | ||
public enum SwitchSize { | ||
case large | ||
case medium | ||
case small | ||
|
||
fileprivate var ratio: CGFloat { | ||
switch self { | ||
case .large: | ||
return 1.0 | ||
case .medium: | ||
return 0.7 | ||
case .small: | ||
return 0.5 | ||
} | ||
} | ||
|
||
fileprivate var switchWidth: CGFloat { | ||
return 51.0 * self.ratio | ||
} | ||
|
||
fileprivate var switchHeight: CGFloat { | ||
return 31.0 * self.ratio | ||
} | ||
} | ||
|
||
// MARK: - 내부에서 사용되는 변수 | ||
private var fgColor: UIColor? | ||
private var bgColor: UIColor? | ||
|
||
// MARK: - 메소드 | ||
|
||
public init() { | ||
super.init(frame: .zero) | ||
setupView() | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
private func setupView() { | ||
setSwitchColor() | ||
updateSwitchSize() | ||
} | ||
|
||
private func setSwitchColor() { | ||
self.subviews.first?.subviews.first?.backgroundColor = HandySemantic.switchUnselected | ||
self.onTintColor = HandySemantic.switchSelected | ||
} | ||
|
||
private func updateSwitchSize() { | ||
self.transform = CGAffineTransform(scaleX: size.ratio, y: size.ratio) | ||
} | ||
|
||
public override func layoutSubviews() { | ||
super.layoutSubviews() | ||
isEnabled = !isDisabled | ||
setSwitchColor() | ||
} | ||
} |
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