git.iko.soy/dashared/GDproject
on master help sign in
GDproject/Controller/ News and channels/NewPostViewController.swift+3−1
since splitsnapshots
unifiedsplit
@@ -232,6 +232,7 @@ class NewPostViewController: UIViewController, UITextViewDelegate, TagsReceiver
232 var indexOfPost = 0
232 var indexOfPost = 0
233 // MARK:- new post
233 // MARK:- new post
234 @objc func newPost(){
234 @objc func newPost(){
235+ self.navigationItem.title = "Sending..."
235 Model.createAndPublish(body: [Model.Attachments(markdown: textView!.text)], tags: currentTags) {
236 Model.createAndPublish(body: [Model.Attachments(markdown: textView!.text)], tags: currentTags) {
236 [weak self] in
237 [weak self] in
237
238
@@ -241,9 +242,10 @@ class NewPostViewController: UIViewController, UITextViewDelegate, TagsReceiver
241 NewPostViewController.hashTagsDraft = []
242 NewPostViewController.hashTagsDraft = []
242 self?.moveBackToParentVC?()
243 self?.moveBackToParentVC?()
243 default:
244 default:
244− // self?.actionSaveDraft()
245 self?.showAlertOn(result: $0)
245 self?.showAlertOn(result: $0)
246+ self?.navigationItem.title = "New post"
246 }
247 }
248+
247 }
249 }
248
250
249 // NewPostViewController.draft = ""
251 // NewPostViewController.draft = ""
GDproject/Controller/ News and channels/NewsVC.swift+3−1
@@ -19,7 +19,9 @@ struct PostCellData{
19
19
20 let markdownParser = MarkdownParser(font: UIFont.systemFont(ofSize: 16))
20 let markdownParser = MarkdownParser(font: UIFont.systemFont(ofSize: 16))
21 markdownParser.enabledElements = .disabledAutomaticLink
21 markdownParser.enabledElements = .disabledAutomaticLink
22+ markdownParser.code.font = UIFont(name: "Menlo", size: 16)
22− markdownParser.code.textBackgroundColor = #colorLiteral(red: 0.8039215803, green: 0.8039215803, blue: 0.8039215803, alpha: 1)
23+ markdownParser.code.textBackgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
24+ markdownParser.code.color = #colorLiteral(red: 0.2549019754, green: 0.2745098174, blue: 0.3019607961, alpha: 1)
23
25
24 return markdownParser.parse(markdown)
26 return markdownParser.parse(markdown)
25 }
27 }
GDproject/Controller/Log In/RegisterTableViewController.swift+1
@@ -50,6 +50,7 @@ class RegisterTableViewController: UITableViewController, ChosenFactulty
50 {
50 {
51 super.viewDidLoad()
51 super.viewDidLoad()
52
52
53+ navigationItem.largeTitleDisplayMode = .never
53 tableView.keyboardDismissMode = .interactive
54 tableView.keyboardDismissMode = .interactive
54 navigationItem.title = user.email
55 navigationItem.title = user.email
55 navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(endRegistration))
56 navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(endRegistration))
GDproject/Controller/Messages/Dialog/DialogViewController.swift+5−2
@@ -61,7 +61,9 @@ class DialogViewController: UIViewController, UpdatableGroup, UITableViewDelegat
61
61
62 self.tableView.delegate = self
62 self.tableView.delegate = self
63 self.tableView.dataSource = self
63 self.tableView.dataSource = self
64−
64+
65+ tableView.setContentOffset(CGPoint(x: 0, y: 50), animated: false)
66+
65 navigationItem.largeTitleDisplayMode = .never
67 navigationItem.largeTitleDisplayMode = .never
66
68
67 tableView.keyboardDismissMode = .onDrag
69 tableView.keyboardDismissMode = .onDrag
@@ -114,6 +116,7 @@ class DialogViewController: UIViewController, UpdatableGroup, UITableViewDelegat
114 let button = UIButton()
116 let button = UIButton()
115 button.setTitle("Send", for: .normal)
117 button.setTitle("Send", for: .normal)
116 button.setTitleColor(.blue, for: .normal)
118 button.setTitleColor(.blue, for: .normal)
119+ button.titleLabel?.font = UIFont.systemFont(ofSize: 17, weight: .semibold)
117 button.addTarget(self, action: #selector(sendMessage), for: .touchUpInside)
120 button.addTarget(self, action: #selector(sendMessage), for: .touchUpInside)
118 return button
121 return button
119 }()
122 }()
@@ -320,7 +323,7 @@ class DialogViewController: UIViewController, UpdatableGroup, UITableViewDelegat
320 var canBePaginated = false
323 var canBePaginated = false
321 func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath)
324 func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath)
322 {
325 {
323− if indexPath.row == cellData.count - 1 && prevLast != indexPath.row && canBePaginated && cellData.count >= 9
326+ if indexPath.row == cellData.count - 1 && prevLast != indexPath.row && canBePaginated && cellData.count >= 24
324 {
327 {
325 print("exclusiveFrom \(currentMessagesInChat.last?.id ?? 0)")
328 print("exclusiveFrom \(currentMessagesInChat.last?.id ?? 0)")
326 if let dialog = dialog
329 if let dialog = dialog
GDproject/Controller/Messages/MessagesViewController.swift+102−4
@@ -8,8 +8,44 @@
8
8
9import UIKit
9import UIKit
10
10
11−class MessagesViewController: UITableViewController {
11+protocol SelectableDialog: class {
12+ func openDialog(with dialog: Model.Dialog)
13+}
12
14
15+class MessagesViewController: UITableViewController, UISearchControllerDelegate, UISearchResultsUpdating, SelectableDialog {
16+
17+ func openDialog(with dialog: Model.Dialog) {
18+ onDialogDisplay?((dialog, users))
19+ }
20+
21+ func updateSearchResults(for searchController: UISearchController) {
22+
23+ let filteredData = currentActiveDialogs
24+ let inputText = searchController.searchBar.text ?? ""
25+
26+ let filteredResults = filteredData.filter {
27+
28+ switch $0 {
29+ case .groupChat(let gropuChat):
30+ return gropuChat.group.name.contains(inputText)
31+
32+ case .userChat(let userChat):
33+ let user = users[userChat.user]
34+ guard let u = user else { return false }
35+ return u.fullName().contains(inputText)
36+
37+ }
38+
39+ }
40+
41+ // Apply the filtered results to the search results table.
42+ if let resultsController = searchController.searchResultsController as? SuggestedDialogsTableViewController {
43+ resultsController.users = users
44+ resultsController.currentDialogs = filteredResults
45+ resultsController.tableView.reloadData()
46+ }
47+ }
48+
13 // curreent Active which can be displayed
49 // curreent Active which can be displayed
14 var currentActiveDialogs: [Model.Dialog] = [] {
50 var currentActiveDialogs: [Model.Dialog] = [] {
15 didSet {
51 didSet {
@@ -17,6 +53,17 @@ class MessagesViewController: UITableViewController {
17 }
53 }
18 }
54 }
19
55
56+ func setUpSearchContr(){
57+
58+ searchController?.delegate = self
59+ searchController?.obscuresBackgroundDuringPresentation = true
60+ navigationItem.searchController = searchController
61+ definesPresentationContext = true
62+ searchController?.searchResultsUpdater = self
63+ searchController?.searchBar.placeholder = "Search dialogs"
64+
65+ }
66+
20 // curreent users
67 // curreent users
21 var users: [Int: Model.Users] = [:]
68 var users: [Int: Model.Users] = [:]
22
69
@@ -24,17 +71,22 @@ class MessagesViewController: UITableViewController {
24
71
25 var onDialogDisplay: (((dialog: Model.Dialog, users: [Int:Model.Users]))->())?
72 var onDialogDisplay: (((dialog: Model.Dialog, users: [Int:Model.Users]))->())?
26
73
27− let searchC = UISearchController(searchResultsController: nil)
74+ var searchController: UISearchController?
28
75
29 override func viewDidLoad() {
76 override func viewDidLoad() {
30 super.viewDidLoad()
77 super.viewDidLoad()
31−
78+
79+ let updater = SuggestedDialogsTableViewController()
80+
81+ updater.delegate = self
82+ searchController = UISearchController(searchResultsController: updater)
83+
32 // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
84 // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
33 self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Write", style: .plain, target: self, action: #selector(choosePerson))
85 self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Write", style: .plain, target: self, action: #selector(choosePerson))
34
86
35 self.navigationItem.title = "Messages"
87 self.navigationItem.title = "Messages"
36 // self.navigationItem.largeTitleDisplayMode = .always
88 // self.navigationItem.largeTitleDisplayMode = .always
37− self.navigationItem.searchController = searchC
89+ setUpSearchContr()
38 navigationController?.navigationBar.prefersLargeTitles = true
90 navigationController?.navigationBar.prefersLargeTitles = true
39 self.navigationItem.hidesSearchBarWhenScrolling = false
91 self.navigationItem.hidesSearchBarWhenScrolling = false
40 }
92 }
@@ -81,3 +133,49 @@ class MessagesViewController: UITableViewController {
81 onDialogDisplay?(tuple)
133 onDialogDisplay?(tuple)
82 }
134 }
83}
135}
136+
137+
138+class SuggestedDialogsTableViewController: UITableViewController {
139+
140+ var idCell = "cell"
141+
142+ var users: [Int: Model.Users] = [:]
143+
144+ weak var delegate: SelectableDialog?
145+
146+ var currentDialogs: [Model.Dialog] = []
147+
148+ override func viewDidLoad() {
149+ super.viewDidLoad()
150+ tableView.register(UITableViewCell.self, forCellReuseIdentifier: idCell)
151+ tableView.reloadData()
152+ }
153+
154+ override func numberOfSections(in tableView: UITableView) -> Int {
155+ return 1
156+ }
157+
158+ override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
159+ return currentDialogs.count
160+ }
161+
162+ override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
163+ {
164+ let cell = tableView.dequeueReusableCell(withIdentifier: idCell, for: indexPath)
165+
166+ switch currentDialogs[indexPath.row] {
167+ case .groupChat(let groupChat):
168+ cell.textLabel?.text = groupChat.group.name
169+ case .userChat(let userChat):
170+ cell.textLabel?.text = users[userChat.user]?.fullName()
171+ }
172+
173+ cell.accessoryType = .disclosureIndicator
174+ return cell
175+ }
176+
177+ override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
178+ delegate?.openDialog(with: currentDialogs[indexPath.row])
179+ // self.dismiss(animated: true)
180+ }
181+}
GDproject/Controller/Profile/ProfileViewController.swift+1−1
@@ -159,7 +159,7 @@ class ProfileViewController: UIViewController, UpdateUser
159 }
159 }
160
160
161 func setUpNavigarionBar(){
161 func setUpNavigarionBar(){
162− navigationController?.navigationBar.prefersLargeTitles = true
162+ // navigationController?.navigationBar.prefersLargeTitles = true
163 let uibarbutton = UIBarButtonItem(title: "More", style: .plain, target: self, action: #selector(showInformation))
163 let uibarbutton = UIBarButtonItem(title: "More", style: .plain, target: self, action: #selector(showInformation))
164 navigationItem.rightBarButtonItems = [uibarbutton]
164 navigationItem.rightBarButtonItems = [uibarbutton]
165 navigationItem.largeTitleDisplayMode = .always
165 navigationItem.largeTitleDisplayMode = .always
GDproject/Simple model/Model.swift+1−1
@@ -953,7 +953,7 @@ class Model{
953 }
953 }
954 }
954 }
955
955
956− static func getMessagesFor(typeOfChat: Model.Dialog, chat id: Int, exclusiveFrom: Int? = nil, limit l: Int = 10, direction: String = "backward", completion: @escaping (([LastMessage])->()))
956+ static func getMessagesFor(typeOfChat: Model.Dialog, chat id: Int, exclusiveFrom: Int? = nil, limit l: Int = 25, direction: String = "backward", completion: @escaping (([LastMessage])->()))
957 {
957 {
958 let req = GeneralRequest<Int>(direction: direction, limit: l, exclusiveFrom: exclusiveFrom, request: id)
958 let req = GeneralRequest<Int>(direction: direction, limit: l, exclusiveFrom: exclusiveFrom, request: id)
959 var request: URLRequest?
959 var request: URLRequest?