git.iko.soy/dashared/GDproject
on 5ca9bbb help sign in
16 files changed+69−309
since splitsnapshots
unifiedsplit
GDproject.xcodeproj/project.pbxproj−4 GDproject/Base.lproj/Main.storyboard+21−38 GDproject/Controller/ News and channels/ChannelListController.swift+1−1 GDproject/Controller/ News and channels/ChannelViewController.swift+2−3 GDproject/Controller/ News and channels/NewPostViewController.swift+7−24 GDproject/Controller/ News and channels/NewsController.swift+1−2 GDproject/Controller/ News and channels/NewsVC.swift+1−3 GDproject/Controller/ News and channels/PostViewCell.swift+1−1 GDproject/Controller/Log In/RegisterTableViewController.swift−1 GDproject/Controller/Messages/ChatInfoViewController.swift+4−25 GDproject/Controller/Messages/Dialog/DialogViewController.swift+6−15 GDproject/Controller/Messages/MessageViewCell.swift−38 GDproject/Controller/Messages/MessagesViewController.swift+12−107 GDproject/Controller/Messages/PeopleToWriteViewController.swift+1 GDproject/Controller/Profile/ProfileViewController.swift+8−31 GDproject/Simple model/Model.swift+4−16
GDproject.xcodeproj/project.pbxproj−4
@@ -10,7 +10,6 @@
1010 1210A0BB223940310080686D /* SimplifiedChannelsList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1210A0BA223940310080686D /* SimplifiedChannelsList.swift */; };
1111 121A8972226B1EAC005EE599 /* TagsSuggestionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 121A8971226B1EAC005EE599 /* TagsSuggestionController.swift */; };
1212 1220FF94227C41270092C6BC /* TaggsSelectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1220FF93227C41270092C6BC /* TaggsSelectionViewController.swift */; };
13− 123589FD22899339002F8028 /* MessageViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123589FC22899339002F8028 /* MessageViewCell.swift */; };
1413 123E37A5221F1B3200F6E42A /* LogInViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123E37A4221F1B3200F6E42A /* LogInViewController.swift */; };
1514 123E37A7221F1DD700F6E42A /* MainController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123E37A6221F1DD700F6E42A /* MainController.swift */; };
1615 124CC7032221C00C009DF531 /* Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 124CC7022221C00C009DF531 /* Model.swift */; };
@@ -109,7 +108,6 @@
109108 1210A0BA223940310080686D /* SimplifiedChannelsList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimplifiedChannelsList.swift; sourceTree = "<group>"; };
110109 121A8971226B1EAC005EE599 /* TagsSuggestionController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagsSuggestionController.swift; sourceTree = "<group>"; };
111110 1220FF93227C41270092C6BC /* TaggsSelectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaggsSelectionViewController.swift; sourceTree = "<group>"; };
112− 123589FC22899339002F8028 /* MessageViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageViewCell.swift; sourceTree = "<group>"; };
113111 123E37A4221F1B3200F6E42A /* LogInViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogInViewController.swift; sourceTree = "<group>"; };
114112 123E37A6221F1DD700F6E42A /* MainController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainController.swift; sourceTree = "<group>"; };
115113 124CC7022221C00C009DF531 /* Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Model.swift; sourceTree = "<group>"; };
@@ -240,7 +238,6 @@
240238 129320082279C3B50035C7B3 /* PeopleToWriteViewController.swift */,
241239 1298810C227F138C0032ACA3 /* Dialog */,
242240 129320032279B4270035C7B3 /* MessagesViewController.swift */,
243− 123589FC22899339002F8028 /* MessageViewCell.swift */,
244241 );
245242 path = Messages;
246243 sourceTree = "<group>";
@@ -454,7 +451,6 @@
454451 1298810B227F13840032ACA3 /* DialogCell.swift in Sources */,
455452 125A9A922286100800513E2A /* FacultyTableViewController.swift in Sources */,
456453 125A9A8E2286068A00513E2A /* RegisterTableViewController.swift in Sources */,
457− 123589FD22899339002F8028 /* MessageViewCell.swift in Sources */,
458454 12E36DCC22144725006FCDD7 /* PostViewCell.swift in Sources */,
459455 123E37A5221F1B3200F6E42A /* LogInViewController.swift in Sources */,
460456 125BD57F22171D73008A3575 /* Extentions.swift in Sources */,
GDproject/Base.lproj/Main.storyboard+21−38
@@ -778,53 +778,29 @@
778778 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
779779 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
780780 <prototypes>
781− <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="MessageViewCell" rowHeight="78" id="67C-fT-WEV" customClass="MessageViewCell" customModule="GDproject" customModuleProvider="target">
782− <rect key="frame" x="0.0" y="28" width="375" height="78"/>
781+ <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="MessagesCell" textLabel="9br-gb-mg8" detailTextLabel="Jxd-We-VyC" style="IBUITableViewCellStyleSubtitle" id="67C-fT-WEV">
782+ <rect key="frame" x="0.0" y="28" width="375" height="44"/>
783783 <autoresizingMask key="autoresizingMask"/>
784784 <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="67C-fT-WEV" id="O3b-Xv-UNk">
785− <rect key="frame" x="0.0" y="0.0" width="375" height="77.5"/>
785+ <rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
786786 <autoresizingMask key="autoresizingMask"/>
787787 <subviews>
788− <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xAY-IF-RpX">
789− <rect key="frame" x="229" y="11" width="130" height="15"/>
790− <constraints>
791− <constraint firstAttribute="width" relation="greaterThanOrEqual" constant="130" id="f99-ZF-f8h"/>
792− </constraints>
793− <fontDescription key="fontDescription" type="system" pointSize="12"/>
794− <color key="textColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
795− <nil key="highlightedColor"/>
796− </label>
797− <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FG3-gU-0r1">
798− <rect key="frame" x="16" y="11" width="46" height="22"/>
799− <fontDescription key="fontDescription" type="system" weight="semibold" pointSize="18"/>
788+ <label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="9br-gb-mg8">
789+ <rect key="frame" x="16" y="5" width="33.5" height="20.5"/>
790+ <autoresizingMask key="autoresizingMask"/>
791+ <fontDescription key="fontDescription" type="system" pointSize="17"/>
800792 <nil key="textColor"/>
801793 <nil key="highlightedColor"/>
802794 </label>
803− <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nTy-rK-XTr">
804− <rect key="frame" x="16" y="49" width="343" height="18"/>
805− <fontDescription key="fontDescription" type="system" pointSize="15"/>
795+ <label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Detail" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Jxd-We-VyC">
796+ <rect key="frame" x="16" y="25.5" width="33" height="14.5"/>
797+ <autoresizingMask key="autoresizingMask"/>
798+ <fontDescription key="fontDescription" type="system" pointSize="12"/>
806799 <nil key="textColor"/>
807800 <nil key="highlightedColor"/>
808801 </label>
809802 </subviews>
810− <constraints>
811− <constraint firstItem="nTy-rK-XTr" firstAttribute="top" secondItem="xAY-IF-RpX" secondAttribute="bottom" constant="23" id="09Y-aK-nD9"/>
812− <constraint firstItem="FG3-gU-0r1" firstAttribute="top" secondItem="O3b-Xv-UNk" secondAttribute="topMargin" id="4Hp-d5-9An"/>
813− <constraint firstItem="xAY-IF-RpX" firstAttribute="top" secondItem="O3b-Xv-UNk" secondAttribute="topMargin" id="G4f-oJ-7ud"/>
814− <constraint firstItem="nTy-rK-XTr" firstAttribute="trailing" secondItem="O3b-Xv-UNk" secondAttribute="trailingMargin" id="MaE-VM-KhL"/>
815− <constraint firstItem="nTy-rK-XTr" firstAttribute="leading" secondItem="O3b-Xv-UNk" secondAttribute="leadingMargin" id="OIX-rY-Leo"/>
816− <constraint firstItem="nTy-rK-XTr" firstAttribute="top" secondItem="FG3-gU-0r1" secondAttribute="bottom" constant="16" id="Qdj-s3-t60"/>
817− <constraint firstItem="nTy-rK-XTr" firstAttribute="bottom" secondItem="O3b-Xv-UNk" secondAttribute="bottomMargin" id="Rv3-Mz-Aed"/>
818− <constraint firstItem="FG3-gU-0r1" firstAttribute="leading" secondItem="O3b-Xv-UNk" secondAttribute="leadingMargin" id="iN1-KG-dYn"/>
819− <constraint firstItem="xAY-IF-RpX" firstAttribute="trailing" secondItem="O3b-Xv-UNk" secondAttribute="trailingMargin" id="opV-4x-VCk"/>
820− <constraint firstItem="xAY-IF-RpX" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="FG3-gU-0r1" secondAttribute="trailing" constant="4" id="x9r-sM-t4x"/>
821− </constraints>
822803 </tableViewCellContentView>
823− <connections>
824− <outlet property="dateLabel" destination="xAY-IF-RpX" id="fcz-re-BXk"/>
825− <outlet property="dialogName" destination="FG3-gU-0r1" id="gd7-ND-wCi"/>
826− <outlet property="lastMessagePreview" destination="nTy-rK-XTr" id="Cmo-IJ-2r0"/>
827− </connections>
828804 </tableViewCell>
829805 </prototypes>
830806 <connections>
@@ -835,7 +811,7 @@
835811 </tableViewController>
836812 <placeholder placeholderIdentifier="IBFirstResponder" id="fu3-z4-EY7" userLabel="First Responder" sceneMemberID="firstResponder"/>
837813 </objects>
838− <point key="canvasLocation" x="2681" y="918"/>
814+ <point key="canvasLocation" x="2798" y="932"/>
839815 </scene>
840816 <!--People To Write View Controller-->
841817 <scene sceneID="6Td-bq-Ebf">
@@ -846,7 +822,7 @@
846822 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
847823 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
848824 <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">
825+ <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">
850826 <rect key="frame" x="0.0" y="28" width="375" height="44"/>
851827 <autoresizingMask key="autoresizingMask"/>
852828 <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 +830,14 @@
854830 <autoresizingMask key="autoresizingMask"/>
855831 <subviews>
856832 <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"/>
833+ <rect key="frame" x="16" y="12" width="33.5" height="20.5"/>
834+ <autoresizingMask key="autoresizingMask"/>
835+ <fontDescription key="fontDescription" type="system" pointSize="17"/>
836+ <nil key="textColor"/>
837+ <nil key="highlightedColor"/>
838+ </label>
839+ <label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="QSb-Bd-4gu">
840+ <rect key="frame" x="315" y="12" width="44" height="20.5"/>
858841 <autoresizingMask key="autoresizingMask"/>
859842 <fontDescription key="fontDescription" type="system" pointSize="17"/>
860843 <nil key="textColor"/>
GDproject/Controller/ News and channels/ChannelListController.swift+1−1
@@ -100,7 +100,7 @@ class ChannelListController: UITableViewController {
100100 @objc func addChannel()
101101 {
102102 // editing mode is on automatically
103− onEditingModeBegins?(Model.Channels(people: [], name: "Untitled", id: 0, tags: []),IndexPath(row: 1, section: 0))
103+ onEditingModeBegins?(Model.Channels(people: [], name: "Untitled", tags: []),IndexPath(row: 1, section: 0))
104104 }
105105
106106 static let generalChannel = Model.Channels(people: [], name: "General", id: -1, tags: [])
GDproject/Controller/ News and channels/ChannelViewController.swift+2−3
@@ -60,9 +60,8 @@ class ChannelViewController: UITableViewController, UpdatableName, UpdatableChan
6060 super.viewWillDisappear(animated)
6161 }
6262
63− guard let _ = self.navigationController?.viewControllers.lastIndex(of: self) else
64− {
65− if let id = channel?.id, id != 0
63+ guard let _ = self.navigationController?.viewControllers.lastIndex(of: self) else {
64+ if let _ = channel?.id
6665 {
6766 Model.updateChannel(with: channel!)
6867 } else {
GDproject/Controller/ News and channels/NewPostViewController.swift+7−24
@@ -41,7 +41,7 @@ class NewPostViewController: UIViewController, UITextViewDelegate, TagsReceiver
4141 let textStorage = MarklightTextStorage()
4242
4343 static var draft: String = ""
44− static var hashTagsDraft: [String] = [ ]
44+ static var hashTagsDraft: [String] = ["tt"]
4545
4646 var textView: UITextView!
4747
@@ -72,7 +72,7 @@ class NewPostViewController: UIViewController, UITextViewDelegate, TagsReceiver
7272
7373 setUpMD()
7474 setUpTextView()
75− // setUpAccessoryView()
75+ setUpAccessoryView()
7676 //setUpTagsView()
7777 }
7878
@@ -141,7 +141,7 @@ class NewPostViewController: UIViewController, UITextViewDelegate, TagsReceiver
141141 func setUpTextView(){
142142 view.addConstraint(bottomTextViewConstraint)
143143 view1.addSubview(textView)
144− textView.edgesToSuperview(insets: .top(8) + .left(8) + .bottom(8) + .right(8))
144+ textView.edgesToSuperview(insets: .top(8) + .left(8) + .bottom(40+8) + .right(8))
145145
146146 if #available(iOS 11.0, *) {
147147 textView.smartDashesType = .no
@@ -210,7 +210,7 @@ class NewPostViewController: UIViewController, UITextViewDelegate, TagsReceiver
210210 }
211211
212212 func setUpMD(){
213− textStorage.marklightTextProcessor.codeColor = UIColor.gray
213+ textStorage.marklightTextProcessor.codeColor = UIColor.orange
214214 textStorage.marklightTextProcessor.quoteColor = UIColor.darkGray
215215 textStorage.marklightTextProcessor.syntaxColor = UIColor.blue
216216 textStorage.marklightTextProcessor.codeFontName = "Courier"
@@ -232,27 +232,10 @@ class NewPostViewController: UIViewController, UITextViewDelegate, TagsReceiver
232232 var indexOfPost = 0
233233 // MARK:- new post
234234 @objc func newPost(){
235− self.navigationItem.title = "Sending..."
236− 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−
251− // NewPostViewController.draft = ""
252− // NewPostViewController.hashTagsDraft = []
235+ Model.createAndPublish(body: [Model.Attachments(markdown: textView!.text)], tags: currentTags)
253236 // adding row to uiTableView after adding new post
254237 // myProtocol?.addPost(post: p)
255− // moveBackToParentVC?()
238+ moveBackToParentVC?()
256239 // somewhere here i will be sending server notifications about new post arrival
257240 }
258241
@@ -264,7 +247,7 @@ class NewPostViewController: UIViewController, UITextViewDelegate, TagsReceiver
264247 [weak self]
265248 _ in
266249 NewPostViewController.draft = self?.textView.text ?? ""
267− NewPostViewController.hashTagsDraft = self?.currentTags ?? []
250+ NewPostViewController.hashTagsDraft = /*self?.tagsField.tags.map { $0.text } ??*/ []
268251 self?.moveBackToParentVC?()
269252 }
270253
GDproject/Controller/ News and channels/NewsController.swift+1−2
@@ -82,7 +82,7 @@ class NewsController: UIViewController, UISearchControllerDelegate, UpdateableWi
8282 searchController?.searchBar.placeholder = "Search tags"
8383 }
8484
85− @objc func refreshPostsData( _ ff: UIRefreshControl) {
85+ @objc func refreshPostsData( _ ff: UIRefreshControl){
8686 decideWhatChannelDisplay()
8787 }
8888
@@ -122,7 +122,6 @@ class NewsController: UIViewController, UISearchControllerDelegate, UpdateableWi
122122 }
123123 }
124124 default:
125− refreshContr.endRefreshing()
126125 break
127126 }
128127
GDproject/Controller/ News and channels/NewsVC.swift+1−3
@@ -19,9 +19,7 @@ struct PostCellData{
1919
2020 let markdownParser = MarkdownParser(font: UIFont.systemFont(ofSize: 16))
2121 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)
24− markdownParser.code.color = #colorLiteral(red: 0.2549019754, green: 0.2745098174, blue: 0.3019607961, alpha: 1)
22+ markdownParser.code.textBackgroundColor = #colorLiteral(red: 0.8039215803, green: 0.8039215803, blue: 0.8039215803, alpha: 1)
2523
2624 return markdownParser.parse(markdown)
2725 }
GDproject/Controller/ News and channels/PostViewCell.swift+1−1
@@ -87,7 +87,7 @@ class PostViewCell: UITableViewCell
8787 nameLabel.setTitle("\(post.user?.firstName ?? "") \(post.user?.lastName ?? "")", for: .normal)
8888 nameLabel.addTarget(self, action: #selector(displayProfile), for: .touchUpInside)
8989 if let user = post.user{
90− fullNameLabel.text = "\(user.faculty.name)"
90+ fullNameLabel.text = "\(user.firstName) \(user.middleName) \(user.lastName)"
9191 }
9292 else {
9393 fullNameLabel.text = "\(post.authorId)"
GDproject/Controller/Log In/RegisterTableViewController.swift−1
@@ -50,7 +50,6 @@ class RegisterTableViewController: UITableViewController, ChosenFactulty
5050 {
5151 super.viewDidLoad()
5252
53− navigationItem.largeTitleDisplayMode = .never
5453 tableView.keyboardDismissMode = .interactive
5554 navigationItem.title = user.email
5655 navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(endRegistration))
GDproject/Controller/Messages/ChatInfoViewController.swift+4−25
@@ -91,12 +91,10 @@ class ChatInfoViewController: UITableViewController {
9191 switch indexPath.section {
9292 case 0:
9393 cell.textLabel?.text = groupChat!.name
94− cell.selectionStyle = .none
9594 return cell
9695 case 1:
9796 cell.textLabel?.text = "Leave chat"
9897 cell.textLabel?.textColor = #colorLiteral(red: 1, green: 0.1491314173, blue: 0, alpha: 1)
99− cell.selectionStyle = .none
10098 return cell
10199 default:
102100 switch myPermissions{
@@ -106,7 +104,6 @@ class ChatInfoViewController: UITableViewController {
106104 case .ordinary:
107105 cell.textLabel?.text = name(for: users[usersArray[indexPath.row]])
108106 }
109− cell.selectionStyle = .none
110107 return cell
111108 }
112109 }
@@ -117,7 +114,7 @@ class ChatInfoViewController: UITableViewController {
117114 case .ordinary:
118115 cell.textLabel?.text = name(for: users[usersArray[indexPath.row]])
119116 }
120− cell.selectionStyle = .none
117+
121118 return cell
122119 }
123120
@@ -146,9 +143,9 @@ class ChatInfoViewController: UITableViewController {
146143
147144
148145 func editName(for cell: UITableViewCell){
149− let alert = UIAlertController(title: "Are you sure?", message: "Title:", preferredStyle: .alert)
146+ let alert = UIAlertController(title: "Вы уверены?", message: "Название:", preferredStyle: .alert)
150147
151− let action1 = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
148+ let action1 = UIAlertAction(title: "Oтмена", style: .cancel, handler: nil)
152149
153150 alert.addTextField { [weak self] (tf) in
154151 tf.textColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1)
@@ -197,28 +194,10 @@ class ChatInfoViewController: UITableViewController {
197194 case .admin:
198195 showUserChoiceVC()
199196 default:
200− showParticipantPage(with: usersArray[indexPath.row])
197+ break
201198 }
202199 }
203200 }
204−
205−
206− if indexPath.section == 2 && indexPath.row != 0 {
207− switch myPermissions{
208− case .admin:
209− showParticipantPage(with: usersArray[indexPath.row-1])
210− default:
211− showParticipantPage(with: usersArray[indexPath.row])
212− }
213− }
214− }
215−
216− var onUserDiplay: ((Int)->())?
217−
218− func showParticipantPage(with user: Int?) {
219− if let user = user {
220− onUserDiplay?(user)
221− }
222201 }
223202
224203 func showUserChoiceVC()
GDproject/Controller/Messages/Dialog/DialogViewController.swift+6−15
@@ -61,9 +61,7 @@ class DialogViewController: UIViewController, UpdatableGroup, UITableViewDelegat
6161
6262 self.tableView.delegate = self
6363 self.tableView.dataSource = self
64−
65− tableView.setContentOffset(CGPoint(x: 0, y: 50), animated: false)
66−
64+
6765 navigationItem.largeTitleDisplayMode = .never
6866
6967 tableView.keyboardDismissMode = .onDrag
@@ -116,7 +114,6 @@ class DialogViewController: UIViewController, UpdatableGroup, UITableViewDelegat
116114 let button = UIButton()
117115 button.setTitle("Send", for: .normal)
118116 button.setTitleColor(.blue, for: .normal)
119− button.titleLabel?.font = UIFont.systemFont(ofSize: 17, weight: .semibold)
120117 button.addTarget(self, action: #selector(sendMessage), for: .touchUpInside)
121118 return button
122119 }()
@@ -135,13 +132,8 @@ class DialogViewController: UIViewController, UpdatableGroup, UITableViewDelegat
135132 {
136133 Model.sendMessage(message: Model.SendMessage(body: Model.Attachments(markdown: messageTextView.text), destination: destination)) { [unowned self] in
137134
138− switch $0 {
139− case .success, .success1:
140− self.getMessagesNew(for: self.dialog!)
141− self.messageTextView.text = ""
142− default:
143− self.showAlertOn(result: $0)
144− }
135+ self.getMessagesNew(for: self.dialog!)
136+ self.messageTextView.text = ""
145137 }
146138
147139 prevLast = -1
@@ -166,7 +158,7 @@ class DialogViewController: UIViewController, UpdatableGroup, UITableViewDelegat
166158
167159 messageSendView.edgesToSuperview(excluding: [.top,.bottom])
168160
169− bottomConstraint = NSLayoutConstraint(item: messageSendView, attribute: .bottom, relatedBy: .equal, toItem: self.view.safeAreaLayoutGuide, attribute: .bottom, multiplier: 1, constant: 0)
161+ bottomConstraint = NSLayoutConstraint(item: messageSendView, attribute: .bottom, relatedBy: .equal, toItem: view, attribute: .bottom, multiplier: 1, constant: 0)
170162 view.addConstraint(bottomConstraint)
171163
172164 messageSendView.height(60)
@@ -199,7 +191,7 @@ class DialogViewController: UIViewController, UpdatableGroup, UITableViewDelegat
199191
200192 let keyBoardFrame = (userInfo[UIResponder.keyboardFrameEndUserInfoKey] as! NSValue).cgRectValue
201193
202− bottomConstraint.constant = notification.name == UIResponder.keyboardWillShowNotification ? -(keyBoardFrame.height) + self.view.safeAreaInsets.bottom : 0
194+ bottomConstraint.constant = notification.name == UIResponder.keyboardWillShowNotification ? -(keyBoardFrame.height) : 0
203195
204196 UIView.animate(withDuration: 0, delay: 0, options: .curveEaseOut, animations: {
205197 self.view.layoutIfNeeded()
@@ -231,7 +223,6 @@ class DialogViewController: UIViewController, UpdatableGroup, UITableViewDelegat
231223
232224 vc.delegate = self
233225 vc.users = users!
234− vc.onUserDiplay = onUserDisplay
235226
236227 if let groupChat = groupChat {
237228 vc.groupChat = groupChat.group
@@ -323,7 +314,7 @@ class DialogViewController: UIViewController, UpdatableGroup, UITableViewDelegat
323314 var canBePaginated = false
324315 func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath)
325316 {
326− if indexPath.row == cellData.count - 1 && prevLast != indexPath.row && canBePaginated && cellData.count >= 24
317+ if indexPath.row == cellData.count - 1 && prevLast != indexPath.row && canBePaginated
327318 {
328319 print("exclusiveFrom \(currentMessagesInChat.last?.id ?? 0)")
329320 if let dialog = dialog
GDproject/Controller/Messages/MessageViewCell.swiftdeleted−38
@@ -1,38 +0,0 @@
1−//
2−// MessageViewCell.swift
3−// GDproject
4−//
5−// Created by cstore on 13/05/2019.
6−// Copyright © 2019 drHSE. All rights reserved.
7−//
8−
9−import UIKit
10−
11−class MessageViewCell: UITableViewCell {
12−
13− @IBOutlet weak var dialogName: UILabel!
14−
15− @IBOutlet weak var lastMessagePreview: UILabel!
16−
17− @IBOutlet weak var dateLabel: UILabel!
18−
19− override func awakeFromNib() {
20− super.awakeFromNib()
21− // Initialization code
22− }
23−
24− func fill(with dialog: Model.Dialog, user: Model.Users? = nil)
25− {
26− switch dialog {
27−
28− case .groupChat(let group):
29− dialogName.text = group.group.name
30− lastMessagePreview.text = group.lastMessage?.body.markdown
31− dateLabel.text = group.lastMessage?.time.getDate()
32− case .userChat(let userChat):
33− dialogName.text = "👤 \(user!.fullName())"
34− lastMessagePreview.text = userChat.lastMessage?.body.markdown
35− dateLabel.text = userChat.lastMessage?.time.getDate()
36− }
37− }
38−}
GDproject/Controller/Messages/MessagesViewController.swift+12−107
@@ -8,44 +8,8 @@
88
99import UIKit
1010
11−protocol SelectableDialog: class {
12− func openDialog(with dialog: Model.Dialog)
13−}
11+class MessagesViewController: UITableViewController {
1412
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−
4913 // curreent Active which can be displayed
5014 var currentActiveDialogs: [Model.Dialog] = [] {
5115 didSet {
@@ -53,17 +17,6 @@ class MessagesViewController: UITableViewController, UISearchControllerDelegate,
5317 }
5418 }
5519
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−
6720 // curreent users
6821 var users: [Int: Model.Users] = [:]
6922
@@ -71,22 +24,17 @@ class MessagesViewController: UITableViewController, UISearchControllerDelegate,
7124
7225 var onDialogDisplay: (((dialog: Model.Dialog, users: [Int:Model.Users]))->())?
7326
74− var searchController: UISearchController?
27+ let searchC = UISearchController(searchResultsController: nil)
7528
7629 override func viewDidLoad() {
7730 super.viewDidLoad()
78−
79− let updater = SuggestedDialogsTableViewController()
80−
81− updater.delegate = self
82− searchController = UISearchController(searchResultsController: updater)
83−
31+
8432 // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
8533 self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Write", style: .plain, target: self, action: #selector(choosePerson))
8634
8735 self.navigationItem.title = "Messages"
8836 // self.navigationItem.largeTitleDisplayMode = .always
89− setUpSearchContr()
37+ self.navigationItem.searchController = searchC
9038 navigationController?.navigationBar.prefersLargeTitles = true
9139 self.navigationItem.hidesSearchBarWhenScrolling = false
9240 }
@@ -116,15 +64,18 @@ class MessagesViewController: UITableViewController, UISearchControllerDelegate,
11664
11765 override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
11866 {
119− let cell = tableView.dequeueReusableCell(withIdentifier: "MessageViewCell", for: indexPath) as! MessageViewCell
67+ let cell = tableView.dequeueReusableCell(withIdentifier: "MessagesCell", for: indexPath)
12068
12169 switch currentActiveDialogs[indexPath.row].self {
122− case .groupChat:
123− cell.fill(with: currentActiveDialogs[indexPath.row])
70+
71+ case .groupChat(let group):
72+ cell.textLabel?.text = group.group.name
73+ cell.detailTextLabel?.text = group.lastMessage?.body.markdown
12474 case .userChat(let userChat):
125− cell.fill(with: currentActiveDialogs[indexPath.row], user: users[userChat.user])
75+ cell.textLabel?.text = "👤 \(users[userChat.user]!.fullName())"
76+ cell.detailTextLabel?.text = userChat.lastMessage?.body.markdown
12677 }
127−
78+
12879 return cell
12980 }
13081
@@ -133,49 +84,3 @@ class MessagesViewController: UITableViewController, UISearchControllerDelegate,
13384 onDialogDisplay?(tuple)
13485 }
13586}
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/Messages/PeopleToWriteViewController.swift+1
@@ -53,6 +53,7 @@ class PeopleToWriteViewController: UITableViewController {
5353 let cell = tableView.dequeueReusableCell(withIdentifier: "peopleToWriteCell", for: indexPath)
5454
5555 cell.textLabel?.text = users[indexPath.row].fullName()
56+ cell.detailTextLabel?.text = "\(users[indexPath.row].id)"
5657
5758 return cell
5859 }
GDproject/Controller/Profile/ProfileViewController.swift+8−31
@@ -159,7 +159,7 @@ class ProfileViewController: UIViewController, UpdateUser
159159 }
160160
161161 func setUpNavigarionBar(){
162− // navigationController?.navigationBar.prefersLargeTitles = true
162+ navigationController?.navigationBar.prefersLargeTitles = true
163163 let uibarbutton = UIBarButtonItem(title: "More", style: .plain, target: self, action: #selector(showInformation))
164164 navigationItem.rightBarButtonItems = [uibarbutton]
165165 navigationItem.largeTitleDisplayMode = .always
@@ -175,43 +175,20 @@ class ProfileViewController: UIViewController, UpdateUser
175175
176176 if idProfile == DataStorage.standard.getUserId() {
177177 let logoutAction = UIAlertAction(title: "Log out", style: .destructive)
178− { [weak self] (_) in
179−
180− if let logOut = self?.logOut {
181− logOut()
182− } else {
183− Model.logout() {
184− DataStorage.standard.setIsLoggedIn(value: false, with: 0)
185− (UIApplication.shared.delegate as! AppDelegate).relaunch()
186− }
187− }
178+ { [weak self]
179+ (_) in
180+ self?.logOut?()
188181 }
189182
190183 let deleetAllSessionsAction = UIAlertAction(title: "Delete all sessions", style: .destructive)
191− { [weak self] _ in
192−
193− if let delete = self?.deleteAllSessions {
194− delete()
195− } else {
196− Model.deactivateAll() {
197− DataStorage.standard.setIsLoggedIn(value: false, with: 0)
198− (UIApplication.shared.delegate as! AppDelegate).relaunch()
199− }
200− }
184+ { [weak self]
185+ (_) in
186+ self?.deleteAllSessions?()
201187 }
202188
203189 let settingsAction = UIAlertAction(title: "Edit profile", style: .default)
204190 { [weak self] (_) in
205−
206− if let settings = self?.onSettings{
207− settings()
208− } else {
209− let vc = self?.storyboard?.instantiateViewController(withIdentifier: "RegisterTableViewController") as! RegisterTableViewController
210− vc.delegate = self
211− vc.userActive = self?.user
212−
213− self?.navigationController?.pushViewController(vc, animated: true)
214− }
191+ self?.onSettings?()
215192 }
216193
217194 optionMenu.addAction(settingsAction)
GDproject/Simple model/Model.swift+4−16
@@ -427,7 +427,7 @@ class Model{
427427 }
428428
429429
430− static func createAndPublish(body: [Attachments], tags: [String], completion: @escaping ((ResultR)->())){
430+ static func createAndPublish(body: [Attachments], tags: [String]){
431431 let jsonUpd = CreatedPost(body: body, tags: tags)
432432 var request = URLRequest(url: postsPublishURL)
433433
@@ -445,14 +445,6 @@ class Model{
445445 if let code = response.response?.statusCode, code == 498 {
446446 return
447447 }
448−
449− if let code = response.response?.statusCode,
450− let result = ResultR(rawValue: code)
451− {
452− completion(result)
453− } else {
454− completion(.internalServerError)
455− }
456448 }
457449 }
458450
@@ -953,7 +945,7 @@ class Model{
953945 }
954946 }
955947
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])->()))
957949 {
958950 let req = GeneralRequest<Int>(direction: direction, limit: l, exclusiveFrom: exclusiveFrom, request: id)
959951 var request: URLRequest?
@@ -1056,7 +1048,7 @@ class Model{
10561048 }
10571049 }
10581050
1059− static func sendMessage(message: SendMessage, completion: @escaping ((ResultR)->())){
1051+ static func sendMessage(message: SendMessage, completion: @escaping (()->())){
10601052
10611053 var request = URLRequest(url: messagesSendURL)
10621054 request.setValue("application/json; charset=utf-8", forHTTPHeaderField: "Content-Type")
@@ -1070,11 +1062,7 @@ class Model{
10701062 return
10711063 }
10721064
1073− if let result = ResultR(rawValue: response.response!.statusCode){
1074− completion(result)
1075− } else {
1076− completion(.internalServerError)
1077− }
1065+ completion()
10781066 }
10791067 }
10801068