Merge branch 'feature/fix_perform_segue_twice' into develop

This commit is contained in:
nixzhu
2016-01-04 11:27:54 +08:00
27 changed files with 61 additions and 278 deletions
+4
View File
@@ -43,6 +43,7 @@
5008A1931B8DB8B500E94274 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 5008A1951B8DB8B500E94274 /* Localizable.strings */; };
500A0B1C1B450C2100D49358 /* EditNicknameAndBadgeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 500A0B1B1B450C2100D49358 /* EditNicknameAndBadgeViewController.swift */; };
500A0B1F1B451A6F00D49358 /* BadgeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 500A0B1E1B451A6F00D49358 /* BadgeView.swift */; };
500D35DF1C3A00D2006D17E3 /* SegueViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 500D35DE1C3A00D2006D17E3 /* SegueViewController.swift */; };
500EED961BF06AC900C6BABC /* NSURL+Yep.swift in Sources */ = {isa = PBXBuildFile; fileRef = 500EED951BF06AC900C6BABC /* NSURL+Yep.swift */; };
500EED981BF07A3000C6BABC /* ConversationViewController+Feed.swift in Sources */ = {isa = PBXBuildFile; fileRef = 500EED971BF07A3000C6BABC /* ConversationViewController+Feed.swift */; };
500EED9A1BF1B81000C6BABC /* MediaPreviewViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 500EED991BF1B81000C6BABC /* MediaPreviewViewController.swift */; };
@@ -409,6 +410,7 @@
5008A1961B8DB8E100E94274 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
500A0B1B1B450C2100D49358 /* EditNicknameAndBadgeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = EditNicknameAndBadgeViewController.swift; path = ViewControllers/EditNicknameAndBadge/EditNicknameAndBadgeViewController.swift; sourceTree = "<group>"; };
500A0B1E1B451A6F00D49358 /* BadgeView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BadgeView.swift; path = Views/Badge/BadgeView.swift; sourceTree = "<group>"; };
500D35DE1C3A00D2006D17E3 /* SegueViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SegueViewController.swift; path = ViewControllers/Base/SegueViewController.swift; sourceTree = "<group>"; };
500EED951BF06AC900C6BABC /* NSURL+Yep.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "NSURL+Yep.swift"; path = "Extensions/NSURL+Yep.swift"; sourceTree = "<group>"; };
500EED971BF07A3000C6BABC /* ConversationViewController+Feed.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "ConversationViewController+Feed.swift"; path = "ViewControllers/Conversation/ConversationViewController+Feed.swift"; sourceTree = "<group>"; };
500EED991BF1B81000C6BABC /* MediaPreviewViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MediaPreviewViewController.swift; path = ViewControllers/MediaPreview/MediaPreviewViewController.swift; sourceTree = "<group>"; };
@@ -897,6 +899,7 @@
0A943A7C1B0F8EB10022DD67 /* Base */ = {
isa = PBXGroup;
children = (
500D35DE1C3A00D2006D17E3 /* SegueViewController.swift */,
0A943A7A1B0F8EAE0022DD67 /* BaseViewController.swift */,
);
name = Base;
@@ -2780,6 +2783,7 @@
50B38FB71B69CD960064C132 /* Array+Yep.swift in Sources */,
5011382C1BCB5E150055A014 /* FeedConversationDockCell.swift in Sources */,
845E1A661B788EF3001E0789 /* EditSkillsViewController.swift in Sources */,
500D35DF1C3A00D2006D17E3 /* SegueViewController.swift in Sources */,
50CC4FA41C1AC58700B6A263 /* UICollectionView+Yep.swift in Sources */,
504F85AC1B4D21DD00F909BE /* DiscoverFilterView.swift in Sources */,
0A271FD71ACA055400822DFC /* YepAudioService.swift in Sources */,
@@ -9,7 +9,7 @@
import UIKit
import Ruler
class AboutViewController: UIViewController {
class AboutViewController: SegueViewController {
@IBOutlet private weak var appLogoImageView: UIImageView!
@IBOutlet private weak var appLogoImageViewTopConstraint: NSLayoutConstraint!
@@ -53,17 +53,6 @@ class AboutViewController: UIViewController {
aboutTableViewHeightConstraint.constant = rowHeight * CGFloat(aboutAnnotations.count) + 1
}
// MARK: Navigation
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
guard navigationController?.topViewController == self else {
return false
}
return true
}
}
// MARK: - UITableViewDataSource, UITableViewDelegate
@@ -10,7 +10,7 @@ import UIKit
import AddressBook
import Proposer
class AddFriendsViewController: UIViewController {
class AddFriendsViewController: SegueViewController {
@IBOutlet private weak var addFriendsTableView: UITableView!
@@ -31,15 +31,6 @@ class AddFriendsViewController: UIViewController {
// MARK: Navigation
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
guard navigationController?.topViewController == self else {
return false
}
return true
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showSearchedUsers" {
if let searchText = sender as? String {
@@ -8,46 +8,40 @@
import UIKit
class BaseViewController: UIViewController {
class BaseViewController: SegueViewController {
var animatedOnNavigationBar = true
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = UIColor.whiteColor()
// Do any additional setup after loading the view.
view.backgroundColor = UIColor.whiteColor()
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
if let navigationController = navigationController {
navigationController.navigationBar.backgroundColor = nil
navigationController.navigationBar.translucent = true
navigationController.navigationBar.shadowImage = nil
navigationController.navigationBar.barStyle = UIBarStyle.Default
navigationController.navigationBar.setBackgroundImage(nil, forBarMetrics: UIBarMetrics.Default)
let textAttributes = [
NSForegroundColorAttributeName: UIColor.yepNavgationBarTitleColor(),
NSFontAttributeName: UIFont.navigationBarTitleFont()
]
navigationController.navigationBar.titleTextAttributes = textAttributes
navigationController.navigationBar.tintColor = nil
}
if let hidden = self.navigationController?.navigationBarHidden {
if hidden {
self.navigationController?.setNavigationBarHidden(false, animated: animatedOnNavigationBar)
}
guard let navigationController = navigationController else {
return
}
navigationController.navigationBar.backgroundColor = nil
navigationController.navigationBar.translucent = true
navigationController.navigationBar.shadowImage = nil
navigationController.navigationBar.barStyle = UIBarStyle.Default
navigationController.navigationBar.setBackgroundImage(nil, forBarMetrics: UIBarMetrics.Default)
let textAttributes = [
NSForegroundColorAttributeName: UIColor.yepNavgationBarTitleColor(),
NSFontAttributeName: UIFont.navigationBarTitleFont()
]
navigationController.navigationBar.titleTextAttributes = textAttributes
navigationController.navigationBar.tintColor = nil
if navigationController.navigationBarHidden {
navigationController.setNavigationBarHidden(false, animated: animatedOnNavigationBar)
}
}
}
@@ -0,0 +1,23 @@
//
// SegueViewController.swift
// Yep
//
// Created by nixzhu on 16/1/4.
// Copyright © 2016 Catch Inc. All rights reserved.
//
import UIKit
class SegueViewController: UIViewController {
override func performSegueWithIdentifier(identifier: String, sender: AnyObject?) {
if let navigationController = navigationController {
guard navigationController.topViewController == self else {
return
}
}
super.performSegueWithIdentifier(identifier, sender: sender)
}
}
@@ -147,15 +147,6 @@ class ContactsViewController: BaseViewController {
// MARK: Navigation
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
guard navigationController?.topViewController == self else {
return false
}
return true
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showProfile" {
@@ -2820,15 +2820,6 @@ class ConversationViewController: BaseViewController {
// MARK: Navigation
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
guard navigationController?.topViewController == self else {
return false
}
return true
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
guard let identifier = segue.identifier else {
@@ -15,7 +15,7 @@ import Proposer
let YepNotificationCommentAction = "YepNotificationCommentAction"
let YepNotificationOKAction = "YepNotificationOKAction"
class ConversationsViewController: UIViewController {
class ConversationsViewController: SegueViewController {
private lazy var activityIndicatorTitleView = ActivityIndicatorTitleView(frame: CGRect(x: 0, y: 0, width: 120, height: 30))
@@ -291,15 +291,6 @@ class ConversationsViewController: UIViewController {
// MARK: Navigation
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
guard navigationController?.topViewController == self else {
return false
}
return true
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showConversation" {
let vc = segue.destinationViewController as! ConversationViewController
@@ -409,10 +400,6 @@ extension ConversationsViewController: UITableViewDataSource, UITableViewDelegat
tableView.deselectRowAtIndexPath(indexPath, animated: true)
}
guard navigationController?.topViewController == self else {
return
}
switch indexPath.section {
case Section.FeedConversation.rawValue:
@@ -230,18 +230,8 @@ class DiscoverViewController: BaseViewController {
})
}
// MARK: - Navigation
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
guard navigationController?.topViewController == self else {
return false
}
return true
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showProfile" {
@@ -12,7 +12,7 @@ import TPKeyboardAvoiding
import Proposer
import Navi
class EditProfileViewController: UIViewController {
class EditProfileViewController: SegueViewController {
struct Notification {
static let Logout = "LogoutNotification"
@@ -82,17 +82,6 @@ class EditProfileViewController: UIViewController {
editProfileTableView.registerNib(UINib(nibName: editProfileColoredTitleCellIdentifier, bundle: nil), forCellReuseIdentifier: editProfileColoredTitleCellIdentifier)
}
// MARK: Navigation
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
guard navigationController?.topViewController == self else {
return false
}
return true
}
// MARK: Actions
private func updateAvatar(completion:() -> Void) {
@@ -9,7 +9,7 @@
import UIKit
import RealmSwift
class FeedConversationsViewController: UIViewController {
class FeedConversationsViewController: SegueViewController {
@IBOutlet weak var feedConversationsTableView: UITableView!
@@ -91,15 +91,6 @@ class FeedConversationsViewController: UIViewController {
// MARK: Navigation
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
guard navigationController?.topViewController == self else {
return false
}
return true
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showConversation" {
let vc = segue.destinationViewController as! ConversationViewController
@@ -624,15 +624,6 @@ class FeedsViewController: BaseViewController {
// MARK: - Navigation
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
guard navigationController?.topViewController == self else {
return false
}
return true
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
guard let identifier = segue.identifier else {
@@ -104,15 +104,6 @@ class FriendsInContactsViewController: BaseViewController {
// MARK: - Navigation
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
guard navigationController?.topViewController == self else {
return false
}
return true
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showProfile" {
@@ -151,15 +151,6 @@ class LoginByMobileViewController: BaseViewController {
// MARK: Navigation
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
guard navigationController?.topViewController == self else {
return false
}
return true
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showLoginVerifyMobile" {
@@ -25,7 +25,7 @@ struct FeedVoice {
let limitedSampleValues: [CGFloat]
}
class NewFeedViewController: UIViewController {
class NewFeedViewController: SegueViewController {
enum Attachment {
case Default
@@ -414,15 +414,6 @@ class NewFeedViewController: UIViewController {
// MARK: Navigation
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
guard navigationController?.topViewController == self else {
return false
}
return true
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showPickPhotos" {
@@ -9,7 +9,7 @@
import UIKit
import AVFoundation
class NewFeedVoiceRecordViewController: UIViewController {
class NewFeedVoiceRecordViewController: SegueViewController {
var preparedSkill: Skill?
@@ -411,15 +411,6 @@ class NewFeedVoiceRecordViewController: UIViewController {
// MARK: - Navigation
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
guard navigationController?.topViewController == self else {
return false
}
return true
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
guard let identifier = segue.identifier else {
@@ -62,7 +62,7 @@ struct DoNotDisturbPeriod {
}
}
class NotificationsViewController: UIViewController {
class NotificationsViewController: SegueViewController {
@IBOutlet private weak var tableView: UITableView!
@@ -112,15 +112,6 @@ class NotificationsViewController: UIViewController {
// MARK: Navigation
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
guard navigationController?.topViewController == self else {
return false
}
return true
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showDoNotDisturbPeriod" {
@@ -10,7 +10,7 @@ import UIKit
import MapKit
import Proposer
class PickLocationViewController: UIViewController {
class PickLocationViewController: SegueViewController {
enum Purpose {
case Message
@@ -189,15 +189,6 @@ class PickLocationViewController: UIViewController {
// MARK: Navigation
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
guard navigationController?.topViewController == self else {
return false
}
return true
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
guard let identifier = segue.identifier else {
@@ -305,7 +305,7 @@ enum ProfileUser {
}
}
class ProfileViewController: UIViewController {
class ProfileViewController: SegueViewController {
private var socialAccount: SocialAccount?
@@ -1184,15 +1184,6 @@ class ProfileViewController: UIViewController {
// MARK: Navigation
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
guard navigationController?.topViewController == self else {
return false
}
return true
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
guard let identifier = segue.identifier else {
@@ -11,7 +11,7 @@ import AVFoundation
import Proposer
import Navi
class RegisterPickAvatarViewController: UIViewController {
class RegisterPickAvatarViewController: SegueViewController {
@IBOutlet private weak var avatarImageView: UIImageView!
@IBOutlet private weak var cameraPreviewView: CameraPreviewView!
@@ -141,22 +141,6 @@ class RegisterPickAvatarViewController: UIViewController {
nextButton.enabled = false
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
}
// MARK: Navigation
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
guard navigationController?.topViewController == self else {
return false
}
return true
}
// MARK: Helpers
private func deviceWithMediaType(mediaType: String, preferringPosition position: AVCaptureDevicePosition) -> AVCaptureDevice? {
@@ -9,7 +9,7 @@
import UIKit
import Ruler
class RegisterPickMobileViewController: UIViewController {
class RegisterPickMobileViewController: SegueViewController {
@IBOutlet private weak var pickMobileNumberPromptLabel: UILabel!
@IBOutlet private weak var pickMobileNumberPromptLabelTopConstraint: NSLayoutConstraint!
@@ -170,15 +170,6 @@ class RegisterPickMobileViewController: UIViewController {
// MARK: Navigation
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
guard navigationController?.topViewController == self else {
return false
}
return true
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showRegisterVerifyMobile" {
@@ -88,17 +88,6 @@ class RegisterPickNameViewController: BaseViewController {
nameTextField.becomeFirstResponder()
}
// MARK: Navigation
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
guard navigationController?.topViewController == self else {
return false
}
return true
}
// MARK: Actions
@objc private func tapTerms(sender: UITapGestureRecognizer) {
@@ -166,15 +166,6 @@ class RegisterPickSkillsViewController: BaseViewController {
// MARK: Navigaition
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
guard navigationController?.topViewController == self else {
return false
}
return true
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "presentSelectSkills" {
@@ -9,7 +9,7 @@
import UIKit
import Ruler
class RegisterVerifyMobileViewController: UIViewController {
class RegisterVerifyMobileViewController: SegueViewController {
var mobile: String!
var areaCode: String!
@@ -95,17 +95,6 @@ class RegisterVerifyMobileViewController: UIViewController {
callMeTimer.fire()
}
// MARK: Navigation
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
guard navigationController?.topViewController == self else {
return false
}
return true
}
// MARK: Actions
@objc private func activeAgain(notification: NSNotification) {
@@ -66,15 +66,6 @@ class SearchedUsersViewController: BaseViewController {
// MARK: Navigation
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
guard navigationController?.topViewController == self else {
return false
}
return true
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showProfile" {
if let indexPath = sender as? NSIndexPath {
@@ -76,17 +76,6 @@ class SettingsViewController: BaseViewController {
}
}
}
// MARK: Navigation
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
guard navigationController?.topViewController == self else {
return false
}
return true
}
}
extension SettingsViewController: UITableViewDataSource, UITableViewDelegate {
@@ -421,15 +421,6 @@ class SkillHomeViewController: BaseViewController {
// MARK: - Navigation
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
guard navigationController?.topViewController == self else {
return false
}
return true
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showProfile" {