From d739f83e61ca63e9e0b26fa50046504e3fae2e28 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Fri, 4 Dec 2015 15:03:24 +0800 Subject: [PATCH 1/8] better logic in imageOfAttachment --- Yep/Caches/ImageCache.swift | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Yep/Caches/ImageCache.swift b/Yep/Caches/ImageCache.swift index 92b26aab..3cb03bf2 100644 --- a/Yep/Caches/ImageCache.swift +++ b/Yep/Caches/ImageCache.swift @@ -37,9 +37,9 @@ class ImageCache { cacheSize = deviceSize } - let attachmentOriginKey = "attachment-\(attachmentURL.absoluteString)" + let attachmentOriginKey = "attachment-0.0-0.0-\(attachmentURL.absoluteString)" - let attachmentSizeKey = "attachment-\(cacheSize)-\(attachmentURL.absoluteString)" + let attachmentSizeKey = "attachment-\(cacheSize.width)-\(cacheSize.height)-\(attachmentURL.absoluteString)" let OptionsInfos: KingfisherManager.Options = (forceRefresh: false, lowPriority: false, cacheMemoryOnly: false, shouldDecode: false, queue: cacheAttachmentQueue, scale: UIScreen.mainScreen().scale) //查找当前 Size 的 Cache @@ -71,8 +71,6 @@ class ImageCache { }) } - Kingfisher.ImageCache.defaultCache.storeImage(finalImage, forKey: attachmentSizeKey) - dispatch_async(dispatch_get_main_queue()) { completion(url: attachmentURL, image: finalImage) } @@ -94,7 +92,7 @@ class ImageCache { if cacheSize != CGSizeZero { storeImage = storeImage.resizeToTargetSize(cacheSize) } - + Kingfisher.ImageCache.defaultCache.storeImage(storeImage, originalData: UIImageJPEGRepresentation(storeImage, 1.0), forKey: attachmentSizeKey, toDisk: true, completionHandler: nil) let finalImage = storeImage.decodedImage() From e8e3c7ac3a9c1e4d8c199a1e8159cf24589d6ca5 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Fri, 4 Dec 2015 16:00:45 +0800 Subject: [PATCH 2/8] update pod Navi --- Podfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index a1afe527..e05ce665 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -17,7 +17,7 @@ PODS: - MZFayeClient (1.0.1): - Base64 (~> 1.0.1) - SocketRocket (~> 0.4) - - Navi (0.3.8) + - Navi (0.3.9) - pop (1.0.8) - Proposer (0.7.1) - Realm (0.96.2): @@ -67,7 +67,7 @@ SPEC CHECKSUMS: Kingfisher: b39315e9dbed7e8ffe73a9ca1be2ee006d1d57e4 MonkeyKing: 9be24307843a80f4cd3eca66adc12c67aefb83bb MZFayeClient: 65e7ef67e61fbe7a7a8b196130541c9f06bcb5d8 - Navi: fd0be0452eacbaa3c0b2a8c815dbc9c08e059ce9 + Navi: 24f5c81aeb46b89d27168ec1d459581230ae2675 pop: bb773ae2c791ca2629de13b347e7a8b450fa6a57 Proposer: e9759ad71a6702fd94315a0bff1f8c116edf6f07 Realm: 3ce8448151c571e90b85002d984d7f93f54fc8a3 From 7ad9d05026433198dbbb85c214b1b3d9aca78a00 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Fri, 4 Dec 2015 16:06:03 +0800 Subject: [PATCH 3/8] update wakeAvatar --- Yep/AppDelegate.swift | 2 +- .../Conversations/ConversationsViewController.swift | 2 +- Yep/Views/Cells/ProfileHeader/ProfileHeaderCell.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Yep/AppDelegate.swift b/Yep/AppDelegate.swift index d4468f7c..46b2a537 100644 --- a/Yep/AppDelegate.swift +++ b/Yep/AppDelegate.swift @@ -477,7 +477,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { conversations.forEach { conversation in if let latestMessage = conversation.messages.last, user = latestMessage.fromFriend { let userAvatar = UserAvatar(userID: user.userID, avatarStyle: miniAvatarStyle) - AvatarPod.wakeAvatar(userAvatar, completion: { _ ,_ in }) + AvatarPod.wakeAvatar(userAvatar, completion: { _ , _, _ in }) } } } diff --git a/Yep/ViewControllers/Conversations/ConversationsViewController.swift b/Yep/ViewControllers/Conversations/ConversationsViewController.swift index ab090c27..fffbfefa 100644 --- a/Yep/ViewControllers/Conversations/ConversationsViewController.swift +++ b/Yep/ViewControllers/Conversations/ConversationsViewController.swift @@ -149,7 +149,7 @@ class ConversationsViewController: UIViewController { for user in normalUsers() { let userAvatar = UserAvatar(userID: user.userID, avatarStyle: nanoAvatarStyle) - AvatarPod.wakeAvatar(userAvatar, completion: { _, _ in }) + AvatarPod.wakeAvatar(userAvatar, completion: { _, _, _ in }) } /* diff --git a/Yep/Views/Cells/ProfileHeader/ProfileHeaderCell.swift b/Yep/Views/Cells/ProfileHeader/ProfileHeaderCell.swift index daed5de0..79cde55f 100644 --- a/Yep/Views/Cells/ProfileHeader/ProfileHeaderCell.swift +++ b/Yep/Views/Cells/ProfileHeader/ProfileHeaderCell.swift @@ -126,7 +126,7 @@ class ProfileHeaderCell: UICollectionViewCell { let avatarStyle = AvatarStyle.Original let plainAvatar = PlainAvatar(avatarURLString: avatarURLString, avatarStyle: avatarStyle) - AvatarPod.wakeAvatar(plainAvatar) { [weak self] finished, image in + AvatarPod.wakeAvatar(plainAvatar) { [weak self] finished, image, _ in if finished { self?.blurImage(image) { blurredImage in From 6c3498fefe03afc160218368905339a684205cd6 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Fri, 4 Dec 2015 16:13:17 +0800 Subject: [PATCH 4/8] adjust TransitionDuration --- Yep/Configs/YepConfig.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Yep/Configs/YepConfig.swift b/Yep/Configs/YepConfig.swift index e5bb128c..5cb46e83 100644 --- a/Yep/Configs/YepConfig.swift +++ b/Yep/Configs/YepConfig.swift @@ -12,8 +12,8 @@ import CoreLocation import Kingfisher let avatarFadeTransitionDuration: NSTimeInterval = 0.0 -let bigAvatarFadeTransitionDuration: NSTimeInterval = 0.2 -let imageFadeTransitionDuration: NSTimeInterval = 0.3 +let bigAvatarFadeTransitionDuration: NSTimeInterval = 0.15 +let imageFadeTransitionDuration: NSTimeInterval = 0.2 let MediaOptionsInfos: KingfisherOptionsInfo = [ .Options([.BackgroundDecode, .LowPriority]), From 82b6fc93b321ad6071673138ba7f56b9d750c2ce Mon Sep 17 00:00:00 2001 From: nixzhu Date: Fri, 4 Dec 2015 16:29:49 +0800 Subject: [PATCH 5/8] better delay fade PreviewImageView --- .../MediaPreviewViewController.swift | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Yep/ViewControllers/MediaPreview/MediaPreviewViewController.swift b/Yep/ViewControllers/MediaPreview/MediaPreviewViewController.swift index b2c649cf..75f4b928 100644 --- a/Yep/ViewControllers/MediaPreview/MediaPreviewViewController.swift +++ b/Yep/ViewControllers/MediaPreview/MediaPreviewViewController.swift @@ -10,6 +10,7 @@ import UIKit import AVFoundation import MonkeyKing import Kingfisher +import Ruler let mediaPreviewWindow = UIWindow(frame: UIScreen.mainScreen().bounds) @@ -140,19 +141,24 @@ class MediaPreviewViewController: UIViewController { }, completion: { [weak self] _ in self?.mediasCollectionView.alpha = 1 + let fade: (() -> Void)? = { [weak self] in + self?.topPreviewImageView.alpha = 0 + self?.bottomPreviewImageView.alpha = 0 + } + UIView.animateWithDuration(0.25, delay: 0.0, options: .CurveLinear, animations: { [weak self] in self?.mediaControlView.alpha = 1 - }, completion: nil) + }, completion: { _ in + Ruler.iPhoneHorizontal(fade, nil, nil).value?() + }) - // 原图需要更快的显示出来,避免停留在 thumbnial 太久 - - UIView.animateWithDuration(0.1, delay: 0.0, options: .CurveLinear, animations: { [weak self] in - self?.topPreviewImageView.alpha = 0 - self?.bottomPreviewImageView.alpha = 0 + UIView.animateWithDuration(0.1, delay: 0.1, options: .CurveLinear, animations: { + Ruler.iPhoneHorizontal(nil, fade, fade).value?() + }, completion: { [weak self] _ in - self?.showFinished = true - println("showFinished") + self?.showFinished = true + println("showFinished") }) }) From 5c7de5b31b96e5bb89e801deeb9f78302735cd23 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Fri, 4 Dec 2015 17:06:48 +0800 Subject: [PATCH 6/8] update dot icons --- .../icon_dot_failed.pdf | Bin 3925 -> 4025 bytes .../icon_dot_sending.pdf | Bin 3923 -> 3914 bytes .../icon_dot_unread.pdf | Bin 3931 -> 3925 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/Yep/Images.xcassets/icon_dot_failed.imageset/icon_dot_failed.pdf b/Yep/Images.xcassets/icon_dot_failed.imageset/icon_dot_failed.pdf index 36f5a5b94647d62f0ab0f4bb880eed5c9ab7f944..7e4e01ab56c93f9a1b1c1b36293da537057e1abb 100644 GIT binary patch delta 625 zcmcaAw^M#XKz(W8=`3bLo;|;{pT$I6|KwbDuKKm^8%6nqs7sSrF8!^4aYOOm6alfE zUeif#o5SA}wz8dVvQ=bp@( ztld}6*=`)1+zZ>?qt?02>aOky;AgwsMDL&<$B`vZbGh`)Ygdd#qI11 zKm7Yj!{evFDvyN6|9r}Gklp&f&AD0P9Sb=l(q@?!>e(l?T3j(^QoOrak*zaVVzYF{ zHA|P(p59%`$x}*C#aR1C$8oanEYzB|?#9hGn=Eoq+qqx3Pxs| z(;3~lA$wsb#XcrHPS&L6W6`sgZe#aiX!gnXy@td8(0FsvVaNK_v>Y3U+o}#U+VF VB^5=fXTSTmTt#&9eXi delta 503 zcmdlfe^qWmK)rAOMXtjNJg)bDi+-;RNEhn;RvCX`d96cY$%5uf|J#?Y+tH-rex7#* zud!Lr6q^WJEtlZMmoijl2Gsp~@^x0-y$_Boi}_xeWc3}?lYFGY!D`wQv8L?yLxY=l zR8QHO70iCT|Lw-Z8_up>8@@%qVtK{me>XT!^EH+GO#U^cS3^KmviI=51d$0hCWXD3 zviQd2x8>hN_0Pl~K4{)N*@sbz(QtA)V?3*&fr6pI=F^Ps+z{quao#*;13lBp9lY9H z29`!f1{NkJ#+H-!@-}Fi7#k}XfPg}t0vDKJU|?isi7sYrG&zk=z23;w0A0qw*xV3Z z%-GP}2wltoXd}9qv7sr3I%6XX3k-F}#$Yi%WM>*1PnP0$h)*%GFfdLwOinULG%+zT zPfJNoOi4B|v^2IzHc3e}H?rfhA*e(lR>97WtGFbwsHCDOHI2*I)WCvERn^tsjSB$Y C^PQ9c diff --git a/Yep/Images.xcassets/icon_dot_sending.imageset/icon_dot_sending.pdf b/Yep/Images.xcassets/icon_dot_sending.imageset/icon_dot_sending.pdf index d5fadbd801b0d1316cb9aea266b70ebbd93eebd1..e2030dece62ac302f738d97adf2834cd42580c74 100644 GIT binary patch delta 515 zcmcaCcS>$TQ2j=(!v;Jq-)oNkb%;4RDYg3BHQkCA>@9q{zKU-z++ROQkwx*~?#Fyv zk`8rEEIuN!)TyW`^4Rk}>3a_*d|-b3>NgAPVdm-IQn$Pl*(vpO)632*MOlq2IkQe) znEl=8M0$!rBkyOX!ni$QArZOT{S{`!2Cd&bsl-C&^PJ<~e_Pc|*L=ehz3aFAWqH>% zT3fhM^HPdSic%AEL9G0wEG|<80|gLmXkt8>nK72t$V|b=Y;!83J2!+mc_U9Av!R~h zWF=m0E<+;&69WrV3nR11;k=DnMn(z-AfS+^zy)R)7#NvapoJ I)!&T^0Fz~$TL1t6 delta 491 zcmX>lcUf*iQ2k!MW&@s<@_CP*c?DQ=s?FS7>daHypp(lwHK2W;ox6m?v^CcC)9S-| zA}(4j|DY8yW9_P)tIX8Su-iR(ee3t0hum+g{wzGp+{M4dcu(PZd)Ij{=BQ0peD^gj zXo|yBHtuGLWoNE(C2rwr?>O{#LfXRs`8{l_KP1_3c{d)``SvhJ^zm7PO}6LNw;$7M z+mi6;@MAV9B}4Ivccqz3jVAtzWi>QVFf`a4!|2WpVNPDblgDhJXF6GuSDVYg(#Xib z!oU22#4MopPTtIC5pQH_YH4b2Y;2xvoNAVoYG7b)XlP<$ uYMNr0Xk?g_YG}u0Lr{rAtb&~#S8+*VQAtHnY8scZseu`ns;aBM8y5f)`;_DW diff --git a/Yep/Images.xcassets/icon_dot_unread.imageset/icon_dot_unread.pdf b/Yep/Images.xcassets/icon_dot_unread.imageset/icon_dot_unread.pdf index 7ec0372736641bb490740980d80a467ab0ffd30b..ed35046c420153569f19987b9e5712b5386d3b36 100644 GIT binary patch delta 502 zcmcaDcU5jeV7#3!ArkUai;pTcsR16!6{5V`b6UTb#(ms|JJk3|Uw z8NUV`ED`0NT2QTlpfl}YS#C1cYXZ+{?&=I#V@AH$mmy25WY)tsQH|560 zxDUrx984^Ud=T6cdFXlH)JC5+^>y2W1O2R)-&8qUYVS2qHQ;HAgkmRex?@Z5zrF)s zR|$A-eAvc5O}~Q8WW~gH(oCi%lermVS&hsTjLbIYGP-j^n3H$% zBXltX6JtzM4NWoB85>zxpzAd@HinAvA)IM!Y-u=oAD>-(ikYcFnwha>Qd*itqG7US zN^)YVNn)CzrMZ!*sfD419hVJ3B?_?$c6MCFC5c5P6-B9OT*jsb7F?>TuKsRZ01ddB AcmMzZ delta 531 zcmcaAcUx{kV12(g*I@%5m+zKG*Kikp-6&dpS2*P=Gm96Or{a@;0Y`cB4)h$WQ%=m4 z*tqcdApzwz7c#EuUj4d;^>qLIx_!&$o7YTGh_L3KrnCITbRJ%*skI?xRy)mZopIc> z**hd^&E#9^^|zAP1>eukjt$)JaPY&izZ;F0$%?deUz~6^a?vDB>oSp3355!W?G}b_ z__ax|ZkqF-lizJ#_lO_U?+Ujx5T5&5a#5~JbBCpdZv?Ac(u6 Date: Fri, 4 Dec 2015 17:17:52 +0800 Subject: [PATCH 7/8] update dotImageView of Right Cells --- Yep/Configs/YepConfig.swift | 2 +- Yep/Views/Cells/ChatRightAudio/ChatRightAudioCell.xib | 8 ++++---- Yep/Views/Cells/ChatRightImage/ChatRightImageCell.xib | 8 ++++---- .../Cells/ChatRightLocation/ChatRightLocationCell.xib | 8 ++++---- Yep/Views/Cells/ChatRightText/ChatRightTextCell.xib | 8 ++++---- Yep/Views/Cells/ChatRightVideo/ChatRightVideoCell.xib | 8 ++++---- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Yep/Configs/YepConfig.swift b/Yep/Configs/YepConfig.swift index 5cb46e83..a0dbb6d9 100644 --- a/Yep/Configs/YepConfig.swift +++ b/Yep/Configs/YepConfig.swift @@ -180,7 +180,7 @@ class YepConfig { static let minTextWidth: CGFloat = 17 - static let gapBetweenDotImageViewAndBubble: CGFloat = 5 + static let gapBetweenDotImageViewAndBubble: CGFloat = 13 static let gapBetweenAvatarImageViewAndBubble: CGFloat = 5 diff --git a/Yep/Views/Cells/ChatRightAudio/ChatRightAudioCell.xib b/Yep/Views/Cells/ChatRightAudio/ChatRightAudioCell.xib index 7cdf7ee8..e3c5161f 100644 --- a/Yep/Views/Cells/ChatRightAudio/ChatRightAudioCell.xib +++ b/Yep/Views/Cells/ChatRightAudio/ChatRightAudioCell.xib @@ -1,8 +1,8 @@ - + - + @@ -54,7 +54,7 @@ - + @@ -77,7 +77,7 @@ - + diff --git a/Yep/Views/Cells/ChatRightImage/ChatRightImageCell.xib b/Yep/Views/Cells/ChatRightImage/ChatRightImageCell.xib index 5549996a..056b5f07 100644 --- a/Yep/Views/Cells/ChatRightImage/ChatRightImageCell.xib +++ b/Yep/Views/Cells/ChatRightImage/ChatRightImageCell.xib @@ -1,8 +1,8 @@ - + - + @@ -22,7 +22,7 @@ - + @@ -38,6 +38,6 @@ - + diff --git a/Yep/Views/Cells/ChatRightLocation/ChatRightLocationCell.xib b/Yep/Views/Cells/ChatRightLocation/ChatRightLocationCell.xib index b9e2f7cb..4ad55b5b 100644 --- a/Yep/Views/Cells/ChatRightLocation/ChatRightLocationCell.xib +++ b/Yep/Views/Cells/ChatRightLocation/ChatRightLocationCell.xib @@ -1,8 +1,8 @@ - + - + @@ -25,7 +25,7 @@ - + @@ -53,6 +53,6 @@ - + diff --git a/Yep/Views/Cells/ChatRightText/ChatRightTextCell.xib b/Yep/Views/Cells/ChatRightText/ChatRightTextCell.xib index b3b27867..c36f8e4c 100644 --- a/Yep/Views/Cells/ChatRightText/ChatRightTextCell.xib +++ b/Yep/Views/Cells/ChatRightText/ChatRightTextCell.xib @@ -1,8 +1,8 @@ - + - + @@ -25,7 +25,7 @@ - + @@ -64,6 +64,6 @@ - + diff --git a/Yep/Views/Cells/ChatRightVideo/ChatRightVideoCell.xib b/Yep/Views/Cells/ChatRightVideo/ChatRightVideoCell.xib index caf44d1e..926b2bd0 100644 --- a/Yep/Views/Cells/ChatRightVideo/ChatRightVideoCell.xib +++ b/Yep/Views/Cells/ChatRightVideo/ChatRightVideoCell.xib @@ -1,8 +1,8 @@ - + - + @@ -29,7 +29,7 @@ - + @@ -49,7 +49,7 @@ - + From b632ca1aaad573a04424557c2e95c54c398822fa Mon Sep 17 00:00:00 2001 From: nixzhu Date: Fri, 4 Dec 2015 17:22:37 +0800 Subject: [PATCH 8/8] fix logic to showSendingAnimation --- Yep/Views/Cells/ChatRightBase/ChatRightBaseCell.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Yep/Views/Cells/ChatRightBase/ChatRightBaseCell.swift b/Yep/Views/Cells/ChatRightBase/ChatRightBaseCell.swift index 07588ff6..91c3c3b1 100644 --- a/Yep/Views/Cells/ChatRightBase/ChatRightBaseCell.swift +++ b/Yep/Views/Cells/ChatRightBase/ChatRightBaseCell.swift @@ -28,10 +28,11 @@ class ChatRightBaseCell: ChatBaseCell { dotImageView.image = UIImage(named: "icon_dot_sending") dotImageView.hidden = false - delay(0.1, work: { [weak self] in - self?.showSendingAnimation() - }) - + delay(0.1) { [weak self] in + if let messageSendState = self?.messageSendState where messageSendState == .NotSend { + self?.showSendingAnimation() + } + } case MessageSendState.Successed: dotImageView.image = UIImage(named: "icon_dot_unread")