Skip to content

Commit

Permalink
[#18] HandyDivider 생성 (#22)
Browse files Browse the repository at this point in the history
* [#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 <[email protected]>
Co-authored-by: LeeJoEun-01 <[email protected]>
  • Loading branch information
3 people authored Oct 9, 2024
1 parent 5c05a43 commit 7cf0deb
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 1 deletion.
74 changes: 74 additions & 0 deletions Handy/Handy-Storybook/Atom/DividerViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//
// DividerViewController.swift
// Handy-Storybook
//
// Created by 서준영 on 9/15/24.
//

import Handy
import UIKit
import SnapKit

class DividerViewController: BaseViewController {

//MARK: - 프로퍼티 선언
let divider1: HandyDivider = {
let divider = HandyDivider()
divider.thickness = .thickness1
return divider
}()

let divider2: HandyDivider = {
let divider = HandyDivider()
divider.thickness = .thickness2
return divider
}()

let divider4: HandyDivider = {
let divider = HandyDivider()
divider.thickness = .thickness4
return divider
}()

let divider8: HandyDivider = {
let divider = HandyDivider()
divider.thickness = .thickness8
return divider
}()

//MARK: - 뷰에 추가
override func setViewHierarchies() {
self.view.backgroundColor = .black
self.view.addSubview(divider1)
self.view.addSubview(divider2)
self.view.addSubview(divider4)
self.view.addSubview(divider8)
}

//MARK: - 레이아웃 배치
override func setViewLayouts() {
divider1.snp.makeConstraints {
$0.width.equalTo(375)
$0.centerX.equalToSuperview()
$0.top.equalTo(self.view.snp.top).offset(300)
}

divider2.snp.makeConstraints {
$0.width.equalTo(375)
$0.centerX.equalToSuperview()
$0.top.equalTo(divider1.snp.bottom).offset(20)
}

divider4.snp.makeConstraints {
$0.width.equalTo(375)
$0.centerX.equalToSuperview()
$0.top.equalTo(divider2.snp.bottom).offset(20)
}

divider8.snp.makeConstraints {
$0.width.equalTo(375)
$0.centerX.equalToSuperview()
$0.top.equalTo(divider4.snp.bottom).offset(20)
}
}
}
2 changes: 1 addition & 1 deletion Handy/Handy-Storybook/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(frame: UIScreen.main.bounds)
window?.windowScene = windowScene
window?.rootViewController = ChipViewController()
window?.rootViewController = DividerViewController()
window?.makeKeyAndVisible()
}

Expand Down
8 changes: 8 additions & 0 deletions Handy/Handy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
A5A12A7F2C57A92000996916 /* HandySematic.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5D02AFC2C46C5A70056CE7B /* HandySematic.swift */; };
A5A12A812C57A93C00996916 /* HandyPrimitive.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5D02AFF2C480A180056CE7B /* HandyPrimitive.swift */; };
A5A12A822C57A93F00996916 /* HandyBasicColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5669A3E2C443E7300DABC21 /* HandyBasicColor.swift */; };
A5F6D36B2C96F32D00FB961F /* HandyDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5F6D36A2C96F32D00FB961F /* HandyDivider.swift */; };
A5F6D36D2C97099C00FB961F /* DividerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5F6D36C2C97099C00FB961F /* DividerViewController.swift */; };
E5669A3F2C443E7300DABC21 /* HandyBasicColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5669A3E2C443E7300DABC21 /* HandyBasicColor.swift */; };
E5D02AFD2C46C5A70056CE7B /* HandySematic.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5D02AFC2C46C5A70056CE7B /* HandySematic.swift */; };
E5D02AFE2C46C9980056CE7B /* HandyBasicColor.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E5669A422C443FE500DABC21 /* HandyBasicColor.xcassets */; };
Expand Down Expand Up @@ -99,6 +101,8 @@
2D41E8152C5A21B50043161D /* HandyFab.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandyFab.swift; sourceTree = "<group>"; };
A56B3DE12C4E51D300C3610A /* HandyChip.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandyChip.swift; sourceTree = "<group>"; };
A5A12A7C2C57A6C200996916 /* ChipViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChipViewController.swift; sourceTree = "<group>"; };
A5F6D36A2C96F32D00FB961F /* HandyDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandyDivider.swift; sourceTree = "<group>"; };
A5F6D36C2C97099C00FB961F /* DividerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DividerViewController.swift; sourceTree = "<group>"; };
E5669A3E2C443E7300DABC21 /* HandyBasicColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandyBasicColor.swift; sourceTree = "<group>"; };
E5669A422C443FE500DABC21 /* HandyBasicColor.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = HandyBasicColor.xcassets; sourceTree = "<group>"; };
E5D02AFC2C46C5A70056CE7B /* HandySematic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandySematic.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -146,6 +150,7 @@
2D41E8132C5A21930043161D /* FabViewController.swift */,
02ED764B2C57BD09001569F1 /* HandyBoxButtonViewController.swift */,
A5A12A7C2C57A6C200996916 /* ChipViewController.swift */,
A5F6D36C2C97099C00FB961F /* DividerViewController.swift */,
);
path = Atom;
sourceTree = "<group>";
Expand Down Expand Up @@ -201,6 +206,7 @@
029E47FC2C49FD1A00D2F3B7 /* HandyLabel.swift */,
2D41E8152C5A21B50043161D /* HandyFab.swift */,
A56B3DE12C4E51D300C3610A /* HandyChip.swift */,
A5F6D36A2C96F32D00FB961F /* HandyDivider.swift */,
);
path = Atom;
sourceTree = "<group>";
Expand Down Expand Up @@ -419,6 +425,7 @@
A5A12A822C57A93F00996916 /* HandyBasicColor.swift in Sources */,
A5A12A7E2C57A6D900996916 /* ChipViewController.swift in Sources */,
A5A12A7F2C57A92000996916 /* HandySematic.swift in Sources */,
A5F6D36D2C97099C00FB961F /* DividerViewController.swift in Sources */,
025776392C4EA98C00272EC6 /* LabelViewController.swift in Sources */,
0257765D2C4EB9EF00272EC6 /* BaseViewController.swift in Sources */,
02ED764C2C57BD09001569F1 /* HandyBoxButtonViewController.swift in Sources */,
Expand All @@ -438,6 +445,7 @@
E5669A3F2C443E7300DABC21 /* HandyBasicColor.swift in Sources */,
02ED76312C5284BB001569F1 /* HandyButtonProtocol.swift in Sources */,
02ED76352C5284F3001569F1 /* HandyTextButton.swift in Sources */,
A5F6D36B2C96F32D00FB961F /* HandyDivider.swift in Sources */,
02BDB7FC2C3E99920050FB67 /* HandyFont.swift in Sources */,
02ED764A2C5779C3001569F1 /* UIImage+.swift in Sources */,
029E48002C49FD4000D2F3B7 /* HandyTypography.swift in Sources */,
Expand Down
67 changes: 67 additions & 0 deletions Handy/Handy/Source/Atom/HandyDivider.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// HandyDivider.swift
// Handy
//
// Created by 서준영 on 9/15/24.
//

import UIKit
import SnapKit

public class HandyDivider: UIView {

public enum DividerThickness {
case thickness1
case thickness2
case thickness4
case thickness8

fileprivate var rawValue: CGFloat {
switch self {
case .thickness1:
return 1
case .thickness2:
return 2
case .thickness4:
return 4
case .thickness8:
return 8
}
}
}

@Invalidating(.layout) public var thickness: DividerThickness = .thickness1 {
didSet {
setNeedsUpdateConstraints()
}
}

public override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}

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

private func setupView() {
setColor()
setThickness()
}

private func setColor() {
self.backgroundColor = HandySemantic.bgBasicStrong
}

override public func updateConstraints() {
super.updateConstraints()
setThickness()
}

private func setThickness() {
self.snp.updateConstraints {
$0.height.equalTo(thickness.rawValue)
}
}
}

0 comments on commit 7cf0deb

Please sign in to comment.