mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-13 23:07:37 +10:00
Merge branch 'feature/fill_more_skills' into develop
This commit is contained in:
@@ -107,6 +107,7 @@
|
||||
506EC20A1AC95BFC00CE42B3 /* UIFont+Yep.swift in Sources */ = {isa = PBXBuildFile; fileRef = 506EC2091AC95BFC00CE42B3 /* UIFont+Yep.swift */; };
|
||||
5076C56A1AC46B9F00B22952 /* FayeService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5076C5691AC46B9F00B22952 /* FayeService.swift */; };
|
||||
5076FC5A1AF9DF6B00D7381A /* ConversationMessagePreviewTransitionManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5076FC591AF9DF6B00D7381A /* ConversationMessagePreviewTransitionManager.swift */; };
|
||||
507CF1681AFC84A500E261B4 /* CustomNavigationBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 507CF1671AFC84A500E261B4 /* CustomNavigationBarViewController.swift */; };
|
||||
50894CF11AEA4726000981AF /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50894CF01AEA4726000981AF /* SettingsViewController.swift */; };
|
||||
50894CF51AEA4A01000981AF /* SettingsUserCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50894CF31AEA4A01000981AF /* SettingsUserCell.swift */; };
|
||||
50894CF61AEA4A01000981AF /* SettingsUserCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50894CF41AEA4A01000981AF /* SettingsUserCell.xib */; };
|
||||
@@ -282,6 +283,7 @@
|
||||
506EC2091AC95BFC00CE42B3 /* UIFont+Yep.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UIFont+Yep.swift"; path = "Extensions/UIFont+Yep.swift"; sourceTree = "<group>"; };
|
||||
5076C5691AC46B9F00B22952 /* FayeService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FayeService.swift; path = Services/FayeService.swift; sourceTree = "<group>"; };
|
||||
5076FC591AF9DF6B00D7381A /* ConversationMessagePreviewTransitionManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ConversationMessagePreviewTransitionManager.swift; path = ViewControllers/Conversation/ConversationMessagePreviewTransitionManager.swift; sourceTree = "<group>"; };
|
||||
507CF1671AFC84A500E261B4 /* CustomNavigationBarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CustomNavigationBarViewController.swift; path = ViewControllers/CustomNavigationBar/CustomNavigationBarViewController.swift; sourceTree = "<group>"; };
|
||||
50894CF01AEA4726000981AF /* SettingsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SettingsViewController.swift; path = ViewControllers/Settings/SettingsViewController.swift; sourceTree = "<group>"; };
|
||||
50894CF31AEA4A01000981AF /* SettingsUserCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SettingsUserCell.swift; path = Views/Cells/SettingsUser/SettingsUserCell.swift; sourceTree = "<group>"; };
|
||||
50894CF41AEA4A01000981AF /* SettingsUserCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = SettingsUserCell.xib; path = Views/Cells/SettingsUser/SettingsUserCell.xib; sourceTree = "<group>"; };
|
||||
@@ -372,12 +374,12 @@
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
0A1CAC6C1AFA3D8C00826B45 /* SkillPage */ = {
|
||||
0A1CAC6C1AFA3D8C00826B45 /* SkillHome */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0A1CAC6D1AFA42D400826B45 /* SkillHomeViewController.swift */,
|
||||
);
|
||||
name = SkillPage;
|
||||
name = SkillHome;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
0A1CAC711AFA481900826B45 /* SkillHomeHeaderView */ = {
|
||||
@@ -516,7 +518,8 @@
|
||||
0A5D83951AC5D3CD000045BF /* TabBar */,
|
||||
50894CF21AEA472B000981AF /* Settings */,
|
||||
50894CFF1AEA5A7E000981AF /* EditProfile */,
|
||||
0A1CAC6C1AFA3D8C00826B45 /* SkillPage */,
|
||||
0A1CAC6C1AFA3D8C00826B45 /* SkillHome */,
|
||||
507CF1691AFC84AA00E261B4 /* CustomNavigationBar */,
|
||||
);
|
||||
name = ViewControllers;
|
||||
sourceTree = "<group>";
|
||||
@@ -892,6 +895,14 @@
|
||||
name = SkillAnnotationHeader;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
507CF1691AFC84AA00E261B4 /* CustomNavigationBar */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
507CF1671AFC84A500E261B4 /* CustomNavigationBarViewController.swift */,
|
||||
);
|
||||
name = CustomNavigationBar;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
50894CF21AEA472B000981AF /* Settings */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -1432,6 +1443,7 @@
|
||||
506BB7F91AE5069500C1A2A0 /* RegisterPickSkillsSelectSkillsTransitionManager.swift in Sources */,
|
||||
502AE52B1AB819AF005BD199 /* YepConfig.swift in Sources */,
|
||||
0A271FD71ACA055400822DFC /* YepAudioService.swift in Sources */,
|
||||
507CF1681AFC84A500E261B4 /* CustomNavigationBarViewController.swift in Sources */,
|
||||
0A3E60601ACCA9C0003DC853 /* String+Yep.swift in Sources */,
|
||||
504F41571AD4D35400FBB19A /* ProfileLayout.swift in Sources */,
|
||||
503315A01AC126100008A209 /* MessageToolbar.swift in Sources */,
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
import UIKit
|
||||
import Crashlytics
|
||||
import AVFoundation
|
||||
import Realm
|
||||
|
||||
@UIApplicationMain
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
@@ -22,6 +23,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
|
||||
|
||||
RLMRealm.setSchemaVersion(1, forRealmAtPath: RLMRealm.defaultRealmPath(), withMigrationBlock: { migration, oldSchemaVersion in
|
||||
// We haven’t migrated anything yet, so oldSchemaVersion == 0
|
||||
if oldSchemaVersion < 1 {
|
||||
// Nothing to do!
|
||||
// Realm will automatically detect new properties and removed properties
|
||||
// And will update the schema on disk automatically
|
||||
}
|
||||
})
|
||||
|
||||
Crashlytics.startWithAPIKey("3030ba006e21bcf8eb4a2127b6a7931ea6667486")
|
||||
|
||||
AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord, withOptions: AVAudioSessionCategoryOptions.DefaultToSpeaker, error: nil)
|
||||
|
||||
@@ -34,10 +34,24 @@ class Avatar: RLMObject {
|
||||
}
|
||||
}
|
||||
|
||||
class UserSkillCategory: RLMObject {
|
||||
dynamic var skillCategoryID: String = ""
|
||||
dynamic var name: String = ""
|
||||
dynamic var localName: String = ""
|
||||
|
||||
var skills: [UserSkill] {
|
||||
return linkingObjectsOfClass("UserSkill", forProperty: "category") as! [UserSkill]
|
||||
}
|
||||
}
|
||||
|
||||
class UserSkill: RLMObject {
|
||||
|
||||
dynamic var category: UserSkillCategory?
|
||||
|
||||
dynamic var skillID: String = ""
|
||||
dynamic var name: String = ""
|
||||
dynamic var localName: String = ""
|
||||
dynamic var coverURLString: String = ""
|
||||
|
||||
var learningUsers: [User] {
|
||||
return linkingObjectsOfClass("User", forProperty: "learningSkills") as! [User]
|
||||
@@ -223,6 +237,11 @@ func userSkillWithSkillID(skillID: String) -> UserSkill? {
|
||||
return UserSkill.objectsWithPredicate(predicate).firstObject() as? UserSkill
|
||||
}
|
||||
|
||||
func userSkillCategoryWithSkillCategoryID(skillCategoryID: String) -> UserSkillCategory? {
|
||||
let predicate = NSPredicate(format: "skillCategoryID = %@", skillCategoryID)
|
||||
return UserSkillCategory.objectsWithPredicate(predicate).firstObject() as? UserSkillCategory
|
||||
}
|
||||
|
||||
func userWithUserID(userID: String) -> User? {
|
||||
let predicate = NSPredicate(format: "userID = %@", userID)
|
||||
return User.objectsWithPredicate(predicate).firstObject() as? User
|
||||
|
||||
@@ -145,11 +145,23 @@ func verifyMobile(mobile: String, withAreaCode areaCode: String, #verifyCode: St
|
||||
|
||||
// MARK: Skills
|
||||
|
||||
struct Skill: Hashable {
|
||||
struct SkillCategory {
|
||||
let id: String
|
||||
let name: String
|
||||
let localName: String
|
||||
|
||||
let skills: [Skill]
|
||||
}
|
||||
|
||||
struct Skill: Hashable {
|
||||
|
||||
let category: SkillCategory?
|
||||
|
||||
let id: String
|
||||
let name: String
|
||||
let localName: String
|
||||
let coverURLString: String?
|
||||
|
||||
var hashValue: Int {
|
||||
return id.hashValue
|
||||
}
|
||||
@@ -159,14 +171,6 @@ func ==(lhs: Skill, rhs: Skill) -> Bool {
|
||||
return lhs.id == rhs.id
|
||||
}
|
||||
|
||||
struct SkillCategory {
|
||||
let id: String
|
||||
let name: String
|
||||
let localName: String
|
||||
|
||||
let skills: [Skill]
|
||||
}
|
||||
|
||||
/*
|
||||
func skillsInSkillCategory(skillCategoryID: String, #failureHandler: ((Reason, String?) -> Void)?, #completion: [Skill] -> Void) {
|
||||
let parse: JSONDictionary -> [Skill]? = { data in
|
||||
@@ -209,7 +213,20 @@ func skillsFromSkillsData(skillsData: [JSONDictionary]) -> [Skill] {
|
||||
let skillID = skillInfo["id"] as? String,
|
||||
let skillName = skillInfo["name"] as? String,
|
||||
let skillLocalName = skillInfo["name_string"] as? String {
|
||||
let skill = Skill(id: skillID, name: skillName, localName: skillName)
|
||||
|
||||
var skillCategory: SkillCategory?
|
||||
if
|
||||
let skillCategoryData = skillInfo["category"] as? JSONDictionary,
|
||||
let categoryID = skillCategoryData["id"] as? String,
|
||||
let categoryName = skillCategoryData["name"] as? String,
|
||||
let categoryLocalName = skillCategoryData["name_string"] as? String {
|
||||
skillCategory = SkillCategory(id: categoryID, name: categoryName, localName: categoryLocalName, skills: [])
|
||||
}
|
||||
|
||||
let coverURLString = skillInfo["cover_url"] as? String
|
||||
|
||||
let skill = Skill(category: skillCategory, id: skillID, name: skillName, localName: skillName, coverURLString: coverURLString)
|
||||
|
||||
skills.append(skill)
|
||||
}
|
||||
}
|
||||
@@ -522,7 +539,7 @@ func discoverUsers(#masterSkills: [String], #learningSkills: [String], #discover
|
||||
|
||||
let parse: JSONDictionary -> [DiscoveredUser]? = { data in
|
||||
|
||||
// println("discoverUsers: \(data)")
|
||||
println("discoverUsers: \(data)")
|
||||
|
||||
if let usersData = data["users"] as? [JSONDictionary] {
|
||||
|
||||
|
||||
@@ -96,6 +96,7 @@ func userSkillsFromSkillsData(skillsData: [JSONDictionary], inRealm realm: RLMRe
|
||||
|
||||
for skillInfo in skillsData {
|
||||
if
|
||||
let categoryData = skillInfo["category"] as? JSONDictionary,
|
||||
let skillID = skillInfo["id"] as? String,
|
||||
let skillName = skillInfo["name"] as? String,
|
||||
let skillLocalName = skillInfo["name_string"] as? String {
|
||||
@@ -108,12 +109,40 @@ func userSkillsFromSkillsData(skillsData: [JSONDictionary], inRealm realm: RLMRe
|
||||
newUserSkill.name = skillID
|
||||
newUserSkill.localName = skillLocalName
|
||||
|
||||
if let coverURLString = skillInfo["cover_url"] as? String {
|
||||
newUserSkill.coverURLString = coverURLString
|
||||
}
|
||||
|
||||
realm.addObject(newUserSkill)
|
||||
|
||||
userSkill = newUserSkill
|
||||
}
|
||||
|
||||
if let userSkill = userSkill {
|
||||
|
||||
if let
|
||||
skillCategoryID = categoryData["id"] as? String,
|
||||
skillCategoryName = categoryData["name"] as? String,
|
||||
skillCategoryLocalName = categoryData["name_string"] as? String {
|
||||
|
||||
var userSkillCategory = userSkillCategoryWithSkillCategoryID(skillCategoryID)
|
||||
|
||||
if userSkillCategory == nil {
|
||||
let newUserSkillCategory = UserSkillCategory()
|
||||
newUserSkillCategory.skillCategoryID = skillCategoryID
|
||||
newUserSkillCategory.name = skillCategoryName
|
||||
newUserSkillCategory.localName = skillCategoryLocalName
|
||||
|
||||
realm.addObject(newUserSkillCategory)
|
||||
|
||||
userSkillCategory = newUserSkillCategory
|
||||
}
|
||||
|
||||
if let userSkillCategory = userSkillCategory {
|
||||
userSkill.category = userSkillCategory
|
||||
}
|
||||
}
|
||||
|
||||
userSkills.append(userSkill)
|
||||
}
|
||||
}
|
||||
@@ -124,7 +153,7 @@ func userSkillsFromSkillsData(skillsData: [JSONDictionary], inRealm realm: RLMRe
|
||||
|
||||
func syncFriendshipsAndDoFurtherAction(furtherAction: () -> Void) {
|
||||
friendships { allFriendships in
|
||||
//println("\n allFriendships: \(allFriendships)")
|
||||
println("\n allFriendships: \(allFriendships)")
|
||||
|
||||
// 先整理出所有的 friend 的 userID
|
||||
var remoteUerIDSet = Set<String>()
|
||||
@@ -177,7 +206,9 @@ func syncFriendshipsAndDoFurtherAction(furtherAction: () -> Void) {
|
||||
let newUser = User()
|
||||
newUser.userID = userID
|
||||
|
||||
//newUser.createdAt = NSDate.dateWithISO08601String(<#dateString: String?#>)
|
||||
if let createdAtString = friendInfo["created_at"] as? String {
|
||||
newUser.createdAt = NSDate.dateWithISO08601String(createdAtString)
|
||||
}
|
||||
|
||||
realm.beginWriteTransaction()
|
||||
realm.addObject(newUser)
|
||||
@@ -189,6 +220,12 @@ func syncFriendshipsAndDoFurtherAction(furtherAction: () -> Void) {
|
||||
if let user = user {
|
||||
realm.beginWriteTransaction()
|
||||
|
||||
// 更新用户信息
|
||||
|
||||
if let lastSignInAtString = friendInfo["last_sign_in_at"] as? String {
|
||||
user.lastSignInAt = NSDate.dateWithISO08601String(lastSignInAtString)
|
||||
}
|
||||
|
||||
if let nickname = friendInfo["nickname"] as? String {
|
||||
user.nickname = nickname
|
||||
}
|
||||
@@ -241,7 +278,7 @@ func syncFriendshipsAndDoFurtherAction(furtherAction: () -> Void) {
|
||||
|
||||
func syncGroupsAndDoFurtherAction(furtherAction: () -> Void) {
|
||||
groups { allGroups in
|
||||
//println("allGroups: \(allGroups)")
|
||||
println("allGroups: \(allGroups)")
|
||||
|
||||
// 先整理出所有的 group 的 groupID
|
||||
var remoteGroupIDSet = Set<String>()
|
||||
@@ -333,12 +370,8 @@ private func syncGroupWithGroupInfo(groupInfo: JSONDictionary, inRealm realm: RL
|
||||
|
||||
newUser.userID = ownerID
|
||||
|
||||
if let nickname = ownerInfo["nickname"] as? String {
|
||||
newUser.nickname = nickname
|
||||
}
|
||||
|
||||
if let avatarURLString = ownerInfo["avatar_url"] as? String {
|
||||
newUser.avatarURLString = avatarURLString
|
||||
if let createdAtString = ownerInfo["created_at"] as? String {
|
||||
newUser.createdAt = NSDate.dateWithISO08601String(createdAtString)
|
||||
}
|
||||
|
||||
if let myUserID = YepUserDefaults.userID.value {
|
||||
@@ -360,7 +393,37 @@ private func syncGroupWithGroupInfo(groupInfo: JSONDictionary, inRealm realm: RL
|
||||
|
||||
if let owner = owner {
|
||||
realm.beginWriteTransaction()
|
||||
|
||||
// 更新个人信息
|
||||
|
||||
if let lastSignInAtString = ownerInfo["last_sign_in_at"] as? String {
|
||||
owner.lastSignInAt = NSDate.dateWithISO08601String(lastSignInAtString)
|
||||
}
|
||||
|
||||
if let nickname = ownerInfo["nickname"] as? String {
|
||||
owner.nickname = nickname
|
||||
}
|
||||
|
||||
if let avatarURLString = ownerInfo["avatar_url"] as? String {
|
||||
owner.avatarURLString = avatarURLString
|
||||
}
|
||||
|
||||
// 更新技能
|
||||
|
||||
if let learningSkillsData = ownerInfo["learning_skills"] as? [JSONDictionary] {
|
||||
owner.learningSkills.removeAllObjects()
|
||||
let userSkills = userSkillsFromSkillsData(learningSkillsData, inRealm: owner.realm)
|
||||
owner.learningSkills.addObjects(userSkills)
|
||||
}
|
||||
|
||||
if let masterSkillsData = ownerInfo["master_skills"] as? [JSONDictionary] {
|
||||
owner.masterSkills.removeAllObjects()
|
||||
let userSkills = userSkillsFromSkillsData(masterSkillsData, inRealm: owner.realm)
|
||||
owner.masterSkills.addObjects(userSkills)
|
||||
}
|
||||
|
||||
group.owner = owner
|
||||
|
||||
realm.commitWriteTransaction()
|
||||
}
|
||||
}
|
||||
@@ -399,12 +462,8 @@ private func syncGroupWithGroupInfo(groupInfo: JSONDictionary, inRealm realm: RL
|
||||
|
||||
newMember.userID = memberID
|
||||
|
||||
if let nickname = memberInfo["nickname"] as? String {
|
||||
newMember.nickname = nickname
|
||||
}
|
||||
|
||||
if let avatarURLString = memberInfo["avatar_url"] as? String {
|
||||
newMember.avatarURLString = avatarURLString
|
||||
if let createdAtString = memberInfo["created_at"] as? String {
|
||||
newMember.createdAt = NSDate.dateWithISO08601String(createdAtString)
|
||||
}
|
||||
|
||||
if let myUserID = YepUserDefaults.userID.value {
|
||||
@@ -425,6 +484,41 @@ private func syncGroupWithGroupInfo(groupInfo: JSONDictionary, inRealm realm: RL
|
||||
|
||||
realm.commitWriteTransaction()
|
||||
}
|
||||
|
||||
if let member = member {
|
||||
|
||||
realm.beginWriteTransaction()
|
||||
|
||||
// 更新个人信息
|
||||
|
||||
if let lastSignInAtString = memberInfo["last_sign_in_at"] as? String {
|
||||
member.lastSignInAt = NSDate.dateWithISO08601String(lastSignInAtString)
|
||||
}
|
||||
|
||||
if let nickname = memberInfo["nickname"] as? String {
|
||||
member.nickname = nickname
|
||||
}
|
||||
|
||||
if let avatarURLString = memberInfo["avatar_url"] as? String {
|
||||
member.avatarURLString = avatarURLString
|
||||
}
|
||||
|
||||
// 更新技能
|
||||
|
||||
if let learningSkillsData = memberInfo["learning_skills"] as? [JSONDictionary] {
|
||||
member.learningSkills.removeAllObjects()
|
||||
let userSkills = userSkillsFromSkillsData(learningSkillsData, inRealm: member.realm)
|
||||
member.learningSkills.addObjects(userSkills)
|
||||
}
|
||||
|
||||
if let masterSkillsData = memberInfo["master_skills"] as? [JSONDictionary] {
|
||||
member.masterSkills.removeAllObjects()
|
||||
let userSkills = userSkillsFromSkillsData(masterSkillsData, inRealm: member.realm)
|
||||
member.masterSkills.addObjects(userSkills)
|
||||
}
|
||||
|
||||
realm.commitWriteTransaction()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// CustomNavigationBarViewController.swift
|
||||
// Yep
|
||||
//
|
||||
// Created by NIX on 15/5/8.
|
||||
// Copyright (c) 2015年 Catch Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class CustomNavigationBarViewController: UIViewController {
|
||||
|
||||
override func viewWillAppear(animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
if let navigationController = navigationController {
|
||||
navigationController.navigationBar.backgroundColor = UIColor.clearColor()
|
||||
navigationController.navigationBar.translucent = true
|
||||
navigationController.navigationBar.shadowImage = UIImage()
|
||||
navigationController.navigationBar.barStyle = UIBarStyle.BlackTranslucent
|
||||
navigationController.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
|
||||
|
||||
let textAttributes = [
|
||||
NSForegroundColorAttributeName: UIColor.whiteColor(),
|
||||
NSFontAttributeName: UIFont.navigationBarTitleFont()
|
||||
]
|
||||
|
||||
navigationController.navigationBar.titleTextAttributes = textAttributes
|
||||
navigationController.navigationBar.tintColor = UIColor.whiteColor()
|
||||
}
|
||||
}
|
||||
|
||||
override func viewWillDisappear(animated: Bool) {
|
||||
super.viewWillDisappear(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.yepTintColor(),
|
||||
NSFontAttributeName: UIFont.navigationBarTitleFont()
|
||||
]
|
||||
|
||||
navigationController.navigationBar.titleTextAttributes = textAttributes
|
||||
navigationController.navigationBar.tintColor = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ enum ProfileUser {
|
||||
case UserType(User)
|
||||
}
|
||||
|
||||
class ProfileViewController: UIViewController {
|
||||
class ProfileViewController: CustomNavigationBarViewController {
|
||||
|
||||
var profileUser: ProfileUser?
|
||||
|
||||
@@ -26,7 +26,6 @@ class ProfileViewController: UIViewController {
|
||||
@IBOutlet weak var sayHiView: UIView!
|
||||
@IBOutlet weak var sayHiButton: UIButton!
|
||||
|
||||
var shouldBackToDefaultNavgationbar = true
|
||||
|
||||
let skillCellIdentifier = "SkillCell"
|
||||
let headerCellIdentifier = "ProfileHeaderCell"
|
||||
@@ -118,51 +117,9 @@ class ProfileViewController: UIViewController {
|
||||
override func viewWillAppear(animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
if let navigationController = navigationController {
|
||||
navigationController.navigationBar.backgroundColor = UIColor.clearColor()
|
||||
navigationController.navigationBar.translucent = true
|
||||
navigationController.navigationBar.shadowImage = UIImage()
|
||||
navigationController.navigationBar.barStyle = UIBarStyle.BlackTranslucent
|
||||
navigationController.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
|
||||
|
||||
let textAttributes = [
|
||||
NSForegroundColorAttributeName: UIColor.whiteColor(),
|
||||
NSFontAttributeName: UIFont.navigationBarTitleFont()
|
||||
]
|
||||
|
||||
navigationController.navigationBar.titleTextAttributes = textAttributes
|
||||
navigationController.navigationBar.tintColor = UIColor.whiteColor()
|
||||
}
|
||||
|
||||
self.setNeedsStatusBarAppearanceUpdate()
|
||||
}
|
||||
|
||||
override func viewWillDisappear(animated: Bool) {
|
||||
super.viewWillDisappear(animated)
|
||||
|
||||
if let navigationController = navigationController {
|
||||
|
||||
if !shouldBackToDefaultNavgationbar {
|
||||
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.yepTintColor(),
|
||||
NSFontAttributeName: UIFont.navigationBarTitleFont()
|
||||
]
|
||||
|
||||
navigationController.navigationBar.titleTextAttributes = textAttributes
|
||||
navigationController.navigationBar.tintColor = nil
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override func preferredStatusBarStyle() -> UIStatusBarStyle {
|
||||
return UIStatusBarStyle.LightContent
|
||||
}
|
||||
@@ -171,8 +128,6 @@ class ProfileViewController: UIViewController {
|
||||
|
||||
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
|
||||
|
||||
shouldBackToDefaultNavgationbar = true
|
||||
|
||||
if segue.identifier == "showConversation" {
|
||||
|
||||
let vc = segue.destinationViewController as! ConversationViewController
|
||||
@@ -185,8 +140,6 @@ class ProfileViewController: UIViewController {
|
||||
let vc = segue.destinationViewController as! SkillHomeViewController
|
||||
vc.hidesBottomBarWhenPushed = true
|
||||
vc.skillName = cell.skillLabel.text
|
||||
shouldBackToDefaultNavgationbar = false
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ enum SkillHomeState: Printable {
|
||||
}
|
||||
}
|
||||
|
||||
class SkillHomeViewController: UIViewController {
|
||||
class SkillHomeViewController: CustomNavigationBarViewController {
|
||||
|
||||
let cellIdentifier = "ContactsCell"
|
||||
|
||||
@@ -50,7 +50,7 @@ class SkillHomeViewController: UIViewController {
|
||||
}
|
||||
}
|
||||
|
||||
var isStateFirstInit = false
|
||||
var isFirstAppear = true
|
||||
|
||||
var state: SkillHomeState = .Master {
|
||||
willSet {
|
||||
@@ -134,11 +134,11 @@ class SkillHomeViewController: UIViewController {
|
||||
|
||||
super.viewDidAppear(animated)
|
||||
|
||||
if !isStateFirstInit {
|
||||
if isFirstAppear {
|
||||
isFirstAppear = false
|
||||
|
||||
state = .Master
|
||||
isStateFirstInit = true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func changeToMaster() {
|
||||
@@ -237,9 +237,7 @@ class SkillHomeViewController: UIViewController {
|
||||
let discoveredUser = getDiscoveredUserWithState(state.hashValue)[indexPath.row]
|
||||
|
||||
let vc = segue.destinationViewController as! ProfileViewController
|
||||
|
||||
vc.shouldBackToDefaultNavgationbar = false
|
||||
|
||||
|
||||
vc.profileUser = ProfileUser.DiscoveredUserType(discoveredUser)
|
||||
|
||||
vc.hidesBottomBarWhenPushed = true
|
||||
|
||||
Reference in New Issue
Block a user