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

[#8] chipViewController 생성 #15

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "icClose.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icInfoCircle.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
143 changes: 143 additions & 0 deletions Handy/Handy-Storybook/Atom/ChipViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
//
// ChipViewController.swift
// Handy-Storybook
//
// Created by 서준영 on 7/29/24.
//

import UIKit
import Handy
import SnapKit

class ChipViewController: BaseViewController {

//MARK: 프로퍼티 선언
let unTappedLargeChip: HandyChip = {
let chip = HandyChip()
chip.chipState = HandyChip.ChipState(type: .enabled)
chip.size = HandyChip.ChipSize(type: .large)
chip.isSelected = false
chip.text = "Label"
chip.leftIcon = UIImage(named: "icInfoCircle")
chip.rightIcon = UIImage(named: "icClose")
chip.addTarget(self, action: #selector(firstChip), for: .touchUpInside)
chip.translatesAutoresizingMaskIntoConstraints = false
return chip
}()

let unTappedSmallChip: HandyChip = {
let chip = HandyChip()
chip.chipState = HandyChip.ChipState(type: .enabled)
chip.size = HandyChip.ChipSize(type: .small)
chip.isSelected = false
chip.text = "Label"
chip.leftIcon = UIImage(named: "icInfoCircle")
chip.rightIcon = UIImage(named: "icClose")
chip.addTarget(self, action: #selector(secondChip), for: .touchUpInside)
chip.translatesAutoresizingMaskIntoConstraints = false
return chip
}()

let tappedLargeChip: HandyChip = {
let chip = HandyChip()
chip.chipState = HandyChip.ChipState(type: .enabled)
chip.size = HandyChip.ChipSize(type: .large)
chip.isSelected = true
chip.text = "Label"
chip.leftIcon = UIImage(named: "icInfoCircle")
chip.rightIcon = UIImage(named: "icClose")
chip.addTarget(self, action: #selector(thirdChip), for: .touchUpInside)
chip.translatesAutoresizingMaskIntoConstraints = false
return chip
}()

let tappedSmallChip: HandyChip = {
let chip = HandyChip()
chip.chipState = HandyChip.ChipState(type: .enabled)
chip.size = HandyChip.ChipSize(type: .small)
chip.isSelected = true
chip.text = "Label"
chip.leftIcon = UIImage(named: "icInfoCircle")
chip.rightIcon = UIImage(named: "icClose")
chip.addTarget(self, action: #selector(fourthChip), for: .touchUpInside)
chip.translatesAutoresizingMaskIntoConstraints = false
return chip
}()

let disabledLargeChip: HandyChip = {
let chip = HandyChip()
chip.chipState = HandyChip.ChipState(type: .disabled)
chip.size = HandyChip.ChipSize(type: .large)
chip.text = "Label"
chip.leftIcon = UIImage(named: "icInfoCircle")
chip.rightIcon = UIImage(named: "icClose")
chip.translatesAutoresizingMaskIntoConstraints = false
return chip
}()

let disabledSmallChip: HandyChip = {
let chip = HandyChip()
chip.chipState = HandyChip.ChipState(type: .disabled)
chip.size = HandyChip.ChipSize(type: .small)
chip.text = "Label"
chip.leftIcon = UIImage(named: "icInfoCircle")
chip.rightIcon = UIImage(named: "icClose")
chip.translatesAutoresizingMaskIntoConstraints = false
return chip
}()


//MARK: Chip 뷰에 추가
override func setViewHierarchies() {
view.addSubview(unTappedLargeChip)
view.addSubview(unTappedSmallChip)
view.addSubview(tappedLargeChip)
view.addSubview(tappedSmallChip)
view.addSubview(disabledLargeChip)
view.addSubview(disabledSmallChip)
}
Comment on lines +91 to +98
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
override func setViewHierarchies() {
view.addSubview(unTappedLargeChip)
view.addSubview(unTappedSmallChip)
view.addSubview(tappedLargeChip)
view.addSubview(tappedSmallChip)
view.addSubview(disabledLargeChip)
view.addSubview(disabledSmallChip)
}
override func setViewHierarchies() {
[unTappedLargeChip,
unTappedSmallChip,
tappedLargeChip,
tappedSmallChip,
disabledLargeChip,
disabledSmallChip
].forEach {
view.addSubview($0)
}
}

view.addSubviews(unTappedLargeChip, unTappedSmallChip, tappedLargeChip, tappedSmallChip, disabledLargeChip, disabledSmallChip) 이런식으로도 사용하실 수 있어요~



//MARK: 레이아웃 배치
override func setViewLayouts() {
unTappedLargeChip.snp.makeConstraints {
$0.centerX.equalToSuperview()
$0.top.equalTo(view.safeAreaLayoutGuide.snp.top).offset(100)
}
unTappedSmallChip.snp.makeConstraints {
$0.centerX.equalToSuperview()
$0.top.equalTo(unTappedLargeChip.snp.bottom).offset(24)
}
tappedLargeChip.snp.makeConstraints {
$0.centerX.equalToSuperview()
$0.top.equalTo(unTappedSmallChip.snp.bottom).offset(51)
}
tappedSmallChip.snp.makeConstraints {
$0.centerX.equalToSuperview()
$0.top.equalTo(tappedLargeChip.snp.bottom).offset(24)
}
disabledLargeChip.snp.makeConstraints {
$0.centerX.equalToSuperview()
$0.top.equalTo(tappedSmallChip.snp.bottom).offset(51)
}
disabledSmallChip.snp.makeConstraints {
$0.centerX.equalToSuperview()
$0.top.equalTo(disabledLargeChip.snp.bottom).offset(24)
}
}


//MARK: Chip 작동 함수
@objc private func firstChip(_ sender: HandyChip) {
sender.isSelected.toggle()
}
@objc private func secondChip(_ sender: HandyChip) {
sender.isSelected.toggle()
}
@objc private func thirdChip(_ sender: HandyChip) {
sender.isSelected.toggle()
}
@objc private func fourthChip(_ sender: HandyChip) {
sender.isSelected.toggle()
}
}
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 = LabelViewController()
window?.rootViewController = ChipViewController()
window?.makeKeyAndVisible()
}

Expand Down
34 changes: 26 additions & 8 deletions Handy/Handy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
025776412C4EA98E00272EC6 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0257763F2C4EA98E00272EC6 /* LaunchScreen.storyboard */; };
0257764A2C4EB68D00272EC6 /* Handy.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02BDB7EF2C3E95580050FB67 /* Handy.framework */; };
0257764B2C4EB68D00272EC6 /* Handy.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 02BDB7EF2C3E95580050FB67 /* Handy.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
025776502C4EB6C000272EC6 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 0257764F2C4EB6C000272EC6 /* SnapKit */; };
025776542C4EB7BB00272EC6 /* Pretendard-Regular.otf in Resources */ = {isa = PBXBuildFile; fileRef = 025776512C4EB7BB00272EC6 /* Pretendard-Regular.otf */; };
025776562C4EB7BB00272EC6 /* Pretendard-SemiBold.otf in Resources */ = {isa = PBXBuildFile; fileRef = 025776532C4EB7BB00272EC6 /* Pretendard-SemiBold.otf */; };
025776592C4EB8BC00272EC6 /* Pretendard-Light.otf in Resources */ = {isa = PBXBuildFile; fileRef = 025776582C4EB8BC00272EC6 /* Pretendard-Light.otf */; };
Expand All @@ -26,6 +25,13 @@
029E48002C49FD4000D2F3B7 /* HandyTypography.swift in Sources */ = {isa = PBXBuildFile; fileRef = 029E47FF2C49FD4000D2F3B7 /* HandyTypography.swift */; };
02BDB7F32C3E95580050FB67 /* Handy.h in Headers */ = {isa = PBXBuildFile; fileRef = 02BDB7F22C3E95580050FB67 /* Handy.h */; settings = {ATTRIBUTES = (Public, ); }; };
02BDB7FC2C3E99920050FB67 /* HandyFont.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02BDB7FB2C3E99920050FB67 /* HandyFont.swift */; };
A56B3DE22C4E51D300C3610A /* HandyChip.swift in Sources */ = {isa = PBXBuildFile; fileRef = A56B3DE12C4E51D300C3610A /* HandyChip.swift */; };
A5A12A7E2C57A6D900996916 /* ChipViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A12A7C2C57A6C200996916 /* ChipViewController.swift */; };
A5A12A7F2C57A92000996916 /* HandySematicColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5D02AFC2C46C5A70056CE7B /* HandySematicColor.swift */; };
A5A12A802C57A93000996916 /* HandyBasicColor.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E5669A422C443FE500DABC21 /* HandyBasicColor.xcassets */; };
A5A12A812C57A93C00996916 /* HandyPrimitiveColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5D02AFF2C480A180056CE7B /* HandyPrimitiveColor.swift */; };
A5A12A822C57A93F00996916 /* HandyBasicColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5669A3E2C443E7300DABC21 /* HandyBasicColor.swift */; };
A5AB585E2C7343A300A3AC5C /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = A5AB585D2C7343A300A3AC5C /* SnapKit */; };
E5669A3F2C443E7300DABC21 /* HandyBasicColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5669A3E2C443E7300DABC21 /* HandyBasicColor.swift */; };
E5D02AFD2C46C5A70056CE7B /* HandySematicColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5D02AFC2C46C5A70056CE7B /* HandySematicColor.swift */; };
E5D02AFE2C46C9980056CE7B /* HandyBasicColor.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E5669A422C443FE500DABC21 /* HandyBasicColor.xcassets */; };
Expand Down Expand Up @@ -77,6 +83,8 @@
02BDB7EF2C3E95580050FB67 /* Handy.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Handy.framework; sourceTree = BUILT_PRODUCTS_DIR; };
02BDB7F22C3E95580050FB67 /* Handy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Handy.h; sourceTree = "<group>"; };
02BDB7FB2C3E99920050FB67 /* HandyFont.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandyFont.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>"; };
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 /* HandySematicColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandySematicColor.swift; sourceTree = "<group>"; };
Expand All @@ -89,14 +97,14 @@
buildActionMask = 2147483647;
files = (
0257764A2C4EB68D00272EC6 /* Handy.framework in Frameworks */,
025776502C4EB6C000272EC6 /* SnapKit in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
02BDB7EC2C3E95580050FB67 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
A5AB585E2C7343A300A3AC5C /* SnapKit in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -121,6 +129,7 @@
isa = PBXGroup;
children = (
025776382C4EA98C00272EC6 /* LabelViewController.swift */,
A5A12A7C2C57A6C200996916 /* ChipViewController.swift */,
);
path = Atom;
sourceTree = "<group>";
Expand Down Expand Up @@ -173,6 +182,7 @@
isa = PBXGroup;
children = (
029E47FC2C49FD1A00D2F3B7 /* HandyLabel.swift */,
A56B3DE12C4E51D300C3610A /* HandyChip.swift */,
);
path = Atom;
sourceTree = "<group>";
Expand Down Expand Up @@ -267,7 +277,6 @@
);
name = "Handy-Storybook";
packageProductDependencies = (
0257764F2C4EB6C000272EC6 /* SnapKit */,
);
productName = "Handy-Storybook";
productReference = 025776322C4EA98C00272EC6 /* Handy-Storybook.app */;
Expand All @@ -287,6 +296,9 @@
dependencies = (
);
name = Handy;
packageProductDependencies = (
A5AB585D2C7343A300A3AC5C /* SnapKit */,
);
productName = Handy;
productReference = 02BDB7EF2C3E95580050FB67 /* Handy.framework */;
productType = "com.apple.product-type.framework";
Expand Down Expand Up @@ -320,7 +332,7 @@
);
mainGroup = 02BDB7E52C3E95580050FB67;
packageReferences = (
025776462C4EB08D00272EC6 /* XCRemoteSwiftPackageReference "SnapKit" */,
A5AB585C2C7343A300A3AC5C /* XCRemoteSwiftPackageReference "SnapKit" */,
);
productRefGroup = 02BDB7F02C3E95580050FB67 /* Products */;
projectDirPath = "";
Expand All @@ -338,6 +350,7 @@
buildActionMask = 2147483647;
files = (
025776412C4EA98E00272EC6 /* LaunchScreen.storyboard in Resources */,
A5A12A802C57A93000996916 /* HandyBasicColor.xcassets in Resources */,
025776562C4EB7BB00272EC6 /* Pretendard-SemiBold.otf in Resources */,
025776542C4EB7BB00272EC6 /* Pretendard-Regular.otf in Resources */,
025776592C4EB8BC00272EC6 /* Pretendard-Light.otf in Resources */,
Expand All @@ -363,6 +376,10 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A5A12A812C57A93C00996916 /* HandyPrimitiveColor.swift in Sources */,
A5A12A822C57A93F00996916 /* HandyBasicColor.swift in Sources */,
A5A12A7E2C57A6D900996916 /* ChipViewController.swift in Sources */,
A5A12A7F2C57A92000996916 /* HandySematicColor.swift in Sources */,
025776392C4EA98C00272EC6 /* LabelViewController.swift in Sources */,
0257765D2C4EB9EF00272EC6 /* BaseViewController.swift in Sources */,
025776352C4EA98C00272EC6 /* AppDelegate.swift in Sources */,
Expand All @@ -380,6 +397,7 @@
02BDB7FC2C3E99920050FB67 /* HandyFont.swift in Sources */,
029E48002C49FD4000D2F3B7 /* HandyTypography.swift in Sources */,
029E47FD2C49FD1A00D2F3B7 /* HandyLabel.swift in Sources */,
A56B3DE22C4E51D300C3610A /* HandyChip.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -694,9 +712,9 @@
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
025776462C4EB08D00272EC6 /* XCRemoteSwiftPackageReference "SnapKit" */ = {
A5AB585C2C7343A300A3AC5C /* XCRemoteSwiftPackageReference "SnapKit" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/SnapKit/SnapKit.git";
repositoryURL = "https://github.com/SnapKit/SnapKit";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 5.7.1;
Expand All @@ -705,9 +723,9 @@
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
0257764F2C4EB6C000272EC6 /* SnapKit */ = {
A5AB585D2C7343A300A3AC5C /* SnapKit */ = {
isa = XCSwiftPackageProductDependency;
package = 025776462C4EB08D00272EC6 /* XCRemoteSwiftPackageReference "SnapKit" */;
package = A5AB585C2C7343A300A3AC5C /* XCRemoteSwiftPackageReference "SnapKit" */;
productName = SnapKit;
};
/* End XCSwiftPackageProductDependency section */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"originHash" : "4cdad746817ac9ed37e44dbe90a2ff25fc018954899b7d513e41a4bfc70f065a",
"pins" : [
{
"identity" : "snapkit",
Expand All @@ -10,5 +11,5 @@
}
}
],
"version" : 2
"version" : 3
}
Loading