forked from RocketChat/Rocket.Chat.iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChatMessageTextViewModel.swift
More file actions
51 lines (40 loc) · 1.03 KB
/
ChatMessageTextViewModel.swift
File metadata and controls
51 lines (40 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// ChatMessageTextViewModel.swift
// Rocket.Chat
//
// Created by Rafael Machado on 01/04/17.
// Copyright © 2017 Rocket.Chat. All rights reserved.
//
import UIKit
import RealmSwift
final class ChatMessageTextViewModel {
var color: UIColor {
return attachment.color != nil
? UIColor(hex: attachment.color)
: UIColor.lightGray
}
var title: String {
return attachment.title
}
var text: String {
if attachment.titleLink.count > 0 {
return localized("chat.message.open_file")
}
return attachment.text ?? ""
}
var thumbURL: URL? {
return URL(string: attachment.thumbURL ?? "")
}
var collapsed: Bool {
return attachment.collapsed
}
let attachment: Attachment
init(withAttachment attachment: Attachment) {
self.attachment = attachment
}
func toggleCollpase() {
Realm.executeOnMainThread({ _ in
self.attachment.collapsed = !self.attachment.collapsed
})
}
}