Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Utils/SecurityService/Store/GenericPasswordQueryable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import Security

// MARK: - SecureStoreQueryable

Expand Down
1 change: 1 addition & 0 deletions Utils/SecurityService/Store/KeyChainSecureStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import Security

public struct KeyChainSecureStore: SecureStore {

Expand Down
22 changes: 21 additions & 1 deletion Utils/String/String+Attributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -108,6 +120,8 @@ extension StringAttribute {
return value
case .paragraphSpacing(let value):
return value
case .oldLineHeight(let value):
return value
}
}
}
Expand Down Expand Up @@ -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
}
Expand Down