From 7fd0bc32662f41bc4b53c4700ea9cdf38c9f6028 Mon Sep 17 00:00:00 2001 From: jysuhr Date: Mon, 29 Jul 2024 16:53:37 +0900 Subject: [PATCH 1/8] Chip --- Handy/Handy.xcodeproj/project.pbxproj | 4 + Handy/Handy/Source/Atom/HandyChip.swift | 140 ++++++++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 Handy/Handy/Source/Atom/HandyChip.swift diff --git a/Handy/Handy.xcodeproj/project.pbxproj b/Handy/Handy.xcodeproj/project.pbxproj index 2a2f40f..4f530c8 100644 --- a/Handy/Handy.xcodeproj/project.pbxproj +++ b/Handy/Handy.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ 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 */; }; 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 */; }; @@ -30,6 +31,7 @@ 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 = ""; }; 02BDB7FB2C3E99920050FB67 /* HandyFont.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandyFont.swift; sourceTree = ""; }; + A56B3DE12C4E51D300C3610A /* HandyChip.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandyChip.swift; sourceTree = ""; }; E5669A3E2C443E7300DABC21 /* HandyBasicColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandyBasicColor.swift; sourceTree = ""; }; E5669A422C443FE500DABC21 /* HandyBasicColor.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = HandyBasicColor.xcassets; sourceTree = ""; }; E5D02AFC2C46C5A70056CE7B /* HandySematicColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandySematicColor.swift; sourceTree = ""; }; @@ -61,6 +63,7 @@ isa = PBXGroup; children = ( 029E47FC2C49FD1A00D2F3B7 /* HandyLabel.swift */, + A56B3DE12C4E51D300C3610A /* HandyChip.swift */, ); path = Atom; sourceTree = ""; @@ -212,6 +215,7 @@ 02BDB7FC2C3E99920050FB67 /* HandyFont.swift in Sources */, 029E48002C49FD4000D2F3B7 /* HandyTypography.swift in Sources */, 029E47FD2C49FD1A00D2F3B7 /* HandyLabel.swift in Sources */, + A56B3DE22C4E51D300C3610A /* HandyChip.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Handy/Handy/Source/Atom/HandyChip.swift b/Handy/Handy/Source/Atom/HandyChip.swift new file mode 100644 index 0000000..443a655 --- /dev/null +++ b/Handy/Handy/Source/Atom/HandyChip.swift @@ -0,0 +1,140 @@ +// +// HandyChip.swift +// Handy +// +// Created by 서준영 on 7/22/24. +// + +import UIKit + +@available(iOS 15, *) + +public class HandyChip: UIControl { + + // MARK: - 외부에서 지정가능한 속성 + @Invalidating(wrappedValue: nil, .layout) public var text: String? + + private var size: ChipSize = ChipSize() + + private struct ChipSize { + enum SizeType { + case medium + case small + } + + var type: SizeType + + var height: CGFloat { + switch type { + case .medium: + return 32 + case .small: + return 24 + } + } + + var cornerRadius: CGFloat { + return height/2 + } + + var padding: CGFloat { + return 12 + } + + init(type: SizeType = .medium) { + self.type = type + } + } + + public override var isSelected: Bool { + didSet { setNeedsLayout() } // 선택되면 다시그려야 함 + } + + // MARK: - 내부에서 사용되는 함수 + + /** + 칩의 글자, 아이콘, 배경 컬러입니다. unselected + */ + private let fgColor: UIColor = HandySemantic.textBasicSecondary + private let icColor: UIColor = HandySemantic.iconBasicSecondary + private let bgColor: UIColor = HandySemantic.chipUnselected + + /** + 칩이 selected 되었을 때 글자, 아이콘, 배경 컬러입니다. + */ + private let fgSelectedColor: UIColor = HandySemantic.textBrandPrimary + private let icSelectedColor: UIColor = HandySemantic.iconBrandPrimary + private let bgSelectedColor: UIColor = HandySemantic.chipSelected + + /** + 칩이 disabled 되었을 때 글자, 아이콘, 배경 컬러입니다. + */ + private let fgDisabledColor: UIColor = HandySemantic.textBasicDisabled + private let icDisabledColor: UIColor = HandySemantic.iconBasicDisabled + private let bgDisabledColor: UIColor = HandySemantic.chipDisabled + + /** + text를 표시하는 Label 입니다. + */ + private let textLabel = HandyLabel(style: .B3Rg14) + + public init() { + super.init(frame: .zero) + + setChipSize() + setColorBasedOnIsSelected() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override public func layoutSubviews() { + super.layoutSubviews() + + setCornerRadius() + textLabel.text = text + setChipSize() + setColorBasedOnIsSelected() + } + + /** + isSelected 값의 맞추어 backgroundColor, textColor를 변경합니다. + */ + private func setColorBasedOnIsSelected() { + self.backgroundColor = !isSelected + ? bgColor + : bgSelectedColor + + self.textLabel.textColor = !isSelected + ? fgColor + : fgSelectedColor + } + + /** + Chip의 높이, Label의 위치를 세팅합니다. + */ + private func setChipSize() { + self.addSubview(textLabel) + + // 높이 제약 조건 설정 + let heightConstraint = self.heightAnchor.constraint(equalToConstant: size.height) + heightConstraint.isActive = true + + // textLabel 제약 조건 설정 + textLabel.translatesAutoresizingMaskIntoConstraints = false + let centerYConstraint = textLabel.centerYAnchor.constraint(equalTo: self.centerYAnchor) + let leadingConstraint = textLabel.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: size.padding) + let trailingConstraint = textLabel.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -size.padding) + + NSLayoutConstraint.activate([centerYConstraint, leadingConstraint, trailingConstraint]) + } + + /** + 칩의 cornerRadius를 세팅합니다. + */ + private func setCornerRadius() { + self.layer.cornerRadius = size.cornerRadius + } +} +// TODO: Small 사이즈 구현, icon 어떻게 해야하나?, 글자수 제한?, 칩간 행열 간격 From 4cf3dd1fa776498efecccdb7d0d435ed5676315e Mon Sep 17 00:00:00 2001 From: jysuhr Date: Mon, 29 Jul 2024 16:53:37 +0900 Subject: [PATCH 2/8] Chip --- Handy/Handy.xcodeproj/project.pbxproj | 4 + Handy/Handy/Source/Atom/HandyChip.swift | 140 ++++++++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 Handy/Handy/Source/Atom/HandyChip.swift diff --git a/Handy/Handy.xcodeproj/project.pbxproj b/Handy/Handy.xcodeproj/project.pbxproj index be87345..d34c3f9 100644 --- a/Handy/Handy.xcodeproj/project.pbxproj +++ b/Handy/Handy.xcodeproj/project.pbxproj @@ -26,6 +26,7 @@ 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 */; }; 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 */; }; @@ -77,6 +78,7 @@ 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 = ""; }; 02BDB7FB2C3E99920050FB67 /* HandyFont.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandyFont.swift; sourceTree = ""; }; + A56B3DE12C4E51D300C3610A /* HandyChip.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandyChip.swift; sourceTree = ""; }; E5669A3E2C443E7300DABC21 /* HandyBasicColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandyBasicColor.swift; sourceTree = ""; }; E5669A422C443FE500DABC21 /* HandyBasicColor.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = HandyBasicColor.xcassets; sourceTree = ""; }; E5D02AFC2C46C5A70056CE7B /* HandySematicColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandySematicColor.swift; sourceTree = ""; }; @@ -173,6 +175,7 @@ isa = PBXGroup; children = ( 029E47FC2C49FD1A00D2F3B7 /* HandyLabel.swift */, + A56B3DE12C4E51D300C3610A /* HandyChip.swift */, ); path = Atom; sourceTree = ""; @@ -380,6 +383,7 @@ 02BDB7FC2C3E99920050FB67 /* HandyFont.swift in Sources */, 029E48002C49FD4000D2F3B7 /* HandyTypography.swift in Sources */, 029E47FD2C49FD1A00D2F3B7 /* HandyLabel.swift in Sources */, + A56B3DE22C4E51D300C3610A /* HandyChip.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Handy/Handy/Source/Atom/HandyChip.swift b/Handy/Handy/Source/Atom/HandyChip.swift new file mode 100644 index 0000000..443a655 --- /dev/null +++ b/Handy/Handy/Source/Atom/HandyChip.swift @@ -0,0 +1,140 @@ +// +// HandyChip.swift +// Handy +// +// Created by 서준영 on 7/22/24. +// + +import UIKit + +@available(iOS 15, *) + +public class HandyChip: UIControl { + + // MARK: - 외부에서 지정가능한 속성 + @Invalidating(wrappedValue: nil, .layout) public var text: String? + + private var size: ChipSize = ChipSize() + + private struct ChipSize { + enum SizeType { + case medium + case small + } + + var type: SizeType + + var height: CGFloat { + switch type { + case .medium: + return 32 + case .small: + return 24 + } + } + + var cornerRadius: CGFloat { + return height/2 + } + + var padding: CGFloat { + return 12 + } + + init(type: SizeType = .medium) { + self.type = type + } + } + + public override var isSelected: Bool { + didSet { setNeedsLayout() } // 선택되면 다시그려야 함 + } + + // MARK: - 내부에서 사용되는 함수 + + /** + 칩의 글자, 아이콘, 배경 컬러입니다. unselected + */ + private let fgColor: UIColor = HandySemantic.textBasicSecondary + private let icColor: UIColor = HandySemantic.iconBasicSecondary + private let bgColor: UIColor = HandySemantic.chipUnselected + + /** + 칩이 selected 되었을 때 글자, 아이콘, 배경 컬러입니다. + */ + private let fgSelectedColor: UIColor = HandySemantic.textBrandPrimary + private let icSelectedColor: UIColor = HandySemantic.iconBrandPrimary + private let bgSelectedColor: UIColor = HandySemantic.chipSelected + + /** + 칩이 disabled 되었을 때 글자, 아이콘, 배경 컬러입니다. + */ + private let fgDisabledColor: UIColor = HandySemantic.textBasicDisabled + private let icDisabledColor: UIColor = HandySemantic.iconBasicDisabled + private let bgDisabledColor: UIColor = HandySemantic.chipDisabled + + /** + text를 표시하는 Label 입니다. + */ + private let textLabel = HandyLabel(style: .B3Rg14) + + public init() { + super.init(frame: .zero) + + setChipSize() + setColorBasedOnIsSelected() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override public func layoutSubviews() { + super.layoutSubviews() + + setCornerRadius() + textLabel.text = text + setChipSize() + setColorBasedOnIsSelected() + } + + /** + isSelected 값의 맞추어 backgroundColor, textColor를 변경합니다. + */ + private func setColorBasedOnIsSelected() { + self.backgroundColor = !isSelected + ? bgColor + : bgSelectedColor + + self.textLabel.textColor = !isSelected + ? fgColor + : fgSelectedColor + } + + /** + Chip의 높이, Label의 위치를 세팅합니다. + */ + private func setChipSize() { + self.addSubview(textLabel) + + // 높이 제약 조건 설정 + let heightConstraint = self.heightAnchor.constraint(equalToConstant: size.height) + heightConstraint.isActive = true + + // textLabel 제약 조건 설정 + textLabel.translatesAutoresizingMaskIntoConstraints = false + let centerYConstraint = textLabel.centerYAnchor.constraint(equalTo: self.centerYAnchor) + let leadingConstraint = textLabel.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: size.padding) + let trailingConstraint = textLabel.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -size.padding) + + NSLayoutConstraint.activate([centerYConstraint, leadingConstraint, trailingConstraint]) + } + + /** + 칩의 cornerRadius를 세팅합니다. + */ + private func setCornerRadius() { + self.layer.cornerRadius = size.cornerRadius + } +} +// TODO: Small 사이즈 구현, icon 어떻게 해야하나?, 글자수 제한?, 칩간 행열 간격 From a9740aff659785864c7fd852cca2d7da3105cf45 Mon Sep 17 00:00:00 2001 From: jysuhr Date: Thu, 1 Aug 2024 17:18:40 +0900 Subject: [PATCH 3/8] =?UTF-8?q?[#8]=20chipViewController=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Atom/ChipViewController.swift | 124 ++++++++++++++++++ Handy/Handy-Storybook/SceneDelegate.swift | 2 +- Handy/Handy.xcodeproj/project.pbxproj | 12 ++ .../xcshareddata/swiftpm/Package.resolved | 3 +- Handy/Handy/Source/Atom/HandyChip.swift | 77 ++++++++--- 5 files changed, 200 insertions(+), 18 deletions(-) create mode 100644 Handy/Handy-Storybook/Atom/ChipViewController.swift diff --git a/Handy/Handy-Storybook/Atom/ChipViewController.swift b/Handy/Handy-Storybook/Atom/ChipViewController.swift new file mode 100644 index 0000000..10a8954 --- /dev/null +++ b/Handy/Handy-Storybook/Atom/ChipViewController.swift @@ -0,0 +1,124 @@ +// +// ChipViewController.swift +// Handy-Storybook +// +// Created by 서준영 on 7/29/24. +// + +import UIKit +import Handy + +class ChipViewController: BaseViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + /** + Chip setup + */ + // enabled 상태(기본), Large(기본), isSelected X + let unTappedLargeChip = HandyChip() + unTappedLargeChip.chipState = HandyChip.ChipState(type: .enabled) + unTappedLargeChip.size = HandyChip.ChipSize(type: .large) + unTappedLargeChip.isSelected = false + unTappedLargeChip.text = "Label" + unTappedLargeChip.addTarget(self, action: #selector(firstChip), for: .touchUpInside) + unTappedLargeChip.translatesAutoresizingMaskIntoConstraints = false + + // enabled 상태(기본), Small, isSelected X + let unTappedSmallChip = HandyChip() + unTappedSmallChip.chipState = HandyChip.ChipState(type: .enabled) + unTappedSmallChip.size = HandyChip.ChipSize(type: .small) + unTappedSmallChip.isSelected = false + unTappedSmallChip.text = "Label" + unTappedSmallChip.addTarget(self, action: #selector(secondChip), for: .touchUpInside) + unTappedSmallChip.translatesAutoresizingMaskIntoConstraints = false + + + // enabled 상태(기본), Large(기본), isSelected O + let tappedLargeChip = HandyChip() + tappedLargeChip.chipState = HandyChip.ChipState(type: .enabled) + tappedLargeChip.size = HandyChip.ChipSize(type: .large) + tappedLargeChip.isSelected = true + tappedLargeChip.text = "Label" + tappedLargeChip.addTarget(self, action: #selector(thirdChip), for: .touchUpInside) + tappedLargeChip.translatesAutoresizingMaskIntoConstraints = false + + // enabled 상태(기본), Small, isSelected X + let tappedSmallChip = HandyChip() + tappedSmallChip.chipState = HandyChip.ChipState(type: .enabled) + tappedSmallChip.size = HandyChip.ChipSize(type: .small) + tappedSmallChip.isSelected = true + tappedSmallChip.text = "Label" + tappedSmallChip.addTarget(self, action: #selector(fourthChip), for: .touchUpInside) + tappedSmallChip.translatesAutoresizingMaskIntoConstraints = false + + + // disabled 상태(기본), Large(기본) + let disabledLargeChip = HandyChip() + disabledLargeChip.chipState = HandyChip.ChipState(type: .disabled) + disabledLargeChip.size = HandyChip.ChipSize(type: .large) + disabledLargeChip.text = "Label" + disabledLargeChip.translatesAutoresizingMaskIntoConstraints = false + + // disabled 상태(기본), Small + let disabledSmallChip = HandyChip() + disabledSmallChip.chipState = HandyChip.ChipState(type: .disabled) + disabledSmallChip.size = HandyChip.ChipSize(type: .small) + disabledSmallChip.text = "Label" + disabledSmallChip.translatesAutoresizingMaskIntoConstraints = false + + /** + Chip 뷰에 추가 + */ + view.addSubview(unTappedLargeChip) + view.addSubview(unTappedSmallChip) + + view.addSubview(tappedLargeChip) + view.addSubview(tappedSmallChip) + + view.addSubview(disabledLargeChip) + view.addSubview(disabledSmallChip) + + /** + Auto Layout 설정 + */ + NSLayoutConstraint.activate([ + unTappedLargeChip.centerXAnchor.constraint(equalTo: view.centerXAnchor), + unTappedLargeChip.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 100), + + unTappedSmallChip.centerXAnchor.constraint(equalTo: view.centerXAnchor), + unTappedSmallChip.topAnchor.constraint(equalTo: unTappedLargeChip.bottomAnchor, constant: 24), + + + tappedLargeChip.centerXAnchor.constraint(equalTo: view.centerXAnchor), + tappedLargeChip.topAnchor.constraint(equalTo: unTappedSmallChip.bottomAnchor, constant: 51), + + tappedSmallChip.centerXAnchor.constraint(equalTo: view.centerXAnchor), + tappedSmallChip.topAnchor.constraint(equalTo: tappedLargeChip.bottomAnchor, constant: 24), + + + disabledLargeChip.centerXAnchor.constraint(equalTo: view.centerXAnchor), + disabledLargeChip.topAnchor.constraint(equalTo: tappedSmallChip.bottomAnchor, constant: 51), + + disabledSmallChip.centerXAnchor.constraint(equalTo: view.centerXAnchor), + disabledSmallChip.topAnchor.constraint(equalTo: disabledLargeChip.bottomAnchor, constant: 24) + ]) + } + + /** + 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() + } +} diff --git a/Handy/Handy-Storybook/SceneDelegate.swift b/Handy/Handy-Storybook/SceneDelegate.swift index 77a051a..fab4479 100644 --- a/Handy/Handy-Storybook/SceneDelegate.swift +++ b/Handy/Handy-Storybook/SceneDelegate.swift @@ -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() } diff --git a/Handy/Handy.xcodeproj/project.pbxproj b/Handy/Handy.xcodeproj/project.pbxproj index d34c3f9..a1453bc 100644 --- a/Handy/Handy.xcodeproj/project.pbxproj +++ b/Handy/Handy.xcodeproj/project.pbxproj @@ -27,6 +27,11 @@ 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 */; }; 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 */; }; @@ -79,6 +84,7 @@ 02BDB7F22C3E95580050FB67 /* Handy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Handy.h; sourceTree = ""; }; 02BDB7FB2C3E99920050FB67 /* HandyFont.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandyFont.swift; sourceTree = ""; }; A56B3DE12C4E51D300C3610A /* HandyChip.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandyChip.swift; sourceTree = ""; }; + A5A12A7C2C57A6C200996916 /* ChipViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChipViewController.swift; sourceTree = ""; }; E5669A3E2C443E7300DABC21 /* HandyBasicColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandyBasicColor.swift; sourceTree = ""; }; E5669A422C443FE500DABC21 /* HandyBasicColor.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = HandyBasicColor.xcassets; sourceTree = ""; }; E5D02AFC2C46C5A70056CE7B /* HandySematicColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandySematicColor.swift; sourceTree = ""; }; @@ -123,6 +129,7 @@ isa = PBXGroup; children = ( 025776382C4EA98C00272EC6 /* LabelViewController.swift */, + A5A12A7C2C57A6C200996916 /* ChipViewController.swift */, ); path = Atom; sourceTree = ""; @@ -341,6 +348,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 */, @@ -366,6 +374,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 */, diff --git a/Handy/Handy.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Handy/Handy.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index ef3d252..3f64b3c 100644 --- a/Handy/Handy.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Handy/Handy.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,4 +1,5 @@ { + "originHash" : "dd27728c8848101841bd8d45243ef43144e233aa3767c82656934b73447347b8", "pins" : [ { "identity" : "snapkit", @@ -10,5 +11,5 @@ } } ], - "version" : 2 + "version" : 3 } diff --git a/Handy/Handy/Source/Atom/HandyChip.swift b/Handy/Handy/Source/Atom/HandyChip.swift index 443a655..42dfbdc 100644 --- a/Handy/Handy/Source/Atom/HandyChip.swift +++ b/Handy/Handy/Source/Atom/HandyChip.swift @@ -12,13 +12,20 @@ import UIKit public class HandyChip: UIControl { // MARK: - 외부에서 지정가능한 속성 - @Invalidating(wrappedValue: nil, .layout) public var text: String? + @Invalidating(wrappedValue: nil, .layout) public var text: String? { + didSet { + if let text = text, text.count > 10 { + self.text = String(text.prefix(10)) + } + setNeedsLayout() + } + } - private var size: ChipSize = ChipSize() + public var size: ChipSize = ChipSize() - private struct ChipSize { - enum SizeType { - case medium + public struct ChipSize { + public enum SizeType { + case large case small } @@ -26,7 +33,7 @@ public class HandyChip: UIControl { var height: CGFloat { switch type { - case .medium: + case .large: return 32 case .small: return 24 @@ -41,13 +48,30 @@ public class HandyChip: UIControl { return 12 } - init(type: SizeType = .medium) { + public init(type: SizeType = .large) { + self.type = type + } + } + + public var chipState: ChipState = ChipState() { + didSet { setNeedsLayout() } + } + + public struct ChipState { + public enum StateType { + case enabled + case disabled + } + + var type: StateType + + public init(type: StateType = .enabled) { self.type = type } } public override var isSelected: Bool { - didSet { setNeedsLayout() } // 선택되면 다시그려야 함 + didSet { setNeedsLayout() } } // MARK: - 내부에서 사용되는 함수 @@ -95,20 +119,33 @@ public class HandyChip: UIControl { setCornerRadius() textLabel.text = text setChipSize() - setColorBasedOnIsSelected() + setColorBasedOnState() } /** isSelected 값의 맞추어 backgroundColor, textColor를 변경합니다. */ private func setColorBasedOnIsSelected() { - self.backgroundColor = !isSelected - ? bgColor - : bgSelectedColor + self.backgroundColor = isSelected + ? bgSelectedColor + : bgColor - self.textLabel.textColor = !isSelected - ? fgColor - : fgSelectedColor + self.textLabel.textColor = isSelected + ? fgSelectedColor + : fgColor + } + + /** + Chip의 enabled disabled 상태에 맞추어 세팅합니다. + */ + private func setColorBasedOnState() { + switch chipState.type { + case .enabled: + setColorBasedOnIsSelected() + case .disabled: + self.backgroundColor = bgDisabledColor + self.textLabel.textColor = fgDisabledColor + } } /** @@ -137,4 +174,12 @@ public class HandyChip: UIControl { self.layer.cornerRadius = size.cornerRadius } } -// TODO: Small 사이즈 구현, icon 어떻게 해야하나?, 글자수 제한?, 칩간 행열 간격 + +// TODO: 리스트 +/* + - [x] Large, Small 사이즈 구현 + - [x] Enabled, Disabled 상태 구현 + - [x] 글자수 제한 + - [ ] icon + - [?] 칩간 행열 간격 + */ From 64ca21356ad4e71d799421f7fa3db49c1b9700f4 Mon Sep 17 00:00:00 2001 From: jysuhr Date: Mon, 12 Aug 2024 23:19:34 +0900 Subject: [PATCH 4/8] =?UTF-8?q?[#8]=20ViewDidLoad=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Atom/ChipViewController.swift | 189 +++++++++--------- Handy/Handy/Source/Atom/HandyChip.swift | 9 - 2 files changed, 98 insertions(+), 100 deletions(-) diff --git a/Handy/Handy-Storybook/Atom/ChipViewController.swift b/Handy/Handy-Storybook/Atom/ChipViewController.swift index 10a8954..6dbcd97 100644 --- a/Handy/Handy-Storybook/Atom/ChipViewController.swift +++ b/Handy/Handy-Storybook/Atom/ChipViewController.swift @@ -7,108 +7,115 @@ import UIKit import Handy +import SnapKit class ChipViewController: BaseViewController { - override func viewDidLoad() { - super.viewDidLoad() - - /** - Chip setup - */ - // enabled 상태(기본), Large(기본), isSelected X - let unTappedLargeChip = HandyChip() - unTappedLargeChip.chipState = HandyChip.ChipState(type: .enabled) - unTappedLargeChip.size = HandyChip.ChipSize(type: .large) - unTappedLargeChip.isSelected = false - unTappedLargeChip.text = "Label" - unTappedLargeChip.addTarget(self, action: #selector(firstChip), for: .touchUpInside) - unTappedLargeChip.translatesAutoresizingMaskIntoConstraints = false - - // enabled 상태(기본), Small, isSelected X - let unTappedSmallChip = HandyChip() - unTappedSmallChip.chipState = HandyChip.ChipState(type: .enabled) - unTappedSmallChip.size = HandyChip.ChipSize(type: .small) - unTappedSmallChip.isSelected = false - unTappedSmallChip.text = "Label" - unTappedSmallChip.addTarget(self, action: #selector(secondChip), for: .touchUpInside) - unTappedSmallChip.translatesAutoresizingMaskIntoConstraints = false - - - // enabled 상태(기본), Large(기본), isSelected O - let tappedLargeChip = HandyChip() - tappedLargeChip.chipState = HandyChip.ChipState(type: .enabled) - tappedLargeChip.size = HandyChip.ChipSize(type: .large) - tappedLargeChip.isSelected = true - tappedLargeChip.text = "Label" - tappedLargeChip.addTarget(self, action: #selector(thirdChip), for: .touchUpInside) - tappedLargeChip.translatesAutoresizingMaskIntoConstraints = false - - // enabled 상태(기본), Small, isSelected X - let tappedSmallChip = HandyChip() - tappedSmallChip.chipState = HandyChip.ChipState(type: .enabled) - tappedSmallChip.size = HandyChip.ChipSize(type: .small) - tappedSmallChip.isSelected = true - tappedSmallChip.text = "Label" - tappedSmallChip.addTarget(self, action: #selector(fourthChip), for: .touchUpInside) - tappedSmallChip.translatesAutoresizingMaskIntoConstraints = false - - - // disabled 상태(기본), Large(기본) - let disabledLargeChip = HandyChip() - disabledLargeChip.chipState = HandyChip.ChipState(type: .disabled) - disabledLargeChip.size = HandyChip.ChipSize(type: .large) - disabledLargeChip.text = "Label" - disabledLargeChip.translatesAutoresizingMaskIntoConstraints = false - - // disabled 상태(기본), Small - let disabledSmallChip = HandyChip() - disabledSmallChip.chipState = HandyChip.ChipState(type: .disabled) - disabledSmallChip.size = HandyChip.ChipSize(type: .small) - disabledSmallChip.text = "Label" - disabledSmallChip.translatesAutoresizingMaskIntoConstraints = false - - /** - Chip 뷰에 추가 - */ + //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.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.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.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.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.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.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) - - /** - Auto Layout 설정 - */ - NSLayoutConstraint.activate([ - unTappedLargeChip.centerXAnchor.constraint(equalTo: view.centerXAnchor), - unTappedLargeChip.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 100), - - unTappedSmallChip.centerXAnchor.constraint(equalTo: view.centerXAnchor), - unTappedSmallChip.topAnchor.constraint(equalTo: unTappedLargeChip.bottomAnchor, constant: 24), - - - tappedLargeChip.centerXAnchor.constraint(equalTo: view.centerXAnchor), - tappedLargeChip.topAnchor.constraint(equalTo: unTappedSmallChip.bottomAnchor, constant: 51), - - tappedSmallChip.centerXAnchor.constraint(equalTo: view.centerXAnchor), - tappedSmallChip.topAnchor.constraint(equalTo: tappedLargeChip.bottomAnchor, constant: 24), - - - disabledLargeChip.centerXAnchor.constraint(equalTo: view.centerXAnchor), - disabledLargeChip.topAnchor.constraint(equalTo: tappedSmallChip.bottomAnchor, constant: 51), - - disabledSmallChip.centerXAnchor.constraint(equalTo: view.centerXAnchor), - disabledSmallChip.topAnchor.constraint(equalTo: disabledLargeChip.bottomAnchor, constant: 24) - ]) } - /** - Chip 작동 함수 - */ + + //MARK: 레이아웃 배치 + override func setViewLayouts() { + unTappedLargeChip.snp.makeConstraints { make in + make.centerX.equalToSuperview() + make.top.equalTo(view.safeAreaLayoutGuide.snp.top).offset(100) + } + unTappedSmallChip.snp.makeConstraints { make in + make.centerX.equalToSuperview() + make.top.equalTo(unTappedLargeChip.snp.bottom).offset(24) + } + tappedLargeChip.snp.makeConstraints { make in + make.centerX.equalToSuperview() + make.top.equalTo(unTappedSmallChip.snp.bottom).offset(51) + } + tappedSmallChip.snp.makeConstraints { make in + make.centerX.equalToSuperview() + make.top.equalTo(tappedLargeChip.snp.bottom).offset(24) + } + disabledLargeChip.snp.makeConstraints { make in + make.centerX.equalToSuperview() + make.top.equalTo(tappedSmallChip.snp.bottom).offset(51) + } + disabledSmallChip.snp.makeConstraints { make in + make.centerX.equalToSuperview() + make.top.equalTo(disabledLargeChip.snp.bottom).offset(24) + } + } + + + //MARK: Chip 작동 함수 @objc private func firstChip(_ sender: HandyChip) { sender.isSelected.toggle() } diff --git a/Handy/Handy/Source/Atom/HandyChip.swift b/Handy/Handy/Source/Atom/HandyChip.swift index 42dfbdc..ef8ff74 100644 --- a/Handy/Handy/Source/Atom/HandyChip.swift +++ b/Handy/Handy/Source/Atom/HandyChip.swift @@ -174,12 +174,3 @@ public class HandyChip: UIControl { self.layer.cornerRadius = size.cornerRadius } } - -// TODO: 리스트 -/* - - [x] Large, Small 사이즈 구현 - - [x] Enabled, Disabled 상태 구현 - - [x] 글자수 제한 - - [ ] icon - - [?] 칩간 행열 간격 - */ From 71e94589d170f1d305d23385263ee3c661b48b33 Mon Sep 17 00:00:00 2001 From: jysuhr Date: Wed, 21 Aug 2024 02:24:32 +0900 Subject: [PATCH 5/8] =?UTF-8?q?[#8]=20SnapKit=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=A0=95=EB=A6=AC,=20icon=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../icClose.imageset/Contents.json | 23 +++ .../icClose.imageset/icClose.png | Bin 0 -> 350 bytes .../icClose.imageset/icClose@2.png | Bin 0 -> 563 bytes .../icClose.imageset/icClose@3.png | Bin 0 -> 645 bytes .../icInfoCircle.imageset/Contents.json | 23 +++ .../icInfoCircle.imageset/icInfoCircle.png | Bin 0 -> 867 bytes .../icInfoCircle.imageset/icInfoCircle@1.png | Bin 0 -> 463 bytes .../icInfoCircle.imageset/icInfoCircle@3.png | Bin 0 -> 1260 bytes .../Atom/ChipViewController.swift | 37 ++++ Handy/Handy.xcodeproj/project.pbxproj | 18 +- .../xcshareddata/swiftpm/Package.resolved | 2 +- Handy/Handy/Source/Atom/HandyChip.swift | 172 ++++++++++++++++-- 12 files changed, 249 insertions(+), 26 deletions(-) create mode 100644 Handy/Handy-Storybook/Assets.xcassets/icClose.imageset/Contents.json create mode 100644 Handy/Handy-Storybook/Assets.xcassets/icClose.imageset/icClose.png create mode 100644 Handy/Handy-Storybook/Assets.xcassets/icClose.imageset/icClose@2.png create mode 100644 Handy/Handy-Storybook/Assets.xcassets/icClose.imageset/icClose@3.png create mode 100644 Handy/Handy-Storybook/Assets.xcassets/icInfoCircle.imageset/Contents.json create mode 100644 Handy/Handy-Storybook/Assets.xcassets/icInfoCircle.imageset/icInfoCircle.png create mode 100644 Handy/Handy-Storybook/Assets.xcassets/icInfoCircle.imageset/icInfoCircle@1.png create mode 100644 Handy/Handy-Storybook/Assets.xcassets/icInfoCircle.imageset/icInfoCircle@3.png diff --git a/Handy/Handy-Storybook/Assets.xcassets/icClose.imageset/Contents.json b/Handy/Handy-Storybook/Assets.xcassets/icClose.imageset/Contents.json new file mode 100644 index 0000000..96d5471 --- /dev/null +++ b/Handy/Handy-Storybook/Assets.xcassets/icClose.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "icClose.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "icClose@2.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "icClose@3.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Handy/Handy-Storybook/Assets.xcassets/icClose.imageset/icClose.png b/Handy/Handy-Storybook/Assets.xcassets/icClose.imageset/icClose.png new file mode 100644 index 0000000000000000000000000000000000000000..8a8e6ffe327d20c0162ac1578fd7eadc91e1fa4a GIT binary patch literal 350 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GG!XV7ZFl&wkP>``W z$lZxy-8q?;Kn_c~qpu?a!^VE@KZ&eB{%21Y$B+ufvy=8-I_MzMcHcMe!S3euMnQtp zALgfRZR^l3;9L}}RT?C*R^r%;9&3)Pe7tjKPuMD%)UH;2_qYC5O@;8tzyFxv=tL&V@%5u(GDFM+pU7c z#z_^RkyB!)2!{Mp6km@0f5(dL0A$Ma$3nbDT{o8B!80kqV+&tckU~}6C@Dbn94HpX z)-c+y@CLa+4E8b@-Dy>?n~=)fd!RtgHy}s67%l(-7c=vbUq(QWWgx!HVacykARS(u z%4_U9&#wh-{ayiOhgI_ord-g9~>b18s02pRL~I0+$?D@IpdWQW83cwVtxZ4xDO)cEo|8>+_2L?Bs_@frhh3#&1Yl8kL~Gv3ouUuffi*h z3xO7CE(3x16YK?lLo()Z5G9lq>D;}kv>DyK2`Qk8p9(QO&kCK002ovPDHLkV1j|C Bsf!;uL;g)W6*x?QI2poYm(#97;hEiygG%qvG zn2%v7oxGR-&r3RK00MzPAn>1Ix(59u?R6kuaDWvsHhG`DzJN!PB<-#te?(#NIYjqa zHeEKg@8}XTOorlPyzBz!)0@HY4m=^m|KMPu_yqr6;`OsG#=roMd>KzBlz0#WweLOF z#c2&}AR1w!<-tv26Q{&8U@Hd2NEfSJ1A=SpAc6ur;N8P$mb$KqI`IW`u0FEqw=P~= z0l^#>QjQ6!D-7Py$86fa|2(#8a}cp2}2 zjR_y(We!J7O!yKn^AONvV*A7SlMnGS7ZJ54jyj|hFY^(iGeIq0<|Ia#ID`DFJY{4@ z^x_3ZTL~K?R$NrY3pjoN)<6wu1-APl+#fYGS#ij*3U7aJ3Y`|OHh%|eg46_wfjaSW z2aD6{cwv*7a5m5+e!hF3t$8|;m~b*+B3|LkL~8>!;uStjv@*~}yn@<Wr ffj}S-2sH2uLj~2av5-i*00000NkvXXu0mjfbpQ!G literal 0 HcmV?d00001 diff --git a/Handy/Handy-Storybook/Assets.xcassets/icInfoCircle.imageset/Contents.json b/Handy/Handy-Storybook/Assets.xcassets/icInfoCircle.imageset/Contents.json new file mode 100644 index 0000000..01ed39a --- /dev/null +++ b/Handy/Handy-Storybook/Assets.xcassets/icInfoCircle.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "icInfoCircle@1.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "icInfoCircle.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "icInfoCircle@3.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Handy/Handy-Storybook/Assets.xcassets/icInfoCircle.imageset/icInfoCircle.png b/Handy/Handy-Storybook/Assets.xcassets/icInfoCircle.imageset/icInfoCircle.png new file mode 100644 index 0000000000000000000000000000000000000000..fa41f8624fbe0275c21a43a17625b0034498a946 GIT binary patch literal 867 zcmV-p1DyPcP)a@x57kYxy6U0ZLzm08m z*A~Gz#x{iZr+G6TguK$eUF~Yu!2b?`Eg)sb4FETyM+0-49tW5yHJW2XR3^}p9Zw@{ z(*j9KYiq=&^lrQldrD+{R6r?#rtH)O!T}Av)G}W{(*vIry7a%Mq3fw-Jb!krE=Ohi z7ZPa6;}byl*v!yrMw05#1yt#B2{%BhLUUJHZjY zP);s?w~cbfge)edFF9U_MEwq7FHi0P0TR66Uv~SI`f!d%fGrNma&j|Ue%g|6y+Q(< zYKQ|!_z|2^<(whxu_BpCeD-3d5#bx(TD%@fwqC2RLFZ6gJMEb&7dLS^@ zE8lRah(mdFS{4IKMT>p4yE< zDN+O+pMU8JeSyCKfgnC&D&fC!3E$(dTF_0^ z@tbW(9Ln|}-B(OD>4+Gs9Zh^B{e4*DvToOO&)ieE3*|+9MPXB#1Z6-?sW@58QH&^B z^j*NdPbdC9pwfIm^POeOE~qoM-dwBEtVl1{> t>TzsX5C^GEsDr{!zGQZlx=;9L_yaeKMBYSW>-PWv002ovPDHLkV1hoyhKK+F literal 0 HcmV?d00001 diff --git a/Handy/Handy-Storybook/Assets.xcassets/icInfoCircle.imageset/icInfoCircle@1.png b/Handy/Handy-Storybook/Assets.xcassets/icInfoCircle.imageset/icInfoCircle@1.png new file mode 100644 index 0000000000000000000000000000000000000000..76f0d1501ffd1d6c2d55ee496614d88adc067ad2 GIT binary patch literal 463 zcmV;=0WkiFP)k*}eycswtl%?TVSWtbc#5Mt!*pk{W)4 zf>EX+l3|>yDS}IRq;Xo2TwMRudGD1J`tDsWWsM+NUe%gHi(%)Wv5usfW#;R#4?yQMQ#Z#z2_(kE#52^yY&_6bNSFx;vRv~Y_#a!WZe z12dR6$dM1n=BL=ksx3MGN;#0DYswHpw# z83lIy9Ca6U7ezN9dUcIjju0c48bB=q8+_0UXtvMhi>3~hgM%?g=i+!oHBgB_yl@nI zR3GwG?o}mHn!qi7_db!orgwsf*{Efu8v27i!%r zD_VsKK+f&2NZ| zqOA;cJZkN{tZ^A75uDZ#v)xsirx4G6(G6KhK(~18`2T0(@c}i2b-q2Yi0&(jpfCw* zQ3rMLQe>bG`%NxhLSA5;<_)~TjhZ@)S|@Vz7LCm%u+HyDO=Bl5{?>Ex$e|@bisFo{ zK15;~HOZ5IuxMP%^gy!51rPzm|YBRHW$Y8T2zZ>IH4WO#EQ59AB z55LWEhdxC2s1#rauy}T;G;NytW(Y*bHHhm~ci$qmD;+xghIt}jLYu4upOjlNPI|>z5%AC>>d}h$=V}#|Ll=etRyC`&1DD z1&&g_sq3R55UeFN-=P|)vhyl@#0^TdtLvk=#LP}6XxCam5lfl}DZa`*=;-c}hCt#S zo{Ldo4>Jwvc0>JrxW%`}R0FsN>LwN;&=dk56?%0~A`eR>a5d1~0XHr!bLWZzc0?7M z%$>Bd1CmZ2c{cq($V;on2s*8%QKNK`l$lm_T@_TLDr0S3ADta=l&aAOxeEBiHkI;) zu1|&ll1@qtFxMcZ{TL0Z+LK;fur9?W2{HsCIdkH=r%9m{0h?zl=0`88SY#O|)AwkQ zxu!_a(!V_T?twz2cB`BMUO0?=p)INa8OX$CUkPy1unaGE)ByWyn1w5is=m*iou`CV#wXNZTW02xT2dc`ki!UTA}FpFpj~F2NKcaigiMvJTlC6m!qS z!{779Nfyb>ESi94(kRj8~n~LW*e$=TQu8wCZ3Fnj4zy>4imBdIGs(FxqWH; z$`X-!K2nu-vKT2g{>}^WNEDr?)b{~HHhJy~YUh+2Vg-m@geDDi8*%!$L2NSpj7f^kosVsLR1kwn7r%wurU#E4o)e0-DpvO1q WYT~zFl@%la0000 Date: Wed, 21 Aug 2024 02:37:05 +0900 Subject: [PATCH 6/8] =?UTF-8?q?[#8]=20icon=EC=B6=94=EA=B0=80,=20=20?= =?UTF-8?q?=EC=A3=BC=EC=84=9D=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Atom/ChipViewController.swift | 25 ------ Handy/Handy/Source/Atom/HandyChip.swift | 76 ------------------- 2 files changed, 101 deletions(-) diff --git a/Handy/Handy-Storybook/Atom/ChipViewController.swift b/Handy/Handy-Storybook/Atom/ChipViewController.swift index 07196ac..b150649 100644 --- a/Handy/Handy-Storybook/Atom/ChipViewController.swift +++ b/Handy/Handy-Storybook/Atom/ChipViewController.swift @@ -11,31 +11,6 @@ import SnapKit class ChipViewController: BaseViewController { - /** - override func viewDidLoad() { - super.viewDidLoad() - - // 에셋에서 이미지 로드 - guard let testImage = UIImage(named: "icClose") else { - print("이미지를 찾을 수 없습니다.") - return - } - - // UIImageView 생성 - let imageView = UIImageView(image: testImage) - - // 이미지뷰의 콘텐츠 모드 설정 (옵션) - imageView.contentMode = .scaleAspectFit - - // 이미지뷰의 크기와 위치 설정 - imageView.frame = CGRect(x: 50, y: 100, width: 200, height: 200) - - // 이미지뷰를 뷰에 추가 - view.addSubview(imageView) - } - */ - - //MARK: 프로퍼티 선언 let unTappedLargeChip: HandyChip = { let chip = HandyChip() diff --git a/Handy/Handy/Source/Atom/HandyChip.swift b/Handy/Handy/Source/Atom/HandyChip.swift index f41b03e..7fb37fd 100644 --- a/Handy/Handy/Source/Atom/HandyChip.swift +++ b/Handy/Handy/Source/Atom/HandyChip.swift @@ -153,82 +153,6 @@ public class HandyChip: UIControl { /** Chip의 높이, Icon, Label의 위치를 세팅합니다. */ - /* - private func setChipSize() { - // 이전 서브뷰 제거 - subviews.filter { $0 !== textLabel && !($0 is UIImageView) }.forEach { $0.removeFromSuperview() } - - // UIImageView에 UIImgae를 넣어서 서브뷰로 추가 - let leftIconView = leftIcon != nil ? UIImageView(image: leftIcon) : nil - let rightIconView = rightIcon != nil ? UIImageView(image: rightIcon) : nil - - // 컨테이너 뷰의 높이 설정 - self.snp.updateConstraints { - $0.height - .equalTo(size.height) - } - - // 왼쪽 아이콘이 있는 경우 - if let leftIconView = leftIconView { - if leftIconView.superview == nil { - self.addSubview(leftIconView) - } - leftIconView.snp.makeConstraints { - $0.leading.equalToSuperview().offset(size.padding) - $0.centerY.equalToSuperview() - $0.height.equalTo(textLabel.snp.height).offset(-4) - $0.width.equalTo(leftIconView.snp.height) - } - } - - // 오른쪽 아이콘이 있는 경우 - if let rightIconView = rightIconView { - if rightIconView.superview == nil { - self.addSubview(rightIconView) - } - rightIconView.snp.makeConstraints { - $0.trailing.equalToSuperview().offset(-size.padding) - $0.centerY.equalToSuperview() - $0.height.equalTo(textLabel.snp.height).offset(-4) - $0.width.equalTo(rightIconView.snp.height) - } - } - - // 텍스트가 있는 경우 - if let text = text, !text.isEmpty { - if textLabel.superview == nil { - self.addSubview(textLabel) - } - - textLabel.snp.makeConstraints { - $0.centerY.equalToSuperview() - - if let leftIconView = leftIconView { - $0.leading.equalTo(leftIconView.snp.trailing).offset(4) - } else { - $0.leading.equalToSuperview().offset(size.padding) - } - - if let rightIconView = rightIconView { - $0.trailing.equalTo(rightIconView.snp.leading).offset(-4) - } else { - $0.trailing.equalToSuperview().offset(-size.padding) - } - } - } else { - // 텍스트 없고 아이콘만 있는 경우 - if let leftIconView = leftIconView { - leftIconView.snp.makeConstraints{ - $0.trailing.equalToSuperview().offset(-size.padding) - } - } else if let rightIconView = rightIconView { - rightIconView.snp.makeConstraints { - $0.leading.equalToSuperview().offset(size.padding) - } - } - } - }*/ - private func setChipSize() { // 이전의 서브뷰 제거 subviews.filter { $0 !== textLabel && !($0 is UIImageView) }.forEach { $0.removeFromSuperview() } From 63c53a8034473b8099fe38b8dd8940ae6ae70b86 Mon Sep 17 00:00:00 2001 From: jysuhr Date: Tue, 3 Sep 2024 23:42:25 +0900 Subject: [PATCH 7/8] =?UTF-8?q?[#8]=20icon=20=EC=83=89=EC=83=81=20?= =?UTF-8?q?=EC=A7=80=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Handy/Handy/Source/Atom/HandyChip.swift | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Handy/Handy/Source/Atom/HandyChip.swift b/Handy/Handy/Source/Atom/HandyChip.swift index 7fb37fd..f92c44e 100644 --- a/Handy/Handy/Source/Atom/HandyChip.swift +++ b/Handy/Handy/Source/Atom/HandyChip.swift @@ -120,8 +120,8 @@ public class HandyChip: UIControl { setCornerRadius() textLabel.text = text - setColorBasedOnState() setChipSize() + setColorBasedOnState() } /** @@ -135,6 +135,16 @@ public class HandyChip: UIControl { self.textLabel.textColor = isSelected ? fgSelectedColor : fgColor + + // 아이콘 색상 변경 + subviews.forEach { subview in + if let imageView = subview as? UIImageView { + imageView.image = imageView.image?.withRenderingMode(.alwaysTemplate) + imageView.tintColor = isSelected + ? icSelectedColor + : icColor + } + } } /** @@ -147,6 +157,14 @@ public class HandyChip: UIControl { case .disabled: self.backgroundColor = bgDisabledColor self.textLabel.textColor = fgDisabledColor + + // 아이콘 색상 변경 + subviews.forEach { subview in + if let imageView = subview as? UIImageView { + imageView.image = imageView.image?.withRenderingMode(.alwaysTemplate) + imageView.tintColor = icDisabledColor + } + } } } From 0de1526b9b964266a12beb90a338a873691730d7 Mon Sep 17 00:00:00 2001 From: jysuhr Date: Sat, 7 Sep 2024 19:37:30 +0900 Subject: [PATCH 8/8] =?UTF-8?q?ChipViewController=20SnapKit=20=EB=AC=B8?= =?UTF-8?q?=EB=B2=95=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Atom/ChipViewController.swift | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Handy/Handy-Storybook/Atom/ChipViewController.swift b/Handy/Handy-Storybook/Atom/ChipViewController.swift index b150649..30cb6f6 100644 --- a/Handy/Handy-Storybook/Atom/ChipViewController.swift +++ b/Handy/Handy-Storybook/Atom/ChipViewController.swift @@ -100,29 +100,29 @@ class ChipViewController: BaseViewController { //MARK: 레이아웃 배치 override func setViewLayouts() { - unTappedLargeChip.snp.makeConstraints { make in - make.centerX.equalToSuperview() - make.top.equalTo(view.safeAreaLayoutGuide.snp.top).offset(100) + unTappedLargeChip.snp.makeConstraints { + $0.centerX.equalToSuperview() + $0.top.equalTo(view.safeAreaLayoutGuide.snp.top).offset(100) } - unTappedSmallChip.snp.makeConstraints { make in - make.centerX.equalToSuperview() - make.top.equalTo(unTappedLargeChip.snp.bottom).offset(24) + unTappedSmallChip.snp.makeConstraints { + $0.centerX.equalToSuperview() + $0.top.equalTo(unTappedLargeChip.snp.bottom).offset(24) } - tappedLargeChip.snp.makeConstraints { make in - make.centerX.equalToSuperview() - make.top.equalTo(unTappedSmallChip.snp.bottom).offset(51) + tappedLargeChip.snp.makeConstraints { + $0.centerX.equalToSuperview() + $0.top.equalTo(unTappedSmallChip.snp.bottom).offset(51) } - tappedSmallChip.snp.makeConstraints { make in - make.centerX.equalToSuperview() - make.top.equalTo(tappedLargeChip.snp.bottom).offset(24) + tappedSmallChip.snp.makeConstraints { + $0.centerX.equalToSuperview() + $0.top.equalTo(tappedLargeChip.snp.bottom).offset(24) } - disabledLargeChip.snp.makeConstraints { make in - make.centerX.equalToSuperview() - make.top.equalTo(tappedSmallChip.snp.bottom).offset(51) + disabledLargeChip.snp.makeConstraints { + $0.centerX.equalToSuperview() + $0.top.equalTo(tappedSmallChip.snp.bottom).offset(51) } - disabledSmallChip.snp.makeConstraints { make in - make.centerX.equalToSuperview() - make.top.equalTo(disabledLargeChip.snp.bottom).offset(24) + disabledSmallChip.snp.makeConstraints { + $0.centerX.equalToSuperview() + $0.top.equalTo(disabledLargeChip.snp.bottom).offset(24) } }