From a52cd7523b311259a60bc504cf790e789044c1ea Mon Sep 17 00:00:00 2001 From: Tony Loehr Date: Wed, 22 Jan 2020 09:51:18 -0800 Subject: [PATCH] Card part attributed text patch (#225) * added UITextView Card Part * Implementation of CardPartAttributesTextView * Implementation of CardPartAttributesTextView * Implementation of CardPartAttributesTextView with adjustments * Implementation of CardPartAttributesTextView with fixes * Implementation of CardPartAttributesTextView with README updates * patch of CardPartAttributedTextView * cleanup * fixed threading issue preventing font and textColor updating * wrapped didSet methods on main thread * fixed setDefaultForType method * added memory leak protection --- .../CardPartAttributedTextView.swift | 31 ++++++++++++------- CardParts/src/Classes/CardPartsTheme.swift | 2 +- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/CardParts/src/Classes/Card Parts/CardPartAttributedTextView.swift b/CardParts/src/Classes/Card Parts/CardPartAttributedTextView.swift index a9074018..7181c606 100644 --- a/CardParts/src/Classes/Card Parts/CardPartAttributedTextView.swift +++ b/CardParts/src/Classes/Card Parts/CardPartAttributedTextView.swift @@ -206,21 +206,30 @@ public class CardPartAttributedTextView: UIView, CardPartView { func setDefaultsForType(_ type: CardPartAttributedTextType) { switch type { case .small: - font = CardParts.theme.smallAttributedTextFont - textColor = CardParts.theme.smallAttributedTextColor + DispatchQueue.main.async { [weak self] in + self?.font = CardParts.theme.smallAttributedTextFont + self?.textColor = CardParts.theme.smallAttributedTextColor + } case .normal: - font = CardParts.theme.normalAttributedTextFont - textColor = CardParts.theme.normalAttributedTextColor + DispatchQueue.main.async { [weak self] in + self?.font = CardParts.theme.normalAttributedTextFont + self?.textColor = CardParts.theme.normalAttributedTextColor + } case .title: - font = CardParts.theme.titleAttributedTextFont - textColor = CardParts.theme.titleAttributedTextColor + DispatchQueue.main.async { [weak self] in + self?.font = CardParts.theme.titleAttributedTextFont + self?.textColor = CardParts.theme.titleAttributedTextColor + } case .header: - font = CardParts.theme.headerAttributedTextFont - textColor = CardParts.theme.headerAttributedTextColor + DispatchQueue.main.async { [weak self] in + self?.font = CardParts.theme.headerAttributedTextFont + self?.textColor = CardParts.theme.headerAttributedTextColor + } case .detail: - font = CardParts.theme.detailAttributedTextFont - textColor = CardParts.theme.detailAttributedTextColor - + DispatchQueue.main.async { [weak self] in + self?.font = CardParts.theme.detailAttributedTextFont + self?.textColor = CardParts.theme.detailAttributedTextColor + } } } diff --git a/CardParts/src/Classes/CardPartsTheme.swift b/CardParts/src/Classes/CardPartsTheme.swift index de434947..57b832d2 100644 --- a/CardParts/src/Classes/CardPartsTheme.swift +++ b/CardParts/src/Classes/CardPartsTheme.swift @@ -113,7 +113,7 @@ public class CardPartsMintTheme: CardPartsTheme { public var smallAttributedTextFont: UIFont = UIFont(name: "HelveticaNeue", size: CGFloat(10))! public var smallAttributedTextColor: UIColor = UIColor.color(136, green: 136, blue: 136) public var normalAttributedTextFont: UIFont = UIFont(name: "HelveticaNeue", size: CGFloat(12))! - public var normalAttributedTextColor: UIColor = UIColor.color(1, green: 1, blue: 255) + public var normalAttributedTextColor: UIColor = UIColor.color(136, green: 136, blue: 136) public var titleAttributedTextFont: UIFont = UIFont(name: "HelveticaNeue-Medium", size: CGFloat(16))! public var titleAttributedTextColor: UIColor = UIColor.color(17, green: 17, blue: 17) public var headerAttributedTextFont: UIFont = UIFont.turboGenericFontBlack(.header)