Browse Source

upgrade to new MessageKit API and Swift 4.1

Alla Reinsch 7 years ago
parent
commit
bdfb0c12e5

+ 2 - 18
deltachat-ios.xcodeproj/project.pbxproj

@@ -449,8 +449,7 @@
 				7A9FB13C1FB061E2001FEA36 /* Sources */,
 				7A9FB13D1FB061E2001FEA36 /* Frameworks */,
 				7A9FB13E1FB061E2001FEA36 /* Resources */,
-				269B032E4F093924FBEF3924 /* [CP] Embed Pods Frameworks */,
-				5666073C703CC2D48B2D265F /* [CP] Copy Pods Resources */,
+				30C8FE37A924BE7AFF9661C1 /* [CP] Embed Pods Frameworks */,
 			);
 			buildRules = (
 			);
@@ -539,7 +538,7 @@
 /* End PBXResourcesBuildPhase section */
 
 /* Begin PBXShellScriptBuildPhase section */
-		269B032E4F093924FBEF3924 /* [CP] Embed Pods Frameworks */ = {
+		30C8FE37A924BE7AFF9661C1 /* [CP] Embed Pods Frameworks */ = {
 			isa = PBXShellScriptBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
@@ -557,21 +556,6 @@
 			shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-deltachat-ios/Pods-deltachat-ios-frameworks.sh\"\n";
 			showEnvVarsInLog = 0;
 		};
-		5666073C703CC2D48B2D265F /* [CP] Copy Pods Resources */ = {
-			isa = PBXShellScriptBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			inputPaths = (
-			);
-			name = "[CP] Copy Pods Resources";
-			outputPaths = (
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-			shellPath = /bin/sh;
-			shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-deltachat-ios/Pods-deltachat-ios-resources.sh\"\n";
-			showEnvVarsInLog = 0;
-		};
 		58C9D79942D26B7F8F210DA1 /* [CP] Check Pods Manifest.lock */ = {
 			isa = PBXShellScriptBuildPhase;
 			buildActionMask = 2147483647;

+ 8 - 0
deltachat-ios.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>IDEDidComputeMac32BitWarning</key>
+	<true/>
+</dict>
+</plist>

+ 19 - 27
deltachat-ios/ChatViewController.swift

@@ -91,7 +91,7 @@ class ChatViewController: MessagesViewController {
         messagesCollectionView.messageCellDelegate = self
         messageInputBar.delegate = self
         messageInputBar.sendButton.tintColor = UIColor(red: 69/255, green: 193/255, blue: 89/255, alpha: 1)
-        scrollsToBottomOnFirstLayout = true //default false
+        // scrollsToBottomOnFirstLayout = true //default false
         scrollsToBottomOnKeybordBeginsEditing = true // default false
         
         navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(named: "ic_keyboard"),
@@ -280,7 +280,7 @@ extension ChatViewController: MessagesDataSource {
 
 // MARK: - MessagesDisplayDelegate
 
-extension ChatViewController: MessagesDisplayDelegate, TextMessageDisplayDelegate {
+extension ChatViewController: MessagesDisplayDelegate {
     
     func backgroundColor(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> UIColor {
         return isFromCurrentSender(message: message) ? Constants.Color.bubble : UIColor(red: 230/255, green: 230/255, blue: 230/255, alpha: 1)
@@ -302,6 +302,9 @@ extension ChatViewController: MessagesDisplayDelegate, TextMessageDisplayDelegat
 // MARK: - MessagesLayoutDelegate
 
 extension ChatViewController: MessagesLayoutDelegate {
+    func heightForLocation(message: MessageType, at indexPath: IndexPath, with maxWidth: CGFloat, in messagesCollectionView: MessagesCollectionView) -> CGFloat {
+        return 40
+    }
     
     func messagePadding(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> UIEdgeInsets {
         if isFromCurrentSender(message: message) {
@@ -327,8 +330,8 @@ extension ChatViewController: MessagesLayoutDelegate {
         }
     }
     
-    func avatarAlignment(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> AvatarAlignment {
-        return .messageBottom
+    func avatarAlignment(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> AvatarPosition.Horizontal {
+        return AvatarPosition.Horizontal.cellLeading
     }
     
     func footerViewSize(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> CGSize {
@@ -338,40 +341,26 @@ extension ChatViewController: MessagesLayoutDelegate {
     
 }
 
-// MARK: - LocationMessageLayoutDelegate
-
-extension ChatViewController: LocationMessageLayoutDelegate {
-    
-    func heightForLocation(message: MessageType, at indexPath: IndexPath, with maxWidth: CGFloat, in messagesCollectionView: MessagesCollectionView) -> CGFloat {
-        return 200
-    }
-    
-}
-
-// MARK: - MediaMessageLayoutDelegate
-
-extension ChatViewController: MediaMessageLayoutDelegate {}
 
 // MARK: - MessageCellDelegate
 
 extension ChatViewController: MessageCellDelegate {
+    func didTapMessage(in cell: MessageCollectionViewCell) {
+        print("Message tapped")
+    }
     
-    func didTapAvatar<T>(in cell: MessageCollectionViewCell<T>) {
+    func didTapAvatar(in cell: MessageCollectionViewCell) {
         print("Avatar tapped")
-    }
     
-    func didTapMessage<T>(in cell: MessageCollectionViewCell<T>) {
-        print("Message tapped")
     }
     
-    func didTapTopLabel<T>(in cell: MessageCollectionViewCell<T>) {
+    func didTapTopLabel(in cell: MessageCollectionViewCell) {
         print("Top label tapped")
     }
-    
-    func didTapBottomLabel<T>(in cell: MessageCollectionViewCell<T>) {
-        print("Bottom label tapped")
+
+    func didTapBottomLabel(in cell: MessageCollectionViewCell) {
+        print ("Bottom label tapped")
     }
-    
 }
 
 // MARK: - MessageLabelDelegate
@@ -395,7 +384,7 @@ extension ChatViewController: MessageLabelDelegate {
     }
     
 }
-
+/*
 // MARK: - LocationMessageDisplayDelegate
 
 extension ChatViewController: LocationMessageDisplayDelegate {
@@ -420,8 +409,10 @@ extension ChatViewController: LocationMessageDisplayDelegate {
     }
     
 }
+*/
 
 // MARK: - MessageInputBarDelegate
+ 
 
 extension ChatViewController: MessageInputBarDelegate {
     
@@ -435,3 +426,4 @@ extension ChatViewController: MessageInputBarDelegate {
 //        messagesCollectionView.scrollToBottom()
     }
 }
+

+ 3 - 3
deltachat-ios/SampleData.swift

@@ -184,11 +184,11 @@ final class SampleData {
     func getAvatarFor(sender: Sender) -> Avatar {
         switch sender {
         case dan:
-            return Avatar(image: #imageLiteral(resourceName: "ic_people_36pt").withRenderingMode(.alwaysTemplate), initals: "DL")
+            return Avatar(image: #imageLiteral(resourceName: "ic_people_36pt").withRenderingMode(.alwaysTemplate), initials: "DL")
         case steven:
-            return Avatar(initals: "S")
+            return Avatar(initials: "S")
         case jobs:
-            return Avatar(image: #imageLiteral(resourceName: "ic_people_36pt").withRenderingMode(.alwaysTemplate), initals: "SJ")
+            return Avatar(image: #imageLiteral(resourceName: "ic_people_36pt").withRenderingMode(.alwaysTemplate), initials: "SJ")
         case cook:
             return Avatar(image: #imageLiteral(resourceName: "ic_people_36pt").withRenderingMode(.alwaysTemplate))
         default: