git.iko.soy/dashared/GDproject
on 46b3bdf help sign in
GDproject/Base.lproj/Main.storyboard+9−2
since splitsnapshots
unifiedsplit
@@ -846,7 +846,7 @@
846 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
846 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
847 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
847 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
848 <prototypes>
848 <prototypes>
849− <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="peopleToWriteCell" textLabel="e4H-yo-W57" style="IBUITableViewCellStyleDefault" id="5ue-Sf-Blf">
849+ <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="peopleToWriteCell" textLabel="e4H-yo-W57" detailTextLabel="QSb-Bd-4gu" style="IBUITableViewCellStyleValue1" id="5ue-Sf-Blf">
850 <rect key="frame" x="0.0" y="28" width="375" height="44"/>
850 <rect key="frame" x="0.0" y="28" width="375" height="44"/>
851 <autoresizingMask key="autoresizingMask"/>
851 <autoresizingMask key="autoresizingMask"/>
852 <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="5ue-Sf-Blf" id="8Dr-YE-x7M">
852 <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="5ue-Sf-Blf" id="8Dr-YE-x7M">
@@ -854,7 +854,14 @@
854 <autoresizingMask key="autoresizingMask"/>
854 <autoresizingMask key="autoresizingMask"/>
855 <subviews>
855 <subviews>
856 <label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="e4H-yo-W57">
856 <label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="e4H-yo-W57">
857− <rect key="frame" x="16" y="0.0" width="343" height="43.5"/>
857+ <rect key="frame" x="16" y="12" width="33.5" height="20.5"/>
858+ <autoresizingMask key="autoresizingMask"/>
859+ <fontDescription key="fontDescription" type="system" pointSize="17"/>
860+ <nil key="textColor"/>
861+ <nil key="highlightedColor"/>
862+ </label>
863+ <label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="QSb-Bd-4gu">
864+ <rect key="frame" x="315" y="12" width="44" height="20.5"/>
858 <autoresizingMask key="autoresizingMask"/>
865 <autoresizingMask key="autoresizingMask"/>
859 <fontDescription key="fontDescription" type="system" pointSize="17"/>
866 <fontDescription key="fontDescription" type="system" pointSize="17"/>
860 <nil key="textColor"/>
867 <nil key="textColor"/>
GDproject/Controller/ News and channels/NewPostViewController.swift+4−18
@@ -232,27 +232,13 @@ 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..."
236− Model.createAndPublish(body: [Model.Attachments(markdown: textView!.text)], tags: currentTags) {
235+ Model.createAndPublish(body: [Model.Attachments(markdown: textView!.text)], tags: currentTags)
237− [weak self] in
238−
239− switch $0 {
240− case .success1, .success:
241− NewPostViewController.draft = ""
242− NewPostViewController.hashTagsDraft = []
243− self?.moveBackToParentVC?()
244− default:
245− self?.showAlertOn(result: $0)
246− self?.navigationItem.title = "New post"
247− }
248−
249− }
250
236
251− // NewPostViewController.draft = ""
237+ NewPostViewController.draft = ""
252− // NewPostViewController.hashTagsDraft = []
238+ NewPostViewController.hashTagsDraft = []
253 // adding row to uiTableView after adding new post
239 // adding row to uiTableView after adding new post
254 // myProtocol?.addPost(post: p)
240 // myProtocol?.addPost(post: p)
255− // moveBackToParentVC?()
241+ moveBackToParentVC?()
256 // somewhere here i will be sending server notifications about new post arrival
242 // somewhere here i will be sending server notifications about new post arrival
257 }
243 }
258
244
GDproject/Controller/ News and channels/NewsVC.swift+1−3
@@ -19,9 +19,7 @@ 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)
23− markdownParser.code.textBackgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
22+ markdownParser.code.textBackgroundColor = #colorLiteral(red: 0.8039215803, green: 0.8039215803, blue: 0.8039215803, alpha: 1)
24− markdownParser.code.color = #colorLiteral(red: 0.2549019754, green: 0.2745098174, blue: 0.3019607961, alpha: 1)
25
23
26 return markdownParser.parse(markdown)
24 return markdownParser.parse(markdown)
27 }
25 }
GDproject/Controller/Log In/RegisterTableViewController.swift−1
@@ -50,7 +50,6 @@ class RegisterTableViewController: UITableViewController, ChosenFactulty
50 {
50 {
51 super.viewDidLoad()
51 super.viewDidLoad()
52
52
53− navigationItem.largeTitleDisplayMode = .never
54 tableView.keyboardDismissMode = .interactive
53 tableView.keyboardDismissMode = .interactive
55 navigationItem.title = user.email
54 navigationItem.title = user.email
56 navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(endRegistration))
55 navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(endRegistration))
GDproject/Controller/Messages/Dialog/DialogViewController.swift+4−12
@@ -61,9 +61,7 @@ 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−
67 navigationItem.largeTitleDisplayMode = .never
65 navigationItem.largeTitleDisplayMode = .never
68
66
69 tableView.keyboardDismissMode = .onDrag
67 tableView.keyboardDismissMode = .onDrag
@@ -116,7 +114,6 @@ class DialogViewController: UIViewController, UpdatableGroup, UITableViewDelegat
116 let button = UIButton()
114 let button = UIButton()
117 button.setTitle("Send", for: .normal)
115 button.setTitle("Send", for: .normal)
118 button.setTitleColor(.blue, for: .normal)
116 button.setTitleColor(.blue, for: .normal)
119− button.titleLabel?.font = UIFont.systemFont(ofSize: 17, weight: .semibold)
120 button.addTarget(self, action: #selector(sendMessage), for: .touchUpInside)
117 button.addTarget(self, action: #selector(sendMessage), for: .touchUpInside)
121 return button
118 return button
122 }()
119 }()
@@ -135,13 +132,8 @@ class DialogViewController: UIViewController, UpdatableGroup, UITableViewDelegat
135 {
132 {
136 Model.sendMessage(message: Model.SendMessage(body: Model.Attachments(markdown: messageTextView.text), destination: destination)) { [unowned self] in
133 Model.sendMessage(message: Model.SendMessage(body: Model.Attachments(markdown: messageTextView.text), destination: destination)) { [unowned self] in
137
134
138− switch $0 {
139− case .success, .success1:
140− self.getMessagesNew(for: self.dialog!)
135+ self.getMessagesNew(for: self.dialog!)
141− self.messageTextView.text = ""
136+ self.messageTextView.text = ""
142− default:
143− self.showAlertOn(result: $0)
144− }
145 }
137 }
146
138
147 prevLast = -1
139 prevLast = -1
@@ -323,7 +315,7 @@ class DialogViewController: UIViewController, UpdatableGroup, UITableViewDelegat
323 var canBePaginated = false
315 var canBePaginated = false
324 func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath)
316 func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath)
325 {
317 {
326− if indexPath.row == cellData.count - 1 && prevLast != indexPath.row && canBePaginated && cellData.count >= 24
318+ if indexPath.row == cellData.count - 1 && prevLast != indexPath.row && canBePaginated && cellData.count >= 9
327 {
319 {
328 print("exclusiveFrom \(currentMessagesInChat.last?.id ?? 0)")
320 print("exclusiveFrom \(currentMessagesInChat.last?.id ?? 0)")
329 if let dialog = dialog
321 if let dialog = dialog
GDproject/Controller/Messages/MessagesViewController.swift+4−102
@@ -8,44 +8,8 @@
8
8
9import UIKit
9import UIKit
10
10
11−protocol SelectableDialog: class {
11+class MessagesViewController: UITableViewController {
12− func openDialog(with dialog: Model.Dialog)
13−}
14
12
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−
49 // curreent Active which can be displayed
13 // curreent Active which can be displayed
50 var currentActiveDialogs: [Model.Dialog] = [] {
14 var currentActiveDialogs: [Model.Dialog] = [] {
51 didSet {
15 didSet {
@@ -53,17 +17,6 @@ class MessagesViewController: UITableViewController, UISearchControllerDelegate,
53 }
17 }
54 }
18 }
55
19
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−
67 // curreent users
20 // curreent users
68 var users: [Int: Model.Users] = [:]
21 var users: [Int: Model.Users] = [:]
69
22
@@ -71,22 +24,17 @@ class MessagesViewController: UITableViewController, UISearchControllerDelegate,
71
24
72 var onDialogDisplay: (((dialog: Model.Dialog, users: [Int:Model.Users]))->())?
25 var onDialogDisplay: (((dialog: Model.Dialog, users: [Int:Model.Users]))->())?
73
26
74− var searchController: UISearchController?
27+ let searchC = UISearchController(searchResultsController: nil)
75
28
76 override func viewDidLoad() {
29 override func viewDidLoad() {
77 super.viewDidLoad()
30 super.viewDidLoad()
78−
31+
79− let updater = SuggestedDialogsTableViewController()
80−
81− updater.delegate = self
82− searchController = UISearchController(searchResultsController: updater)
83−
84 // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
32 // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
85 self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Write", style: .plain, target: self, action: #selector(choosePerson))
33 self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Write", style: .plain, target: self, action: #selector(choosePerson))
86
34
87 self.navigationItem.title = "Messages"
35 self.navigationItem.title = "Messages"
88 // self.navigationItem.largeTitleDisplayMode = .always
36 // self.navigationItem.largeTitleDisplayMode = .always
89− setUpSearchContr()
37+ self.navigationItem.searchController = searchC
90 navigationController?.navigationBar.prefersLargeTitles = true
38 navigationController?.navigationBar.prefersLargeTitles = true
91 self.navigationItem.hidesSearchBarWhenScrolling = false
39 self.navigationItem.hidesSearchBarWhenScrolling = false
92 }
40 }
@@ -133,49 +81,3 @@ class MessagesViewController: UITableViewController, UISearchControllerDelegate,
133 onDialogDisplay?(tuple)
81 onDialogDisplay?(tuple)
134 }
82 }
135}
83}
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+4−16
@@ -427,7 +427,7 @@ class Model{
427 }
427 }
428
428
429
429
430− static func createAndPublish(body: [Attachments], tags: [String], completion: @escaping ((ResultR)->())){
430+ static func createAndPublish(body: [Attachments], tags: [String]){
431 let jsonUpd = CreatedPost(body: body, tags: tags)
431 let jsonUpd = CreatedPost(body: body, tags: tags)
432 var request = URLRequest(url: postsPublishURL)
432 var request = URLRequest(url: postsPublishURL)
433
433
@@ -445,14 +445,6 @@ class Model{
445 if let code = response.response?.statusCode, code == 498 {
445 if let code = response.response?.statusCode, code == 498 {
446 return
446 return
447 }
447 }
448−
449− if let code = response.response?.statusCode,
450− let result = ResultR(rawValue: code)
451− {
452− completion(result)
453− } else {
454− completion(.internalServerError)
455− }
456 }
448 }
457 }
449 }
458
450
@@ -953,7 +945,7 @@ class Model{
953 }
945 }
954 }
946 }
955
947
956− static func getMessagesFor(typeOfChat: Model.Dialog, chat id: Int, exclusiveFrom: Int? = nil, limit l: Int = 25, direction: String = "backward", completion: @escaping (([LastMessage])->()))
948+ static func getMessagesFor(typeOfChat: Model.Dialog, chat id: Int, exclusiveFrom: Int? = nil, limit l: Int = 10, direction: String = "backward", completion: @escaping (([LastMessage])->()))
957 {
949 {
958 let req = GeneralRequest<Int>(direction: direction, limit: l, exclusiveFrom: exclusiveFrom, request: id)
950 let req = GeneralRequest<Int>(direction: direction, limit: l, exclusiveFrom: exclusiveFrom, request: id)
959 var request: URLRequest?
951 var request: URLRequest?
@@ -1056,7 +1048,7 @@ class Model{
1056 }
1048 }
1057 }
1049 }
1058
1050
1059− static func sendMessage(message: SendMessage, completion: @escaping ((ResultR)->())){
1051+ static func sendMessage(message: SendMessage, completion: @escaping (()->())){
1060
1052
1061 var request = URLRequest(url: messagesSendURL)
1053 var request = URLRequest(url: messagesSendURL)
1062 request.setValue("application/json; charset=utf-8", forHTTPHeaderField: "Content-Type")
1054 request.setValue("application/json; charset=utf-8", forHTTPHeaderField: "Content-Type")
@@ -1070,11 +1062,7 @@ class Model{
1070 return
1062 return
1071 }
1063 }
1072
1064
1073− if let result = ResultR(rawValue: response.response!.statusCode){
1074− completion(result)
1075− } else {
1076− completion(.internalServerError)
1065+ completion()
1077− }
1078 }
1066 }
1079 }
1067 }
1080
1068