From 6ba8096c6db9a3e82f4e5ae32d56627e53899ff8 Mon Sep 17 00:00:00 2001 From: J0onYEong Date: Mon, 21 Oct 2024 15:16:21 +0900 Subject: [PATCH 1/5] =?UTF-8?q?[IDLE-450]=20typography=20Foundation=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Component/Typography/Typograpy.swift | 56 +++++++++++++------ 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/project/Projects/Presentation/DSKit/Sources/Component/Typography/Typograpy.swift b/project/Projects/Presentation/DSKit/Sources/Component/Typography/Typograpy.swift index 335889e5..2a1f246e 100644 --- a/project/Projects/Presentation/DSKit/Sources/Component/Typography/Typograpy.swift +++ b/project/Projects/Presentation/DSKit/Sources/Component/Typography/Typograpy.swift @@ -21,6 +21,7 @@ public enum Typography { case Heading2 case Heading3 case Heading4 + case Heading5 case Subtitle1 case Subtitle2 @@ -37,23 +38,25 @@ public enum Typography { var lineHeight: CGFloat? { switch self { case .Heading1: - 36 + 38 case .Heading2: - 32 + 36 case .Heading3: - 30 + 32 case .Heading4: + 30 + case .Heading5: 26 case .Subtitle1: - 32 + 36 case .Subtitle2: - 30 + 32 case .Subtitle3: - 26 + 30 case .Subtitle4: - 22 + 26 case .Body1: @@ -63,6 +66,9 @@ public enum Typography { case .Body3: 22 + case .caption: + 22 + default: nil } @@ -89,77 +95,93 @@ public enum Typography { case .Heading2: createAttribute( weight: .Bold, - size: 20, + size: 22, letterSpacing: -0.2, color: DSKitAsset.Colors.gray900.color ) case .Heading3: createAttribute( weight: .Bold, - size: 18, + size: 20, letterSpacing: -0.2, color: DSKitAsset.Colors.gray900.color ) case .Heading4: + createAttribute( + weight: .Bold, + size: 18, + letterSpacing: -0.2, + color: DSKitAsset.Colors.gray900.color + ) + case .Heading5: createAttribute( weight: .Bold, size: 16, letterSpacing: -0.2, color: DSKitAsset.Colors.gray900.color ) + + case .Subtitle1: createAttribute( weight: .Semibold, - size: 20, + size: 22, letterSpacing: -0.2, color: DSKitAsset.Colors.gray900.color ) case .Subtitle2: createAttribute( weight: .Semibold, - size: 18, + size: 20, letterSpacing: -0.2, color: DSKitAsset.Colors.gray900.color ) case .Subtitle3: createAttribute( weight: .Semibold, - size: 16, + size: 18, letterSpacing: -0.2, color: DSKitAsset.Colors.gray900.color ) case .Subtitle4: createAttribute( weight: .Semibold, - size: 14, + size: 16, letterSpacing: -0.2, color: DSKitAsset.Colors.gray900.color ) + + + case .Body1: createAttribute( weight: .medium, - size: 18, + size: 20, letterSpacing: -0.2, color: DSKitAsset.Colors.gray900.color ) case .Body2: createAttribute( weight: .medium, - size: 16, + size: 18, letterSpacing: -0.2, color: DSKitAsset.Colors.gray900.color ) case .Body3: createAttribute( weight: .medium, - size: 14, + size: 16, letterSpacing: -0.2, color: DSKitAsset.Colors.gray900.color ) + + + + case .caption: createAttribute( weight: .medium, - size: 12, + size: 14, letterSpacing: -0.2, color: DSKitAsset.Colors.gray900.color ) From c727bc305ae14cc00212fd57fd3c12775eb754a5 Mon Sep 17 00:00:00 2001 From: J0onYEong Date: Mon, 21 Oct 2024 15:48:41 +0900 Subject: [PATCH 2/5] =?UTF-8?q?[IDLE-450]=20WorkTimeAndPayContentView=20UI?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Foundation변화로인한 UI깨짐현상 해결 --- .../CommonUI/Button/StateButtonTyp1.swift | 29 +++++++++++-------- .../EditPost/WorkTimeAndPayContentView.swift | 12 ++++++-- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/project/Projects/Presentation/DSKit/Sources/CommonUI/Button/StateButtonTyp1.swift b/project/Projects/Presentation/DSKit/Sources/CommonUI/Button/StateButtonTyp1.swift index 41a686e9..e1c794a8 100644 --- a/project/Projects/Presentation/DSKit/Sources/CommonUI/Button/StateButtonTyp1.swift +++ b/project/Projects/Presentation/DSKit/Sources/CommonUI/Button/StateButtonTyp1.swift @@ -13,21 +13,26 @@ public class StateButtonTyp1: UIView { // Init values public private(set) var state: State - public var normalAppearance = StateSetting.normalDefault - public var accentAppearance = StateSetting.accentDefault + public var normalAppearance: StateSetting + public var accentAppearance: StateSetting public let eventPublisher: PublishRelay = .init() // View public let label: IdleLabel = { - let view = IdleLabel(typography: .Body3) - return view }() - public init(text: String, initial: State) { + public init( + text: String, + initial: State, + normalAppearance: StateSetting = .normalDefault, + accentAppearance: StateSetting = .accentDefault + ) { self.state = initial + self.normalAppearance = normalAppearance + self.accentAppearance = accentAppearance super.init(frame: .zero) @@ -46,7 +51,7 @@ public class StateButtonTyp1: UIView { self.layer.cornerRadius = 6.0 self.clipsToBounds = true - applySetting(setting: self.state == .accent ? .accentDefault : .normalDefault) + applySetting(setting: self.state == .accent ? accentAppearance : normalAppearance) } private func setAutoLayout() { @@ -114,13 +119,13 @@ public extension StateButtonTyp1 { struct StateSetting { - let textColor: UIColor - let typography: Typography + public var textColor: UIColor + public var typography: Typography - let borderColor: UIColor - let backgroundColor: UIColor + public var borderColor: UIColor + public var backgroundColor: UIColor - static var normalDefault: StateSetting { + public static var normalDefault: StateSetting { StateSetting( textColor: DSKitAsset.Colors.gray500.color, typography: .Body3, @@ -129,7 +134,7 @@ public extension StateButtonTyp1 { ) } - static var accentDefault: StateSetting { + public static var accentDefault: StateSetting { StateSetting( textColor: DSKitAsset.Colors.orange500.color, typography: .Subtitle4, diff --git a/project/Projects/Presentation/Feature/Base/Sources/PostDetailForCenter/EditPost/WorkTimeAndPayContentView.swift b/project/Projects/Presentation/Feature/Base/Sources/PostDetailForCenter/EditPost/WorkTimeAndPayContentView.swift index 5e9bbd1d..87fbb0d0 100644 --- a/project/Projects/Presentation/Feature/Base/Sources/PostDetailForCenter/EditPost/WorkTimeAndPayContentView.swift +++ b/project/Projects/Presentation/Feature/Base/Sources/PostDetailForCenter/EditPost/WorkTimeAndPayContentView.swift @@ -32,10 +32,16 @@ public class WorkTimeAndPayContentView: UIView { // 근무 요일 let workDayButtons: [StateButtonTyp1] = { WorkDay.allCases.map { day in - StateButtonTyp1( + var normalSetting = StateButtonTyp1.StateSetting.normalDefault + normalSetting.typography = .Body2 + + let button = StateButtonTyp1( text: day.korOneLetterText, - initial: .normal + initial: .normal, + normalAppearance: normalSetting ) + + return button } }() @@ -107,7 +113,7 @@ public class WorkTimeAndPayContentView: UIView { IdleContentTitleLabel(titleText: "근무 요일"), HStack([ workDayButtons as [UIView], - [UIView()] + [Spacer()] ].flatMap({ $0 }), spacing: 4), ], spacing: 6, From 1a025bf1a97d77d58f237eab88571da8d207dc01 Mon Sep 17 00:00:00 2001 From: J0onYEong Date: Mon, 21 Oct 2024 16:49:45 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[IDLE-450]=20lineHeight=EC=A0=81=EC=9A=A9?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DSKit/Sources/CommonUI/Button/StateButtonTyp1.swift | 2 +- .../DSKit/Sources/Component/Label/IdleLabel.swift | 9 ++++++++- .../DSKit/Sources/Component/Typography/Typograpy.swift | 4 +++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/project/Projects/Presentation/DSKit/Sources/CommonUI/Button/StateButtonTyp1.swift b/project/Projects/Presentation/DSKit/Sources/CommonUI/Button/StateButtonTyp1.swift index e1c794a8..493c53fc 100644 --- a/project/Projects/Presentation/DSKit/Sources/CommonUI/Button/StateButtonTyp1.swift +++ b/project/Projects/Presentation/DSKit/Sources/CommonUI/Button/StateButtonTyp1.swift @@ -85,7 +85,7 @@ public class StateButtonTyp1: UIView { } } - public func setState(_ state: State, withAnimation: Bool = true) { + public func setState(_ state: State, withAnimation: Bool = false) { if self.state == state { return } diff --git a/project/Projects/Presentation/DSKit/Sources/Component/Label/IdleLabel.swift b/project/Projects/Presentation/DSKit/Sources/Component/Label/IdleLabel.swift index 5a20a57f..526e8eef 100644 --- a/project/Projects/Presentation/DSKit/Sources/Component/Label/IdleLabel.swift +++ b/project/Projects/Presentation/DSKit/Sources/Component/Label/IdleLabel.swift @@ -26,6 +26,13 @@ public class IdleLabel: UILabel { updateText() } + public override var intrinsicContentSize: CGSize { + return .init( + width: super.intrinsicContentSize.width, + height: typography.lineHeight! + ) + } + public required init?(coder: NSCoder) { fatalError() } public var typography: Typography { @@ -93,6 +100,6 @@ public class IdleLabel: UILabel { let attributedStr = NSMutableAttributedString(string: currentText, attributes: currentAttributes) self.attributedText = attributedStr - self.sizeToFit() + self.invalidateIntrinsicContentSize() } } diff --git a/project/Projects/Presentation/DSKit/Sources/Component/Typography/Typograpy.swift b/project/Projects/Presentation/DSKit/Sources/Component/Typography/Typograpy.swift index 2a1f246e..c6d6cb8e 100644 --- a/project/Projects/Presentation/DSKit/Sources/Component/Typography/Typograpy.swift +++ b/project/Projects/Presentation/DSKit/Sources/Component/Typography/Typograpy.swift @@ -220,7 +220,9 @@ public enum Typography { paragraphStyle.minimumLineHeight = lineHeight paragraphStyle.maximumLineHeight = lineHeight - baseLineOffset = (lineHeight-font.lineHeight)/2 + let wordMinHeight = font.ascender + abs(font.descender) + + baseLineOffset = (lineHeight-wordMinHeight)/2 } return [ From 2ebff6b30103a6284b588c34c8fa34df9f24d687 Mon Sep 17 00:00:00 2001 From: J0onYEong Date: Tue, 22 Oct 2024 11:06:14 +0900 Subject: [PATCH 4/5] =?UTF-8?q?[IDLE-450]=20MultiLineTextField=20=EB=86=92?= =?UTF-8?q?=EC=9D=B4=20=EA=B9=A8=EC=A7=90=ED=98=84=EC=83=81=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DSKit/Sources/Component/Label/IdleLabel.swift | 7 ------- .../Sources/Component/TextField/MultiLineTextField.swift | 1 + 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/project/Projects/Presentation/DSKit/Sources/Component/Label/IdleLabel.swift b/project/Projects/Presentation/DSKit/Sources/Component/Label/IdleLabel.swift index 526e8eef..3c6867d2 100644 --- a/project/Projects/Presentation/DSKit/Sources/Component/Label/IdleLabel.swift +++ b/project/Projects/Presentation/DSKit/Sources/Component/Label/IdleLabel.swift @@ -26,13 +26,6 @@ public class IdleLabel: UILabel { updateText() } - public override var intrinsicContentSize: CGSize { - return .init( - width: super.intrinsicContentSize.width, - height: typography.lineHeight! - ) - } - public required init?(coder: NSCoder) { fatalError() } public var typography: Typography { diff --git a/project/Projects/Presentation/DSKit/Sources/Component/TextField/MultiLineTextField.swift b/project/Projects/Presentation/DSKit/Sources/Component/TextField/MultiLineTextField.swift index 838b1eb5..c226d1ec 100644 --- a/project/Projects/Presentation/DSKit/Sources/Component/TextField/MultiLineTextField.swift +++ b/project/Projects/Presentation/DSKit/Sources/Component/TextField/MultiLineTextField.swift @@ -96,6 +96,7 @@ public class MultiLineTextField: UITextView { placeHolderLabel.topAnchor.constraint(equalTo: frameGuide.topAnchor, constant: textContainerInset.top), placeHolderLabel.leftAnchor.constraint(equalTo: frameGuide.leftAnchor, constant: textContainerInset.left), placeHolderLabel.rightAnchor.constraint(equalTo: frameGuide.rightAnchor, constant: -textContainerInset.right), + placeHolderLabel.bottomAnchor.constraint(equalTo: frameGuide.bottomAnchor, constant: -textContainerInset.bottom), ]) } From 82e4cb435667723c016e5598755c2a0b2910beac Mon Sep 17 00:00:00 2001 From: J0onYEong Date: Tue, 22 Oct 2024 11:08:24 +0900 Subject: [PATCH 5/5] =?UTF-8?q?[IDLE-450]=20State=EB=B2=84=ED=8A=BC=20?= =?UTF-8?q?=EC=95=A0=EB=8B=88=EB=A9=94=EC=9D=B4=EC=85=98=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DSKit/Sources/CommonUI/Button/StateButtonTyp1.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Projects/Presentation/DSKit/Sources/CommonUI/Button/StateButtonTyp1.swift b/project/Projects/Presentation/DSKit/Sources/CommonUI/Button/StateButtonTyp1.swift index 493c53fc..e1c794a8 100644 --- a/project/Projects/Presentation/DSKit/Sources/CommonUI/Button/StateButtonTyp1.swift +++ b/project/Projects/Presentation/DSKit/Sources/CommonUI/Button/StateButtonTyp1.swift @@ -85,7 +85,7 @@ public class StateButtonTyp1: UIView { } } - public func setState(_ state: State, withAnimation: Bool = false) { + public func setState(_ state: State, withAnimation: Bool = true) { if self.state == state { return }