<commit_before>//
//  TweetTableViewCell.swift
//  Smashtag
//
//  Created by <NAME> on 1/5/16.
//  Copyright © 2016 USF. All rights reserved.
//

import UIKit

class TweetTableViewCell: UITableViewCell {
    
    var tweet: Tweet? {
        didSet {
            updateUI()
        }
    }

    @IBOutlet weak var tweetProfileImageView: UIImageView!
    @IBOutlet weak var tweetScreenNameLabel: UILabel!
    @IBOutlet weak var tweetTextLabel: UILabel!
    
    
    func updateUI() {
        // reset any existing tweet information
        tweetTextLabel?.attributedText = nil
        tweetScreenNameLabel?.text = nil
        tweetProfileImageView?.image = nil
//        tweetCreatedLabel?.text = nil
        
        // load new information from our tweet (if any)
        if let tweet = self.tweet {
            tweetTextLabel?.text = tweet.text
            if tweetTextLabel?.text != nil {
                
                // highlight mentions
                if let attributedString = tweetTextLabel?.attributedText {
                    let mutableAttributedString = NSMutableAttributedString(attributedString: attributedString)
                    for url in tweet.urls {
                        if let nsrange = url.nsrange {
                            mutableAttributedString.addAttribute(NSForegroundColorAttributeName,
                                value: UIColor.blueColor(),
                                range: nsrange)
                            mutableAttributedString.addAttribute(NSUnderlineStyleAttributeName,
                                value: NSUnderlineStyle.StyleSingle.rawValue,
                                range: nsrange)
                            tweetTextLabel.attributedText = mutableAttributedString
                        }
                    }
                    for hash in tweet.hashtags {
                        if let nsrange = hash.nsrange {
                            mutableAttributedString.addAttribute(NSForegroundColorAttributeName,
                                value: UIColor.blueColor(),
                                range: nsrange)
                            mutableAttributedString.addAttribute(NSFontAttributeName,
                                value: UIFont.boldSystemFontOfSize(15),
                                range: nsrange)
                            tweetTextLabel.attributedText = mutableAttributedString
                        }
                    }
                    for mention in tweet.userMentions {
                        if let nsrange = mention.nsrange {
                            mutableAttributedString.addAttribute(NSForegroundColorAttributeName,<commit_msg>Using preset font size instead of hard coded font size.<commit_after>//
//  TweetTableViewCell.swift
//  Smashtag
//
//  Created by <NAME> on 1/5/16.
//  Copyright © 2016 USF. All rights reserved.
//

import UIKit

class TweetTableViewCell: UITableViewCell {
    
    var tweet: Tweet? {
        didSet {
            updateUI()
        }
    }

    @IBOutlet weak var tweetProfileImageView: UIImageView!
    @IBOutlet weak var tweetScreenNameLabel: UILabel!
    @IBOutlet weak var tweetTextLabel: UILabel!
    
    
    func updateUI() {
        // reset any existing tweet information
        tweetTextLabel?.attributedText = nil
        tweetScreenNameLabel?.text = nil
        tweetProfileImageView?.image = nil
//        tweetCreatedLabel?.text = nil
        
        // load new information from our tweet (if any)
        if let tweet = self.tweet {
            tweetTextLabel?.text = tweet.text
            if tweetTextLabel?.text != nil {
                
                // highlight mentions
                if let attributedString = tweetTextLabel?.attributedText {
                    let mutableAttributedString = NSMutableAttributedString(attributedString: attributedString)
                    for url in tweet.urls {
                        if let nsrange = url.nsrange {
                            mutableAttributedString.addAttribute(NSForegroundColorAttributeName,
                                value: UIColor.blueColor(),
                                range: nsrange)
                            mutableAttributedString.addAttribute(NSUnderlineStyleAttributeName,
                                value: NSUnderlineStyle.StyleSingle.rawValue,
                                range: nsrange)
                            tweetTextLabel.attributedText = mutableAttributedString
                        }
                    }
                    for hash in tweet.hashtags {
                        if let nsrange = hash.nsrange {
                            mutableAttributedString.addAttribute(NSForegroundColorAttributeName,
                                value: UIColor.blueColor(),
                                range: nsrange)
                            mutableAttributedString.addAttribute(NSFontAttributeName,
                                value: UIFont.boldSystemFontOfSize(tweetTextLabel.font.pointSize),
                                range: nsrange)
                            tweetTextLabel.attributedText = mutableAttributedString
                        }
                    }
                    for mention in tweet.userMentions {
                        if let nsrange = mention.nsrange {
                            mutableAttributedString.addAttribute(NSForegroundColorAttributeName,
{'fraction_non_alphanumeric': 0.05799518250880119, 'fraction_numerical': 0.0033351862145636463, 'mean_word_length': 1.3727472527472528, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6591803', 'n_tokens_mistral': 1355, 'n_tokens_neox': 1228, 'n_words': 270}