From 26b6bec8f69e557b9b5fcd6ce934ee8b5e4a2d9b Mon Sep 17 00:00:00 2001 From: kati-kms Date: Thu, 18 Aug 2022 23:49:36 +0900 Subject: [PATCH] =?UTF-8?q?[#163]=20picker=20Item=20=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?=EC=A4=91=20=EA=B0=80=EB=8F=85=EC=84=B1=EC=9D=B4=20=EB=96=A8?= =?UTF-8?q?=EC=96=B4=EC=A7=80=EB=8D=98=20=EA=B2=83=EB=93=A4=EC=9D=84=20?= =?UTF-8?q?=EB=B3=B4=EA=B8=B0=20=EC=89=BD=EA=B2=8C=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?-=20NS=EA=B4=80=EB=A0=A8=20=EA=B0=9D=EC=B2=B4=EC=97=90=20Custom?= =?UTF-8?q?StringConvertible=EC=9D=84=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LabelPageViewController.swift | 11 +++--- ...ineBreakMode+CustomStringConvertible.swift | 29 +++++++++++++++ ...reakStrategy+CustomStringConvertible.swift | 36 ++++++++++++++++++ ...ntationStyle+CustomStringConvertible.swift | 37 +++++++++++++++++++ YDS-Storybook/Resources/YDSColorArray.swift | 6 +++ YDS.xcodeproj/project.pbxproj | 20 ++++++++++ 6 files changed, 134 insertions(+), 5 deletions(-) create mode 100644 YDS-Storybook/Extension/Description/NSLineBreakMode+CustomStringConvertible.swift create mode 100644 YDS-Storybook/Extension/Description/NSParagraphStyle.LineBreakStrategy+CustomStringConvertible.swift create mode 100644 YDS-Storybook/Extension/Description/UIModalPresentationStyle+CustomStringConvertible.swift diff --git a/YDS-Storybook/AtomSampleViewController/LabelPageViewController.swift b/YDS-Storybook/AtomSampleViewController/LabelPageViewController.swift index 980dd8e6..112c4063 100644 --- a/YDS-Storybook/AtomSampleViewController/LabelPageViewController.swift +++ b/YDS-Storybook/AtomSampleViewController/LabelPageViewController.swift @@ -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", @@ -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 } } @@ -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,] } diff --git a/YDS-Storybook/Extension/Description/NSLineBreakMode+CustomStringConvertible.swift b/YDS-Storybook/Extension/Description/NSLineBreakMode+CustomStringConvertible.swift new file mode 100644 index 00000000..782b59c3 --- /dev/null +++ b/YDS-Storybook/Extension/Description/NSLineBreakMode+CustomStringConvertible.swift @@ -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" + } + } +} diff --git a/YDS-Storybook/Extension/Description/NSParagraphStyle.LineBreakStrategy+CustomStringConvertible.swift b/YDS-Storybook/Extension/Description/NSParagraphStyle.LineBreakStrategy+CustomStringConvertible.swift new file mode 100644 index 00000000..8dc4ac7b --- /dev/null +++ b/YDS-Storybook/Extension/Description/NSParagraphStyle.LineBreakStrategy+CustomStringConvertible.swift @@ -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" + } + } + } +} diff --git a/YDS-Storybook/Extension/Description/UIModalPresentationStyle+CustomStringConvertible.swift b/YDS-Storybook/Extension/Description/UIModalPresentationStyle+CustomStringConvertible.swift new file mode 100644 index 00000000..a0a749dd --- /dev/null +++ b/YDS-Storybook/Extension/Description/UIModalPresentationStyle+CustomStringConvertible.swift @@ -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" + } + } +} diff --git a/YDS-Storybook/Resources/YDSColorArray.swift b/YDS-Storybook/Resources/YDSColorArray.swift index 3fdb7b7c..2a0aa0cb 100644 --- a/YDS-Storybook/Resources/YDSColorArray.swift +++ b/YDS-Storybook/Resources/YDSColorArray.swift @@ -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? diff --git a/YDS.xcodeproj/project.pbxproj b/YDS.xcodeproj/project.pbxproj index d6c87f8f..99664db4 100644 --- a/YDS.xcodeproj/project.pbxproj +++ b/YDS.xcodeproj/project.pbxproj @@ -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 */; }; @@ -239,6 +242,9 @@ C3985FB527F832EA00389A22 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; C3985FB727F839A700389A22 /* UIApplication+findWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIApplication+findWindow.swift"; sourceTree = ""; }; C3A3498527E710F900005034 /* Optional+isEmpty.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Optional+isEmpty.swift"; sourceTree = ""; }; + C3A8033628AE23D3008E2380 /* NSLineBreakMode+CustomStringConvertible.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSLineBreakMode+CustomStringConvertible.swift"; sourceTree = ""; }; + C3A8033828AE27E9008E2380 /* NSParagraphStyle.LineBreakStrategy+CustomStringConvertible.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSParagraphStyle.LineBreakStrategy+CustomStringConvertible.swift"; sourceTree = ""; }; + C3A8033A28AE2A96008E2380 /* UIModalPresentationStyle+CustomStringConvertible.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIModalPresentationStyle+CustomStringConvertible.swift"; sourceTree = ""; }; C3AFE2E1289FB1FA007D391D /* BottomSheetPageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BottomSheetPageViewController.swift; sourceTree = ""; }; C3BCE663284BB3C40098E49E /* ContentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentViewController.swift; sourceTree = ""; }; C3BD4E38285DBCEA00B484DC /* YDSTabBarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YDSTabBarViewController.swift; sourceTree = ""; }; @@ -321,6 +327,7 @@ 532DBFD326EC7330008C2354 /* Extension */ = { isa = PBXGroup; children = ( + C3A8033528AE23B4008E2380 /* Description */, 532DBFD126EC7323008C2354 /* UITableView+Generic.swift */, C3A3498527E710F900005034 /* Optional+isEmpty.swift */, 532DBFD426EC734F008C2354 /* UIView+AddSubviews.swift */, @@ -570,6 +577,16 @@ path = Extension; sourceTree = ""; }; + C3A8033528AE23B4008E2380 /* Description */ = { + isa = PBXGroup; + children = ( + C3A8033628AE23D3008E2380 /* NSLineBreakMode+CustomStringConvertible.swift */, + C3A8033828AE27E9008E2380 /* NSParagraphStyle.LineBreakStrategy+CustomStringConvertible.swift */, + C3A8033A28AE2A96008E2380 /* UIModalPresentationStyle+CustomStringConvertible.swift */, + ); + path = Description; + sourceTree = ""; + }; C3DCB319282000E500F98257 /* List */ = { isa = PBXGroup; children = ( @@ -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 */, @@ -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 */,