import UIKit
import Eureka

class MultilineLinkCell: MultilineLabelCell {
    required init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    override func update() {
        super.update()
        
        self.textLabel?.text = nil
        self.detailTextLabel?.text = nil
        
        self.title.text = row.title
        
        if let url = row.value {
            self.value.attributedText = NSAttributedString(string: url, attributes: [
                .link: url
            ])
        } else {
            self.title.attributedText = NSAttributedString(string: "")
        }
    }
}

final class MultilineLinkRow: Row<MultilineLinkCell>, RowType {
    required init(tag: String?) {
        super.init(tag: tag)
        cellProvider = CellProvider<MultilineLinkCell>()
    }
}
