Skip to content

Commit

Permalink
Card part attributed text patch (#225)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jl-codes authored and croossin committed Jan 22, 2020
1 parent 7902479 commit a52cd75
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
31 changes: 20 additions & 11 deletions CardParts/src/Classes/Card Parts/CardPartAttributedTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion CardParts/src/Classes/CardPartsTheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a52cd75

Please sign in to comment.