/
Provider.swift
88 lines (72 loc) · 2.78 KB
/
Provider.swift
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//
// Provider.swift
// AFNetworking
//
// Created by ben3 on 24/04/2021.
//
import Foundation
public class Provider {
public func sectionNib() -> UINib {
return UINib(nibName: "SectionCell", bundle: Bundle(for: SectionCell.self))
}
public func makeBackground(blur: Bool = true) -> UIView {
if blur {
var background: UIVisualEffectView
if #available(iOS 13.0, *) {
background = UIVisualEffectView(effect: UIBlurEffect(style: .systemThinMaterial))
} else {
background = UIVisualEffectView(effect: UIBlurEffect(style: .light))
}
background.autoresizingMask = [.flexibleWidth, .flexibleHeight]
return background
} else {
let background = UIView()
background.backgroundColor = ChatKit.asset(color: "background")
return background
}
}
public func sectionView(for section: Section) -> UIView? {
let view: SectionCell = .fromNib()
view.titleLabel.text = section.date().dateAgo()
let background = makeBackground()
view.backgroundView.addSubview(background)
background.keepInsets.equal = 0
return view
}
public func messageReplyView() -> MessageReplyView {
let view: MessageReplyView = .fromNib()
return view
}
public func optionCellView() -> OptionCellView {
let view: OptionCellView = .fromNib()
view.background.layer.cornerRadius = 5
view.background.backgroundColor = ChatKit.asset(color: ChatKit.config().chatOptionsIconBackgroundColor)
view.label.textColor = ChatKit.asset(color: ChatKit.config().chatOptionsTextColor)
view.imageView.tintColor = ChatKit.asset(color: ChatKit.config().chatOptionsIconColor)
return view
}
public func messagesView() -> MessagesView {
return MessagesView()
}
public func chatHeaderView() -> ChatHeaderView {
return ChatHeaderView()
}
public func reconnectingView() -> ReconnectingView {
return ReconnectingView()
}
public func replyView() -> ReplyView {
return ReplyView()
}
public func chatToolbar(_ delegate: ChatToolbarDelegate, actions: ChatToolbarActionsDelegate) -> ChatToolbar {
let toolbar = ChatToolbar(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 35))
toolbar.setActionsDelegate(actions)
toolbar.setDelegate(delegate)
return toolbar
}
public func sendBarView() -> SendBarView {
return SendBarView()
}
public func messagesModel(_ thread: Thread, delegate: PMessagesModelDelegate) -> MessagesModel {
return MessagesModel(thread, delegate: delegate)
}
}