git.iko.soy/dashared/GDproject
on master help sign in
Fixed a few bags. Preview and pagination in messages
d03e636Darya Rednikina
GDproject.xcodeproj/project.pbxproj+4
@@ -10,6 +10,7 @@
10 1210A0BB223940310080686D /* SimplifiedChannelsList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1210A0BA223940310080686D /* SimplifiedChannelsList.swift */; };
10 1210A0BB223940310080686D /* SimplifiedChannelsList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1210A0BA223940310080686D /* SimplifiedChannelsList.swift */; };
11 121A8972226B1EAC005EE599 /* TagsSuggestionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 121A8971226B1EAC005EE599 /* TagsSuggestionController.swift */; };
11 121A8972226B1EAC005EE599 /* TagsSuggestionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 121A8971226B1EAC005EE599 /* TagsSuggestionController.swift */; };
12 1220FF94227C41270092C6BC /* TaggsSelectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1220FF93227C41270092C6BC /* TaggsSelectionViewController.swift */; };
12 1220FF94227C41270092C6BC /* TaggsSelectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1220FF93227C41270092C6BC /* TaggsSelectionViewController.swift */; };
13+ 123589FD22899339002F8028 /* MessageViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123589FC22899339002F8028 /* MessageViewCell.swift */; };
13 123E37A5221F1B3200F6E42A /* LogInViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123E37A4221F1B3200F6E42A /* LogInViewController.swift */; };
14 123E37A5221F1B3200F6E42A /* LogInViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123E37A4221F1B3200F6E42A /* LogInViewController.swift */; };
14 123E37A7221F1DD700F6E42A /* MainController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123E37A6221F1DD700F6E42A /* MainController.swift */; };
15 123E37A7221F1DD700F6E42A /* MainController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123E37A6221F1DD700F6E42A /* MainController.swift */; };
15 124CC7032221C00C009DF531 /* Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 124CC7022221C00C009DF531 /* Model.swift */; };
16 124CC7032221C00C009DF531 /* Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 124CC7022221C00C009DF531 /* Model.swift */; };
@@ -108,6 +109,7 @@
108 1210A0BA223940310080686D /* SimplifiedChannelsList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimplifiedChannelsList.swift; sourceTree = "<group>"; };
109 1210A0BA223940310080686D /* SimplifiedChannelsList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimplifiedChannelsList.swift; sourceTree = "<group>"; };
109 121A8971226B1EAC005EE599 /* TagsSuggestionController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagsSuggestionController.swift; sourceTree = "<group>"; };
110 121A8971226B1EAC005EE599 /* TagsSuggestionController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagsSuggestionController.swift; sourceTree = "<group>"; };
110 1220FF93227C41270092C6BC /* TaggsSelectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaggsSelectionViewController.swift; sourceTree = "<group>"; };
111 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>"; };
111 123E37A4221F1B3200F6E42A /* LogInViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogInViewController.swift; sourceTree = "<group>"; };
113 123E37A4221F1B3200F6E42A /* LogInViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogInViewController.swift; sourceTree = "<group>"; };
112 123E37A6221F1DD700F6E42A /* MainController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainController.swift; sourceTree = "<group>"; };
114 123E37A6221F1DD700F6E42A /* MainController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainController.swift; sourceTree = "<group>"; };
113 124CC7022221C00C009DF531 /* Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Model.swift; sourceTree = "<group>"; };
115 124CC7022221C00C009DF531 /* Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Model.swift; sourceTree = "<group>"; };
@@ -238,6 +240,7 @@
238 129320082279C3B50035C7B3 /* PeopleToWriteViewController.swift */,
240 129320082279C3B50035C7B3 /* PeopleToWriteViewController.swift */,
239 1298810C227F138C0032ACA3 /* Dialog */,
241 1298810C227F138C0032ACA3 /* Dialog */,
240 129320032279B4270035C7B3 /* MessagesViewController.swift */,
242 129320032279B4270035C7B3 /* MessagesViewController.swift */,
243+ 123589FC22899339002F8028 /* MessageViewCell.swift */,
241 );
244 );
242 path = Messages;
245 path = Messages;
243 sourceTree = "<group>";
246 sourceTree = "<group>";
@@ -451,6 +454,7 @@
451 1298810B227F13840032ACA3 /* DialogCell.swift in Sources */,
454 1298810B227F13840032ACA3 /* DialogCell.swift in Sources */,
452 125A9A922286100800513E2A /* FacultyTableViewController.swift in Sources */,
455 125A9A922286100800513E2A /* FacultyTableViewController.swift in Sources */,
453 125A9A8E2286068A00513E2A /* RegisterTableViewController.swift in Sources */,
456 125A9A8E2286068A00513E2A /* RegisterTableViewController.swift in Sources */,
457+ 123589FD22899339002F8028 /* MessageViewCell.swift in Sources */,
454 12E36DCC22144725006FCDD7 /* PostViewCell.swift in Sources */,
458 12E36DCC22144725006FCDD7 /* PostViewCell.swift in Sources */,
455 123E37A5221F1B3200F6E42A /* LogInViewController.swift in Sources */,
459 123E37A5221F1B3200F6E42A /* LogInViewController.swift in Sources */,
456 125BD57F22171D73008A3575 /* Extentions.swift in Sources */,
460 125BD57F22171D73008A3575 /* Extentions.swift in Sources */,
GDproject/Base.lproj/Main.storyboard+36−12
@@ -778,29 +778,53 @@
778 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
778 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
779 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
779 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
780 <prototypes>
780 <prototypes>
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">
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="44"/>
782+ <rect key="frame" x="0.0" y="28" width="375" height="78"/>
783 <autoresizingMask key="autoresizingMask"/>
783 <autoresizingMask key="autoresizingMask"/>
784 <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="67C-fT-WEV" id="O3b-Xv-UNk">
784 <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="43.5"/>
785+ <rect key="frame" x="0.0" y="0.0" width="375" height="77.5"/>
786 <autoresizingMask key="autoresizingMask"/>
786 <autoresizingMask key="autoresizingMask"/>
787 <subviews>
787 <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>
788− <label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="9br-gb-mg8">
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">
789− <rect key="frame" x="16" y="5" width="33.5" height="20.5"/>
798+ <rect key="frame" x="16" y="11" width="46" height="22"/>
790− <autoresizingMask key="autoresizingMask"/>
791− <fontDescription key="fontDescription" type="system" pointSize="17"/>
799+ <fontDescription key="fontDescription" type="system" weight="semibold" pointSize="18"/>
792 <nil key="textColor"/>
800 <nil key="textColor"/>
793 <nil key="highlightedColor"/>
801 <nil key="highlightedColor"/>
794 </label>
802 </label>
795− <label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Detail" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Jxd-We-VyC">
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">
796− <rect key="frame" x="16" y="25.5" width="33" height="14.5"/>
804+ <rect key="frame" x="16" y="49" width="343" height="18"/>
797− <autoresizingMask key="autoresizingMask"/>
798− <fontDescription key="fontDescription" type="system" pointSize="12"/>
805+ <fontDescription key="fontDescription" type="system" pointSize="15"/>
799 <nil key="textColor"/>
806 <nil key="textColor"/>
800 <nil key="highlightedColor"/>
807 <nil key="highlightedColor"/>
801 </label>
808 </label>
802 </subviews>
809 </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>
803 </tableViewCellContentView>
822 </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>
804 </tableViewCell>
828 </tableViewCell>
805 </prototypes>
829 </prototypes>
806 <connections>
830 <connections>
@@ -811,7 +835,7 @@
811 </tableViewController>
835 </tableViewController>
812 <placeholder placeholderIdentifier="IBFirstResponder" id="fu3-z4-EY7" userLabel="First Responder" sceneMemberID="firstResponder"/>
836 <placeholder placeholderIdentifier="IBFirstResponder" id="fu3-z4-EY7" userLabel="First Responder" sceneMemberID="firstResponder"/>
813 </objects>
837 </objects>
814− <point key="canvasLocation" x="2798" y="932"/>
838+ <point key="canvasLocation" x="2681" y="918"/>
815 </scene>
839 </scene>
816 <!--People To Write View Controller-->
840 <!--People To Write View Controller-->
817 <scene sceneID="6Td-bq-Ebf">
841 <scene sceneID="6Td-bq-Ebf">
GDproject/Controller/ News and channels/ChannelListController.swift+1−1
@@ -100,7 +100,7 @@ class ChannelListController: UITableViewController {
100 @objc func addChannel()
100 @objc func addChannel()
101 {
101 {
102 // editing mode is on automatically
102 // editing mode is on automatically
103− onEditingModeBegins?(Model.Channels(people: [], name: "Untitled", tags: []),IndexPath(row: 1, section: 0))
103+ onEditingModeBegins?(Model.Channels(people: [], name: "Untitled", id: 0, tags: []),IndexPath(row: 1, section: 0))
104 }
104 }
105
105
106 static let generalChannel = Model.Channels(people: [], name: "General", id: -1, tags: [])
106 static let generalChannel = Model.Channels(people: [], name: "General", id: -1, tags: [])
GDproject/Controller/ News and channels/ChannelViewController.swift+3−2
@@ -60,8 +60,9 @@ class ChannelViewController: UITableViewController, UpdatableName, UpdatableChan
60 super.viewWillDisappear(animated)
60 super.viewWillDisappear(animated)
61 }
61 }
62
62
63− guard let _ = self.navigationController?.viewControllers.lastIndex(of: self) else {
63+ guard let _ = self.navigationController?.viewControllers.lastIndex(of: self) else
64+ {
64− if let _ = channel?.id
65+ if let id = channel?.id, id != 0
65 {
66 {
66 Model.updateChannel(with: channel!)
67 Model.updateChannel(with: channel!)
67 } else {
68 } else {
GDproject/Controller/Messages/ChatInfoViewController.swift+25−4
@@ -91,10 +91,12 @@ class ChatInfoViewController: UITableViewController {
91 switch indexPath.section {
91 switch indexPath.section {
92 case 0:
92 case 0:
93 cell.textLabel?.text = groupChat!.name
93 cell.textLabel?.text = groupChat!.name
94+ cell.selectionStyle = .none
94 return cell
95 return cell
95 case 1:
96 case 1:
96 cell.textLabel?.text = "Leave chat"
97 cell.textLabel?.text = "Leave chat"
97 cell.textLabel?.textColor = #colorLiteral(red: 1, green: 0.1491314173, blue: 0, alpha: 1)
98 cell.textLabel?.textColor = #colorLiteral(red: 1, green: 0.1491314173, blue: 0, alpha: 1)
99+ cell.selectionStyle = .none
98 return cell
100 return cell
99 default:
101 default:
100 switch myPermissions{
102 switch myPermissions{
@@ -104,6 +106,7 @@ class ChatInfoViewController: UITableViewController {
104 case .ordinary:
106 case .ordinary:
105 cell.textLabel?.text = name(for: users[usersArray[indexPath.row]])
107 cell.textLabel?.text = name(for: users[usersArray[indexPath.row]])
106 }
108 }
109+ cell.selectionStyle = .none
107 return cell
110 return cell
108 }
111 }
109 }
112 }
@@ -114,7 +117,7 @@ class ChatInfoViewController: UITableViewController {
114 case .ordinary:
117 case .ordinary:
115 cell.textLabel?.text = name(for: users[usersArray[indexPath.row]])
118 cell.textLabel?.text = name(for: users[usersArray[indexPath.row]])
116 }
119 }
117−
120+ cell.selectionStyle = .none
118 return cell
121 return cell
119 }
122 }
120
123
@@ -143,9 +146,9 @@ class ChatInfoViewController: UITableViewController {
143
146
144
147
145 func editName(for cell: UITableViewCell){
148 func editName(for cell: UITableViewCell){
146− let alert = UIAlertController(title: "Вы уверены?", message: "Название:", preferredStyle: .alert)
149+ let alert = UIAlertController(title: "Are you sure?", message: "Title:", preferredStyle: .alert)
147
150
148− let action1 = UIAlertAction(title: "Oтмена", style: .cancel, handler: nil)
151+ let action1 = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
149
152
150 alert.addTextField { [weak self] (tf) in
153 alert.addTextField { [weak self] (tf) in
151 tf.textColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1)
154 tf.textColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1)
@@ -194,10 +197,28 @@ class ChatInfoViewController: UITableViewController {
194 case .admin:
197 case .admin:
195 showUserChoiceVC()
198 showUserChoiceVC()
196 default:
199 default:
197− break
200+ showParticipantPage(with: usersArray[indexPath.row])
198 }
201 }
199 }
202 }
200 }
203 }
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+ }
201 }
222 }
202
223
203 func showUserChoiceVC()
224 func showUserChoiceVC()
GDproject/Controller/Messages/Dialog/DialogViewController.swift+2−1
@@ -223,6 +223,7 @@ class DialogViewController: UIViewController, UpdatableGroup, UITableViewDelegat
223
223
224 vc.delegate = self
224 vc.delegate = self
225 vc.users = users!
225 vc.users = users!
226+ vc.onUserDiplay = onUserDisplay
226
227
227 if let groupChat = groupChat {
228 if let groupChat = groupChat {
228 vc.groupChat = groupChat.group
229 vc.groupChat = groupChat.group
@@ -314,7 +315,7 @@ class DialogViewController: UIViewController, UpdatableGroup, UITableViewDelegat
314 var canBePaginated = false
315 var canBePaginated = false
315 func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath)
316 func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath)
316 {
317 {
317− if indexPath.row == cellData.count - 1 && prevLast != indexPath.row && canBePaginated
318+ if indexPath.row == cellData.count - 1 && prevLast != indexPath.row && canBePaginated && cellData.count >= 9
318 {
319 {
319 print("exclusiveFrom \(currentMessagesInChat.last?.id ?? 0)")
320 print("exclusiveFrom \(currentMessagesInChat.last?.id ?? 0)")
320 if let dialog = dialog
321 if let dialog = dialog
GDproject/Controller/Messages/MessageViewCell.swiftnew file+38
@@ -0,0 +1,38 @@
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+5−8
@@ -64,18 +64,15 @@ class MessagesViewController: UITableViewController {
64
64
65 override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
65 override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
66 {
66 {
67− let cell = tableView.dequeueReusableCell(withIdentifier: "MessagesCell", for: indexPath)
67+ let cell = tableView.dequeueReusableCell(withIdentifier: "MessageViewCell", for: indexPath) as! MessageViewCell
68
68
69 switch currentActiveDialogs[indexPath.row].self {
69 switch currentActiveDialogs[indexPath.row].self {
70−
71− case .groupChat(let group):
70+ case .groupChat:
72− cell.textLabel?.text = group.group.name
71+ cell.fill(with: currentActiveDialogs[indexPath.row])
73− cell.detailTextLabel?.text = group.lastMessage?.body.markdown
74 case .userChat(let userChat):
72 case .userChat(let userChat):
75− cell.textLabel?.text = "👤 \(users[userChat.user]!.fullName())"
73+ cell.fill(with: currentActiveDialogs[indexPath.row], user: users[userChat.user])
76− cell.detailTextLabel?.text = userChat.lastMessage?.body.markdown
77 }
74 }
78−
75+
79 return cell
76 return cell
80 }
77 }
81
78
GDproject/Controller/Messages/PeopleToWriteViewController.swift−1
@@ -53,7 +53,6 @@ class PeopleToWriteViewController: UITableViewController {
53 let cell = tableView.dequeueReusableCell(withIdentifier: "peopleToWriteCell", for: indexPath)
53 let cell = tableView.dequeueReusableCell(withIdentifier: "peopleToWriteCell", for: indexPath)
54
54
55 cell.textLabel?.text = users[indexPath.row].fullName()
55 cell.textLabel?.text = users[indexPath.row].fullName()
56− cell.detailTextLabel?.text = "\(users[indexPath.row].id)"
57
56
58 return cell
57 return cell
59 }
58 }
GDproject/Controller/Profile/ProfileViewController.swift+30−7
@@ -175,20 +175,43 @@ class ProfileViewController: UIViewController, UpdateUser
175
175
176 if idProfile == DataStorage.standard.getUserId() {
176 if idProfile == DataStorage.standard.getUserId() {
177 let logoutAction = UIAlertAction(title: "Log out", style: .destructive)
177 let logoutAction = UIAlertAction(title: "Log out", style: .destructive)
178− { [weak self]
178+ { [weak self] (_) in
179− (_) in
179+
180− self?.logOut?()
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+ }
181 }
188 }
182
189
183 let deleetAllSessionsAction = UIAlertAction(title: "Delete all sessions", style: .destructive)
190 let deleetAllSessionsAction = UIAlertAction(title: "Delete all sessions", style: .destructive)
184− { [weak self]
191+ { [weak self] _ in
185− (_) in
192+
186− self?.deleteAllSessions?()
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+ }
187 }
201 }
188
202
189 let settingsAction = UIAlertAction(title: "Edit profile", style: .default)
203 let settingsAction = UIAlertAction(title: "Edit profile", style: .default)
190 { [weak self] (_) in
204 { [weak self] (_) in
205+
191− self?.onSettings?()
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+ }
192 }
215 }
193
216
194 optionMenu.addAction(settingsAction)
217 optionMenu.addAction(settingsAction)