<commit_before>//
//  ChatViewItem.swift
//  Umalahokan
//
//  Created by <NAME> on 18/03/2017.
//  Copyright © 2017 Ner. All rights reserved.
//

import Kingfisher

protocol ChatViewItem {

    var isOnline: Bool { get }
    var moodText: String { get }
    var moodColor: UIColor { get }
    var avatarUrl: URL? { get }
    var displayNameText: String { get }
}

protocol ChatViewConfiguration {
    
    func configure(_ item: ChatViewItem?, isPrototype: Bool)
}

extension ChatView: ChatViewConfiguration {
    
    func configure(_ item: ChatViewItem?, isPrototype: Bool = false) {
        guard let item = item else { return }
        
        if !isPrototype {
            if let url = item.avatarUrl {
                let resource = ImageResource(downloadURL: url)
                topBar.avatarImageView.kf.setImage(with: resource)
            
            } else {
                topBar.avatarImageView.image = nil
            }
        }
        
        topBar.displayNameLabel.text = item.displayNameText
        topBar.moodLabel.text = item.moodText
        topBar.moodIndicator.backgroundColor = item.moodColor
        topBar.onlineStatusIndicator.isHidden = !item.isOnline
        
        topBar.setNeedsLayout()
        topBar.layoutIfNeeded()
    }
}


<commit_msg>Extended RecentChatDisplayDataItem with ChatViewItem.<commit_after>//
//  ChatViewItem.swift
//  Umalahokan
//
//  Created by <NAME> on 18/03/2017.
//  Copyright © 2017 Ner. All rights reserved.
//

import Kingfisher

protocol ChatViewItem {

    var isOnline: Bool { get }
    var moodText: String { get }
    var moodColor: UIColor? { get }
    var avatarUrl: URL? { get }
    var displayNameText: String { get }
}

protocol ChatViewConfiguration {
    
    func configure(_ item: ChatViewItem?, isPrototype: Bool)
}

extension ChatView: ChatViewConfiguration {
    
    func configure(_ item: ChatViewItem?, isPrototype: Bool = false) {
        guard let item = item else { return }
        
        if !isPrototype {
            if let url = item.avatarUrl {
                let resource = ImageResource(downloadURL: url)
                topBar.avatarImageView.kf.setImage(with: resource)
            
            } else {
                topBar.avatarImageView.image = nil
            }
        }
        
        topBar.displayNameLabel.text = item.displayNameText
        topBar.moodLabel.text = item.moodText
        topBar.moodIndicator.backgroundColor = item.moodColor
        topBar.onlineStatusIndicator.isHidden = !item.isOnline
        
        topBar.setNeedsLayout()
        topBar.layoutIfNeeded()
    }
}

extension RecentChatDisplayDataItem: ChatViewItem { }

{'fraction_non_alphanumeric': 0.08602554470323065, 'fraction_numerical': 0.009015777610818933, 'mean_word_length': 2.1514792899408284, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1680463', 'n_tokens_mistral': 810, 'n_tokens_neox': 773, 'n_words': 182}