Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.02 KB | None | 0 0
  1. func configure(with object: AnyObject) {
  2.         guard let cellModel = object as? CartSoldoutCellModel else { return }
  3.        
  4.         model = cellModel
  5.         let product = cellModel.cartProduct
  6.         guard let productName = product.name else { return }
  7.        
  8.         let productNameAttributed = (productName + "\n").color(UIColor.iosTurquoiseColor()).underlined().font(UIFont.regular(14))
  9.        
  10.         var optionsText = ""
  11.         if let options = product.options, options.count > 0 {
  12.             let optionsStrings: [String] = options.map { "\($0.title): \($0.value)" }
  13.             optionsText = "(\(optionsStrings.joined(separator: " | "))) "
  14.         }
  15.        
  16.         var errorText = ""
  17.        
  18.         if let errorMessage = product.combinedErrors() {
  19.             errorText = errorMessage
  20.         }
  21.        
  22.         let labelText = productNameAttributed + (optionsText + errorText).font(UIFont.regular(14)).color(UIColor.iosNightgrayColor())
  23.        
  24.         soldoutLabel.attributedText = labelText
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement