mirror of
https://github.com/dashared/GDproject.git
synced 2024-11-29 02:54:30 +03:00
Fixed a few bags. Preview and pagination in messages
This commit is contained in:
parent
5ca9bbb7f8
commit
d03e636533
@ -10,6 +10,7 @@
|
||||
1210A0BB223940310080686D /* SimplifiedChannelsList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1210A0BA223940310080686D /* SimplifiedChannelsList.swift */; };
|
||||
121A8972226B1EAC005EE599 /* TagsSuggestionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 121A8971226B1EAC005EE599 /* TagsSuggestionController.swift */; };
|
||||
1220FF94227C41270092C6BC /* TaggsSelectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1220FF93227C41270092C6BC /* TaggsSelectionViewController.swift */; };
|
||||
123589FD22899339002F8028 /* MessageViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123589FC22899339002F8028 /* MessageViewCell.swift */; };
|
||||
123E37A5221F1B3200F6E42A /* LogInViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123E37A4221F1B3200F6E42A /* LogInViewController.swift */; };
|
||||
123E37A7221F1DD700F6E42A /* MainController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123E37A6221F1DD700F6E42A /* MainController.swift */; };
|
||||
124CC7032221C00C009DF531 /* Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 124CC7022221C00C009DF531 /* Model.swift */; };
|
||||
@ -108,6 +109,7 @@
|
||||
1210A0BA223940310080686D /* SimplifiedChannelsList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimplifiedChannelsList.swift; sourceTree = "<group>"; };
|
||||
121A8971226B1EAC005EE599 /* TagsSuggestionController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagsSuggestionController.swift; sourceTree = "<group>"; };
|
||||
1220FF93227C41270092C6BC /* TaggsSelectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaggsSelectionViewController.swift; sourceTree = "<group>"; };
|
||||
123589FC22899339002F8028 /* MessageViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageViewCell.swift; sourceTree = "<group>"; };
|
||||
123E37A4221F1B3200F6E42A /* LogInViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogInViewController.swift; sourceTree = "<group>"; };
|
||||
123E37A6221F1DD700F6E42A /* MainController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainController.swift; sourceTree = "<group>"; };
|
||||
124CC7022221C00C009DF531 /* Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Model.swift; sourceTree = "<group>"; };
|
||||
@ -238,6 +240,7 @@
|
||||
129320082279C3B50035C7B3 /* PeopleToWriteViewController.swift */,
|
||||
1298810C227F138C0032ACA3 /* Dialog */,
|
||||
129320032279B4270035C7B3 /* MessagesViewController.swift */,
|
||||
123589FC22899339002F8028 /* MessageViewCell.swift */,
|
||||
);
|
||||
path = Messages;
|
||||
sourceTree = "<group>";
|
||||
@ -451,6 +454,7 @@
|
||||
1298810B227F13840032ACA3 /* DialogCell.swift in Sources */,
|
||||
125A9A922286100800513E2A /* FacultyTableViewController.swift in Sources */,
|
||||
125A9A8E2286068A00513E2A /* RegisterTableViewController.swift in Sources */,
|
||||
123589FD22899339002F8028 /* MessageViewCell.swift in Sources */,
|
||||
12E36DCC22144725006FCDD7 /* PostViewCell.swift in Sources */,
|
||||
123E37A5221F1B3200F6E42A /* LogInViewController.swift in Sources */,
|
||||
125BD57F22171D73008A3575 /* Extentions.swift in Sources */,
|
||||
|
@ -778,29 +778,53 @@
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<prototypes>
|
||||
<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">
|
||||
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
|
||||
<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">
|
||||
<rect key="frame" x="0.0" y="28" width="375" height="78"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="67C-fT-WEV" id="O3b-Xv-UNk">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="77.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="9br-gb-mg8">
|
||||
<rect key="frame" x="16" y="5" width="33.5" height="20.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<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">
|
||||
<rect key="frame" x="229" y="11" width="130" height="15"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="130" id="f99-ZF-f8h"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="12"/>
|
||||
<color key="textColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<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">
|
||||
<rect key="frame" x="16" y="11" width="46" height="22"/>
|
||||
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="18"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Detail" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Jxd-We-VyC">
|
||||
<rect key="frame" x="16" y="25.5" width="33" height="14.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="12"/>
|
||||
<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">
|
||||
<rect key="frame" x="16" y="49" width="343" height="18"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="15"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="nTy-rK-XTr" firstAttribute="top" secondItem="xAY-IF-RpX" secondAttribute="bottom" constant="23" id="09Y-aK-nD9"/>
|
||||
<constraint firstItem="FG3-gU-0r1" firstAttribute="top" secondItem="O3b-Xv-UNk" secondAttribute="topMargin" id="4Hp-d5-9An"/>
|
||||
<constraint firstItem="xAY-IF-RpX" firstAttribute="top" secondItem="O3b-Xv-UNk" secondAttribute="topMargin" id="G4f-oJ-7ud"/>
|
||||
<constraint firstItem="nTy-rK-XTr" firstAttribute="trailing" secondItem="O3b-Xv-UNk" secondAttribute="trailingMargin" id="MaE-VM-KhL"/>
|
||||
<constraint firstItem="nTy-rK-XTr" firstAttribute="leading" secondItem="O3b-Xv-UNk" secondAttribute="leadingMargin" id="OIX-rY-Leo"/>
|
||||
<constraint firstItem="nTy-rK-XTr" firstAttribute="top" secondItem="FG3-gU-0r1" secondAttribute="bottom" constant="16" id="Qdj-s3-t60"/>
|
||||
<constraint firstItem="nTy-rK-XTr" firstAttribute="bottom" secondItem="O3b-Xv-UNk" secondAttribute="bottomMargin" id="Rv3-Mz-Aed"/>
|
||||
<constraint firstItem="FG3-gU-0r1" firstAttribute="leading" secondItem="O3b-Xv-UNk" secondAttribute="leadingMargin" id="iN1-KG-dYn"/>
|
||||
<constraint firstItem="xAY-IF-RpX" firstAttribute="trailing" secondItem="O3b-Xv-UNk" secondAttribute="trailingMargin" id="opV-4x-VCk"/>
|
||||
<constraint firstItem="xAY-IF-RpX" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="FG3-gU-0r1" secondAttribute="trailing" constant="4" id="x9r-sM-t4x"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<connections>
|
||||
<outlet property="dateLabel" destination="xAY-IF-RpX" id="fcz-re-BXk"/>
|
||||
<outlet property="dialogName" destination="FG3-gU-0r1" id="gd7-ND-wCi"/>
|
||||
<outlet property="lastMessagePreview" destination="nTy-rK-XTr" id="Cmo-IJ-2r0"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</prototypes>
|
||||
<connections>
|
||||
@ -811,7 +835,7 @@
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="fu3-z4-EY7" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="2798" y="932"/>
|
||||
<point key="canvasLocation" x="2681" y="918"/>
|
||||
</scene>
|
||||
<!--People To Write View Controller-->
|
||||
<scene sceneID="6Td-bq-Ebf">
|
||||
|
@ -100,7 +100,7 @@ class ChannelListController: UITableViewController {
|
||||
@objc func addChannel()
|
||||
{
|
||||
// editing mode is on automatically
|
||||
onEditingModeBegins?(Model.Channels(people: [], name: "Untitled", tags: []),IndexPath(row: 1, section: 0))
|
||||
onEditingModeBegins?(Model.Channels(people: [], name: "Untitled", id: 0, tags: []),IndexPath(row: 1, section: 0))
|
||||
}
|
||||
|
||||
static let generalChannel = Model.Channels(people: [], name: "General", id: -1, tags: [])
|
||||
|
@ -60,8 +60,9 @@ class ChannelViewController: UITableViewController, UpdatableName, UpdatableChan
|
||||
super.viewWillDisappear(animated)
|
||||
}
|
||||
|
||||
guard let _ = self.navigationController?.viewControllers.lastIndex(of: self) else {
|
||||
if let _ = channel?.id
|
||||
guard let _ = self.navigationController?.viewControllers.lastIndex(of: self) else
|
||||
{
|
||||
if let id = channel?.id, id != 0
|
||||
{
|
||||
Model.updateChannel(with: channel!)
|
||||
} else {
|
||||
|
@ -91,10 +91,12 @@ class ChatInfoViewController: UITableViewController {
|
||||
switch indexPath.section {
|
||||
case 0:
|
||||
cell.textLabel?.text = groupChat!.name
|
||||
cell.selectionStyle = .none
|
||||
return cell
|
||||
case 1:
|
||||
cell.textLabel?.text = "Leave chat"
|
||||
cell.textLabel?.textColor = #colorLiteral(red: 1, green: 0.1491314173, blue: 0, alpha: 1)
|
||||
cell.selectionStyle = .none
|
||||
return cell
|
||||
default:
|
||||
switch myPermissions{
|
||||
@ -104,6 +106,7 @@ class ChatInfoViewController: UITableViewController {
|
||||
case .ordinary:
|
||||
cell.textLabel?.text = name(for: users[usersArray[indexPath.row]])
|
||||
}
|
||||
cell.selectionStyle = .none
|
||||
return cell
|
||||
}
|
||||
}
|
||||
@ -114,7 +117,7 @@ class ChatInfoViewController: UITableViewController {
|
||||
case .ordinary:
|
||||
cell.textLabel?.text = name(for: users[usersArray[indexPath.row]])
|
||||
}
|
||||
|
||||
cell.selectionStyle = .none
|
||||
return cell
|
||||
}
|
||||
|
||||
@ -143,9 +146,9 @@ class ChatInfoViewController: UITableViewController {
|
||||
|
||||
|
||||
func editName(for cell: UITableViewCell){
|
||||
let alert = UIAlertController(title: "Вы уверены?", message: "Название:", preferredStyle: .alert)
|
||||
let alert = UIAlertController(title: "Are you sure?", message: "Title:", preferredStyle: .alert)
|
||||
|
||||
let action1 = UIAlertAction(title: "Oтмена", style: .cancel, handler: nil)
|
||||
let action1 = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
|
||||
|
||||
alert.addTextField { [weak self] (tf) in
|
||||
tf.textColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1)
|
||||
@ -194,10 +197,28 @@ class ChatInfoViewController: UITableViewController {
|
||||
case .admin:
|
||||
showUserChoiceVC()
|
||||
default:
|
||||
break
|
||||
showParticipantPage(with: usersArray[indexPath.row])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if indexPath.section == 2 && indexPath.row != 0 {
|
||||
switch myPermissions{
|
||||
case .admin:
|
||||
showParticipantPage(with: usersArray[indexPath.row-1])
|
||||
default:
|
||||
showParticipantPage(with: usersArray[indexPath.row])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var onUserDiplay: ((Int)->())?
|
||||
|
||||
func showParticipantPage(with user: Int?) {
|
||||
if let user = user {
|
||||
onUserDiplay?(user)
|
||||
}
|
||||
}
|
||||
|
||||
func showUserChoiceVC()
|
||||
|
@ -223,6 +223,7 @@ class DialogViewController: UIViewController, UpdatableGroup, UITableViewDelegat
|
||||
|
||||
vc.delegate = self
|
||||
vc.users = users!
|
||||
vc.onUserDiplay = onUserDisplay
|
||||
|
||||
if let groupChat = groupChat {
|
||||
vc.groupChat = groupChat.group
|
||||
@ -314,7 +315,7 @@ class DialogViewController: UIViewController, UpdatableGroup, UITableViewDelegat
|
||||
var canBePaginated = false
|
||||
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath)
|
||||
{
|
||||
if indexPath.row == cellData.count - 1 && prevLast != indexPath.row && canBePaginated
|
||||
if indexPath.row == cellData.count - 1 && prevLast != indexPath.row && canBePaginated && cellData.count >= 9
|
||||
{
|
||||
print("exclusiveFrom \(currentMessagesInChat.last?.id ?? 0)")
|
||||
if let dialog = dialog
|
||||
|
38
GDproject/Controller/Messages/MessageViewCell.swift
Normal file
38
GDproject/Controller/Messages/MessageViewCell.swift
Normal file
@ -0,0 +1,38 @@
|
||||
//
|
||||
// MessageViewCell.swift
|
||||
// GDproject
|
||||
//
|
||||
// Created by cstore on 13/05/2019.
|
||||
// Copyright © 2019 drHSE. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class MessageViewCell: UITableViewCell {
|
||||
|
||||
@IBOutlet weak var dialogName: UILabel!
|
||||
|
||||
@IBOutlet weak var lastMessagePreview: UILabel!
|
||||
|
||||
@IBOutlet weak var dateLabel: UILabel!
|
||||
|
||||
override func awakeFromNib() {
|
||||
super.awakeFromNib()
|
||||
// Initialization code
|
||||
}
|
||||
|
||||
func fill(with dialog: Model.Dialog, user: Model.Users? = nil)
|
||||
{
|
||||
switch dialog {
|
||||
|
||||
case .groupChat(let group):
|
||||
dialogName.text = group.group.name
|
||||
lastMessagePreview.text = group.lastMessage?.body.markdown
|
||||
dateLabel.text = group.lastMessage?.time.getDate()
|
||||
case .userChat(let userChat):
|
||||
dialogName.text = "👤 \(user!.fullName())"
|
||||
lastMessagePreview.text = userChat.lastMessage?.body.markdown
|
||||
dateLabel.text = userChat.lastMessage?.time.getDate()
|
||||
}
|
||||
}
|
||||
}
|
@ -64,16 +64,13 @@ class MessagesViewController: UITableViewController {
|
||||
|
||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
|
||||
{
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: "MessagesCell", for: indexPath)
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: "MessageViewCell", for: indexPath) as! MessageViewCell
|
||||
|
||||
switch currentActiveDialogs[indexPath.row].self {
|
||||
|
||||
case .groupChat(let group):
|
||||
cell.textLabel?.text = group.group.name
|
||||
cell.detailTextLabel?.text = group.lastMessage?.body.markdown
|
||||
case .groupChat:
|
||||
cell.fill(with: currentActiveDialogs[indexPath.row])
|
||||
case .userChat(let userChat):
|
||||
cell.textLabel?.text = "👤 \(users[userChat.user]!.fullName())"
|
||||
cell.detailTextLabel?.text = userChat.lastMessage?.body.markdown
|
||||
cell.fill(with: currentActiveDialogs[indexPath.row], user: users[userChat.user])
|
||||
}
|
||||
|
||||
return cell
|
||||
|
@ -53,7 +53,6 @@ class PeopleToWriteViewController: UITableViewController {
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: "peopleToWriteCell", for: indexPath)
|
||||
|
||||
cell.textLabel?.text = users[indexPath.row].fullName()
|
||||
cell.detailTextLabel?.text = "\(users[indexPath.row].id)"
|
||||
|
||||
return cell
|
||||
}
|
||||
|
@ -175,20 +175,43 @@ class ProfileViewController: UIViewController, UpdateUser
|
||||
|
||||
if idProfile == DataStorage.standard.getUserId() {
|
||||
let logoutAction = UIAlertAction(title: "Log out", style: .destructive)
|
||||
{ [weak self]
|
||||
(_) in
|
||||
self?.logOut?()
|
||||
{ [weak self] (_) in
|
||||
|
||||
if let logOut = self?.logOut {
|
||||
logOut()
|
||||
} else {
|
||||
Model.logout() {
|
||||
DataStorage.standard.setIsLoggedIn(value: false, with: 0)
|
||||
(UIApplication.shared.delegate as! AppDelegate).relaunch()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let deleetAllSessionsAction = UIAlertAction(title: "Delete all sessions", style: .destructive)
|
||||
{ [weak self]
|
||||
(_) in
|
||||
self?.deleteAllSessions?()
|
||||
{ [weak self] _ in
|
||||
|
||||
if let delete = self?.deleteAllSessions {
|
||||
delete()
|
||||
} else {
|
||||
Model.deactivateAll() {
|
||||
DataStorage.standard.setIsLoggedIn(value: false, with: 0)
|
||||
(UIApplication.shared.delegate as! AppDelegate).relaunch()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let settingsAction = UIAlertAction(title: "Edit profile", style: .default)
|
||||
{ [weak self] (_) in
|
||||
self?.onSettings?()
|
||||
|
||||
if let settings = self?.onSettings{
|
||||
settings()
|
||||
} else {
|
||||
let vc = self?.storyboard?.instantiateViewController(withIdentifier: "RegisterTableViewController") as! RegisterTableViewController
|
||||
vc.delegate = self
|
||||
vc.userActive = self?.user
|
||||
|
||||
self?.navigationController?.pushViewController(vc, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
optionMenu.addAction(settingsAction)
|
||||
|
Loading…
Reference in New Issue
Block a user