diff --git a/Sources/Views/Products/Detail/ProductAttributes/AttributeTableViewCell.swift b/Sources/Views/Products/Detail/ProductAttributes/AttributeTableViewCell.swift index 0c2c04f6deb..b934e087e11 100644 --- a/Sources/Views/Products/Detail/ProductAttributes/AttributeTableViewCell.swift +++ b/Sources/Views/Products/Detail/ProductAttributes/AttributeTableViewCell.swift @@ -100,23 +100,20 @@ class AttributeBLTNPageItem: BLTNPageItem { var attributeView: AttributeView? override func makeHeaderViews(with interfaceBuilder: BLTNInterfaceBuilder) -> [UIView]? { - if let attributeV = attributeView { - var views = [UIView]() - - let viewB = UIView() - viewB.backgroundColor = iconImageBackgroundColor + let containerA = UIView() + containerA.backgroundColor = iconImageBackgroundColor if let attributeV = attributeView { - viewB.addSubview(attributeV) + containerA.addSubview(attributeV) - constrain(attributeV, viewB) { (attributeV, viewB) in - viewB.width == attributeV.width - viewB.height == attributeV.height - attributeV.edges == viewB.edges + constrain(attributeV, containerA) { (attributeV, containerA) in + containerA.width == attributeV.width + containerA.height == attributeV.height + attributeV.edges == containerA.edges } - var views: [UIView] = [viewB] + var views: [UIView] = [containerA] if let attribute = attribute { let descriptionLabel = UILabel() @@ -124,7 +121,7 @@ class AttributeBLTNPageItem: BLTNPageItem { descriptionLabel.textAlignment = .center descriptionLabel.font = UIFont.boldSystemFont(ofSize: 17) - descriptionLabel.text = attribute.descriptionLong ?? attribute.descriptionShort ?? "empty descriptions" + descriptionLabel.text = attribute.descriptionLong ?? attribute.descriptionShort ?? "empty description" views.append(descriptionLabel) } return views diff --git a/Sources/Views/Products/Detail/ProductAttributes/AttributeView.swift b/Sources/Views/Products/Detail/ProductAttributes/AttributeView.swift index d0af695cccd..9decd42ef49 100644 --- a/Sources/Views/Products/Detail/ProductAttributes/AttributeView.swift +++ b/Sources/Views/Products/Detail/ProductAttributes/AttributeView.swift @@ -23,7 +23,7 @@ import Cartography func configure(_ attribute: Attribute) { self.layer.cornerRadius = 5 self.attribute = attribute - //setIconImageView(imageURL: attribute.iconUrl) + setIconImageView(imageURL: attribute.iconUrl) if let label = attribute.name, let description = attribute.descriptionShort ?? attribute.title { let text = formatAttributedText(label: label, description: description) descriptionShort.attributedText = text @@ -72,9 +72,7 @@ extension AttributeView: formatAttributedString { var boldWordsPattern: String { return "(_\\w+_)" } func formatAttributedText(label: String, description: String) -> NSMutableAttributedString? { - let headline = UIFont(descriptor: UIFontDescriptor.preferredFontDescriptor(withTextStyle: UIFont.TextStyle.headline), size: UIFontDescriptor.preferredFontDescriptor(withTextStyle: UIFont.TextStyle.headline).pointSize) - - let value = NSAttributedString(string: description) + let headline = UIFont(descriptor: UIFontDescriptor.preferredFontDescriptor(withTextStyle: UIFont.TextStyle.headline), size: UIFontDescriptor.preferredFontDescriptor(withTextStyle: UIFont.TextStyle.caption1).pointSize) var bold: [NSAttributedString.Key: Any] = [:] if #available(iOS 13.0, *) { bold = [NSAttributedString.Key.foregroundColor: UIColor.label, NSAttributedString.Key.font: headline] @@ -82,10 +80,18 @@ extension AttributeView: formatAttributedString { bold = [NSAttributedString.Key.foregroundColor: UIColor.black, NSAttributedString.Key.font: headline] } + let body = UIFont(descriptor: UIFontDescriptor.preferredFontDescriptor(withTextStyle: UIFont.TextStyle.body), size: UIFontDescriptor.preferredFontDescriptor(withTextStyle: UIFont.TextStyle.caption2).pointSize) + var regular: [NSAttributedString.Key: Any] = [:] + if #available(iOS 13.0, *) { + regular = [NSAttributedString.Key.foregroundColor: UIColor.label, NSAttributedString.Key.font: body] + } else { + regular = [NSAttributedString.Key.foregroundColor: UIColor.black, NSAttributedString.Key.font: body] + } let combination = NSMutableAttributedString() combination.append(NSAttributedString(string: label + "\n", attributes: bold)) - combination.append(makeWordsBold(for: value)) + let descrip = NSAttributedString(string: description, attributes: regular) + combination.append(descrip) return combination } diff --git a/Sources/Views/Products/Detail/ProductAttributes/AttributeView.xib b/Sources/Views/Products/Detail/ProductAttributes/AttributeView.xib index 194caaf63ea..69ee1556323 100644 --- a/Sources/Views/Products/Detail/ProductAttributes/AttributeView.xib +++ b/Sources/Views/Products/Detail/ProductAttributes/AttributeView.xib @@ -28,7 +28,7 @@ - + @@ -54,7 +54,4 @@ - - -