Skip to content

Commit

Permalink
Merge branch 'master' of github.com:weiran/Hackers
Browse files Browse the repository at this point in the history
# Conflicts:
#	Hackers.xcodeproj/project.pbxproj
#	Podfile
#	Podfile.lock
#	Pods/Manifest.lock
#	Pods/Pods.xcodeproj/project.pbxproj
#	Pods/Target Support Files/Pods-Hackers/Pods-Hackers-resources.sh
#	Pods/Target Support Files/Pods-Hackers/Pods-Hackers.debug.xcconfig
#	Pods/Target Support Files/Pods-Hackers/Pods-Hackers.release.xcconfig
#	Pods/Target Support Files/libHN/libHN.xcconfig
  • Loading branch information
weiran committed Jun 23, 2016
2 parents 90e14c8 + 1900ff4 commit a0b72dd
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 16 deletions.
1 change: 1 addition & 0 deletions Client/Post List/NewsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class NewsViewController : UITableViewController, UISplitViewControllerDelegate,
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
UIApplication.sharedApplication().statusBarStyle = .LightContent
rz_smoothlyDeselectRows(tableView: tableView)
}

func loadPosts() {
Expand Down
38 changes: 38 additions & 0 deletions Client/UIViewControllerSmoothlyDeselectCellExtension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// UIViewControllerSmoothlyDeselectCellExtension.swift
// Hackers
//
// Created by Weiran Zhang on 08/06/2016.
// Copyright © 2016 Glass Umbrella. All rights reserved.
//

extension UIViewController {
func rz_smoothlyDeselectRows(tableView tableView: UITableView?) {
// Get the initially selected index paths, if any
let selectedIndexPaths = tableView?.indexPathsForSelectedRows ?? []

// Grab the transition coordinator responsible for the current transition
if let coordinator = transitionCoordinator() {
// Animate alongside the master view controller's view
coordinator.animateAlongsideTransitionInView(parentViewController?.view, animation: { context in
// Deselect the cells, with animations enabled if this is an animated transition
selectedIndexPaths.forEach {
tableView?.deselectRowAtIndexPath($0, animated: context.isAnimated())
}
}, completion: { context in
// If the transition was cancel, reselect the rows that were selected before,
// so they are still selected the next time the same animation is triggered
if context.isCancelled() {
selectedIndexPaths.forEach {
tableView?.selectRowAtIndexPath($0, animated: false, scrollPosition: .None)
}
}
})
}
else { // If this isn't a transition coordinator, just deselect the rows without animating
selectedIndexPaths.forEach {
tableView?.deselectRowAtIndexPath($0, animated: false)
}
}
}
}
4 changes: 4 additions & 0 deletions Hackers.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
240C5BE018D267C70011177A /* Icons.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 240C5BDF18D267C70011177A /* Icons.xcassets */; };
24191F8D1944C991003C0D98 /* CommentsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24191F8C1944C991003C0D98 /* CommentsController.swift */; };
241E8DAA1944AF870004F457 /* CommentModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 241E8DA91944AF870004F457 /* CommentModel.swift */; };
242A00D31D086927003D915B /* UIViewControllerSmoothlyDeselectCellExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 242A00D21D086927003D915B /* UIViewControllerSmoothlyDeselectCellExtension.swift */; };
245DCAB01CD4DA2A00152AA3 /* SFSafariViewController+PreviewActionItems.swift in Sources */ = {isa = PBXBuildFile; fileRef = 245DCAAF1CD4DA2A00152AA3 /* SFSafariViewController+PreviewActionItems.swift */; };
249A7E32194374550059C079 /* CommentTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 249A7E31194374550059C079 /* CommentTableViewCell.swift */; };
24B5BFEF1B52CE8900328C62 /* PostTitleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24B5BFEE1B52CE8900328C62 /* PostTitleView.swift */; };
Expand All @@ -34,6 +35,7 @@
241387A51945A6E100D71220 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
24191F8C1944C991003C0D98 /* CommentsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CommentsController.swift; sourceTree = "<group>"; };
241E8DA91944AF870004F457 /* CommentModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CommentModel.swift; sourceTree = "<group>"; };
242A00D21D086927003D915B /* UIViewControllerSmoothlyDeselectCellExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIViewControllerSmoothlyDeselectCellExtension.swift; sourceTree = "<group>"; };
245DCAAF1CD4DA2A00152AA3 /* SFSafariViewController+PreviewActionItems.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SFSafariViewController+PreviewActionItems.swift"; sourceTree = "<group>"; };
249A7E31194374550059C079 /* CommentTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CommentTableViewCell.swift; sourceTree = "<group>"; };
24B5BFEE1B52CE8900328C62 /* PostTitleView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PostTitleView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -162,6 +164,7 @@
24B5BFEE1B52CE8900328C62 /* PostTitleView.swift */,
24D6B8C91C1EDBFC00618422 /* Theme.swift */,
245DCAAF1CD4DA2A00152AA3 /* SFSafariViewController+PreviewActionItems.swift */,
242A00D21D086927003D915B /* UIViewControllerSmoothlyDeselectCellExtension.swift */,
);
path = Client;
sourceTree = "<group>";
Expand Down Expand Up @@ -314,6 +317,7 @@
24E4F26119B4DA9900574B52 /* CommentDelegate.swift in Sources */,
24D6B8CA1C1EDBFC00618422 /* Theme.swift in Sources */,
245DCAB01CD4DA2A00152AA3 /* SFSafariViewController+PreviewActionItems.swift in Sources */,
242A00D31D086927003D915B /* UIViewControllerSmoothlyDeselectCellExtension.swift in Sources */,
24B5BFEF1B52CE8900328C62 /* PostTitleView.swift in Sources */,
241E8DAA1944AF870004F457 /* CommentModel.swift in Sources */,
24191F8D1944C991003C0D98 /* CommentsController.swift in Sources */,
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit a0b72dd

Please sign in to comment.