Skip to content

Commit

Permalink
[#163] picker Item 이름 중 가독성이 떨어지던 것들을 보기 쉽게 수정
Browse files Browse the repository at this point in the history
- NS관련 객체에 CustomStringConvertible을 구현
  • Loading branch information
kati-kms committed Aug 21, 2022
1 parent 7abfae9 commit 26b6bec
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ class LabelPageViewController: StoryBookViewController {
}

addOption(description: "textColor",
cases: textColors.items.map { $0.color },
defaultIndex: 0) { [weak self] value in
self?.sampleLabel.textColor = value
cases: textColors.items,
defaultIndex: 0) { [weak self] colorInfo in
self?.sampleLabel.textColor = colorInfo.color
}

addOption(description: "lineBreakMode",
Expand All @@ -77,7 +77,7 @@ class LabelPageViewController: StoryBookViewController {
if #available(iOS 14.0, *) {
addOption(description: "lineBreakStrategy",
cases: NSParagraphStyle.LineBreakStrategy.allCases,
defaultIndex: 1) { [weak self] value in
defaultIndex: 2) { [weak self] value in
self?.sampleLabel.lineBreakStrategy = value
}
}
Expand Down Expand Up @@ -105,7 +105,8 @@ extension NSLineBreakMode: CaseIterable {

@available(iOS 14.0, *)
extension NSParagraphStyle.LineBreakStrategy: CaseIterable {
public static var allCases: [NSParagraphStyle.LineBreakStrategy] = [.pushOut,
public static var allCases: [NSParagraphStyle.LineBreakStrategy] = [[],
.pushOut,
.hangulWordPriority,
.standard,]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// NSLineBreakMode+CustomStringConvertible.swift
// YDS-Storybook
//
// Created by 강민석 on 2022/08/18.
//

import UIKit

extension NSLineBreakMode: CustomStringConvertible {
public var description: String {
switch self {
case .byWordWrapping:
return "byWordWrapping"
case .byCharWrapping:
return "byCharWrapping"
case .byClipping:
return "byClipping"
case .byTruncatingHead:
return "byTruncatingHead"
case .byTruncatingTail:
return "byTruncatingTail"
case .byTruncatingMiddle:
return "byTruncatingMiddle"
@unknown default:
return "unknown"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// NSParagraphStyle.LineBreakStrategy+CustomStringConvertible.swift
// YDS-Storybook
//
// Created by 강민석 on 2022/08/18.
//

import UIKit

extension NSParagraphStyle.LineBreakStrategy: CustomStringConvertible {
public var description: String {
if #available(iOS 14.0, *) {
switch self {
case .pushOut:
return "pushOut"
case .hangulWordPriority:
return "hangulWordPriority"
case .standard:
return "standard"
case []:
return "none"
default:
return "unknown"
}
} else {
switch self {
case .pushOut:
return "pushOut"
case []:
return "none"
default:
return "unknown"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// UIModalPresentationStyle+CustomStringConvertible.swift
// YDS-Storybook
//
// Created by 강민석 on 2022/08/18.
//

import UIKit

extension UIModalPresentationStyle: CustomStringConvertible {
public var description: String {
switch self {
case .fullScreen:
return "fullScreen"
case .pageSheet:
return "pageSheet"
case .formSheet:
return "formSheet"
case .currentContext:
return "currentContext"
case .custom:
return "custom"
case .overFullScreen:
return "overFullScreen"
case .overCurrentContext:
return "overCurrentContext"
case .popover:
return "popover"
case .none:
return "none"
case .automatic:
return "automatic"
@unknown default:
return "unknown"
}
}
}
6 changes: 6 additions & 0 deletions YDS-Storybook/Resources/YDSColorArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ struct Color {
let basicColorName: String
}

extension Color: CustomStringConvertible {
var description: String {
return self.name
}
}

struct Colors {
let items: [Color]
let description: String?
Expand Down
20 changes: 20 additions & 0 deletions YDS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@
C3985FB827F839A700389A22 /* UIApplication+findWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3985FB727F839A700389A22 /* UIApplication+findWindow.swift */; };
C3A3498627E710F900005034 /* Optional+isEmpty.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3A3498527E710F900005034 /* Optional+isEmpty.swift */; };
C3A48BC3285DC90100601094 /* Parchment in Frameworks */ = {isa = PBXBuildFile; productRef = C3A48BC2285DC90100601094 /* Parchment */; };
C3A8033728AE23D3008E2380 /* NSLineBreakMode+CustomStringConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3A8033628AE23D3008E2380 /* NSLineBreakMode+CustomStringConvertible.swift */; };
C3A8033928AE27E9008E2380 /* NSParagraphStyle.LineBreakStrategy+CustomStringConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3A8033828AE27E9008E2380 /* NSParagraphStyle.LineBreakStrategy+CustomStringConvertible.swift */; };
C3A8033B28AE2A96008E2380 /* UIModalPresentationStyle+CustomStringConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3A8033A28AE2A96008E2380 /* UIModalPresentationStyle+CustomStringConvertible.swift */; };
C3AFE2E2289FB1FA007D391D /* BottomSheetPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3AFE2E1289FB1FA007D391D /* BottomSheetPageViewController.swift */; };
C3BCE664284BB3C40098E49E /* ContentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3BCE663284BB3C40098E49E /* ContentViewController.swift */; };
C3BD4E39285DBCEA00B484DC /* YDSTabBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3BD4E38285DBCEA00B484DC /* YDSTabBarViewController.swift */; };
Expand Down Expand Up @@ -239,6 +242,9 @@
C3985FB527F832EA00389A22 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
C3985FB727F839A700389A22 /* UIApplication+findWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIApplication+findWindow.swift"; sourceTree = "<group>"; };
C3A3498527E710F900005034 /* Optional+isEmpty.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Optional+isEmpty.swift"; sourceTree = "<group>"; };
C3A8033628AE23D3008E2380 /* NSLineBreakMode+CustomStringConvertible.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSLineBreakMode+CustomStringConvertible.swift"; sourceTree = "<group>"; };
C3A8033828AE27E9008E2380 /* NSParagraphStyle.LineBreakStrategy+CustomStringConvertible.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSParagraphStyle.LineBreakStrategy+CustomStringConvertible.swift"; sourceTree = "<group>"; };
C3A8033A28AE2A96008E2380 /* UIModalPresentationStyle+CustomStringConvertible.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIModalPresentationStyle+CustomStringConvertible.swift"; sourceTree = "<group>"; };
C3AFE2E1289FB1FA007D391D /* BottomSheetPageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BottomSheetPageViewController.swift; sourceTree = "<group>"; };
C3BCE663284BB3C40098E49E /* ContentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentViewController.swift; sourceTree = "<group>"; };
C3BD4E38285DBCEA00B484DC /* YDSTabBarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YDSTabBarViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -321,6 +327,7 @@
532DBFD326EC7330008C2354 /* Extension */ = {
isa = PBXGroup;
children = (
C3A8033528AE23B4008E2380 /* Description */,
532DBFD126EC7323008C2354 /* UITableView+Generic.swift */,
C3A3498527E710F900005034 /* Optional+isEmpty.swift */,
532DBFD426EC734F008C2354 /* UIView+AddSubviews.swift */,
Expand Down Expand Up @@ -570,6 +577,16 @@
path = Extension;
sourceTree = "<group>";
};
C3A8033528AE23B4008E2380 /* Description */ = {
isa = PBXGroup;
children = (
C3A8033628AE23D3008E2380 /* NSLineBreakMode+CustomStringConvertible.swift */,
C3A8033828AE27E9008E2380 /* NSParagraphStyle.LineBreakStrategy+CustomStringConvertible.swift */,
C3A8033A28AE2A96008E2380 /* UIModalPresentationStyle+CustomStringConvertible.swift */,
);
path = Description;
sourceTree = "<group>";
};
C3DCB319282000E500F98257 /* List */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -896,8 +913,10 @@
C3BCE664284BB3C40098E49E /* ContentViewController.swift in Sources */,
C7F6908927DDCD17002B63C9 /* IconsPageViewController.swift in Sources */,
532DBFD526EC734F008C2354 /* UIView+AddSubviews.swift in Sources */,
C3A8033928AE27E9008E2380 /* NSParagraphStyle.LineBreakStrategy+CustomStringConvertible.swift in Sources */,
537A0ACE26C4188C00142DCE /* DoubleTitleTopBarSampleViewController.swift in Sources */,
537FFAA626C3E6F800270C22 /* TopBarSampleViewController.swift in Sources */,
C3A8033B28AE2A96008E2380 /* UIModalPresentationStyle+CustomStringConvertible.swift in Sources */,
C350ABE42808589200BFC9C0 /* TooltipSampleViewController.swift in Sources */,
53E26E8626F0619E0036648E /* TypographiesPageViewController.swift in Sources */,
C3985FB627F832EA00389A22 /* SceneDelegate.swift in Sources */,
Expand All @@ -914,6 +933,7 @@
53E2CF4226D2A3DA000DE005 /* SearchTextFieldPageViewController.swift in Sources */,
53C9F70626B5BCCE00EF7B86 /* ProfileImageViewPageViewController.swift in Sources */,
532DBFD926EC7863008C2354 /* UIViewController+Embed.swift in Sources */,
C3A8033728AE23D3008E2380 /* NSLineBreakMode+CustomStringConvertible.swift in Sources */,
533A27B326A52E56009FD90A /* PageListViewController.swift in Sources */,
532DBFD226EC7323008C2354 /* UITableView+Generic.swift in Sources */,
5359A5C526BED19900FCCECC /* DoubleTitleTopBarPageViewController.swift in Sources */,
Expand Down

0 comments on commit 26b6bec

Please sign in to comment.