From 7076dfb63e3173b37027b241021dd9f014c5b011 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Wed, 29 Jun 2016 14:58:17 +0800 Subject: [PATCH 01/34] release MeetGenius --- Yep.xcodeproj/project.pbxproj | 2 +- .../Discover/DiscoverContainerViewController.swift | 8 ++++---- .../Discover/MeetGeniusViewController.swift | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Yep.xcodeproj/project.pbxproj b/Yep.xcodeproj/project.pbxproj index 92b163622..4c0e1bccd 100644 --- a/Yep.xcodeproj/project.pbxproj +++ b/Yep.xcodeproj/project.pbxproj @@ -5106,7 +5106,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; - OTHER_SWIFT_FLAGS = "-D DEBUG -D STAGING_"; + OTHER_SWIFT_FLAGS = "-D DEBUG -D STAGING"; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; }; diff --git a/Yep/ViewControllers/Discover/DiscoverContainerViewController.swift b/Yep/ViewControllers/Discover/DiscoverContainerViewController.swift index b16435f28..aad75da79 100644 --- a/Yep/ViewControllers/Discover/DiscoverContainerViewController.swift +++ b/Yep/ViewControllers/Discover/DiscoverContainerViewController.swift @@ -92,7 +92,7 @@ class DiscoverContainerViewController: UIViewController { geniusesContainerView.hidden = true discoveredUsersContainerView.hidden = false - navigationItem.leftBarButtonItem = discoveredUsersLayoutModeButtonItem + //navigationItem.leftBarButtonItem = discoveredUsersLayoutModeButtonItem navigationItem.rightBarButtonItem = discoveredUsersFilterButtonItem } } @@ -101,10 +101,10 @@ class DiscoverContainerViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - navigationItem.titleView = nil - navigationItem.title = NSLocalizedString("Discover", comment: "") + //navigationItem.titleView = nil + //navigationItem.title = NSLocalizedString("Discover", comment: "") - currentOption = .FindAll + currentOption = .MeetGenius segmentedControl.selectedSegmentIndex = currentOption.rawValue segmentedControl.addTarget(self, action: #selector(DiscoverContainerViewController.chooseOption(_:)), forControlEvents: .ValueChanged) diff --git a/Yep/ViewControllers/Discover/MeetGeniusViewController.swift b/Yep/ViewControllers/Discover/MeetGeniusViewController.swift index 4215c93aa..b9f9a873a 100644 --- a/Yep/ViewControllers/Discover/MeetGeniusViewController.swift +++ b/Yep/ViewControllers/Discover/MeetGeniusViewController.swift @@ -39,7 +39,7 @@ class MeetGeniusViewController: UIViewController { extension MeetGeniusViewController: UITableViewDataSource, UITableViewDelegate { func numberOfSectionsInTableView(tableView: UITableView) -> Int { - return 0 + return 1 } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { From 70876b07adca4e7ce3f0af15e43e3ded1945c2c9 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Wed, 29 Jun 2016 15:27:17 +0800 Subject: [PATCH 02/34] add MeetGeniusShowView --- Yep.xcodeproj/project.pbxproj | 12 ++++ .../Discover/MeetGeniusViewController.swift | 4 +- .../EditProfile/EditProfile.storyboard | 2 +- .../MeetGeniusShow/MeetGeniusShowView.swift | 66 +++++++++++++++++++ 4 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift diff --git a/Yep.xcodeproj/project.pbxproj b/Yep.xcodeproj/project.pbxproj index 4c0e1bccd..319326104 100644 --- a/Yep.xcodeproj/project.pbxproj +++ b/Yep.xcodeproj/project.pbxproj @@ -304,6 +304,7 @@ 50A6A7B31D23643100E01190 /* ConversationViewController+YepFayeServiceDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A6A7B21D23643100E01190 /* ConversationViewController+YepFayeServiceDelegate.swift */; }; 50A6A7B51D23676300E01190 /* ConversationViewController+SendMessages.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A6A7B41D23676300E01190 /* ConversationViewController+SendMessages.swift */; }; 50A6A7B71D2377E100E01190 /* ConversationViewController+SyncMessages.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A6A7B61D2377E100E01190 /* ConversationViewController+SyncMessages.swift */; }; + 50A6A7BA1D23AD4000E01190 /* MeetGeniusShowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A6A7B91D23AD4000E01190 /* MeetGeniusShowView.swift */; }; 50A820241B969B0F007CD30E /* NSTimeZone+Yep.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A820231B969B0F007CD30E /* NSTimeZone+Yep.swift */; }; 50A93A9D1BD8C515007005DB /* FeedSkillPickerItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A93A9C1BD8C515007005DB /* FeedSkillPickerItemView.swift */; }; 50A9D4571ACD393A000B2599 /* YepWaverView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A9D4541ACD393A000B2599 /* YepWaverView.swift */; }; @@ -1020,6 +1021,7 @@ 50A6A7B21D23643100E01190 /* ConversationViewController+YepFayeServiceDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "ConversationViewController+YepFayeServiceDelegate.swift"; path = "ViewControllers/Conversation/ConversationViewController+YepFayeServiceDelegate.swift"; sourceTree = ""; }; 50A6A7B41D23676300E01190 /* ConversationViewController+SendMessages.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "ConversationViewController+SendMessages.swift"; path = "ViewControllers/Conversation/ConversationViewController+SendMessages.swift"; sourceTree = ""; }; 50A6A7B61D2377E100E01190 /* ConversationViewController+SyncMessages.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "ConversationViewController+SyncMessages.swift"; path = "ViewControllers/Conversation/ConversationViewController+SyncMessages.swift"; sourceTree = ""; }; + 50A6A7B91D23AD4000E01190 /* MeetGeniusShowView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MeetGeniusShowView.swift; path = Views/MeetGeniusShow/MeetGeniusShowView.swift; sourceTree = ""; }; 50A820231B969B0F007CD30E /* NSTimeZone+Yep.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "NSTimeZone+Yep.swift"; path = "Extensions/NSTimeZone+Yep.swift"; sourceTree = ""; }; 50A93A9C1BD8C515007005DB /* FeedSkillPickerItemView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FeedSkillPickerItemView.swift; path = Views/PickerItems/FeedSkill/FeedSkillPickerItemView.swift; sourceTree = ""; }; 50A9D4541ACD393A000B2599 /* YepWaverView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = YepWaverView.swift; path = Views/AudioWaves/YepWaverView.swift; sourceTree = ""; }; @@ -1911,6 +1913,7 @@ 5023DE391AB6979C00B3EE96 /* Views */ = { isa = PBXGroup; children = ( + 50A6A7B81D23AD1600E01190 /* MeetGeniusShow */, 50B6A03D1CA282B100C460E3 /* ActionSheet */, 50B8E6191B41341000C17EA1 /* ProgressViews */, 504CBA3B1B3D048900663A90 /* TextViews */, @@ -2820,6 +2823,14 @@ name = DoNotDisturbPeriod; sourceTree = ""; }; + 50A6A7B81D23AD1600E01190 /* MeetGeniusShow */ = { + isa = PBXGroup; + children = ( + 50A6A7B91D23AD4000E01190 /* MeetGeniusShowView.swift */, + ); + name = MeetGeniusShow; + sourceTree = ""; + }; 50A93A9E1BD8C51D007005DB /* PickerItems */ = { isa = PBXGroup; children = ( @@ -4463,6 +4474,7 @@ 502AE5581AB932D5005BD199 /* ProfileSectionHeaderReusableView.swift in Sources */, 500EED981BF07A3000C6BABC /* ConversationViewController+Feed.swift in Sources */, 508F8FDE1B049ACF00461B0B /* InstagramMediaCell.swift in Sources */, + 50A6A7BA1D23AD4000E01190 /* MeetGeniusShowView.swift in Sources */, 502AE5211AB71C7E005BD199 /* BorderButton.swift in Sources */, 50858EBB1C22487900EDE492 /* FeedBasicCell.swift in Sources */, 84C959891B731FD20017D3ED /* ChatBaseCell.swift in Sources */, diff --git a/Yep/ViewControllers/Discover/MeetGeniusViewController.swift b/Yep/ViewControllers/Discover/MeetGeniusViewController.swift index b9f9a873a..313c892d2 100644 --- a/Yep/ViewControllers/Discover/MeetGeniusViewController.swift +++ b/Yep/ViewControllers/Discover/MeetGeniusViewController.swift @@ -13,7 +13,7 @@ class MeetGeniusViewController: UIViewController { @IBOutlet weak var tableView: UITableView! { didSet { tableView.rowHeight = 90 - tableView.tableFooterView = InfoView(NSLocalizedString("To be continue.", comment: "")) + //tableView.tableHeaderView = InfoView(NSLocalizedString("To be continue.", comment: "")) tableView.registerNibOf(GeniusInterviewCell) } @@ -21,6 +21,8 @@ class MeetGeniusViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() + + println("tableView.tableHeaderView: \(tableView.tableHeaderView)") } /* diff --git a/Yep/ViewControllers/EditProfile/EditProfile.storyboard b/Yep/ViewControllers/EditProfile/EditProfile.storyboard index 83bd0f672..b8a01ef25 100644 --- a/Yep/ViewControllers/EditProfile/EditProfile.storyboard +++ b/Yep/ViewControllers/EditProfile/EditProfile.storyboard @@ -1,5 +1,5 @@ - + diff --git a/Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift b/Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift new file mode 100644 index 000000000..a8abd4daf --- /dev/null +++ b/Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift @@ -0,0 +1,66 @@ +// +// MeetGeniusShowView.swift +// Yep +// +// Created by NIX on 16/6/29. +// Copyright © 2016年 Catch Inc. All rights reserved. +// + +import UIKit + +class MeetGeniusShowView: UIView { + + lazy var backgroundImageView: UIImageView = { + let view = UIImageView() + return view + }() + + lazy var showButton: UIButton = { + let button = UIButton() + button.setTitle("SHOW", forState: .Normal) + return button + }() + + lazy var titleLabel: UILabel = { + let label = UILabel() + label.text = "Hello World!" + return label + }() + + func makeUI() { + + backgroundImageView.translatesAutoresizingMaskIntoConstraints = false + addSubview(backgroundImageView) + + let views = [ + "backgroundImageView": backgroundImageView, + "showButton": showButton, + "titleLabel": titleLabel, + ] + + do { + let constraintsH = NSLayoutConstraint.constraintsWithVisualFormat("H:|[backgroundImageView]|", options: [], metrics: nil, views: views) + let constraintsV = NSLayoutConstraint.constraintsWithVisualFormat("V:|[backgroundImageView]|", options: [], metrics: nil, views: views) + NSLayoutConstraint.activateConstraints(constraintsH) + NSLayoutConstraint.activateConstraints(constraintsV) + } + + do { + showButton.translatesAutoresizingMaskIntoConstraints = false + titleLabel.translatesAutoresizingMaskIntoConstraints = false + + let stackView = UIStackView() + stackView.axis = .Vertical + stackView.addArrangedSubview(showButton) + stackView.addArrangedSubview(titleLabel) + + stackView.translatesAutoresizingMaskIntoConstraints = false + addSubview(stackView) + + let centerX = stackView.centerXAnchor.constraintEqualToAnchor(centerXAnchor) + let centerY = stackView.centerYAnchor.constraintEqualToAnchor(centerYAnchor) + NSLayoutConstraint.activateConstraints([centerX, centerY]) + } + } +} + From fa65cbcb8fa7062db1e8243b0f89beb6f50a0b38 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Wed, 29 Jun 2016 15:32:27 +0800 Subject: [PATCH 03/34] use MeetGeniusShowView --- .../Discover/MeetGeniusViewController.swift | 1 + Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/Yep/ViewControllers/Discover/MeetGeniusViewController.swift b/Yep/ViewControllers/Discover/MeetGeniusViewController.swift index 313c892d2..beb1f6a27 100644 --- a/Yep/ViewControllers/Discover/MeetGeniusViewController.swift +++ b/Yep/ViewControllers/Discover/MeetGeniusViewController.swift @@ -14,6 +14,7 @@ class MeetGeniusViewController: UIViewController { didSet { tableView.rowHeight = 90 //tableView.tableHeaderView = InfoView(NSLocalizedString("To be continue.", comment: "")) + tableView.tableHeaderView = MeetGeniusShowView(frame: CGRect(x: 0, y: 0, width: 200, height: 200)) tableView.registerNibOf(GeniusInterviewCell) } diff --git a/Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift b/Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift index a8abd4daf..ec46ba0cd 100644 --- a/Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift +++ b/Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift @@ -27,6 +27,16 @@ class MeetGeniusShowView: UIView { return label }() + override init(frame: CGRect) { + super.init(frame: frame) + + makeUI() + } + + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + func makeUI() { backgroundImageView.translatesAutoresizingMaskIntoConstraints = false From b93ff04a6f4d7859f762857228a6ae0998666573 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Wed, 29 Jun 2016 16:18:38 +0800 Subject: [PATCH 04/34] detail --- Yep/ViewControllers/Discover/MeetGeniusViewController.swift | 4 ++-- Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Yep/ViewControllers/Discover/MeetGeniusViewController.swift b/Yep/ViewControllers/Discover/MeetGeniusViewController.swift index beb1f6a27..d23efbf85 100644 --- a/Yep/ViewControllers/Discover/MeetGeniusViewController.swift +++ b/Yep/ViewControllers/Discover/MeetGeniusViewController.swift @@ -12,9 +12,9 @@ class MeetGeniusViewController: UIViewController { @IBOutlet weak var tableView: UITableView! { didSet { + tableView.tableHeaderView = MeetGeniusShowView(frame: CGRect(x: 0, y: 0, width: 100, height: 180)) + tableView.rowHeight = 90 - //tableView.tableHeaderView = InfoView(NSLocalizedString("To be continue.", comment: "")) - tableView.tableHeaderView = MeetGeniusShowView(frame: CGRect(x: 0, y: 0, width: 200, height: 200)) tableView.registerNibOf(GeniusInterviewCell) } diff --git a/Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift b/Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift index ec46ba0cd..490c0c8c3 100644 --- a/Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift +++ b/Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift @@ -12,12 +12,14 @@ class MeetGeniusShowView: UIView { lazy var backgroundImageView: UIImageView = { let view = UIImageView() + view.backgroundColor = UIColor.lightGrayColor() return view }() lazy var showButton: UIButton = { let button = UIButton() button.setTitle("SHOW", forState: .Normal) + button.backgroundColor = UIColor.blueColor() return button }() @@ -61,6 +63,8 @@ class MeetGeniusShowView: UIView { let stackView = UIStackView() stackView.axis = .Vertical + stackView.spacing = 12 + stackView.addArrangedSubview(showButton) stackView.addArrangedSubview(titleLabel) From 1252e040fa9ca1d3330785fd6a59637e9babbf89 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Wed, 29 Jun 2016 16:20:10 +0800 Subject: [PATCH 05/34] only imageView --- Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift b/Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift index 490c0c8c3..f9d323b5d 100644 --- a/Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift +++ b/Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift @@ -12,7 +12,7 @@ class MeetGeniusShowView: UIView { lazy var backgroundImageView: UIImageView = { let view = UIImageView() - view.backgroundColor = UIColor.lightGrayColor() + view.backgroundColor = UIColor.blueColor() return view }() @@ -46,8 +46,6 @@ class MeetGeniusShowView: UIView { let views = [ "backgroundImageView": backgroundImageView, - "showButton": showButton, - "titleLabel": titleLabel, ] do { @@ -57,6 +55,7 @@ class MeetGeniusShowView: UIView { NSLayoutConstraint.activateConstraints(constraintsV) } + /* do { showButton.translatesAutoresizingMaskIntoConstraints = false titleLabel.translatesAutoresizingMaskIntoConstraints = false @@ -75,6 +74,7 @@ class MeetGeniusShowView: UIView { let centerY = stackView.centerYAnchor.constraintEqualToAnchor(centerYAnchor) NSLayoutConstraint.activateConstraints([centerX, centerY]) } + */ } } From 6f176a3fdbf9a8e61ec281350c508d081767536e Mon Sep 17 00:00:00 2001 From: nixzhu Date: Wed, 29 Jun 2016 16:22:30 +0800 Subject: [PATCH 06/34] tapAction --- Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift b/Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift index f9d323b5d..5c00ef5ca 100644 --- a/Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift +++ b/Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift @@ -10,9 +10,16 @@ import UIKit class MeetGeniusShowView: UIView { + var tapAction: (() -> Void)? + lazy var backgroundImageView: UIImageView = { let view = UIImageView() view.backgroundColor = UIColor.blueColor() + view.userInteractionEnabled = true + + let tap = UITapGestureRecognizer(target: self, action: #selector(MeetGeniusShowView.didTap(_:))) + view.addGestureRecognizer(tap) + return view }() @@ -39,7 +46,7 @@ class MeetGeniusShowView: UIView { fatalError("init(coder:) has not been implemented") } - func makeUI() { + private func makeUI() { backgroundImageView.translatesAutoresizingMaskIntoConstraints = false addSubview(backgroundImageView) @@ -76,5 +83,11 @@ class MeetGeniusShowView: UIView { } */ } + + @objc private func didTap(sender: UITapGestureRecognizer) { + println("tap MeetGeniusShowView") + + tapAction?() + } } From 48f5a2579893bd85d1f353f2d6ea2312f2c9a9be Mon Sep 17 00:00:00 2001 From: nixzhu Date: Wed, 29 Jun 2016 16:33:46 +0800 Subject: [PATCH 07/34] add GeniusInterviewViewController --- Yep.xcodeproj/project.pbxproj | 16 +++++++++ .../GeniusInterview.storyboard | 27 ++++++++++++++ .../GeniusInterviewViewController.swift | 35 +++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 Yep/ViewControllers/GeniusInterview/GeniusInterview.storyboard create mode 100644 Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift diff --git a/Yep.xcodeproj/project.pbxproj b/Yep.xcodeproj/project.pbxproj index 319326104..489f3b102 100644 --- a/Yep.xcodeproj/project.pbxproj +++ b/Yep.xcodeproj/project.pbxproj @@ -305,6 +305,8 @@ 50A6A7B51D23676300E01190 /* ConversationViewController+SendMessages.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A6A7B41D23676300E01190 /* ConversationViewController+SendMessages.swift */; }; 50A6A7B71D2377E100E01190 /* ConversationViewController+SyncMessages.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A6A7B61D2377E100E01190 /* ConversationViewController+SyncMessages.swift */; }; 50A6A7BA1D23AD4000E01190 /* MeetGeniusShowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A6A7B91D23AD4000E01190 /* MeetGeniusShowView.swift */; }; + 50A6A7BD1D23BED600E01190 /* GeniusInterviewViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A6A7BC1D23BED600E01190 /* GeniusInterviewViewController.swift */; }; + 50A6A7BF1D23BEEF00E01190 /* GeniusInterview.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 50A6A7BE1D23BEEF00E01190 /* GeniusInterview.storyboard */; }; 50A820241B969B0F007CD30E /* NSTimeZone+Yep.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A820231B969B0F007CD30E /* NSTimeZone+Yep.swift */; }; 50A93A9D1BD8C515007005DB /* FeedSkillPickerItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A93A9C1BD8C515007005DB /* FeedSkillPickerItemView.swift */; }; 50A9D4571ACD393A000B2599 /* YepWaverView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A9D4541ACD393A000B2599 /* YepWaverView.swift */; }; @@ -1022,6 +1024,8 @@ 50A6A7B41D23676300E01190 /* ConversationViewController+SendMessages.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "ConversationViewController+SendMessages.swift"; path = "ViewControllers/Conversation/ConversationViewController+SendMessages.swift"; sourceTree = ""; }; 50A6A7B61D2377E100E01190 /* ConversationViewController+SyncMessages.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "ConversationViewController+SyncMessages.swift"; path = "ViewControllers/Conversation/ConversationViewController+SyncMessages.swift"; sourceTree = ""; }; 50A6A7B91D23AD4000E01190 /* MeetGeniusShowView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MeetGeniusShowView.swift; path = Views/MeetGeniusShow/MeetGeniusShowView.swift; sourceTree = ""; }; + 50A6A7BC1D23BED600E01190 /* GeniusInterviewViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GeniusInterviewViewController.swift; path = ViewControllers/GeniusInterview/GeniusInterviewViewController.swift; sourceTree = ""; }; + 50A6A7BE1D23BEEF00E01190 /* GeniusInterview.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = GeniusInterview.storyboard; path = ViewControllers/GeniusInterview/GeniusInterview.storyboard; sourceTree = ""; }; 50A820231B969B0F007CD30E /* NSTimeZone+Yep.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "NSTimeZone+Yep.swift"; path = "Extensions/NSTimeZone+Yep.swift"; sourceTree = ""; }; 50A93A9C1BD8C515007005DB /* FeedSkillPickerItemView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FeedSkillPickerItemView.swift; path = Views/PickerItems/FeedSkill/FeedSkillPickerItemView.swift; sourceTree = ""; }; 50A9D4541ACD393A000B2599 /* YepWaverView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = YepWaverView.swift; path = Views/AudioWaves/YepWaverView.swift; sourceTree = ""; }; @@ -1806,6 +1810,7 @@ 502048251B0F1BB8002EBFC7 /* SearchedUsers */, 502280F91B1C3F2F00E984EE /* FriendsInContacts */, 5023DE2E1AB685F100B3EE96 /* Discover */, + 50A6A7BB1D23BE7600E01190 /* GeniusInterview */, 5023DE311AB6861900B3EE96 /* Profile */, 845E1A671B788EFC001E0789 /* EditSkills */, 502AE51C1AB70DE5005BD199 /* Welcome */, @@ -2831,6 +2836,15 @@ name = MeetGeniusShow; sourceTree = ""; }; + 50A6A7BB1D23BE7600E01190 /* GeniusInterview */ = { + isa = PBXGroup; + children = ( + 50A6A7BC1D23BED600E01190 /* GeniusInterviewViewController.swift */, + 50A6A7BE1D23BEEF00E01190 /* GeniusInterview.storyboard */, + ); + name = GeniusInterview; + sourceTree = ""; + }; 50A93A9E1BD8C51D007005DB /* PickerItems */ = { isa = PBXGroup; children = ( @@ -4141,6 +4155,7 @@ 84385C461B8594E80071130D /* Show.xcassets in Resources */, 50894CFB1AEA54BA000981AF /* SettingsMoreCell.xib in Resources */, 50E1CE8F1BE0BFF00025B933 /* MediaViewCell.xib in Resources */, + 50A6A7BF1D23BEEF00E01190 /* GeniusInterview.storyboard in Resources */, 505EC8181ADF8151001D27E0 /* SkillCategoryCell.xib in Resources */, 6A8215091BCBE8F10011F36C /* DiscoverSkillCell.xib in Resources */, 50DEE0451BEA025100015741 /* About.storyboard in Resources */, @@ -4540,6 +4555,7 @@ 5080EB1C1B93F43A006F3C2D /* PodsHelpYepViewController.swift in Sources */, 0A1CAC731AFA526200826B45 /* SkillHomeSectionButton.swift in Sources */, 50E392BC1C22752C00C0CECB /* FeedNormalImagesCell.swift in Sources */, + 50A6A7BD1D23BED600E01190 /* GeniusInterviewViewController.swift in Sources */, 50E34C261CBB8A37007CAE80 /* SearchFeedsViewController.swift in Sources */, 50B38FCC1B6B37F00064C132 /* FeedbackViewController.swift in Sources */, 50CB05761CC5D0FD0024BE06 /* SearchedFeedBasicCell.swift in Sources */, diff --git a/Yep/ViewControllers/GeniusInterview/GeniusInterview.storyboard b/Yep/ViewControllers/GeniusInterview/GeniusInterview.storyboard new file mode 100644 index 000000000..a5386a14f --- /dev/null +++ b/Yep/ViewControllers/GeniusInterview/GeniusInterview.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift b/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift new file mode 100644 index 000000000..03f655c70 --- /dev/null +++ b/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift @@ -0,0 +1,35 @@ +// +// GeniusInterviewViewController.swift +// Yep +// +// Created by NIX on 16/6/29. +// Copyright © 2016年 Catch Inc. All rights reserved. +// + +import UIKit + +class GeniusInterviewViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + // Do any additional setup after loading the view. + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + // Get the new view controller using segue.destinationViewController. + // Pass the selected object to the new view controller. + } + */ + +} From 870b17d94a44258249599674ba48faf89a2e1c0d Mon Sep 17 00:00:00 2001 From: nixzhu Date: Wed, 29 Jun 2016 16:38:56 +0800 Subject: [PATCH 08/34] showGeniusInterviewAction --- .../Discover/Discover.storyboard | 17 +++++++++++++---- .../DiscoverContainerViewController.swift | 9 +++++++++ .../Discover/MeetGeniusViewController.swift | 9 +++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/Yep/ViewControllers/Discover/Discover.storyboard b/Yep/ViewControllers/Discover/Discover.storyboard index 345c9b7ca..3552cf191 100644 --- a/Yep/ViewControllers/Discover/Discover.storyboard +++ b/Yep/ViewControllers/Discover/Discover.storyboard @@ -49,7 +49,7 @@ - + @@ -86,7 +86,7 @@ - + @@ -94,7 +94,15 @@ - + + + + + + + + + @@ -111,7 +119,7 @@ - + @@ -150,6 +158,7 @@ + diff --git a/Yep/ViewControllers/Discover/DiscoverContainerViewController.swift b/Yep/ViewControllers/Discover/DiscoverContainerViewController.swift index aad75da79..c8978e298 100644 --- a/Yep/ViewControllers/Discover/DiscoverContainerViewController.swift +++ b/Yep/ViewControllers/Discover/DiscoverContainerViewController.swift @@ -155,6 +155,15 @@ class DiscoverContainerViewController: UIViewController { switch identifier { + case "embedMeetGenius": + let vc = segue.destinationViewController as! MeetGeniusViewController + + vc.showGeniusInterviewAction = { + SafeDispatch.async { [weak self] in + self?.performSegueWithIdentifier("showGeniusInterview", sender: nil) + } + } + case "embedDiscover": let vc = segue.destinationViewController as! DiscoverViewController diff --git a/Yep/ViewControllers/Discover/MeetGeniusViewController.swift b/Yep/ViewControllers/Discover/MeetGeniusViewController.swift index d23efbf85..2e73a0051 100644 --- a/Yep/ViewControllers/Discover/MeetGeniusViewController.swift +++ b/Yep/ViewControllers/Discover/MeetGeniusViewController.swift @@ -10,6 +10,8 @@ import UIKit class MeetGeniusViewController: UIViewController { + var showGeniusInterviewAction: (() -> Void)? + @IBOutlet weak var tableView: UITableView! { didSet { tableView.tableHeaderView = MeetGeniusShowView(frame: CGRect(x: 0, y: 0, width: 100, height: 180)) @@ -50,10 +52,17 @@ extension MeetGeniusViewController: UITableViewDataSource, UITableViewDelegate { } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + let cell: GeniusInterviewCell = tableView.dequeueReusableCell() cell.avatarImageView.image = UIImage(named: "yep_icon_solo") cell.numberLabel.text = String(format: "#%03d", indexPath.row) + return cell } + + func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { + + showGeniusInterviewAction?() + } } From c735a6650396d7773b09f013bb0b8623351c86d9 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Wed, 29 Jun 2016 16:44:32 +0800 Subject: [PATCH 09/34] hide bottom bar --- Yep/ViewControllers/GeniusInterview/GeniusInterview.storyboard | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Yep/ViewControllers/GeniusInterview/GeniusInterview.storyboard b/Yep/ViewControllers/GeniusInterview/GeniusInterview.storyboard index a5386a14f..3d02e20b8 100644 --- a/Yep/ViewControllers/GeniusInterview/GeniusInterview.storyboard +++ b/Yep/ViewControllers/GeniusInterview/GeniusInterview.storyboard @@ -7,7 +7,7 @@ - + From 2fce33d52b7381c9a3c2b7911884e940116533d0 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Wed, 29 Jun 2016 16:50:36 +0800 Subject: [PATCH 10/34] add GeniusInterviewActionView --- Yep.xcodeproj/project.pbxproj | 12 ++++++++ .../GeniusInterviewActionView.swift | 28 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift diff --git a/Yep.xcodeproj/project.pbxproj b/Yep.xcodeproj/project.pbxproj index 489f3b102..4c0ac399f 100644 --- a/Yep.xcodeproj/project.pbxproj +++ b/Yep.xcodeproj/project.pbxproj @@ -307,6 +307,7 @@ 50A6A7BA1D23AD4000E01190 /* MeetGeniusShowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A6A7B91D23AD4000E01190 /* MeetGeniusShowView.swift */; }; 50A6A7BD1D23BED600E01190 /* GeniusInterviewViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A6A7BC1D23BED600E01190 /* GeniusInterviewViewController.swift */; }; 50A6A7BF1D23BEEF00E01190 /* GeniusInterview.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 50A6A7BE1D23BEEF00E01190 /* GeniusInterview.storyboard */; }; + 50A6A7C21D23C2D300E01190 /* GeniusInterviewActionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A6A7C11D23C2D300E01190 /* GeniusInterviewActionView.swift */; }; 50A820241B969B0F007CD30E /* NSTimeZone+Yep.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A820231B969B0F007CD30E /* NSTimeZone+Yep.swift */; }; 50A93A9D1BD8C515007005DB /* FeedSkillPickerItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A93A9C1BD8C515007005DB /* FeedSkillPickerItemView.swift */; }; 50A9D4571ACD393A000B2599 /* YepWaverView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A9D4541ACD393A000B2599 /* YepWaverView.swift */; }; @@ -1026,6 +1027,7 @@ 50A6A7B91D23AD4000E01190 /* MeetGeniusShowView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MeetGeniusShowView.swift; path = Views/MeetGeniusShow/MeetGeniusShowView.swift; sourceTree = ""; }; 50A6A7BC1D23BED600E01190 /* GeniusInterviewViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GeniusInterviewViewController.swift; path = ViewControllers/GeniusInterview/GeniusInterviewViewController.swift; sourceTree = ""; }; 50A6A7BE1D23BEEF00E01190 /* GeniusInterview.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = GeniusInterview.storyboard; path = ViewControllers/GeniusInterview/GeniusInterview.storyboard; sourceTree = ""; }; + 50A6A7C11D23C2D300E01190 /* GeniusInterviewActionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GeniusInterviewActionView.swift; path = Views/GeniusInterviewAction/GeniusInterviewActionView.swift; sourceTree = ""; }; 50A820231B969B0F007CD30E /* NSTimeZone+Yep.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "NSTimeZone+Yep.swift"; path = "Extensions/NSTimeZone+Yep.swift"; sourceTree = ""; }; 50A93A9C1BD8C515007005DB /* FeedSkillPickerItemView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FeedSkillPickerItemView.swift; path = Views/PickerItems/FeedSkill/FeedSkillPickerItemView.swift; sourceTree = ""; }; 50A9D4541ACD393A000B2599 /* YepWaverView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = YepWaverView.swift; path = Views/AudioWaves/YepWaverView.swift; sourceTree = ""; }; @@ -1919,6 +1921,7 @@ isa = PBXGroup; children = ( 50A6A7B81D23AD1600E01190 /* MeetGeniusShow */, + 50A6A7C01D23C28D00E01190 /* GeniusInterviewActionView */, 50B6A03D1CA282B100C460E3 /* ActionSheet */, 50B8E6191B41341000C17EA1 /* ProgressViews */, 504CBA3B1B3D048900663A90 /* TextViews */, @@ -2845,6 +2848,14 @@ name = GeniusInterview; sourceTree = ""; }; + 50A6A7C01D23C28D00E01190 /* GeniusInterviewActionView */ = { + isa = PBXGroup; + children = ( + 50A6A7C11D23C2D300E01190 /* GeniusInterviewActionView.swift */, + ); + name = GeniusInterviewActionView; + sourceTree = ""; + }; 50A93A9E1BD8C51D007005DB /* PickerItems */ = { isa = PBXGroup; children = ( @@ -4637,6 +4648,7 @@ 338940371CB7C80900B276C1 /* NewFeedPreviewCell.swift in Sources */, 502AE52E1AB83879005BD199 /* UnderLineTextField.swift in Sources */, 5012FDDA1BFABDE400294145 /* ProfileFeedsCell.swift in Sources */, + 50A6A7C21D23C2D300E01190 /* GeniusInterviewActionView.swift in Sources */, 508F8FD71B01EDB400461B0B /* DribbbleShotCell.swift in Sources */, 508DF62B1B9985F300B194A4 /* YepLog.swift in Sources */, 50A6A7AF1D2361A900E01190 /* ConversationViewController+AVAudioPlayerDelegate.swift in Sources */, diff --git a/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift b/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift new file mode 100644 index 000000000..4c260340a --- /dev/null +++ b/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift @@ -0,0 +1,28 @@ +// +// GeniusInterviewActionView.swift +// Yep +// +// Created by NIX on 16/6/29. +// Copyright © 2016年 Catch Inc. All rights reserved. +// + +import UIKit + +class GeniusInterviewActionView: UIView { + + lazy var sayHiButton: UIButton = { + let button = UIButton() + button.titleLabel?.font = UIFont.systemFontOfSize(14) + button.setTitle(NSLocalizedString("Say Hi", comment: ""), forState: .Normal) + button.backgroundColor = UIColor.yepTintColor() + button.setTitleColor(UIColor.whiteColor(), forState: .Normal) + button.layer.cornerRadius = 5 + button.addTarget(self, action: #selector(GeniusInterviewActionView.sayHi(_:)), forControlEvents: UIControlEvents.TouchUpInside) + return button + }() + + @objc private func sayHi(sender: UIButton) { + println("Say Hi") + } +} + From 2f3a9a90a7f1cc6d4b9a146faea73985ddb7afc0 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Wed, 29 Jun 2016 16:59:53 +0800 Subject: [PATCH 11/34] GeniusInterviewActionView makeUI --- .../GeniusInterviewActionView.swift | 34 +++++++++++++++++++ .../MeetGeniusShow/MeetGeniusShowView.swift | 12 +++---- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift b/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift index 4c260340a..cbb3a17c6 100644 --- a/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift +++ b/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift @@ -10,6 +10,14 @@ import UIKit class GeniusInterviewActionView: UIView { + lazy var toolbar = UIToolbar() + + lazy var avatarImageView: UIImageView = { + let view = UIImageView(frame: CGRect(x: 0, y: 0, width: 30, height: 30)) + view.backgroundColor = UIColor.redColor() + return view + }() + lazy var sayHiButton: UIButton = { let button = UIButton() button.titleLabel?.font = UIFont.systemFontOfSize(14) @@ -24,5 +32,31 @@ class GeniusInterviewActionView: UIView { @objc private func sayHi(sender: UIButton) { println("Say Hi") } + + private func makeUI() { + + do { + toolbar.translatesAutoresizingMaskIntoConstraints = false + addSubview(toolbar) + + let leading = toolbar.leadingAnchor.constraintEqualToAnchor(leadingAnchor) + let trailing = toolbar.trailingAnchor.constraintEqualToAnchor(trailingAnchor) + let top = toolbar.topAnchor.constraintEqualToAnchor(topAnchor) + let bottom = toolbar.bottomAnchor.constraintEqualToAnchor(bottomAnchor) + NSLayoutConstraint.activateConstraints([leading, trailing, top, bottom]) + } + + do { + let avatarItem = UIBarButtonItem(customView: avatarImageView) + let sayHiItem = UIBarButtonItem(customView: sayHiButton) + let shareItem = UIBarButtonItem(barButtonSystemItem: .Action, target: self, action: #selector(GeniusInterviewActionView.share(_:))) + + toolbar.setItems([avatarItem, sayHiItem, shareItem], animated: false) + } + } + + @objc private func share(sender: UIBarButtonItem) { + println("share") + } } diff --git a/Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift b/Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift index 5c00ef5ca..3170812ab 100644 --- a/Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift +++ b/Yep/Views/MeetGeniusShow/MeetGeniusShowView.swift @@ -48,14 +48,14 @@ class MeetGeniusShowView: UIView { private func makeUI() { - backgroundImageView.translatesAutoresizingMaskIntoConstraints = false - addSubview(backgroundImageView) + do { + backgroundImageView.translatesAutoresizingMaskIntoConstraints = false + addSubview(backgroundImageView) - let views = [ - "backgroundImageView": backgroundImageView, - ] + let views = [ + "backgroundImageView": backgroundImageView, + ] - do { let constraintsH = NSLayoutConstraint.constraintsWithVisualFormat("H:|[backgroundImageView]|", options: [], metrics: nil, views: views) let constraintsV = NSLayoutConstraint.constraintsWithVisualFormat("V:|[backgroundImageView]|", options: [], metrics: nil, views: views) NSLayoutConstraint.activateConstraints(constraintsH) From 974ec7d6fe148467fb5e2485f8f9b6a11de09f43 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Wed, 29 Jun 2016 17:29:10 +0800 Subject: [PATCH 12/34] use GeniusInterviewActionView --- .../GeniusInterview.storyboard | 14 +++++++++++ .../GeniusInterviewActionView.swift | 24 +++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/Yep/ViewControllers/GeniusInterview/GeniusInterview.storyboard b/Yep/ViewControllers/GeniusInterview/GeniusInterview.storyboard index 3d02e20b8..77dec0111 100644 --- a/Yep/ViewControllers/GeniusInterview/GeniusInterview.storyboard +++ b/Yep/ViewControllers/GeniusInterview/GeniusInterview.storyboard @@ -15,7 +15,21 @@ + + + + + + + + + + + + + + diff --git a/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift b/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift index cbb3a17c6..a43d79140 100644 --- a/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift +++ b/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift @@ -19,7 +19,7 @@ class GeniusInterviewActionView: UIView { }() lazy var sayHiButton: UIButton = { - let button = UIButton() + let button = UIButton(frame: CGRect(x: 0, y: 0, width: 185, height: 30)) button.titleLabel?.font = UIFont.systemFontOfSize(14) button.setTitle(NSLocalizedString("Say Hi", comment: ""), forState: .Normal) button.backgroundColor = UIColor.yepTintColor() @@ -29,8 +29,10 @@ class GeniusInterviewActionView: UIView { return button }() - @objc private func sayHi(sender: UIButton) { - println("Say Hi") + override func didMoveToSuperview() { + super.didMoveToSuperview() + + makeUI() } private func makeUI() { @@ -48,13 +50,27 @@ class GeniusInterviewActionView: UIView { do { let avatarItem = UIBarButtonItem(customView: avatarImageView) + + let gap0Item = UIBarButtonItem(barButtonSystemItem: .FixedSpace, target: nil, action: nil) + gap0Item.width = 11 + let gap1Item = UIBarButtonItem(barButtonSystemItem: .FlexibleSpace, target: nil, action: nil) + gap1Item.width = 20 + let sayHiItem = UIBarButtonItem(customView: sayHiButton) + + let gap2Item = UIBarButtonItem(barButtonSystemItem: .FlexibleSpace, target: nil, action: nil) + gap2Item.width = 20 + let shareItem = UIBarButtonItem(barButtonSystemItem: .Action, target: self, action: #selector(GeniusInterviewActionView.share(_:))) - toolbar.setItems([avatarItem, sayHiItem, shareItem], animated: false) + toolbar.setItems([avatarItem, gap0Item, gap1Item, sayHiItem, gap2Item, shareItem], animated: false) } } + @objc private func sayHi(sender: UIButton) { + println("Say Hi") + } + @objc private func share(sender: UIBarButtonItem) { println("share") } From e21d69dc83cd04387e05f390f3885505d8558d09 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Wed, 29 Jun 2016 17:47:48 +0800 Subject: [PATCH 13/34] layout --- .../GeniusInterviewActionView.swift | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift b/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift index a43d79140..93c7d9b59 100644 --- a/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift +++ b/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift @@ -15,11 +15,12 @@ class GeniusInterviewActionView: UIView { lazy var avatarImageView: UIImageView = { let view = UIImageView(frame: CGRect(x: 0, y: 0, width: 30, height: 30)) view.backgroundColor = UIColor.redColor() + view.layer.cornerRadius = 15 return view }() lazy var sayHiButton: UIButton = { - let button = UIButton(frame: CGRect(x: 0, y: 0, width: 185, height: 30)) + let button = UIButton(frame: CGRect(x: 0, y: 0, width: 150, height: 30)) button.titleLabel?.font = UIFont.systemFontOfSize(14) button.setTitle(NSLocalizedString("Say Hi", comment: ""), forState: .Normal) button.backgroundColor = UIColor.yepTintColor() @@ -51,19 +52,15 @@ class GeniusInterviewActionView: UIView { do { let avatarItem = UIBarButtonItem(customView: avatarImageView) - let gap0Item = UIBarButtonItem(barButtonSystemItem: .FixedSpace, target: nil, action: nil) - gap0Item.width = 11 let gap1Item = UIBarButtonItem(barButtonSystemItem: .FlexibleSpace, target: nil, action: nil) - gap1Item.width = 20 let sayHiItem = UIBarButtonItem(customView: sayHiButton) let gap2Item = UIBarButtonItem(barButtonSystemItem: .FlexibleSpace, target: nil, action: nil) - gap2Item.width = 20 let shareItem = UIBarButtonItem(barButtonSystemItem: .Action, target: self, action: #selector(GeniusInterviewActionView.share(_:))) - toolbar.setItems([avatarItem, gap0Item, gap1Item, sayHiItem, gap2Item, shareItem], animated: false) + toolbar.setItems([avatarItem, gap1Item, sayHiItem, gap2Item, shareItem], animated: false) } } From 051a94a04806ea3e0266cf88acb2eec86b8a5823 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Wed, 29 Jun 2016 17:49:51 +0800 Subject: [PATCH 14/34] sayHiButton width --- .../GeniusInterviewAction/GeniusInterviewActionView.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift b/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift index 93c7d9b59..7687e1a3d 100644 --- a/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift +++ b/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift @@ -7,6 +7,7 @@ // import UIKit +import Ruler class GeniusInterviewActionView: UIView { @@ -20,7 +21,8 @@ class GeniusInterviewActionView: UIView { }() lazy var sayHiButton: UIButton = { - let button = UIButton(frame: CGRect(x: 0, y: 0, width: 150, height: 30)) + let width: CGFloat = Ruler.iPhoneHorizontal(150, 185, 185).value + let button = UIButton(frame: CGRect(x: 0, y: 0, width: width, height: 30)) button.titleLabel?.font = UIFont.systemFontOfSize(14) button.setTitle(NSLocalizedString("Say Hi", comment: ""), forState: .Normal) button.backgroundColor = UIColor.yepTintColor() From 2ef50f0673864b1101e0a24bbc84f9ff0aaee93c Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 30 Jun 2016 09:38:18 +0800 Subject: [PATCH 15/34] add webView --- .../GeniusInterviewViewController.swift | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift b/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift index 03f655c70..3359d5942 100644 --- a/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift +++ b/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift @@ -7,13 +7,28 @@ // import UIKit +import WebKit class GeniusInterviewViewController: UIViewController { + lazy var webView: WKWebView = { + let view = WKWebView() + return view + }() + override func viewDidLoad() { super.viewDidLoad() - // Do any additional setup after loading the view. + do { + webView.translatesAutoresizingMaskIntoConstraints = false + view.insertSubview(webView, atIndex: 0) + + let leading = webView.leadingAnchor.constraintEqualToAnchor(view.leadingAnchor) + let trailing = webView.trailingAnchor.constraintEqualToAnchor(view.trailingAnchor) + let top = webView.topAnchor.constraintEqualToAnchor(view.topAnchor) + let bottom = webView.bottomAnchor.constraintEqualToAnchor(view.bottomAnchor) + NSLayoutConstraint.activateConstraints([leading, trailing, top, bottom]) + } } override func didReceiveMemoryWarning() { From ce45e092f27f446891cf253d48d27d737f4e6682 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 30 Jun 2016 09:42:36 +0800 Subject: [PATCH 16/34] loadRequest --- Yep/ViewControllers/Discover/MeetGeniusViewController.swift | 4 ++++ .../GeniusInterview/GeniusInterviewViewController.swift | 2 ++ 2 files changed, 6 insertions(+) diff --git a/Yep/ViewControllers/Discover/MeetGeniusViewController.swift b/Yep/ViewControllers/Discover/MeetGeniusViewController.swift index 2e73a0051..f961e8913 100644 --- a/Yep/ViewControllers/Discover/MeetGeniusViewController.swift +++ b/Yep/ViewControllers/Discover/MeetGeniusViewController.swift @@ -62,6 +62,10 @@ extension MeetGeniusViewController: UITableViewDataSource, UITableViewDelegate { func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { + defer { + tableView.deselectRowAtIndexPath(indexPath, animated: true) + } + showGeniusInterviewAction?() } } diff --git a/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift b/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift index 3359d5942..3b3912033 100644 --- a/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift +++ b/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift @@ -13,6 +13,8 @@ class GeniusInterviewViewController: UIViewController { lazy var webView: WKWebView = { let view = WKWebView() + let request = NSURLRequest(URL: NSURL(string: "https://soyep.com")!) + view.loadRequest(request) return view }() From 3d29def84914b2e35e02935959cb8079638bd663 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 30 Jun 2016 09:47:26 +0800 Subject: [PATCH 17/34] tapAvatarAction --- .../GeniusInterviewActionView.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift b/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift index 7687e1a3d..e8840fed4 100644 --- a/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift +++ b/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift @@ -11,6 +11,8 @@ import Ruler class GeniusInterviewActionView: UIView { + var tapAvatarAction: (() -> Void)? + lazy var toolbar = UIToolbar() lazy var avatarImageView: UIImageView = { @@ -53,6 +55,8 @@ class GeniusInterviewActionView: UIView { do { let avatarItem = UIBarButtonItem(customView: avatarImageView) + avatarItem.target = self + avatarItem.action = #selector(GeniusInterviewActionView.tapAvatar(_:)) let gap1Item = UIBarButtonItem(barButtonSystemItem: .FlexibleSpace, target: nil, action: nil) @@ -66,6 +70,11 @@ class GeniusInterviewActionView: UIView { } } + @objc private func tapAvatar(sender: UIBarButtonItem) { + println("tapAvatar") + tapAvatarAction?() + } + @objc private func sayHi(sender: UIButton) { println("Say Hi") } From 6ae505dc70ab238fb1ec6efe23008bc904fbf997 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 30 Jun 2016 09:57:08 +0800 Subject: [PATCH 18/34] sayHiAction --- Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift b/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift index e8840fed4..e7016b378 100644 --- a/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift +++ b/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift @@ -12,6 +12,7 @@ import Ruler class GeniusInterviewActionView: UIView { var tapAvatarAction: (() -> Void)? + var sayHiAction: (() -> Void)? lazy var toolbar = UIToolbar() @@ -77,6 +78,7 @@ class GeniusInterviewActionView: UIView { @objc private func sayHi(sender: UIButton) { println("Say Hi") + sayHiAction?() } @objc private func share(sender: UIBarButtonItem) { From 446c006b38b78edd56d4ce0779c072f9fedb25f5 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 30 Jun 2016 09:59:28 +0800 Subject: [PATCH 19/34] shareAction --- .../GeniusInterviewActionView.swift | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift b/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift index e7016b378..efbb55c13 100644 --- a/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift +++ b/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift @@ -13,6 +13,7 @@ class GeniusInterviewActionView: UIView { var tapAvatarAction: (() -> Void)? var sayHiAction: (() -> Void)? + var shareAction: (() -> Void)? lazy var toolbar = UIToolbar() @@ -20,6 +21,11 @@ class GeniusInterviewActionView: UIView { let view = UIImageView(frame: CGRect(x: 0, y: 0, width: 30, height: 30)) view.backgroundColor = UIColor.redColor() view.layer.cornerRadius = 15 + + view.userInteractionEnabled = true + let tap = UITapGestureRecognizer(target: self, action: #selector(GeniusInterviewActionView.tapAvatar(_:))) + view.addGestureRecognizer(tap) + return view }() @@ -56,8 +62,6 @@ class GeniusInterviewActionView: UIView { do { let avatarItem = UIBarButtonItem(customView: avatarImageView) - avatarItem.target = self - avatarItem.action = #selector(GeniusInterviewActionView.tapAvatar(_:)) let gap1Item = UIBarButtonItem(barButtonSystemItem: .FlexibleSpace, target: nil, action: nil) @@ -71,18 +75,19 @@ class GeniusInterviewActionView: UIView { } } - @objc private func tapAvatar(sender: UIBarButtonItem) { + @objc private func tapAvatar(sender: UITapGestureRecognizer) { println("tapAvatar") tapAvatarAction?() } @objc private func sayHi(sender: UIButton) { - println("Say Hi") + println("sayHi") sayHiAction?() } @objc private func share(sender: UIBarButtonItem) { println("share") + shareAction?() } } From 4f7d6f31fa1f8248ca27ab588cb410b62f4f81f8 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 30 Jun 2016 10:04:37 +0800 Subject: [PATCH 20/34] use actions --- .../GeniusInterview/GeniusInterview.storyboard | 3 +++ .../GeniusInterviewViewController.swift | 16 ++++++++++++++++ .../GeniusInterviewActionView.swift | 10 +++++++--- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Yep/ViewControllers/GeniusInterview/GeniusInterview.storyboard b/Yep/ViewControllers/GeniusInterview/GeniusInterview.storyboard index 77dec0111..85ee8106f 100644 --- a/Yep/ViewControllers/GeniusInterview/GeniusInterview.storyboard +++ b/Yep/ViewControllers/GeniusInterview/GeniusInterview.storyboard @@ -32,6 +32,9 @@ + + + diff --git a/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift b/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift index 3b3912033..5aab414d0 100644 --- a/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift +++ b/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift @@ -18,6 +18,22 @@ class GeniusInterviewViewController: UIViewController { return view }() + @IBOutlet weak var actionView: GeniusInterviewActionView! { + didSet { + actionView.tapAvatarAction = { + println("tapAvatarAction") + } + + actionView.sayHiAction = { + println("sayHiAction") + } + + actionView.shareAction = { + println("shareAction") + } + } + } + override func viewDidLoad() { super.viewDidLoad() diff --git a/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift b/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift index efbb55c13..e7482718d 100644 --- a/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift +++ b/Yep/Views/GeniusInterviewAction/GeniusInterviewActionView.swift @@ -18,6 +18,7 @@ class GeniusInterviewActionView: UIView { lazy var toolbar = UIToolbar() lazy var avatarImageView: UIImageView = { + let view = UIImageView(frame: CGRect(x: 0, y: 0, width: 30, height: 30)) view.backgroundColor = UIColor.redColor() view.layer.cornerRadius = 15 @@ -30,6 +31,7 @@ class GeniusInterviewActionView: UIView { }() lazy var sayHiButton: UIButton = { + let width: CGFloat = Ruler.iPhoneHorizontal(150, 185, 185).value let button = UIButton(frame: CGRect(x: 0, y: 0, width: width, height: 30)) button.titleLabel?.font = UIFont.systemFontOfSize(14) @@ -37,7 +39,9 @@ class GeniusInterviewActionView: UIView { button.backgroundColor = UIColor.yepTintColor() button.setTitleColor(UIColor.whiteColor(), forState: .Normal) button.layer.cornerRadius = 5 + button.addTarget(self, action: #selector(GeniusInterviewActionView.sayHi(_:)), forControlEvents: UIControlEvents.TouchUpInside) + return button }() @@ -76,17 +80,17 @@ class GeniusInterviewActionView: UIView { } @objc private func tapAvatar(sender: UITapGestureRecognizer) { - println("tapAvatar") + tapAvatarAction?() } @objc private func sayHi(sender: UIButton) { - println("sayHi") + sayHiAction?() } @objc private func share(sender: UIBarButtonItem) { - println("share") + shareAction?() } } From e440e00a00e598efe7681cb55fd8f862b0c8b7f2 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 30 Jun 2016 10:47:20 +0800 Subject: [PATCH 21/34] lazy actionView --- .../GeniusInterview.storyboard | 17 -------- .../GeniusInterviewViewController.swift | 41 +++++++++++++------ 2 files changed, 28 insertions(+), 30 deletions(-) diff --git a/Yep/ViewControllers/GeniusInterview/GeniusInterview.storyboard b/Yep/ViewControllers/GeniusInterview/GeniusInterview.storyboard index 85ee8106f..3d02e20b8 100644 --- a/Yep/ViewControllers/GeniusInterview/GeniusInterview.storyboard +++ b/Yep/ViewControllers/GeniusInterview/GeniusInterview.storyboard @@ -15,26 +15,9 @@ - - - - - - - - - - - - - - - - - diff --git a/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift b/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift index 5aab414d0..3eb612c83 100644 --- a/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift +++ b/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift @@ -12,34 +12,38 @@ import WebKit class GeniusInterviewViewController: UIViewController { lazy var webView: WKWebView = { + let view = WKWebView() let request = NSURLRequest(URL: NSURL(string: "https://soyep.com")!) view.loadRequest(request) return view }() - @IBOutlet weak var actionView: GeniusInterviewActionView! { - didSet { - actionView.tapAvatarAction = { - println("tapAvatarAction") - } + lazy var actionView: GeniusInterviewActionView = { - actionView.sayHiAction = { - println("sayHiAction") - } + let view = GeniusInterviewActionView() - actionView.shareAction = { - println("shareAction") - } + view.tapAvatarAction = { + println("tapAvatarAction") + } + + view.sayHiAction = { + println("sayHiAction") } - } + + view.shareAction = { + println("shareAction") + } + + return view + }() override func viewDidLoad() { super.viewDidLoad() do { webView.translatesAutoresizingMaskIntoConstraints = false - view.insertSubview(webView, atIndex: 0) + view.addSubview(webView) let leading = webView.leadingAnchor.constraintEqualToAnchor(view.leadingAnchor) let trailing = webView.trailingAnchor.constraintEqualToAnchor(view.trailingAnchor) @@ -47,6 +51,17 @@ class GeniusInterviewViewController: UIViewController { let bottom = webView.bottomAnchor.constraintEqualToAnchor(view.bottomAnchor) NSLayoutConstraint.activateConstraints([leading, trailing, top, bottom]) } + + do { + actionView.translatesAutoresizingMaskIntoConstraints = false + view.addSubview(actionView) + + let leading = actionView.leadingAnchor.constraintEqualToAnchor(view.leadingAnchor) + let trailing = actionView.trailingAnchor.constraintEqualToAnchor(view.trailingAnchor) + let top = actionView.topAnchor.constraintEqualToAnchor(view.bottomAnchor, constant: -50) + let height = actionView.heightAnchor.constraintEqualToConstant(50) + NSLayoutConstraint.activateConstraints([leading, trailing, top, height]) + } } override func didReceiveMemoryWarning() { From 0c408e2004c587b6d6ef729f91278c5cb9c4d442 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 30 Jun 2016 11:06:27 +0800 Subject: [PATCH 22/34] scrollView.delegate --- .../GeniusInterviewViewController.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift b/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift index 3eb612c83..3103b9165 100644 --- a/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift +++ b/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift @@ -14,8 +14,13 @@ class GeniusInterviewViewController: UIViewController { lazy var webView: WKWebView = { let view = WKWebView() + + view.scrollView.contentInset.bottom = 50 + view.scrollView.delegate = self + let request = NSURLRequest(URL: NSURL(string: "https://soyep.com")!) view.loadRequest(request) + return view }() @@ -81,3 +86,13 @@ class GeniusInterviewViewController: UIViewController { */ } + +extension GeniusInterviewViewController: UIScrollViewDelegate { + + func scrollViewDidScroll(scrollView: UIScrollView) { + + println("scrollView.contentOffset.y: \(scrollView.contentOffset.y)") + println("scrollView.contentSize.height: \(scrollView.contentSize.height)") + } +} + From d80663aa220fcda4f7df53ad5bbfda60a2395b29 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 30 Jun 2016 11:35:27 +0800 Subject: [PATCH 23/34] scroll adjust actionViewTopConstraint --- .../GeniusInterviewViewController.swift | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift b/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift index 3103b9165..acd4bb0b6 100644 --- a/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift +++ b/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift @@ -24,6 +24,7 @@ class GeniusInterviewViewController: UIViewController { return view }() + private var actionViewTopConstraint: NSLayoutConstraint? lazy var actionView: GeniusInterviewActionView = { let view = GeniusInterviewActionView() @@ -43,6 +44,10 @@ class GeniusInterviewViewController: UIViewController { return view }() + deinit { + webView.scrollView.delegate = nil + } + override func viewDidLoad() { super.viewDidLoad() @@ -63,7 +68,8 @@ class GeniusInterviewViewController: UIViewController { let leading = actionView.leadingAnchor.constraintEqualToAnchor(view.leadingAnchor) let trailing = actionView.trailingAnchor.constraintEqualToAnchor(view.trailingAnchor) - let top = actionView.topAnchor.constraintEqualToAnchor(view.bottomAnchor, constant: -50) + let top = actionView.topAnchor.constraintEqualToAnchor(view.bottomAnchor, constant: 0) + self.actionViewTopConstraint = top let height = actionView.heightAnchor.constraintEqualToConstant(50) NSLayoutConstraint.activateConstraints([leading, trailing, top, height]) } @@ -91,8 +97,28 @@ extension GeniusInterviewViewController: UIScrollViewDelegate { func scrollViewDidScroll(scrollView: UIScrollView) { - println("scrollView.contentOffset.y: \(scrollView.contentOffset.y)") - println("scrollView.contentSize.height: \(scrollView.contentSize.height)") + let scrollViewContentOffsetY = scrollView.contentOffset.y + guard scrollViewContentOffsetY > 0 else { + return + } + let scrollViewHeight = scrollView.bounds.height + let scrollViewContentSizeHeight = scrollView.contentSize.height + + println("scrollViewContentOffsetY: \(scrollViewContentOffsetY)") + println("scrollViewHeight: \(scrollViewHeight)") + println("scrollViewContentSizeHeight: \(scrollViewContentSizeHeight)") + +// if scrollViewContentOffsetY + scrollViewHeight == (scrollViewContentSizeHeight - 50) { +// actionViewTopConstraint?.constant = -50 +// } + + let y = (scrollViewContentOffsetY + scrollViewHeight) - scrollViewContentSizeHeight + if y > 0 { + actionViewTopConstraint?.constant = -min(y, 50) + } else { + //actionViewTopConstraint?.constant = min(y, 0) + } } + } From aa48c83e831fb793dfeea1f16a9595d2de7ff57b Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 30 Jun 2016 11:45:37 +0800 Subject: [PATCH 24/34] generic ObjectKeypathObserver --- Yep/Extensions/UISearchBar+Yep.swift | 9 ++++----- Yep/Helpers/KVO/ObjectKeypathObserver.swift | 10 +++++----- .../SearchContacts/SearchContactsViewController.swift | 2 +- .../SearchConversationsViewController.swift | 2 +- .../SearchFeeds/SearchFeedsViewController.swift | 2 +- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Yep/Extensions/UISearchBar+Yep.swift b/Yep/Extensions/UISearchBar+Yep.swift index 141dae973..307012fd9 100644 --- a/Yep/Extensions/UISearchBar+Yep.swift +++ b/Yep/Extensions/UISearchBar+Yep.swift @@ -30,7 +30,7 @@ extension UISearchBar { yep_cancelButton?.enabled = true } - func yep_makeSureCancelButtonAlwaysEnabled() -> ObjectKeypathObserver? { + func yep_makeSureCancelButtonAlwaysEnabled() -> ObjectKeypathObserver? { guard let cancelButton = yep_cancelButton else { println("Not cancelButton in searchBar!") @@ -38,10 +38,9 @@ extension UISearchBar { } return ObjectKeypathObserver(object: cancelButton, keypath: "enabled", afterValueChanged: { object in - if let cancelButton = object as? UIButton { - if !cancelButton.enabled { - cancelButton.enabled = true - } + let cancelButton = object + if !cancelButton.enabled { + cancelButton.enabled = true } }) } diff --git a/Yep/Helpers/KVO/ObjectKeypathObserver.swift b/Yep/Helpers/KVO/ObjectKeypathObserver.swift index c51e472b2..1bb573956 100644 --- a/Yep/Helpers/KVO/ObjectKeypathObserver.swift +++ b/Yep/Helpers/KVO/ObjectKeypathObserver.swift @@ -8,18 +8,18 @@ import UIKit -final class ObjectKeypathObserver: NSObject { +final class ObjectKeypathObserver: NSObject { - weak var object: NSObject? + weak var object: Object? var keypath: String - typealias AfterValueChanged = (object: NSObject) -> Void + typealias AfterValueChanged = (object: Object) -> Void var afterValueChanged: AfterValueChanged? deinit { object?.removeObserver(self, forKeyPath: keypath) } - init(object: NSObject, keypath: String, afterValueChanged: AfterValueChanged) { + init(object: Object, keypath: String, afterValueChanged: AfterValueChanged) { self.object = object self.keypath = keypath @@ -32,7 +32,7 @@ final class ObjectKeypathObserver: NSObject { override func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer) { - guard let object = object as? NSObject else { + guard let object = object as? Object else { return } diff --git a/Yep/ViewControllers/SearchContacts/SearchContactsViewController.swift b/Yep/ViewControllers/SearchContacts/SearchContactsViewController.swift index 7048ea3c6..d2cd5209d 100644 --- a/Yep/ViewControllers/SearchContacts/SearchContactsViewController.swift +++ b/Yep/ViewControllers/SearchContacts/SearchContactsViewController.swift @@ -15,7 +15,7 @@ final class SearchContactsViewController: SegueViewController { var originalNavigationControllerDelegate: UINavigationControllerDelegate? var searchTransition: SearchTransition? - private var searchBarCancelButtonEnabledObserver: ObjectKeypathObserver? + private var searchBarCancelButtonEnabledObserver: ObjectKeypathObserver? @IBOutlet weak var searchBar: UISearchBar! { didSet { searchBar.placeholder = NSLocalizedString("Search Friend", comment: "") diff --git a/Yep/ViewControllers/SearchConversations/SearchConversationsViewController.swift b/Yep/ViewControllers/SearchConversations/SearchConversationsViewController.swift index f48f6a41f..3d75d940c 100644 --- a/Yep/ViewControllers/SearchConversations/SearchConversationsViewController.swift +++ b/Yep/ViewControllers/SearchConversations/SearchConversationsViewController.swift @@ -15,7 +15,7 @@ final class SearchConversationsViewController: SegueViewController { var originalNavigationControllerDelegate: UINavigationControllerDelegate? var searchTransition: SearchTransition? - private var searchBarCancelButtonEnabledObserver: ObjectKeypathObserver? + private var searchBarCancelButtonEnabledObserver: ObjectKeypathObserver? @IBOutlet weak var searchBar: UISearchBar! { didSet { searchBar.placeholder = NSLocalizedString("Search", comment: "") diff --git a/Yep/ViewControllers/SearchFeeds/SearchFeedsViewController.swift b/Yep/ViewControllers/SearchFeeds/SearchFeedsViewController.swift index f564fc40d..2e19541cf 100644 --- a/Yep/ViewControllers/SearchFeeds/SearchFeedsViewController.swift +++ b/Yep/ViewControllers/SearchFeeds/SearchFeedsViewController.swift @@ -27,7 +27,7 @@ final class SearchFeedsViewController: SegueViewController { var skill: Skill? var profileUser: ProfileUser? - private var searchBarCancelButtonEnabledObserver: ObjectKeypathObserver? + private var searchBarCancelButtonEnabledObserver: ObjectKeypathObserver? @IBOutlet weak var searchBar: UISearchBar! { didSet { searchBar.setSearchFieldBackgroundImage(UIImage(named: "searchbar_textfield_background"), forState: .Normal) From 65569f115fbdbfbf7a7fcfdec584256e87a4e44e Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 30 Jun 2016 11:58:46 +0800 Subject: [PATCH 25/34] animation --- .../GeniusInterviewViewController.swift | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift b/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift index acd4bb0b6..bbd48f0c1 100644 --- a/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift +++ b/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift @@ -93,6 +93,8 @@ class GeniusInterviewViewController: UIViewController { } +// MARK: - UIScrollViewDelegate + extension GeniusInterviewViewController: UIScrollViewDelegate { func scrollViewDidScroll(scrollView: UIScrollView) { @@ -108,17 +110,18 @@ extension GeniusInterviewViewController: UIScrollViewDelegate { println("scrollViewHeight: \(scrollViewHeight)") println("scrollViewContentSizeHeight: \(scrollViewContentSizeHeight)") -// if scrollViewContentOffsetY + scrollViewHeight == (scrollViewContentSizeHeight - 50) { -// actionViewTopConstraint?.constant = -50 -// } - let y = (scrollViewContentOffsetY + scrollViewHeight) - scrollViewContentSizeHeight if y > 0 { - actionViewTopConstraint?.constant = -min(y, 50) + UIView.animateWithDuration(0.25, animations: { [weak self] in + self?.actionViewTopConstraint?.constant = -50 + self?.view.layoutIfNeeded() + }) } else { - //actionViewTopConstraint?.constant = min(y, 0) + UIView.animateWithDuration(0.25, animations: { [weak self] in + self?.actionViewTopConstraint?.constant = 0 + self?.view.layoutIfNeeded() + }) } } - } From c5fd777be9fe4a6bc76f80e1a2518e523ed3d4d7 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 30 Jun 2016 15:24:29 +0800 Subject: [PATCH 26/34] indicatorView --- .../GeniusInterviewViewController.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift b/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift index bbd48f0c1..d580cd7ea 100644 --- a/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift +++ b/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift @@ -24,6 +24,14 @@ class GeniusInterviewViewController: UIViewController { return view }() + lazy var indicatorView: UIActivityIndicatorView = { + + let view = UIActivityIndicatorView(activityIndicatorStyle: .Gray) + view.hidesWhenStopped = true + view.startAnimating() + return view + }() + private var actionViewTopConstraint: NSLayoutConstraint? lazy var actionView: GeniusInterviewActionView = { @@ -62,6 +70,15 @@ class GeniusInterviewViewController: UIViewController { NSLayoutConstraint.activateConstraints([leading, trailing, top, bottom]) } + do { + indicatorView.translatesAutoresizingMaskIntoConstraints = false + view.addSubview(indicatorView) + + let centerX = indicatorView.centerXAnchor.constraintEqualToAnchor(view.centerXAnchor) + let centerY = indicatorView.centerYAnchor.constraintEqualToAnchor(view.centerYAnchor) + NSLayoutConstraint.activateConstraints([centerX, centerY]) + } + do { actionView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(actionView) From 0cfc5065b1629a7297be970665df188f0ffe7008 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 30 Jun 2016 15:28:06 +0800 Subject: [PATCH 27/34] use WKNavigationDelegate to control indicatorView --- .../GeniusInterviewViewController.swift | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift b/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift index d580cd7ea..7b5cb7fb4 100644 --- a/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift +++ b/Yep/ViewControllers/GeniusInterview/GeniusInterviewViewController.swift @@ -15,6 +15,8 @@ class GeniusInterviewViewController: UIViewController { let view = WKWebView() + view.navigationDelegate = self + view.scrollView.contentInset.bottom = 50 view.scrollView.delegate = self @@ -28,7 +30,6 @@ class GeniusInterviewViewController: UIViewController { let view = UIActivityIndicatorView(activityIndicatorStyle: .Gray) view.hidesWhenStopped = true - view.startAnimating() return view }() @@ -110,6 +111,21 @@ class GeniusInterviewViewController: UIViewController { } +// MARK: - WKNavigationDelegate + +extension GeniusInterviewViewController: WKNavigationDelegate { + + func webView(webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) { + + indicatorView.startAnimating() + } + + func webView(webView: WKWebView, didFinishNavigation navigation: WKNavigation!) { + + indicatorView.stopAnimating() + } +} + // MARK: - UIScrollViewDelegate extension GeniusInterviewViewController: UIScrollViewDelegate { From d0cc363782c642f64073afe4f26c13858d6ce05f Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 30 Jun 2016 16:15:04 +0800 Subject: [PATCH 28/34] add model GeniusInterview --- YepKit/Remote/YepService.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/YepKit/Remote/YepService.swift b/YepKit/Remote/YepService.swift index 78a656ee7..a7f03bbc0 100644 --- a/YepKit/Remote/YepService.swift +++ b/YepKit/Remote/YepService.swift @@ -3878,3 +3878,20 @@ public func usersMatchWithUsernamePrefix(usernamePrefix: String, failureHandler: apiRequest({_ in}, baseURL: yepBaseURL, resource: resource, failure: failureHandler, completion: completion) } +// MARK: - GeniusInterview + +public struct GeniusInterview { + + public let user: DiscoveredUser + + public let number: Int + public let title: String + public let abstract: String + public let url: NSURL + + public init?(_ info: JSONDictionary) { + return nil + } +} + + From bdba53a8536c29b1e60b07ac646b2e238e6b20d4 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 30 Jun 2016 16:20:44 +0800 Subject: [PATCH 29/34] configure GeniusInterviewCell --- .../GeniusInterview/GeniusInterviewCell.swift | 14 +++++++++++++- YepKit/Remote/YepService.swift | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Yep/Views/Cells/GeniusInterview/GeniusInterviewCell.swift b/Yep/Views/Cells/GeniusInterview/GeniusInterviewCell.swift index 125010732..a9d8734c9 100644 --- a/Yep/Views/Cells/GeniusInterview/GeniusInterviewCell.swift +++ b/Yep/Views/Cells/GeniusInterview/GeniusInterviewCell.swift @@ -7,6 +7,8 @@ // import UIKit +import YepKit +import Navi class GeniusInterviewCell: UITableViewCell { @@ -27,5 +29,15 @@ class GeniusInterviewCell: UITableViewCell { // Configure the view for the selected state } - + + func configure(withGeniusInterview geniusInterview: GeniusInterview) { + + let avatar = PlainAvatar(avatarURLString: geniusInterview.user.avatarURLString, avatarStyle: miniAvatarStyle) + avatarImageView.navi_setAvatar(avatar, withFadeTransitionDuration: avatarFadeTransitionDuration) + + numberLabel.text = String(format: "#%03d", geniusInterview.number) + titleLabel.text = geniusInterview.title + detailLabel.text = geniusInterview.detail + } } + diff --git a/YepKit/Remote/YepService.swift b/YepKit/Remote/YepService.swift index a7f03bbc0..07db5a4c7 100644 --- a/YepKit/Remote/YepService.swift +++ b/YepKit/Remote/YepService.swift @@ -3886,7 +3886,7 @@ public struct GeniusInterview { public let number: Int public let title: String - public let abstract: String + public let detail: String public let url: NSURL public init?(_ info: JSONDictionary) { From 5416ac8d58915e9a60ad11b7a3894b3a96d26b9b Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 30 Jun 2016 16:39:33 +0800 Subject: [PATCH 30/34] geniusInterviews --- .../Discover/MeetGeniusViewController.swift | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Yep/ViewControllers/Discover/MeetGeniusViewController.swift b/Yep/ViewControllers/Discover/MeetGeniusViewController.swift index f961e8913..d972ef211 100644 --- a/Yep/ViewControllers/Discover/MeetGeniusViewController.swift +++ b/Yep/ViewControllers/Discover/MeetGeniusViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import YepKit class MeetGeniusViewController: UIViewController { @@ -22,6 +23,8 @@ class MeetGeniusViewController: UIViewController { } } + var geniusInterviews: [GeniusInterview] = [] + override func viewDidLoad() { super.viewDidLoad() @@ -48,14 +51,14 @@ extension MeetGeniusViewController: UITableViewDataSource, UITableViewDelegate { } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return 15 + return geniusInterviews.count } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell: GeniusInterviewCell = tableView.dequeueReusableCell() - cell.avatarImageView.image = UIImage(named: "yep_icon_solo") - cell.numberLabel.text = String(format: "#%03d", indexPath.row) + let geniusInterview = geniusInterviews[indexPath.row] + cell.configure(withGeniusInterview: geniusInterview) return cell } From 0d9e7093f02951cc5813759ee09ec644c66cd2cb Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 30 Jun 2016 16:44:42 +0800 Subject: [PATCH 31/34] Section for MeetGeniusViewController --- .../Discover/MeetGeniusViewController.swift | 55 ++++++++++++++++--- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/Yep/ViewControllers/Discover/MeetGeniusViewController.swift b/Yep/ViewControllers/Discover/MeetGeniusViewController.swift index d972ef211..966cb6ca5 100644 --- a/Yep/ViewControllers/Discover/MeetGeniusViewController.swift +++ b/Yep/ViewControllers/Discover/MeetGeniusViewController.swift @@ -20,6 +20,7 @@ class MeetGeniusViewController: UIViewController { tableView.rowHeight = 90 tableView.registerNibOf(GeniusInterviewCell) + tableView.registerNibOf(LoadMoreTableViewCell) } } @@ -46,21 +47,50 @@ class MeetGeniusViewController: UIViewController { extension MeetGeniusViewController: UITableViewDataSource, UITableViewDelegate { + private enum Section: Int { + case GeniusInterview + case LoadMore + } + func numberOfSectionsInTableView(tableView: UITableView) -> Int { - return 1 + + return 2 } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return geniusInterviews.count + + guard let section = Section(rawValue: section) else { + fatalError("Invalid Section") + } + + switch section { + + case .GeniusInterview: + return geniusInterviews.count + + case .LoadMore: + return 1 + } } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { - let cell: GeniusInterviewCell = tableView.dequeueReusableCell() - let geniusInterview = geniusInterviews[indexPath.row] - cell.configure(withGeniusInterview: geniusInterview) + guard let section = Section(rawValue: indexPath.section) else { + fatalError("Invalid Section") + } + + switch section { + + case .GeniusInterview: + let cell: GeniusInterviewCell = tableView.dequeueReusableCell() + let geniusInterview = geniusInterviews[indexPath.row] + cell.configure(withGeniusInterview: geniusInterview) + return cell - return cell + case .LoadMore: + let cell: LoadMoreTableViewCell = tableView.dequeueReusableCell() + return cell + } } func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { @@ -69,7 +99,18 @@ extension MeetGeniusViewController: UITableViewDataSource, UITableViewDelegate { tableView.deselectRowAtIndexPath(indexPath, animated: true) } - showGeniusInterviewAction?() + guard let section = Section(rawValue: indexPath.section) else { + fatalError("Invalid Section") + } + + switch section { + + case .GeniusInterview: + showGeniusInterviewAction?() + + case .LoadMore: + break + } } } From 342ea0074fab71d09aeb442607b4195d42e7661e Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 30 Jun 2016 16:49:46 +0800 Subject: [PATCH 32/34] tableFooterView --- Yep/ViewControllers/Discover/MeetGeniusViewController.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Yep/ViewControllers/Discover/MeetGeniusViewController.swift b/Yep/ViewControllers/Discover/MeetGeniusViewController.swift index 966cb6ca5..9704c3a53 100644 --- a/Yep/ViewControllers/Discover/MeetGeniusViewController.swift +++ b/Yep/ViewControllers/Discover/MeetGeniusViewController.swift @@ -16,6 +16,7 @@ class MeetGeniusViewController: UIViewController { @IBOutlet weak var tableView: UITableView! { didSet { tableView.tableHeaderView = MeetGeniusShowView(frame: CGRect(x: 0, y: 0, width: 100, height: 180)) + tableView.tableFooterView = UIView() tableView.rowHeight = 90 @@ -89,6 +90,7 @@ extension MeetGeniusViewController: UITableViewDataSource, UITableViewDelegate { case .LoadMore: let cell: LoadMoreTableViewCell = tableView.dequeueReusableCell() + cell.isLoading = true return cell } } From cc0ba378bc1dc6a072a03c6dc6e359b657bc5ed1 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 30 Jun 2016 17:37:51 +0800 Subject: [PATCH 33/34] show load more logic --- .../Discover/MeetGeniusViewController.swift | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Yep/ViewControllers/Discover/MeetGeniusViewController.swift b/Yep/ViewControllers/Discover/MeetGeniusViewController.swift index 9704c3a53..c2a8043ed 100644 --- a/Yep/ViewControllers/Discover/MeetGeniusViewController.swift +++ b/Yep/ViewControllers/Discover/MeetGeniusViewController.swift @@ -27,6 +27,8 @@ class MeetGeniusViewController: UIViewController { var geniusInterviews: [GeniusInterview] = [] + private var canLoadMore: Bool = false + override func viewDidLoad() { super.viewDidLoad() @@ -95,6 +97,37 @@ extension MeetGeniusViewController: UITableViewDataSource, UITableViewDelegate { } } + func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) { + + guard let section = Section(rawValue: indexPath.section) else { + fatalError("Invalid Section") + } + + switch section { + + case .GeniusInterview: + break + + case .LoadMore: + guard let cell = cell as? LoadMoreTableViewCell else { + break + } + + guard canLoadMore else { + cell.isLoading = false + break + } + + println("load more feeds") + + if !cell.isLoading { + cell.isLoading = true + } + + // TODO + } + } + func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { defer { From bbb22855d8557ab1224cedc11e935e2fa05e3133 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 30 Jun 2016 17:42:40 +0800 Subject: [PATCH 34/34] hide --- .../Discover/DiscoverContainerViewController.swift | 8 ++++---- .../Discover/MeetGeniusViewController.swift | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Yep/ViewControllers/Discover/DiscoverContainerViewController.swift b/Yep/ViewControllers/Discover/DiscoverContainerViewController.swift index c8978e298..539a20da1 100644 --- a/Yep/ViewControllers/Discover/DiscoverContainerViewController.swift +++ b/Yep/ViewControllers/Discover/DiscoverContainerViewController.swift @@ -92,7 +92,7 @@ class DiscoverContainerViewController: UIViewController { geniusesContainerView.hidden = true discoveredUsersContainerView.hidden = false - //navigationItem.leftBarButtonItem = discoveredUsersLayoutModeButtonItem + navigationItem.leftBarButtonItem = discoveredUsersLayoutModeButtonItem navigationItem.rightBarButtonItem = discoveredUsersFilterButtonItem } } @@ -101,10 +101,10 @@ class DiscoverContainerViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - //navigationItem.titleView = nil - //navigationItem.title = NSLocalizedString("Discover", comment: "") + navigationItem.titleView = nil + navigationItem.title = NSLocalizedString("Discover", comment: "") - currentOption = .MeetGenius + currentOption = .FindAll segmentedControl.selectedSegmentIndex = currentOption.rawValue segmentedControl.addTarget(self, action: #selector(DiscoverContainerViewController.chooseOption(_:)), forControlEvents: .ValueChanged) diff --git a/Yep/ViewControllers/Discover/MeetGeniusViewController.swift b/Yep/ViewControllers/Discover/MeetGeniusViewController.swift index c2a8043ed..68afca946 100644 --- a/Yep/ViewControllers/Discover/MeetGeniusViewController.swift +++ b/Yep/ViewControllers/Discover/MeetGeniusViewController.swift @@ -28,7 +28,7 @@ class MeetGeniusViewController: UIViewController { var geniusInterviews: [GeniusInterview] = [] private var canLoadMore: Bool = false - + override func viewDidLoad() { super.viewDidLoad()