diff --git a/Podfile b/Podfile index 701adb19..440b0090 100644 --- a/Podfile +++ b/Podfile @@ -4,7 +4,7 @@ use_frameworks! def pods pod 'DeviceGuru' - pod '1PasswordExtension' + pod '1PasswordExtension', '~> 1.5' pod 'KeyboardMan' pod 'Ruler' pod 'Proposer' diff --git a/Podfile.lock b/Podfile.lock index 2f6313ab..2b4860bb 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - 1PasswordExtension (1.2) + - 1PasswordExtension (1.5) - AFNetworking (2.5.4): - AFNetworking/NSURLConnection (= 2.5.4) - AFNetworking/NSURLSession (= 2.5.4) @@ -44,7 +44,7 @@ PODS: - TPKeyboardAvoiding (1.2.9) DEPENDENCIES: - - 1PasswordExtension + - 1PasswordExtension (~> 1.5) - AFNetworking (~> 2.5.4) - APAddressBook/Swift - DeviceGuru @@ -60,10 +60,10 @@ DEPENDENCIES: EXTERNAL SOURCES: MZFayeClient: - :path: "../CatchLib-iOS/MZFayeClient/" + :path: ../CatchLib-iOS/MZFayeClient/ SPEC CHECKSUMS: - 1PasswordExtension: fcf300204bda5b5c78936dbb937a7d661f1ca796 + 1PasswordExtension: d2392e44526be30ae7d23f305e96e411ede9b9d1 AFNetworking: 05edc0ac4c4c8cf57bcf4b84be5b0744b6d8e71e APAddressBook: 2c949367b190a993d2cce769a3b20bce8bcf000c Base64: 4924bf3ca6fa559a5161ef717291bd450eb7bd1a diff --git a/Yep.xcodeproj/project.pbxproj b/Yep.xcodeproj/project.pbxproj index 6fd792f1..3f574f45 100644 --- a/Yep.xcodeproj/project.pbxproj +++ b/Yep.xcodeproj/project.pbxproj @@ -207,6 +207,7 @@ 50E114FC1ABC549300F13000 /* ContactsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E114FA1ABC549300F13000 /* ContactsCell.swift */; }; 50E114FD1ABC549300F13000 /* ContactsCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50E114FB1ABC549300F13000 /* ContactsCell.xib */; }; 50E18BB71B180F7D0076C3C6 /* BottomButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E18BB61B180F7D0076C3C6 /* BottomButtonView.swift */; }; + 50E1D7291B870D7500D90A82 /* NSParagraphStyle+Yep.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E1D7281B870D7500D90A82 /* NSParagraphStyle+Yep.swift */; }; 50E61CEB1AF1F69D00908A9D /* ConversationTitleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E61CEA1AF1F69D00908A9D /* ConversationTitleView.swift */; }; 50EB8C5E1AE78AB9001AC1EE /* YepAsset.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50EB8C5D1AE78AB9001AC1EE /* YepAsset.swift */; }; 50EB8CBF1AE89ED8001AC1EE /* ChatLeftVideoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50EB8CBD1AE89ED8001AC1EE /* ChatLeftVideoCell.swift */; }; @@ -454,6 +455,7 @@ 50E114FA1ABC549300F13000 /* ContactsCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ContactsCell.swift; path = Views/Cells/Contacts/ContactsCell.swift; sourceTree = ""; }; 50E114FB1ABC549300F13000 /* ContactsCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = ContactsCell.xib; path = Views/Cells/Contacts/ContactsCell.xib; sourceTree = ""; }; 50E18BB61B180F7D0076C3C6 /* BottomButtonView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BottomButtonView.swift; path = Views/SayHi/BottomButtonView.swift; sourceTree = ""; }; + 50E1D7281B870D7500D90A82 /* NSParagraphStyle+Yep.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "NSParagraphStyle+Yep.swift"; path = "Extensions/NSParagraphStyle+Yep.swift"; sourceTree = ""; }; 50E61CEA1AF1F69D00908A9D /* ConversationTitleView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ConversationTitleView.swift; path = Views/ConversationTitle/ConversationTitleView.swift; sourceTree = ""; }; 50EB8C5D1AE78AB9001AC1EE /* YepAsset.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = YepAsset.swift; path = Helpers/YepAsset.swift; sourceTree = ""; }; 50EB8CBD1AE89ED8001AC1EE /* ChatLeftVideoCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ChatLeftVideoCell.swift; path = Views/Cells/ChatLeftVideo/ChatLeftVideoCell.swift; sourceTree = ""; }; @@ -809,6 +811,7 @@ 501560D61B427FD6000933F0 /* Results+Yep.swift */, 50B38FB61B69CD960064C132 /* Array+Yep.swift */, 50FA9A431B661698009BF2A0 /* UIViewController+Yep.swift */, + 50E1D7281B870D7500D90A82 /* NSParagraphStyle+Yep.swift */, ); name = Extensions; sourceTree = ""; @@ -1968,6 +1971,7 @@ 5023DE2A1AB685BA00B3EE96 /* ContactsViewController.swift in Sources */, 50CDBE491ACBAD3200459CE0 /* ChatLeftImageCell.swift in Sources */, 5033159C1AC101C80008A209 /* ChatRightTextCell.swift in Sources */, + 50E1D7291B870D7500D90A82 /* NSParagraphStyle+Yep.swift in Sources */, 5044BF061B5FA74800930ADC /* BubbleMenuView.swift in Sources */, 5023DE561AB6CA1000B3EE96 /* AvatarCache.swift in Sources */, 5023DE371AB6979600B3EE96 /* ConversationCell.swift in Sources */, diff --git a/Yep/Configs/YepConfig.swift b/Yep/Configs/YepConfig.swift index 5b98a489..3fe76c57 100644 --- a/Yep/Configs/YepConfig.swift +++ b/Yep/Configs/YepConfig.swift @@ -136,6 +136,15 @@ class YepConfig { static let centerXOffset: CGFloat = 4 static let imageAppearDuration: NSTimeInterval = 0.1 + + static let textAttributes:[String: NSObject] = [ + NSFontAttributeName: UIFont.chatTextFont(), + ] +// static let textAttributes: [String: NSObject] = [ +// NSFontAttributeName: UIFont.chatTextFont(), +// NSKernAttributeName: 0.5, +// NSParagraphStyleAttributeName: NSParagraphStyle.chatTextParagraphStyle(), +// ] } struct MetaData { diff --git a/Yep/Extensions/NSParagraphStyle+Yep.swift b/Yep/Extensions/NSParagraphStyle+Yep.swift new file mode 100644 index 00000000..fd14a0cb --- /dev/null +++ b/Yep/Extensions/NSParagraphStyle+Yep.swift @@ -0,0 +1,25 @@ +// +// NSParagraphStyle+Yep.swift +// Yep +// +// Created by nixzhu on 15/8/21. +// Copyright (c) 2015年 Catch Inc. All rights reserved. +// + +import UIKit + +extension NSParagraphStyle { + + class func chatTextParagraphStyle() -> NSParagraphStyle { + + let style = NSMutableParagraphStyle() + + style.minimumLineHeight = 17.3 + style.lineSpacing = 0 + style.paragraphSpacing = 0 + style.paragraphSpacingBefore = 0 + style.lineBreakMode = .ByWordWrapping + + return style + } +} diff --git a/Yep/ViewControllers/Conversation/ConversationViewController.swift b/Yep/ViewControllers/Conversation/ConversationViewController.swift index 1a271262..5d6b8b11 100644 --- a/Yep/ViewControllers/Conversation/ConversationViewController.swift +++ b/Yep/ViewControllers/Conversation/ConversationViewController.swift @@ -103,7 +103,6 @@ class ConversationViewController: BaseViewController { let sectionInsetTop: CGFloat = 10 let sectionInsetBottom: CGFloat = 10 - let messageTextAttributes = [NSFontAttributeName: UIFont.chatTextFont()] lazy var messageTextLabelMaxWidth: CGFloat = { let maxWidth = self.collectionViewWidth - (YepConfig.chatCellGapBetweenWallAndAvatar() + YepConfig.chatCellAvatarSize() + YepConfig.chatCellGapBetweenTextContentLabelAndAvatar() + YepConfig.chatTextGapBetweenWallAndContentLabel()) return maxWidth @@ -1011,7 +1010,7 @@ class ConversationViewController: BaseViewController { switch message.mediaType { case MessageMediaType.Text.rawValue: - let rect = message.textContent.boundingRectWithSize(CGSize(width: messageTextLabelMaxWidth, height: CGFloat(FLT_MAX)), options: .UsesLineFragmentOrigin | .UsesFontLeading, attributes: messageTextAttributes, context: nil) + let rect = message.textContent.boundingRectWithSize(CGSize(width: messageTextLabelMaxWidth, height: CGFloat(FLT_MAX)), options: .UsesLineFragmentOrigin | .UsesFontLeading, attributes: YepConfig.ChatCell.textAttributes, context: nil) height = max(ceil(rect.height) + (11 * 2), YepConfig.chatCellAvatarSize()) @@ -1081,7 +1080,7 @@ class ConversationViewController: BaseViewController { } } - let rect = message.textContent.boundingRectWithSize(CGSize(width: messageTextLabelMaxWidth, height: CGFloat(FLT_MAX)), options: .UsesLineFragmentOrigin | .UsesFontLeading, attributes: messageTextAttributes, context: nil) + let rect = message.textContent.boundingRectWithSize(CGSize(width: messageTextLabelMaxWidth, height: CGFloat(FLT_MAX)), options: .UsesLineFragmentOrigin | .UsesFontLeading, attributes: YepConfig.ChatCell.textAttributes, context: nil) let width = ceil(rect.width) diff --git a/Yep/ViewControllers/OAuth/OAuthViewController.swift b/Yep/ViewControllers/OAuth/OAuthViewController.swift index 7a8c7173..6fba89ff 100644 --- a/Yep/ViewControllers/OAuth/OAuthViewController.swift +++ b/Yep/ViewControllers/OAuth/OAuthViewController.swift @@ -49,7 +49,7 @@ class OAuthViewController: BaseViewController, UIWebViewDelegate, NSURLConnectio } @IBAction func fillPassword(sender: AnyObject) { - OnePasswordExtension.sharedExtension().fillLoginIntoWebView(webView, forViewController: self, sender: sender) { (finish, error) -> Void in + OnePasswordExtension.sharedExtension().fillItemIntoWebView(webView, forViewController: self, sender: sender, showOnlyLogins: false) { (finish, error) -> Void in } } diff --git a/Yep/Views/Cells/ChatLeftText/ChatLeftTextCell.swift b/Yep/Views/Cells/ChatLeftText/ChatLeftTextCell.swift index 4c072129..e749211e 100644 --- a/Yep/Views/Cells/ChatLeftText/ChatLeftTextCell.swift +++ b/Yep/Views/Cells/ChatLeftText/ChatLeftTextCell.swift @@ -58,6 +58,7 @@ class ChatLeftTextCell: ChatBaseCell { self.user = message.fromFriend textContentTextView.text = message.textContent + //textContentTextView.attributedText = NSAttributedString(string: message.textContent, attributes: textAttributes) textContentTextViewWidthConstraint.constant = max(YepConfig.minMessageTextLabelWidth, textContentLabelWidth) textContentTextView.textAlignment = textContentLabelWidth < YepConfig.minMessageTextLabelWidth ? .Center : .Left diff --git a/Yep/Views/Cells/ChatLeftText/ChatLeftTextCell.xib b/Yep/Views/Cells/ChatLeftText/ChatLeftTextCell.xib index 915ae8be..b7d0fccf 100644 --- a/Yep/Views/Cells/ChatLeftText/ChatLeftTextCell.xib +++ b/Yep/Views/Cells/ChatLeftText/ChatLeftTextCell.xib @@ -1,5 +1,5 @@ - + @@ -14,7 +14,7 @@ - + @@ -22,12 +22,12 @@ - + - + @@ -35,7 +35,7 @@ - + @@ -51,11 +51,12 @@ - + + diff --git a/Yep/Views/Cells/ChatRightText/ChatRightTextCell.swift b/Yep/Views/Cells/ChatRightText/ChatRightTextCell.swift index 751b90ff..53931cd9 100644 --- a/Yep/Views/Cells/ChatRightText/ChatRightTextCell.swift +++ b/Yep/Views/Cells/ChatRightText/ChatRightTextCell.swift @@ -73,6 +73,7 @@ class ChatRightTextCell: ChatRightBaseCell { self.mediaTapAction = mediaTapAction textContentTextView.text = message.textContent + //textContentTextView.attributedText = NSAttributedString(string: message.textContent, attributes: textAttributes) textContentTextViewWidthConstraint.constant = max(YepConfig.minMessageTextLabelWidth, textContentLabelWidth) textContentTextView.textAlignment = textContentLabelWidth < YepConfig.minMessageTextLabelWidth ? .Center : .Left diff --git a/Yep/Views/Cells/ChatRightText/ChatRightTextCell.xib b/Yep/Views/Cells/ChatRightText/ChatRightTextCell.xib index d2215328..97fdbdee 100644 --- a/Yep/Views/Cells/ChatRightText/ChatRightTextCell.xib +++ b/Yep/Views/Cells/ChatRightText/ChatRightTextCell.xib @@ -1,5 +1,5 @@ - + @@ -14,7 +14,7 @@ - + @@ -22,11 +22,11 @@ - + - + @@ -35,7 +35,7 @@ - + @@ -46,7 +46,7 @@ - + @@ -67,10 +67,11 @@ - + +