From cd4a009207850e2517e1f5ff1479c08cd9c55977 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 14 Oct 2022 13:42:37 +0300 Subject: [PATCH 1/2] added backward compatibility attribute for previous lineHeight version --- Utils/String/String+Attributes.swift | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Utils/String/String+Attributes.swift b/Utils/String/String+Attributes.swift index 5fdc1f4..7d38836 100644 --- a/Utils/String/String+Attributes.swift +++ b/Utils/String/String+Attributes.swift @@ -34,6 +34,16 @@ public enum StringAttribute { case lineHeight(CGFloat) /// Paragrapth spacing case paragraphSpacing(CGFloat) + + /// Previous version of .lineHeight attribute + /// + /// It needs for backward compatibility. + /// It setups paragraphStyle.lineSpacing value, but gets as parameter not spacing value, + /// but total lineHeight value. And setup paragraphStyle.lineSpacing as + /// `lineHeight - font.lineHeight`. + /// So you need to specify in attributes array both `oldLineHeight` and `.font`, otherwise - + /// nothing will happen. + case oldLineHeight(CGFloat) } // MARK: - Nested types @@ -71,7 +81,9 @@ extension StringAttribute { extension StringAttribute { var attributeKey: NSAttributedString.Key { switch self { - case .lineSpacing, .aligment, .lineHeight, .lineBreakMode, .paragraphSpacing: + case .lineSpacing, .aligment, .lineBreakMode, .paragraphSpacing: + return NSAttributedString.Key.paragraphStyle + case .lineHeight, .oldLineHeight: return NSAttributedString.Key.paragraphStyle case .kern: return NSAttributedString.Key.kern @@ -108,6 +120,8 @@ extension StringAttribute { return value case .paragraphSpacing(let value): return value + case .oldLineHeight(let value): + return value } } } @@ -191,6 +205,12 @@ public extension Array where Element == StringAttribute { case .paragraphSpacing(let value): paragraph.paragraphSpacing = value resultAttributes[attribute.attributeKey] = paragraph + case .oldLineHeight(let value): + guard let font = self.findFont() else { + break + } + paragraph.lineSpacing = value - font.lineHeight + resultAttributes[attribute.attributeKey] = paragraph default: resultAttributes[attribute.attributeKey] = attribute.value } From 08cad0a377e85e0d1f5c7a59cb612dec6fad9e10 Mon Sep 17 00:00:00 2001 From: Alexander Date: Sun, 20 Nov 2022 21:33:15 +0300 Subject: [PATCH 2/2] added missed imports --- Utils/SecurityService/Store/GenericPasswordQueryable.swift | 1 + Utils/SecurityService/Store/KeyChainSecureStore.swift | 1 + 2 files changed, 2 insertions(+) diff --git a/Utils/SecurityService/Store/GenericPasswordQueryable.swift b/Utils/SecurityService/Store/GenericPasswordQueryable.swift index ba33c95..cd6f06e 100644 --- a/Utils/SecurityService/Store/GenericPasswordQueryable.swift +++ b/Utils/SecurityService/Store/GenericPasswordQueryable.swift @@ -7,6 +7,7 @@ // import Foundation +import Security // MARK: - SecureStoreQueryable diff --git a/Utils/SecurityService/Store/KeyChainSecureStore.swift b/Utils/SecurityService/Store/KeyChainSecureStore.swift index 58de34a..98b1871 100644 --- a/Utils/SecurityService/Store/KeyChainSecureStore.swift +++ b/Utils/SecurityService/Store/KeyChainSecureStore.swift @@ -7,6 +7,7 @@ // import Foundation +import Security public struct KeyChainSecureStore: SecureStore {