ConversationCell.swift 2.63 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
 *  Copyright (C) 2017 Savoir-faire Linux Inc.
 *
 *  Author: Silbino Gonçalves Matado <silbino.gmatado@savoirfairelinux.com>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
 */

import UIKit
import RxSwift
23
import Reusable
24

25
class ConversationCell: UITableViewCell, NibReusable {
26

27
    @IBOutlet weak var fallbackAvatar: UILabel!
28
    @IBOutlet weak var profileImage: UIImageView!
29
    @IBOutlet weak var fallbackAvatarImage: UIImageView!
30 31 32 33 34
    @IBOutlet weak var nameLabel: UILabel!
    @IBOutlet weak var newMessagesIndicator: UIView!
    @IBOutlet weak var newMessagesLabel: UILabel!
    @IBOutlet weak var lastMessageDateLabel: UILabel!
    @IBOutlet weak var lastMessagePreviewLabel: UILabel!
35
    @IBOutlet weak var presenceIndicator: UIView!
36 37

    override func setSelected(_ selected: Bool, animated: Bool) {
38 39 40
        let presenceBGColor = self.presenceIndicator.backgroundColor
        let fallbackAvatarBGColor = self.fallbackAvatar.backgroundColor
        let newMessagesIndicatorBGColor = self.newMessagesIndicator.backgroundColor
41
        super.setSelected(selected, animated: animated)
42 43 44
        self.newMessagesIndicator.backgroundColor = newMessagesIndicatorBGColor
        self.presenceIndicator.backgroundColor = presenceBGColor
        self.fallbackAvatar.backgroundColor = fallbackAvatarBGColor
45 46 47
    }

    override func setHighlighted(_ highlighted: Bool, animated: Bool) {
48 49 50 51 52 53 54
        let presenceBGColor = self.presenceIndicator.backgroundColor
        let fallbackAvatarBGColor = self.fallbackAvatar.backgroundColor
        let newMessagesIndicatorBGColor = self.newMessagesIndicator.backgroundColor
        super.setSelected(highlighted, animated: animated)
        self.newMessagesIndicator.backgroundColor = newMessagesIndicatorBGColor
        self.presenceIndicator.backgroundColor = presenceBGColor
        self.fallbackAvatar.backgroundColor = fallbackAvatarBGColor
55
    }
56 57 58 59 60 61

    var disposeBag = DisposeBag()

    override func prepareForReuse() {
        self.disposeBag = DisposeBag()
    }
62
}