From 1931c0bec2f5b616535e8c46a32c9fe4d9a3906b Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 31 Dec 2015 09:42:21 +0800 Subject: [PATCH 1/7] =?UTF-8?q?trans=20=E6=B6=88=E6=81=AF=E5=B7=B2?= =?UTF-8?q?=E8=A2=AB=E6=92=A4=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Yep/Realm/Models.swift | 2 +- Yep/zh-Hans.lproj/Localizable.strings | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Yep/Realm/Models.swift b/Yep/Realm/Models.swift index aff0e74f..fe8cdb6a 100644 --- a/Yep/Realm/Models.swift +++ b/Yep/Realm/Models.swift @@ -513,7 +513,7 @@ class Message: Object { dynamic var textContent: String = "" var textContentToShow: String { if deletedByCreator { - return NSLocalizedString("Deleted by creator.", comment: "") + return NSLocalizedString("Recalled by creator.", comment: "") } else { return textContent } diff --git a/Yep/zh-Hans.lproj/Localizable.strings b/Yep/zh-Hans.lproj/Localizable.strings index 8595eff8..e1fc8f76 100644 --- a/Yep/zh-Hans.lproj/Localizable.strings +++ b/Yep/zh-Hans.lproj/Localizable.strings @@ -726,5 +726,5 @@ "Hide" = "隐藏"; -"Deleted by creator." = "被创建者删除。"; +"Recalled by creator." = "消息已被撤回。"; From 2239468c884aa8556dd46b4a72144db16f820f62 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 31 Dec 2015 09:54:47 +0800 Subject: [PATCH 2/7] ReloadData if need when updateFeeds --- Yep/ViewControllers/Feeds/FeedsViewController.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Yep/ViewControllers/Feeds/FeedsViewController.swift b/Yep/ViewControllers/Feeds/FeedsViewController.swift index 4fb5c8e9..d456a282 100644 --- a/Yep/ViewControllers/Feeds/FeedsViewController.swift +++ b/Yep/ViewControllers/Feeds/FeedsViewController.swift @@ -515,6 +515,9 @@ class FeedsViewController: BaseViewController { if newFeed.id != oldFeed.id { wayToUpdate = .ReloadData break + } else if newFeed.messagesCount != oldFeed.messagesCount { + wayToUpdate = .ReloadData + break } index += 1 From 03f5363ff195491de891195d198e08b1737b3483 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 31 Dec 2015 10:07:34 +0800 Subject: [PATCH 3/7] feedsTableView WayToUpdate: ReloadIndexPaths if MessagesCountUpdated --- Yep/Extensions/UITableView+Yep.swift | 10 ++++++++++ Yep/ViewControllers/Feeds/FeedsViewController.swift | 11 +++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Yep/Extensions/UITableView+Yep.swift b/Yep/Extensions/UITableView+Yep.swift index 44b2f1f8..a1821bf5 100644 --- a/Yep/Extensions/UITableView+Yep.swift +++ b/Yep/Extensions/UITableView+Yep.swift @@ -14,6 +14,7 @@ extension UITableView { case None case ReloadData + case ReloadIndexPaths([NSIndexPath]) case Insert([NSIndexPath]) var needsLabor: Bool { @@ -23,6 +24,8 @@ extension UITableView { return false case .ReloadData: return true + case .ReloadIndexPaths: + return true case .Insert: return true } @@ -31,12 +34,19 @@ extension UITableView { func performWithTableView(tableView: UITableView) { switch self { + case .None: println("tableView WayToUpdate: None") break + case .ReloadData: println("tableView WayToUpdate: ReloadData") tableView.reloadData() + + case .ReloadIndexPaths(let indexPaths): + println("tableView WayToUpdate: ReloadIndexPaths") + tableView.reloadRowsAtIndexPaths(indexPaths, withRowAnimation: .None) + case .Insert(let indexPaths): println("tableView WayToUpdate: Insert") tableView.insertRowsAtIndexPaths(indexPaths, withRowAnimation: .None) diff --git a/Yep/ViewControllers/Feeds/FeedsViewController.swift b/Yep/ViewControllers/Feeds/FeedsViewController.swift index d456a282..1d2c2502 100644 --- a/Yep/ViewControllers/Feeds/FeedsViewController.swift +++ b/Yep/ViewControllers/Feeds/FeedsViewController.swift @@ -503,6 +503,8 @@ class FeedsViewController: BaseViewController { strongSelf.feeds = newFeeds } + var indexesOfMessagesCountUpdated = [Int]() + if !wayToUpdate.needsLabor && !newFeeds.isEmpty { if newFeeds.count == oldFeeds.count { @@ -516,8 +518,7 @@ class FeedsViewController: BaseViewController { wayToUpdate = .ReloadData break } else if newFeed.messagesCount != oldFeed.messagesCount { - wayToUpdate = .ReloadData - break + indexesOfMessagesCountUpdated.append(index) } index += 1 @@ -528,6 +529,12 @@ class FeedsViewController: BaseViewController { } } + if !wayToUpdate.needsLabor { + let indexPaths = indexesOfMessagesCountUpdated.map({ NSIndexPath(forRow: $0, inSection: Section.Feed.rawValue) }) + + wayToUpdate = .ReloadIndexPaths(indexPaths) + } + wayToUpdate.performWithTableView(strongSelf.feedsTableView) } } From 04da9d99e35db16cb7112527e298e5b9bc99aef7 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 31 Dec 2015 11:13:57 +0800 Subject: [PATCH 4/7] add UpdateFeedsMode; conversationDirtyAction for Conversation to updateFeeds Static --- .../ConversationViewController.swift | 12 +++- .../Feeds/FeedsViewController.swift | 62 ++++++++++++++----- 2 files changed, 54 insertions(+), 20 deletions(-) diff --git a/Yep/ViewControllers/Conversation/ConversationViewController.swift b/Yep/ViewControllers/Conversation/ConversationViewController.swift index 4fe9202a..3a4b8bdd 100644 --- a/Yep/ViewControllers/Conversation/ConversationViewController.swift +++ b/Yep/ViewControllers/Conversation/ConversationViewController.swift @@ -289,13 +289,13 @@ enum ConversationFeed { class ConversationViewController: BaseViewController { - var conversationFeed: ConversationFeed? - var conversation: Conversation! + var conversationFeed: ConversationFeed? var afterSentMessageAction: (() -> Void)? - var afterDeletedFeedAction: (() -> Void)? + var conversationDirtyAction: (() -> Void)? + var conversationIsDirty = false private var selectedIndexPathForMenu: NSIndexPath? @@ -1343,6 +1343,10 @@ class ConversationViewController: BaseViewController { override func viewWillDisappear(animated: Bool) { super.viewWillDisappear(animated) + if conversationIsDirty { + conversationDirtyAction?() + } + if let checkTypingStatusTimer = checkTypingStatusTimer { checkTypingStatusTimer.invalidate() } @@ -2552,6 +2556,8 @@ class ConversationViewController: BaseViewController { if messageIDs == nil { afterSentMessageAction?() + conversationIsDirty = true + if isSubscribeViewShowing { realm.beginWrite() diff --git a/Yep/ViewControllers/Feeds/FeedsViewController.swift b/Yep/ViewControllers/Feeds/FeedsViewController.swift index 1d2c2502..de9831e4 100644 --- a/Yep/ViewControllers/Feeds/FeedsViewController.swift +++ b/Yep/ViewControllers/Feeds/FeedsViewController.swift @@ -431,7 +431,12 @@ class FeedsViewController: BaseViewController { private var currentPageIndex = 1 private var isFetchingFeeds = false - private func updateFeeds(isLoadMore isLoadMore: Bool = false, finish: (() -> Void)? = nil) { + enum UpdateFeedsMode { + case Top + case LoadMore + case Static + } + private func updateFeeds(mode mode: UpdateFeedsMode = .Top, finish: (() -> Void)? = nil) { if isFetchingFeeds { finish?() @@ -440,15 +445,17 @@ class FeedsViewController: BaseViewController { isFetchingFeeds = true - if !isLoadMore && feeds.isEmpty { + if mode == .Top && feeds.isEmpty { activityIndicator.startAnimating() } - if isLoadMore { - currentPageIndex++ - - } else { + switch mode { + case .Top: currentPageIndex = 1 + case .LoadMore: + currentPageIndex++ + case .Static: + break } let failureHandler: (Reason, String?) -> Void = { reason, errorMessage in @@ -489,7 +496,11 @@ class FeedsViewController: BaseViewController { wayToUpdate = .ReloadData } - if isLoadMore { + switch mode { + case .Top: + strongSelf.feeds = newFeeds + + case .LoadMore: let oldFeedsCount = strongSelf.feeds.count strongSelf.feeds += newFeeds let newFeedsCount = strongSelf.feeds.count @@ -499,14 +510,26 @@ class FeedsViewController: BaseViewController { wayToUpdate = .Insert(indexPaths) } - } else { - strongSelf.feeds = newFeeds + case .Static: + var indexesOfMessagesCountUpdated = [Int]() + newFeeds.forEach({ feed in + if let index = strongSelf.feeds.indexOf(feed) { + if strongSelf.feeds[index].messagesCount != feed.messagesCount { + strongSelf.feeds[index].messagesCount = feed.messagesCount + indexesOfMessagesCountUpdated.append(index) + } + } + }) + + let indexPaths = indexesOfMessagesCountUpdated.map({ NSIndexPath(forRow: $0, inSection: Section.Feed.rawValue) }) + + wayToUpdate = .ReloadIndexPaths(indexPaths) } - var indexesOfMessagesCountUpdated = [Int]() - if !wayToUpdate.needsLabor && !newFeeds.isEmpty { + var indexesOfMessagesCountUpdated = [Int]() + if newFeeds.count == oldFeeds.count { var index = 0 @@ -527,12 +550,12 @@ class FeedsViewController: BaseViewController { } else { wayToUpdate = .ReloadData } - } - if !wayToUpdate.needsLabor { - let indexPaths = indexesOfMessagesCountUpdated.map({ NSIndexPath(forRow: $0, inSection: Section.Feed.rawValue) }) + if !wayToUpdate.needsLabor { + let indexPaths = indexesOfMessagesCountUpdated.map({ NSIndexPath(forRow: $0, inSection: Section.Feed.rawValue) }) - wayToUpdate = .ReloadIndexPaths(indexPaths) + wayToUpdate = .ReloadIndexPaths(indexPaths) + } } wayToUpdate.performWithTableView(strongSelf.feedsTableView) @@ -552,7 +575,7 @@ class FeedsViewController: BaseViewController { feedSortStyle = .Time } - let maxFeedID = (isLoadMore && (feedSortStyle == FeedSortStyle.Time)) ? feeds.last?.id : nil + let maxFeedID = (mode == .LoadMore && (feedSortStyle == FeedSortStyle.Time)) ? feeds.last?.id : nil discoverFeedsWithSortStyle(feedSortStyle, skill: skill, pageIndex: currentPageIndex, perPage: perPage, maxFeedID: maxFeedID, failureHandler:failureHandler, completion: completion) } @@ -686,10 +709,15 @@ class FeedsViewController: BaseViewController { vc.conversation = feedConversation vc.conversationFeed = ConversationFeed.DiscoveredFeedType(feed) + vc.afterDeletedFeedAction = { [weak self] in self?.updateFeeds() } + vc.conversationDirtyAction = { [weak self] in + self?.updateFeeds(mode: .Static) + } + case "presentNewFeed": guard let @@ -1160,7 +1188,7 @@ extension FeedsViewController: UITableViewDataSource, UITableViewDelegate { cell.loadingActivityIndicator.startAnimating() } - updateFeeds(isLoadMore: true, finish: { [weak cell] in + updateFeeds(mode: .LoadMore, finish: { [weak cell] in cell?.loadingActivityIndicator.stopAnimating() }) From fb39841cf8a4e7803b8684ddc10d5fc596d47afe Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 31 Dec 2015 11:51:08 +0800 Subject: [PATCH 5/7] white background for FeedGithubRepoContainerView --- .../Contents.json | 26 ++++++++++++++++++ .../feed_container_background.pdf | Bin 0 -> 3925 bytes .../FeedGithubRepoContainerView.swift | 17 ++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 Yep/Images.xcassets/feed_container_background.imageset/Contents.json create mode 100644 Yep/Images.xcassets/feed_container_background.imageset/feed_container_background.pdf diff --git a/Yep/Images.xcassets/feed_container_background.imageset/Contents.json b/Yep/Images.xcassets/feed_container_background.imageset/Contents.json new file mode 100644 index 00000000..c0abd5b3 --- /dev/null +++ b/Yep/Images.xcassets/feed_container_background.imageset/Contents.json @@ -0,0 +1,26 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "feed_container_background.pdf", + "resizing" : { + "mode" : "9-part", + "center" : { + "mode" : "tile", + "width" : 1, + "height" : 1 + }, + "cap-insets" : { + "bottom" : 5, + "top" : 5, + "right" : 5, + "left" : 5 + } + } + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Yep/Images.xcassets/feed_container_background.imageset/feed_container_background.pdf b/Yep/Images.xcassets/feed_container_background.imageset/feed_container_background.pdf new file mode 100644 index 0000000000000000000000000000000000000000..8052f68837e5c867234e95f7996112cd4875a516 GIT binary patch literal 3925 zcmai%c{o(<8^tIr92xZr77~2%Gl~9&2vNutZ$eN`nJK2+7 zlWeJw7?LfLHTli7{NCQ>y54i0YtEVPd7k@up6`AC@wp+!dIkz`MI;!~#GGeNW`Dl( zqNxRp0$>1@;0!)|7*H}IyE}S00ce(V5>PUrxO$O2SWj2H7g>)?q>{*hrY6|a%Y%$} z1N(BC<8;8>`vj_I<;HAs{>bZ`sZe@lx)(@PC=YGk!0e#sHOG>q6Ott@&IQ3r_RYsV zkh==q+$!L5pMP|w7(~4us-Qk?nkJekf!{8DZk}$uHuQd>Oj<5)QiGBDBHAeLCCWVW zc!Gs%$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(S{gbNM6#5;dmEnkA zu*&9Fw#I^7Lkvb2?@1;BY=Aup*!~*AM(bZp{3m&P{yR&vA^ALu$Kim|F$&3(13hg+QRJU@#fh{pZNv_QRrn(s?4QjrzVO zt7E{hx+gCR)m@K`?B8Ru+XyP@_y2$H)YpUT0EPi@BpCMp3s6R*k!ZjH_^BaLNS3GU z3vmCX!4S%<^!!yrB4Dia{8fX&5UgYUO+%nrj{Z$Us<1r!tA>QD{Bte}`OkIX=zoku zB2-yr@wa$L{}@yd7tflMI7$S^bsp{7P8s}fL11RhC(A&_WI@P7~aQEr}ItkU?N5F{F=3Wh-R IaR%W30e`-tZvX%Q literal 0 HcmV?d00001 diff --git a/Yep/Views/ContainerViews/FeedGithubRepoContainerView.swift b/Yep/Views/ContainerViews/FeedGithubRepoContainerView.swift index 8e0e68f8..f77a8fe0 100644 --- a/Yep/Views/ContainerViews/FeedGithubRepoContainerView.swift +++ b/Yep/Views/ContainerViews/FeedGithubRepoContainerView.swift @@ -12,6 +12,12 @@ class FeedGithubRepoContainerView: UIView { var tapAction: (() -> Void)? + lazy var backgroundImageView: UIImageView = { + let imageView = UIImageView() + imageView.image = UIImage(named: "feed_container_background") + return imageView + }() + lazy var iconImageView: UIImageView = { let imageView = UIImageView() imageView.image = UIImage(named: "icon_repo") @@ -51,23 +57,34 @@ class FeedGithubRepoContainerView: UIView { private func makeUI() { + backgroundColor = UIColor.whiteColor() + tintAdjustmentMode = .Normal + + addSubview(backgroundImageView) addSubview(iconImageView) addSubview(nameLabel) addSubview(descriptionLabel) addSubview(accessoryImageView) + backgroundImageView.translatesAutoresizingMaskIntoConstraints = false iconImageView.translatesAutoresizingMaskIntoConstraints = false nameLabel.translatesAutoresizingMaskIntoConstraints = false descriptionLabel.translatesAutoresizingMaskIntoConstraints = false accessoryImageView.translatesAutoresizingMaskIntoConstraints = false let views = [ + "backgroundImageView": backgroundImageView, "iconImageView": iconImageView, "nameLabel": nameLabel, "descriptionLabel": descriptionLabel, "accessoryImageView": accessoryImageView, ] + let backgroundH = NSLayoutConstraint.constraintsWithVisualFormat("H:|[backgroundImageView]|", options: [], metrics: nil, views: views) + let backgroundV = NSLayoutConstraint.constraintsWithVisualFormat("V:|[backgroundImageView]|", options: [], metrics: nil, views: views) + NSLayoutConstraint.activateConstraints(backgroundH) + NSLayoutConstraint.activateConstraints(backgroundV) + let constraintsH = NSLayoutConstraint.constraintsWithVisualFormat("H:|-10-[iconImageView(16)]-10-[nameLabel]-5-[accessoryImageView(8)]-10-|", options: [], metrics: nil, views: views) iconImageView.setContentHuggingPriority(UILayoutPriorityDefaultHigh, forAxis: .Horizontal) From 8a8fb117ef9f27922d3dd13d19e31b935604981b Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 31 Dec 2015 11:55:10 +0800 Subject: [PATCH 6/7] white background for FeedMediaContainerView --- .../ContainerViews/FeedMediaContainerView.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Yep/Views/ContainerViews/FeedMediaContainerView.swift b/Yep/Views/ContainerViews/FeedMediaContainerView.swift index 24cce38e..e67fe291 100644 --- a/Yep/Views/ContainerViews/FeedMediaContainerView.swift +++ b/Yep/Views/ContainerViews/FeedMediaContainerView.swift @@ -13,6 +13,12 @@ class FeedMediaContainerView: UIView { var tapMediaAction: ((mediaImageView: UIImageView) -> Void)? + lazy var backgroundImageView: UIImageView = { + let imageView = UIImageView() + imageView.image = UIImage(named: "feed_container_background") + return imageView + }() + lazy var mediaImageView: UIImageView = { let imageView = UIImageView() imageView.contentMode = .ScaleAspectFill @@ -44,20 +50,28 @@ class FeedMediaContainerView: UIView { private func makeUI() { + addSubview(backgroundImageView) addSubview(mediaImageView) addSubview(horizontalLineView) addSubview(linkContainerView) + backgroundImageView.translatesAutoresizingMaskIntoConstraints = false mediaImageView.translatesAutoresizingMaskIntoConstraints = false horizontalLineView.translatesAutoresizingMaskIntoConstraints = false linkContainerView.translatesAutoresizingMaskIntoConstraints = false let views = [ + "backgroundImageView": backgroundImageView, "mediaImageView": mediaImageView, "horizontalLineView": horizontalLineView, "linkContainerView": linkContainerView, ] + let backgroundH = NSLayoutConstraint.constraintsWithVisualFormat("H:|[backgroundImageView]|", options: [], metrics: nil, views: views) + let backgroundV = NSLayoutConstraint.constraintsWithVisualFormat("V:|[backgroundImageView]|", options: [], metrics: nil, views: views) + NSLayoutConstraint.activateConstraints(backgroundH) + NSLayoutConstraint.activateConstraints(backgroundV) + let constraintsH = NSLayoutConstraint.constraintsWithVisualFormat("H:|[mediaImageView]|", options: [], metrics: nil, views: views) let linkContainerViewHeight: CGFloat = Ruler.iPhoneHorizontal(44, 50, 50).value From c9a90069be19a8abaac94b2952f43ce9140eafee Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 31 Dec 2015 11:58:20 +0800 Subject: [PATCH 7/7] white background for FeedLocationContainerView --- .../ContainerViews/FeedLocationContainerView.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Yep/Views/ContainerViews/FeedLocationContainerView.swift b/Yep/Views/ContainerViews/FeedLocationContainerView.swift index 41a7987c..ef7d8656 100644 --- a/Yep/Views/ContainerViews/FeedLocationContainerView.swift +++ b/Yep/Views/ContainerViews/FeedLocationContainerView.swift @@ -12,6 +12,12 @@ class FeedLocationContainerView: UIView { var tapAction: (() -> Void)? + lazy var backgroundImageView: UIImageView = { + let imageView = UIImageView() + imageView.image = UIImage(named: "feed_container_background") + return imageView + }() + lazy var mapImageView: UIImageView = { let imageView = UIImageView() imageView.contentMode = .ScaleAspectFill @@ -49,22 +55,30 @@ class FeedLocationContainerView: UIView { private func makeUI() { + addSubview(backgroundImageView) addSubview(mapImageView) addSubview(pinImageView) addSubview(horizontalLineView) addSubview(nameLabel) + backgroundImageView.translatesAutoresizingMaskIntoConstraints = false mapImageView.translatesAutoresizingMaskIntoConstraints = false pinImageView.translatesAutoresizingMaskIntoConstraints = false horizontalLineView.translatesAutoresizingMaskIntoConstraints = false nameLabel.translatesAutoresizingMaskIntoConstraints = false let views = [ + "backgroundImageView": backgroundImageView, "mapImageView": mapImageView, "horizontalLineView": horizontalLineView, "nameLabel": nameLabel, ] + let backgroundH = NSLayoutConstraint.constraintsWithVisualFormat("H:|[backgroundImageView]|", options: [], metrics: nil, views: views) + let backgroundV = NSLayoutConstraint.constraintsWithVisualFormat("V:|[backgroundImageView]|", options: [], metrics: nil, views: views) + NSLayoutConstraint.activateConstraints(backgroundH) + NSLayoutConstraint.activateConstraints(backgroundV) + let constraintsH1 = NSLayoutConstraint.constraintsWithVisualFormat("H:|[mapImageView]|", options: [], metrics: nil, views: views) let constraintsH2 = NSLayoutConstraint.constraintsWithVisualFormat("H:|[horizontalLineView]|", options: [], metrics: nil, views: views) let constraintsH3 = NSLayoutConstraint.constraintsWithVisualFormat("H:|-10-[nameLabel]-10-|", options: [], metrics: nil, views: views)