From a9fe2b7e36386a3cb4b546596c029e9790cc7db7 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Fri, 24 Apr 2015 17:50:58 +0800 Subject: [PATCH 01/14] add SettingsViewController --- Yep.xcodeproj/project.pbxproj | 12 +++++ Yep/Base.lproj/Main.storyboard | 42 +++++++++++++++++- .../icon_settings.imageset/Contents.json | 13 ++++++ .../icon_settings.imageset/icon_settings.pdf | Bin 0 -> 5175 bytes .../Profile/ProfileViewController.swift | 2 + .../Settings/SettingsViewController.swift | 22 +++++++++ 6 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 Yep/Images.xcassets/icon_settings.imageset/Contents.json create mode 100644 Yep/Images.xcassets/icon_settings.imageset/icon_settings.pdf create mode 100644 Yep/ViewControllers/Settings/SettingsViewController.swift diff --git a/Yep.xcodeproj/project.pbxproj b/Yep.xcodeproj/project.pbxproj index 13ea51d7..ed414b3b 100644 --- a/Yep.xcodeproj/project.pbxproj +++ b/Yep.xcodeproj/project.pbxproj @@ -94,6 +94,7 @@ 506E241E1AE6391A00A33C1A /* TouchZoomButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 506E241D1AE6391A00A33C1A /* TouchZoomButton.swift */; }; 506EC20A1AC95BFC00CE42B3 /* UIFont+Yep.swift in Sources */ = {isa = PBXBuildFile; fileRef = 506EC2091AC95BFC00CE42B3 /* UIFont+Yep.swift */; }; 5076C56A1AC46B9F00B22952 /* FayeService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5076C5691AC46B9F00B22952 /* FayeService.swift */; }; + 50894CF11AEA4726000981AF /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50894CF01AEA4726000981AF /* SettingsViewController.swift */; }; 508C2AA01AD648B2002B8097 /* SearchUsersViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 508C2A9F1AD648B2002B8097 /* SearchUsersViewController.swift */; }; 508C2AA41AD661B3002B8097 /* UserStateCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 508C2AA21AD661B3002B8097 /* UserStateCell.swift */; }; 508C2AA51AD661B3002B8097 /* UserStateCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 508C2AA31AD661B3002B8097 /* UserStateCell.xib */; }; @@ -241,6 +242,7 @@ 506E241D1AE6391A00A33C1A /* TouchZoomButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TouchZoomButton.swift; path = Views/Buttons/TouchZoomButton.swift; sourceTree = ""; }; 506EC2091AC95BFC00CE42B3 /* UIFont+Yep.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UIFont+Yep.swift"; path = "Extensions/UIFont+Yep.swift"; sourceTree = ""; }; 5076C5691AC46B9F00B22952 /* FayeService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FayeService.swift; path = Services/FayeService.swift; sourceTree = ""; }; + 50894CF01AEA4726000981AF /* SettingsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SettingsViewController.swift; path = ViewControllers/Settings/SettingsViewController.swift; sourceTree = ""; }; 508C2A9F1AD648B2002B8097 /* SearchUsersViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SearchUsersViewController.swift; path = ViewControllers/SearchUsers/SearchUsersViewController.swift; sourceTree = ""; }; 508C2AA21AD661B3002B8097 /* UserStateCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UserStateCell.swift; path = Views/Cells/UserState/UserStateCell.swift; sourceTree = ""; }; 508C2AA31AD661B3002B8097 /* UserStateCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = UserStateCell.xib; path = Views/Cells/UserState/UserStateCell.xib; sourceTree = ""; }; @@ -433,6 +435,7 @@ 502AE51F1AB712D6005BD199 /* Register */, 502AE5361AB864A3005BD199 /* Login */, 0A5D83951AC5D3CD000045BF /* TabBar */, + 50894CF21AEA472B000981AF /* Settings */, ); name = ViewControllers; sourceTree = ""; @@ -758,6 +761,14 @@ name = SkillAnnotationHeader; sourceTree = ""; }; + 50894CF21AEA472B000981AF /* Settings */ = { + isa = PBXGroup; + children = ( + 50894CF01AEA4726000981AF /* SettingsViewController.swift */, + ); + name = Settings; + sourceTree = ""; + }; 508C2AA11AD648BE002B8097 /* SearchUsers */ = { isa = PBXGroup; children = ( @@ -1196,6 +1207,7 @@ 506E241C1AE6254F00A33C1A /* MessageTypeButton.swift in Sources */, 508C2AA01AD648B2002B8097 /* SearchUsersViewController.swift in Sources */, 0A3E60671ACCAECE003DC853 /* YepLocationService.swift in Sources */, + 50894CF11AEA4726000981AF /* SettingsViewController.swift in Sources */, 5023DE2A1AB685BA00B3EE96 /* ContactsViewController.swift in Sources */, 50CDBE491ACBAD3200459CE0 /* ChatLeftImageCell.swift in Sources */, 5033159C1AC101C80008A209 /* ChatRightTextCell.swift in Sources */, diff --git a/Yep/Base.lproj/Main.storyboard b/Yep/Base.lproj/Main.storyboard index 67aeb9a1..8b13570a 100644 --- a/Yep/Base.lproj/Main.storyboard +++ b/Yep/Base.lproj/Main.storyboard @@ -412,7 +412,13 @@ - + + + + + + + @@ -421,6 +427,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -548,5 +587,6 @@ + diff --git a/Yep/Images.xcassets/icon_settings.imageset/Contents.json b/Yep/Images.xcassets/icon_settings.imageset/Contents.json new file mode 100644 index 00000000..0b85cc6d --- /dev/null +++ b/Yep/Images.xcassets/icon_settings.imageset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "icon_settings.pdf" + } + ], + "info" : { + "version" : 1, + "author" : "xcode", + "template-rendering-intent" : "template" + } +} \ No newline at end of file diff --git a/Yep/Images.xcassets/icon_settings.imageset/icon_settings.pdf b/Yep/Images.xcassets/icon_settings.imageset/icon_settings.pdf new file mode 100644 index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)B=$d-6okQqaTAs>%I4Y!j9csHe>AN{I{+P&Cb#+( z`XiAy<{ZOkM>I1v%bOlpS8lF!$-I@(oNweEG$ga{w5PJ)n6a!ZvHg_9Vlwo@tbZYV zL7i}2oMHr!ut z(nA%+>k=Zhs#O;>zZkBv|GXZP!Um!mGyZs11XAAjd-^0_dX7XRuydp1N+NNyrI z;4OS+eP+JCn9TuD=T0w@EIAuJ9JefN+*{8ae}JxhW)&S$C(D14cvPm|eg$2KzO7KD z@J+Eq5sf-R&3M1r>)h%`B@HhIH*=lW93&1EXFTyZX|yuy?bxy#T1$~snJs7%IUd`0 zShe`FH0)usnU^0vTihhMA8?j+V!qcM`*mIYP(3jtQqtow(dmvSyMyJ*+(FRp$-lAs zl0tu?Gz<*+4Xc;@dMU#|uClDG48jFz0lWlQEuiu5CYNaan~DD>ZpYMP7)YBPh2>=1X0szqeT|k(i zpnxFI68K97g$ZNE^zs5a{+59S!I>RkO;7_Aj|@cfWROYU`q+W c|8DYExVgAuLgVLzK!pT_0c>pY>I#7W05kmpS^xk5 literal 0 HcmV?d00001 diff --git a/Yep/ViewControllers/Profile/ProfileViewController.swift b/Yep/ViewControllers/Profile/ProfileViewController.swift index f616f3b3..1c09c274 100644 --- a/Yep/ViewControllers/Profile/ProfileViewController.swift +++ b/Yep/ViewControllers/Profile/ProfileViewController.swift @@ -74,6 +74,8 @@ class ProfileViewController: UIViewController { navigationController.navigationBar.titleTextAttributes = textAttributes + navigationItem.rightBarButtonItem?.tintColor = UIColor.whiteColor() + navigationItem.title = YepUserDefaults.nickname() } diff --git a/Yep/ViewControllers/Settings/SettingsViewController.swift b/Yep/ViewControllers/Settings/SettingsViewController.swift new file mode 100644 index 00000000..0fffbb12 --- /dev/null +++ b/Yep/ViewControllers/Settings/SettingsViewController.swift @@ -0,0 +1,22 @@ +// +// SettingsViewController.swift +// Yep +// +// Created by NIX on 15/4/24. +// Copyright (c) 2015年 Catch Inc. All rights reserved. +// + +import UIKit + +class SettingsViewController: UIViewController { + + @IBOutlet weak var settingsTableView: UITableView! + + + override func viewDidLoad() { + super.viewDidLoad() + + title = NSLocalizedString("Settings", comment: "") + } + +} From 411106515a90879721f56329dfe0cb1f29812267 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Fri, 24 Apr 2015 18:37:14 +0800 Subject: [PATCH 02/14] add SettingsUserCell --- Yep.xcodeproj/project.pbxproj | 16 ++++ Yep/Base.lproj/Main.storyboard | 4 + Yep/Configs/YepConfig.swift | 4 + .../icon_accessory.imageset/Contents.json | 13 ++++ .../icon_accessory.pdf | Bin 0 -> 3921 bytes .../Settings/SettingsViewController.swift | 49 ++++++++++++ .../Cells/SettingsUser/SettingsUserCell.swift | 55 ++++++++++++++ .../Cells/SettingsUser/SettingsUserCell.xib | 70 ++++++++++++++++++ 8 files changed, 211 insertions(+) create mode 100644 Yep/Images.xcassets/icon_accessory.imageset/Contents.json create mode 100644 Yep/Images.xcassets/icon_accessory.imageset/icon_accessory.pdf create mode 100644 Yep/Views/Cells/SettingsUser/SettingsUserCell.swift create mode 100644 Yep/Views/Cells/SettingsUser/SettingsUserCell.xib diff --git a/Yep.xcodeproj/project.pbxproj b/Yep.xcodeproj/project.pbxproj index ed414b3b..67917a55 100644 --- a/Yep.xcodeproj/project.pbxproj +++ b/Yep.xcodeproj/project.pbxproj @@ -95,6 +95,8 @@ 506EC20A1AC95BFC00CE42B3 /* UIFont+Yep.swift in Sources */ = {isa = PBXBuildFile; fileRef = 506EC2091AC95BFC00CE42B3 /* UIFont+Yep.swift */; }; 5076C56A1AC46B9F00B22952 /* FayeService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5076C5691AC46B9F00B22952 /* FayeService.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 */; }; 508C2AA01AD648B2002B8097 /* SearchUsersViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 508C2A9F1AD648B2002B8097 /* SearchUsersViewController.swift */; }; 508C2AA41AD661B3002B8097 /* UserStateCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 508C2AA21AD661B3002B8097 /* UserStateCell.swift */; }; 508C2AA51AD661B3002B8097 /* UserStateCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 508C2AA31AD661B3002B8097 /* UserStateCell.xib */; }; @@ -243,6 +245,8 @@ 506EC2091AC95BFC00CE42B3 /* UIFont+Yep.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UIFont+Yep.swift"; path = "Extensions/UIFont+Yep.swift"; sourceTree = ""; }; 5076C5691AC46B9F00B22952 /* FayeService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FayeService.swift; path = Services/FayeService.swift; sourceTree = ""; }; 50894CF01AEA4726000981AF /* SettingsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SettingsViewController.swift; path = ViewControllers/Settings/SettingsViewController.swift; sourceTree = ""; }; + 50894CF31AEA4A01000981AF /* SettingsUserCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SettingsUserCell.swift; path = Views/Cells/SettingsUser/SettingsUserCell.swift; sourceTree = ""; }; + 50894CF41AEA4A01000981AF /* SettingsUserCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = SettingsUserCell.xib; path = Views/Cells/SettingsUser/SettingsUserCell.xib; sourceTree = ""; }; 508C2A9F1AD648B2002B8097 /* SearchUsersViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SearchUsersViewController.swift; path = ViewControllers/SearchUsers/SearchUsersViewController.swift; sourceTree = ""; }; 508C2AA21AD661B3002B8097 /* UserStateCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UserStateCell.swift; path = Views/Cells/UserState/UserStateCell.swift; sourceTree = ""; }; 508C2AA31AD661B3002B8097 /* UserStateCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = UserStateCell.xib; path = Views/Cells/UserState/UserStateCell.xib; sourceTree = ""; }; @@ -527,6 +531,7 @@ 505EC81E1ADFBE1F001D27E0 /* SkillSelection */, 50EB8CC11AE89EDE001AC1EE /* ChatLeftVideo */, 50EB8CC61AE89F15001AC1EE /* ChatRightVideo */, + 50894CF71AEA4A04000981AF /* SettingsUser */, ); name = Cells; sourceTree = ""; @@ -769,6 +774,15 @@ name = Settings; sourceTree = ""; }; + 50894CF71AEA4A04000981AF /* SettingsUser */ = { + isa = PBXGroup; + children = ( + 50894CF31AEA4A01000981AF /* SettingsUserCell.swift */, + 50894CF41AEA4A01000981AF /* SettingsUserCell.xib */, + ); + name = SettingsUser; + sourceTree = ""; + }; 508C2AA11AD648BE002B8097 /* SearchUsers */ = { isa = PBXGroup; children = ( @@ -1048,6 +1062,7 @@ 502AE5411AB88862005BD199 /* SkillRankCell.xib in Resources */, 502AE5541AB93215005BD199 /* ProfileFooterCell.xib in Resources */, 50CDBE4A1ACBAD3200459CE0 /* ChatLeftImageCell.xib in Resources */, + 50894CF61AEA4A01000981AF /* SettingsUserCell.xib in Resources */, 508D17481ACCF4710092D666 /* ChatLeftAudioCell.xib in Resources */, 0A8F54B61AB67D11004AD60E /* Main.storyboard in Resources */, 5033159D1AC101C80008A209 /* ChatRightTextCell.xib in Resources */, @@ -1227,6 +1242,7 @@ 0A5D83991AC5D91E000045BF /* ContactsSearchTableViewController.swift in Sources */, 0A944C251AC8BB2F00037A06 /* YepStorageService.swift in Sources */, 505EC8171ADF8151001D27E0 /* SkillCategoryCell.swift in Sources */, + 50894CF51AEA4A01000981AF /* SettingsUserCell.swift in Sources */, 504F415A1AD5028200FBB19A /* SkillCell.swift in Sources */, 5023DE521AB6C51300B3EE96 /* CGRect+Yep.swift in Sources */, ); diff --git a/Yep/Base.lproj/Main.storyboard b/Yep/Base.lproj/Main.storyboard index 8b13570a..f79c138c 100644 --- a/Yep/Base.lproj/Main.storyboard +++ b/Yep/Base.lproj/Main.storyboard @@ -442,6 +442,10 @@ + + + + diff --git a/Yep/Configs/YepConfig.swift b/Yep/Configs/YepConfig.swift index c81b685c..7a4d692f 100644 --- a/Yep/Configs/YepConfig.swift +++ b/Yep/Configs/YepConfig.swift @@ -57,4 +57,8 @@ class YepConfig { class func audioSampleGap() -> CGFloat { return 1 } + + class func settingsUserCellAvatarSize() -> CGFloat { + return 80 + } } \ No newline at end of file diff --git a/Yep/Images.xcassets/icon_accessory.imageset/Contents.json b/Yep/Images.xcassets/icon_accessory.imageset/Contents.json new file mode 100644 index 00000000..6ee2edb4 --- /dev/null +++ b/Yep/Images.xcassets/icon_accessory.imageset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "icon_accessory.pdf" + } + ], + "info" : { + "version" : 1, + "author" : "xcode", + "template-rendering-intent" : "template" + } +} \ No newline at end of file diff --git a/Yep/Images.xcassets/icon_accessory.imageset/icon_accessory.pdf b/Yep/Images.xcassets/icon_accessory.imageset/icon_accessory.pdf new file mode 100644 index 0000000000000000000000000000000000000000..ececd72074c05b0c2a903afe62211e190114c4f2 GIT binary patch literal 3921 zcmai%c{o)4`^PO)7(!)aQ9&Su9^hIc1~dXF z%$&MMCs>>b=#l>GQ#SKof+hEmf?X>E4u|99vV()~#Tdx86O8mGa=3|f8I$5Njf44F z9pif6-Y$Q+JWTqw7-ZhnHx{@=+^f4kWurx*@SCB-qmI!dxh(i6E;ab8tkR~48&IMP z;b(y08{=Gz!!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CsQ-D{@J**Br7ykKKyiP&dDtB$wEgDOsKLOZTJBg>FR;9IVT@Wixw?H2rYinL6!S zxpiy2^k)4Izo`wYO}UYkT0i>D?ezVukvlg&$=3UBTfbGF_8ZyiVJqUXR_*dRzGc6K zpB>MUgz6v7C{``q>R%hQEut>ZW({7VRo<|R39UiPZ6~dl>o@P97154qS80F5lwxR6 z>rul#_m`i2?u<(A9S>=c`u1owsi!3Kn&&3f4%gB0*|BFPRrSnBVZGAEz>4z};lo6) zCuu&vAY!DXUUemKD|-{a+!i-ItG}k7lo_q+d6nbqqL+lT?d0fc@Y3dgQZ<7@zoWDQ z9PtZQ8T`u7K*-fWqcyPZL;}D7SR=sd*ANC;|6<~Q$lLwDvor&euYf!b2jtF@2<{*} zGr%2O?KeP%Gtm3b713A<)`@KQ1M1y>()>S24RZRA8AtT6ctGD6Fa_W+S@1>zhF7p| z6dwR2^zW$eMUnayH~g1nIHGw10RycB3W0*dUj&OY5&wXG06waA83G#$YiiT7(D_Vc Int { + return 2 + } + + func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + switch section { + case Section.User.rawValue: + return 1 + case Section.More.rawValue: + return 0 + default: + return 0 + } + } + + func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + switch indexPath.section { + case Section.User.rawValue: + let cell = tableView.dequeueReusableCellWithIdentifier(settingsUserCellIdentifier) as! SettingsUserCell + return cell + case Section.More.rawValue: + return UITableViewCell() + default: + return UITableViewCell() + } + } + + func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { + switch indexPath.section { + case Section.User.rawValue: + return 120 + case Section.More.rawValue: + return 0 + default: + return 0 + } + } +} \ No newline at end of file diff --git a/Yep/Views/Cells/SettingsUser/SettingsUserCell.swift b/Yep/Views/Cells/SettingsUser/SettingsUserCell.swift new file mode 100644 index 00000000..0236bb5f --- /dev/null +++ b/Yep/Views/Cells/SettingsUser/SettingsUserCell.swift @@ -0,0 +1,55 @@ +// +// SettingsUserCell.swift +// Yep +// +// Created by NIX on 15/4/24. +// Copyright (c) 2015年 Catch Inc. All rights reserved. +// + +import UIKit + +class SettingsUserCell: UITableViewCell { + + @IBOutlet weak var avatarImageView: UIImageView! + @IBOutlet weak var avatarImageViewWidthConstraint: NSLayoutConstraint! + + @IBOutlet weak var nameLabel: UILabel! + + @IBOutlet weak var introLabel: UILabel! + + @IBOutlet weak var accessoryImageView: UIImageView! + + + override func awakeFromNib() { + super.awakeFromNib() + + let avatarSize = YepConfig.settingsUserCellAvatarSize() + avatarImageViewWidthConstraint.constant = avatarSize + + if let avatarURLString = YepUserDefaults.avatarURLString() { + AvatarCache.sharedInstance.roundAvatarWithAvatarURLString(avatarURLString, withRadius: avatarSize * 0.5) { image in + dispatch_async(dispatch_get_main_queue()) { + self.avatarImageView.image = image + UIView.animateWithDuration(0.2, delay: 0.0, options: .CurveEaseOut, animations: { () -> Void in + self.avatarImageView.alpha = 1 + }, completion: { (finished) -> Void in + }) + } + } + } + + nameLabel.text = YepUserDefaults.nickname() + + introLabel.text = "I'm good at iOS Development and Singing. Come here, let me teach you." + + accessoryImageView.tintColor = UIColor.lightGrayColor() + + } + + override func setSelected(selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + + // Configure the view for the selected state + } + +} diff --git a/Yep/Views/Cells/SettingsUser/SettingsUserCell.xib b/Yep/Views/Cells/SettingsUser/SettingsUserCell.xib new file mode 100644 index 00000000..aed36728 --- /dev/null +++ b/Yep/Views/Cells/SettingsUser/SettingsUserCell.xib @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 4bb900393290c0704c1fe59126fb5368956c7bdd Mon Sep 17 00:00:00 2001 From: nixzhu Date: Fri, 24 Apr 2015 18:53:23 +0800 Subject: [PATCH 03/14] add SettingsMoreCell --- Yep.xcodeproj/project.pbxproj | 16 +++++++ .../Settings/SettingsViewController.swift | 21 ++++++-- .../Cells/SettingsMore/SettingsMoreCell.swift | 30 ++++++++++++ .../Cells/SettingsMore/SettingsMoreCell.xib | 48 +++++++++++++++++++ 4 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 Yep/Views/Cells/SettingsMore/SettingsMoreCell.swift create mode 100644 Yep/Views/Cells/SettingsMore/SettingsMoreCell.xib diff --git a/Yep.xcodeproj/project.pbxproj b/Yep.xcodeproj/project.pbxproj index 67917a55..38f2da24 100644 --- a/Yep.xcodeproj/project.pbxproj +++ b/Yep.xcodeproj/project.pbxproj @@ -97,6 +97,8 @@ 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 */; }; + 50894CFA1AEA54BA000981AF /* SettingsMoreCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50894CF81AEA54BA000981AF /* SettingsMoreCell.swift */; }; + 50894CFB1AEA54BA000981AF /* SettingsMoreCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50894CF91AEA54BA000981AF /* SettingsMoreCell.xib */; }; 508C2AA01AD648B2002B8097 /* SearchUsersViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 508C2A9F1AD648B2002B8097 /* SearchUsersViewController.swift */; }; 508C2AA41AD661B3002B8097 /* UserStateCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 508C2AA21AD661B3002B8097 /* UserStateCell.swift */; }; 508C2AA51AD661B3002B8097 /* UserStateCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 508C2AA31AD661B3002B8097 /* UserStateCell.xib */; }; @@ -247,6 +249,8 @@ 50894CF01AEA4726000981AF /* SettingsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SettingsViewController.swift; path = ViewControllers/Settings/SettingsViewController.swift; sourceTree = ""; }; 50894CF31AEA4A01000981AF /* SettingsUserCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SettingsUserCell.swift; path = Views/Cells/SettingsUser/SettingsUserCell.swift; sourceTree = ""; }; 50894CF41AEA4A01000981AF /* SettingsUserCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = SettingsUserCell.xib; path = Views/Cells/SettingsUser/SettingsUserCell.xib; sourceTree = ""; }; + 50894CF81AEA54BA000981AF /* SettingsMoreCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SettingsMoreCell.swift; path = Views/Cells/SettingsMore/SettingsMoreCell.swift; sourceTree = ""; }; + 50894CF91AEA54BA000981AF /* SettingsMoreCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = SettingsMoreCell.xib; path = Views/Cells/SettingsMore/SettingsMoreCell.xib; sourceTree = ""; }; 508C2A9F1AD648B2002B8097 /* SearchUsersViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SearchUsersViewController.swift; path = ViewControllers/SearchUsers/SearchUsersViewController.swift; sourceTree = ""; }; 508C2AA21AD661B3002B8097 /* UserStateCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UserStateCell.swift; path = Views/Cells/UserState/UserStateCell.swift; sourceTree = ""; }; 508C2AA31AD661B3002B8097 /* UserStateCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = UserStateCell.xib; path = Views/Cells/UserState/UserStateCell.xib; sourceTree = ""; }; @@ -532,6 +536,7 @@ 50EB8CC11AE89EDE001AC1EE /* ChatLeftVideo */, 50EB8CC61AE89F15001AC1EE /* ChatRightVideo */, 50894CF71AEA4A04000981AF /* SettingsUser */, + 50894CFC1AEA54BE000981AF /* SettingsMore */, ); name = Cells; sourceTree = ""; @@ -783,6 +788,15 @@ name = SettingsUser; sourceTree = ""; }; + 50894CFC1AEA54BE000981AF /* SettingsMore */ = { + isa = PBXGroup; + children = ( + 50894CF81AEA54BA000981AF /* SettingsMoreCell.swift */, + 50894CF91AEA54BA000981AF /* SettingsMoreCell.xib */, + ); + name = SettingsMore; + sourceTree = ""; + }; 508C2AA11AD648BE002B8097 /* SearchUsers */ = { isa = PBXGroup; children = ( @@ -1066,6 +1080,7 @@ 508D17481ACCF4710092D666 /* ChatLeftAudioCell.xib in Resources */, 0A8F54B61AB67D11004AD60E /* Main.storyboard in Resources */, 5033159D1AC101C80008A209 /* ChatRightTextCell.xib in Resources */, + 50894CFB1AEA54BA000981AF /* SettingsMoreCell.xib in Resources */, 505EC8181ADF8151001D27E0 /* SkillCategoryCell.xib in Resources */, 505EC81D1ADFBE1B001D27E0 /* SkillSelectionCell.xib in Resources */, 50EB8CC01AE89ED8001AC1EE /* ChatLeftVideoCell.xib in Resources */, @@ -1179,6 +1194,7 @@ 502AE53D1AB87C0D005BD199 /* YepUserDefaults.swift in Sources */, 50EB8CC41AE89F12001AC1EE /* ChatRightVideoCell.swift in Sources */, 508D17471ACCF4710092D666 /* ChatLeftAudioCell.swift in Sources */, + 50894CFA1AEA54BA000981AF /* SettingsMoreCell.swift in Sources */, 502AE51B1AB70DDB005BD199 /* WelcomeViewController.swift in Sources */, 50E114F41ABBF9CC00F13000 /* Models.swift in Sources */, 50A9D4571ACD393A000B2599 /* YepWaverView.swift in Sources */, diff --git a/Yep/ViewControllers/Settings/SettingsViewController.swift b/Yep/ViewControllers/Settings/SettingsViewController.swift index be27a53a..c0089081 100644 --- a/Yep/ViewControllers/Settings/SettingsViewController.swift +++ b/Yep/ViewControllers/Settings/SettingsViewController.swift @@ -13,13 +13,21 @@ class SettingsViewController: UIViewController { @IBOutlet weak var settingsTableView: UITableView! let settingsUserCellIdentifier = "SettingsUserCell" - + let settingsMoreCellIdentifier = "SettingsMoreCell" + + let moreAnnotations: [String] = [ + NSLocalizedString("Notifications", comment: ""), + NSLocalizedString("Feedback", comment: ""), + NSLocalizedString("About", comment: ""), + ] + override func viewDidLoad() { super.viewDidLoad() title = NSLocalizedString("Settings", comment: "") settingsTableView.registerNib(UINib(nibName: settingsUserCellIdentifier, bundle: nil), forCellReuseIdentifier: settingsUserCellIdentifier) + settingsTableView.registerNib(UINib(nibName: settingsMoreCellIdentifier, bundle: nil), forCellReuseIdentifier: settingsMoreCellIdentifier) } } @@ -40,7 +48,7 @@ extension SettingsViewController: UITableViewDataSource, UITableViewDelegate { case Section.User.rawValue: return 1 case Section.More.rawValue: - return 0 + return moreAnnotations.count default: return 0 } @@ -48,11 +56,16 @@ extension SettingsViewController: UITableViewDataSource, UITableViewDelegate { func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { switch indexPath.section { + case Section.User.rawValue: let cell = tableView.dequeueReusableCellWithIdentifier(settingsUserCellIdentifier) as! SettingsUserCell return cell + case Section.More.rawValue: - return UITableViewCell() + let cell = tableView.dequeueReusableCellWithIdentifier(settingsMoreCellIdentifier) as! SettingsMoreCell + cell.annotationLabel.text = moreAnnotations[indexPath.row] + return cell + default: return UITableViewCell() } @@ -63,7 +76,7 @@ extension SettingsViewController: UITableViewDataSource, UITableViewDelegate { case Section.User.rawValue: return 120 case Section.More.rawValue: - return 0 + return 60 default: return 0 } diff --git a/Yep/Views/Cells/SettingsMore/SettingsMoreCell.swift b/Yep/Views/Cells/SettingsMore/SettingsMoreCell.swift new file mode 100644 index 00000000..4940fabe --- /dev/null +++ b/Yep/Views/Cells/SettingsMore/SettingsMoreCell.swift @@ -0,0 +1,30 @@ +// +// SettingsMoreCell.swift +// Yep +// +// Created by NIX on 15/4/24. +// Copyright (c) 2015年 Catch Inc. All rights reserved. +// + +import UIKit + +class SettingsMoreCell: UITableViewCell { + + @IBOutlet weak var annotationLabel: UILabel! + + @IBOutlet weak var accessoryImageView: UIImageView! + + + override func awakeFromNib() { + super.awakeFromNib() + + accessoryImageView.tintColor = UIColor.lightGrayColor() + } + + override func setSelected(selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + + // Configure the view for the selected state + } + +} diff --git a/Yep/Views/Cells/SettingsMore/SettingsMoreCell.xib b/Yep/Views/Cells/SettingsMore/SettingsMoreCell.xib new file mode 100644 index 00000000..8576039a --- /dev/null +++ b/Yep/Views/Cells/SettingsMore/SettingsMoreCell.xib @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From e849ff25eee0a21615721d05c263a71f2fd6c3e6 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Fri, 24 Apr 2015 19:00:49 +0800 Subject: [PATCH 04/14] use radius in imageKey for avatarCache --- Yep/Caches/AvatarCache.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Yep/Caches/AvatarCache.swift b/Yep/Caches/AvatarCache.swift index 7643d7e3..dc681f26 100644 --- a/Yep/Caches/AvatarCache.swift +++ b/Yep/Caches/AvatarCache.swift @@ -143,7 +143,7 @@ class AvatarCache { } if let url = NSURL(string: avatarURLString) { - let roundImageKey = "round-\(url.hashValue)" + let roundImageKey = "round-\(radius)-\(url.hashValue)" // 先看看缓存 if let roundImage = cache.objectForKey(roundImageKey) as? UIImage { @@ -219,7 +219,7 @@ class AvatarCache { } if let url = NSURL(string: user.avatarURLString) { - let roundImageKey = "round-\(url.hashValue)" + let roundImageKey = "round-\(radius)-\(url.hashValue)" // 先看看缓存 if let roundImage = cache.objectForKey(roundImageKey) as? UIImage { From 8e7fdc128dd5600302de2ff3492421cca73b27ae Mon Sep 17 00:00:00 2001 From: nixzhu Date: Fri, 24 Apr 2015 19:09:07 +0800 Subject: [PATCH 05/14] add EditProfileViewController --- Yep.xcodeproj/project.pbxproj | 12 ++++++++++++ Yep/Base.lproj/Main.storyboard | 19 +++++++++++++++++++ .../EditProfileViewController.swift | 19 +++++++++++++++++++ .../Settings/SettingsViewController.swift | 16 +++++++++++++++- 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 Yep/ViewControllers/EditProfile/EditProfileViewController.swift diff --git a/Yep.xcodeproj/project.pbxproj b/Yep.xcodeproj/project.pbxproj index 38f2da24..6072ce3e 100644 --- a/Yep.xcodeproj/project.pbxproj +++ b/Yep.xcodeproj/project.pbxproj @@ -99,6 +99,7 @@ 50894CF61AEA4A01000981AF /* SettingsUserCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50894CF41AEA4A01000981AF /* SettingsUserCell.xib */; }; 50894CFA1AEA54BA000981AF /* SettingsMoreCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50894CF81AEA54BA000981AF /* SettingsMoreCell.swift */; }; 50894CFB1AEA54BA000981AF /* SettingsMoreCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50894CF91AEA54BA000981AF /* SettingsMoreCell.xib */; }; + 50894CFE1AEA5A78000981AF /* EditProfileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50894CFD1AEA5A78000981AF /* EditProfileViewController.swift */; }; 508C2AA01AD648B2002B8097 /* SearchUsersViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 508C2A9F1AD648B2002B8097 /* SearchUsersViewController.swift */; }; 508C2AA41AD661B3002B8097 /* UserStateCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 508C2AA21AD661B3002B8097 /* UserStateCell.swift */; }; 508C2AA51AD661B3002B8097 /* UserStateCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 508C2AA31AD661B3002B8097 /* UserStateCell.xib */; }; @@ -251,6 +252,7 @@ 50894CF41AEA4A01000981AF /* SettingsUserCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = SettingsUserCell.xib; path = Views/Cells/SettingsUser/SettingsUserCell.xib; sourceTree = ""; }; 50894CF81AEA54BA000981AF /* SettingsMoreCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SettingsMoreCell.swift; path = Views/Cells/SettingsMore/SettingsMoreCell.swift; sourceTree = ""; }; 50894CF91AEA54BA000981AF /* SettingsMoreCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = SettingsMoreCell.xib; path = Views/Cells/SettingsMore/SettingsMoreCell.xib; sourceTree = ""; }; + 50894CFD1AEA5A78000981AF /* EditProfileViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = EditProfileViewController.swift; path = ViewControllers/EditProfile/EditProfileViewController.swift; sourceTree = ""; }; 508C2A9F1AD648B2002B8097 /* SearchUsersViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SearchUsersViewController.swift; path = ViewControllers/SearchUsers/SearchUsersViewController.swift; sourceTree = ""; }; 508C2AA21AD661B3002B8097 /* UserStateCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UserStateCell.swift; path = Views/Cells/UserState/UserStateCell.swift; sourceTree = ""; }; 508C2AA31AD661B3002B8097 /* UserStateCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = UserStateCell.xib; path = Views/Cells/UserState/UserStateCell.xib; sourceTree = ""; }; @@ -444,6 +446,7 @@ 502AE5361AB864A3005BD199 /* Login */, 0A5D83951AC5D3CD000045BF /* TabBar */, 50894CF21AEA472B000981AF /* Settings */, + 50894CFF1AEA5A7E000981AF /* EditProfile */, ); name = ViewControllers; sourceTree = ""; @@ -797,6 +800,14 @@ name = SettingsMore; sourceTree = ""; }; + 50894CFF1AEA5A7E000981AF /* EditProfile */ = { + isa = PBXGroup; + children = ( + 50894CFD1AEA5A78000981AF /* EditProfileViewController.swift */, + ); + name = EditProfile; + sourceTree = ""; + }; 508C2AA11AD648BE002B8097 /* SearchUsers */ = { isa = PBXGroup; children = ( @@ -1174,6 +1185,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 50894CFE1AEA5A78000981AF /* EditProfileViewController.swift in Sources */, 50CDBE421ACA9B4200459CE0 /* ChatRightImageCell.swift in Sources */, 5099B9C41AB9510D002F940B /* RankView.swift in Sources */, 502AE5311AB85067005BD199 /* RegisterPickMobileViewController.swift in Sources */, diff --git a/Yep/Base.lproj/Main.storyboard b/Yep/Base.lproj/Main.storyboard index f79c138c..6e5d2aa8 100644 --- a/Yep/Base.lproj/Main.storyboard +++ b/Yep/Base.lproj/Main.storyboard @@ -458,12 +458,31 @@ + + + + + + + + + + + + + + + + + + + diff --git a/Yep/ViewControllers/EditProfile/EditProfileViewController.swift b/Yep/ViewControllers/EditProfile/EditProfileViewController.swift new file mode 100644 index 00000000..eb7b55b4 --- /dev/null +++ b/Yep/ViewControllers/EditProfile/EditProfileViewController.swift @@ -0,0 +1,19 @@ +// +// EditProfileViewController.swift +// Yep +// +// Created by NIX on 15/4/24. +// Copyright (c) 2015年 Catch Inc. All rights reserved. +// + +import UIKit + +class EditProfileViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + title = NSLocalizedString("Edit Profile", comment: "") + } + +} diff --git a/Yep/ViewControllers/Settings/SettingsViewController.swift b/Yep/ViewControllers/Settings/SettingsViewController.swift index c0089081..5b2313cc 100644 --- a/Yep/ViewControllers/Settings/SettingsViewController.swift +++ b/Yep/ViewControllers/Settings/SettingsViewController.swift @@ -81,4 +81,18 @@ extension SettingsViewController: UITableViewDataSource, UITableViewDelegate { return 0 } } -} \ No newline at end of file + + func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { + tableView.deselectRowAtIndexPath(indexPath, animated: true) + + switch indexPath.section { + + case Section.User.rawValue: + performSegueWithIdentifier("showEditProfile", sender: nil) + + default: + break + } + } +} + From b9e961d95efd5a108ab1d107b4bfe5ad196208c7 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Fri, 24 Apr 2015 19:28:30 +0800 Subject: [PATCH 06/14] EditProfile's avatar --- Yep/Base.lproj/Main.storyboard | 49 ++++++++++++++++++ Yep/Configs/YepConfig.swift | 4 ++ .../Contents.json | 12 +++++ .../profile_avatar_frame.pdf | Bin 0 -> 4643 bytes .../EditProfileViewController.swift | 40 ++++++++++++++ 5 files changed, 105 insertions(+) create mode 100644 Yep/Images.xcassets/profile_avatar_frame.imageset/Contents.json create mode 100644 Yep/Images.xcassets/profile_avatar_frame.imageset/profile_avatar_frame.pdf diff --git a/Yep/Base.lproj/Main.storyboard b/Yep/Base.lproj/Main.storyboard index 6e5d2aa8..5dc21a30 100644 --- a/Yep/Base.lproj/Main.storyboard +++ b/Yep/Base.lproj/Main.storyboard @@ -2,6 +2,7 @@ + @@ -476,8 +477,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -611,5 +659,6 @@ + diff --git a/Yep/Configs/YepConfig.swift b/Yep/Configs/YepConfig.swift index 7a4d692f..e9bac5bc 100644 --- a/Yep/Configs/YepConfig.swift +++ b/Yep/Configs/YepConfig.swift @@ -61,4 +61,8 @@ class YepConfig { class func settingsUserCellAvatarSize() -> CGFloat { return 80 } + + class func editProfileAvatarSize() -> CGFloat { + return 100 + } } \ No newline at end of file diff --git a/Yep/Images.xcassets/profile_avatar_frame.imageset/Contents.json b/Yep/Images.xcassets/profile_avatar_frame.imageset/Contents.json new file mode 100644 index 00000000..327b9bd8 --- /dev/null +++ b/Yep/Images.xcassets/profile_avatar_frame.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "profile_avatar_frame.pdf" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Yep/Images.xcassets/profile_avatar_frame.imageset/profile_avatar_frame.pdf b/Yep/Images.xcassets/profile_avatar_frame.imageset/profile_avatar_frame.pdf new file mode 100644 index 0000000000000000000000000000000000000000..042970cddd0d220b5c731eb509fcd10a7d6d06e7 GIT binary patch literal 4643 zcmai&2{=^m+s7?am?TP+C6g>E%#1N2jAh1FvS;7M%#d};zNC;PTe4?_tl0)d5sf`d z$|PG75`*kp*5sXOd4Ip&|Mgz~bDcToneVyJ^E~IA`@XNw{Rr!!)Fq&jFraWNWtB4b zc}IROy5S%I*fWYdGE}l4d>e&VDi9_Kqcq|TtKma{F z-EnAFpfCMG3dxNZ%G&Oucwm~rSa>#|dw|&SjtQcd7iI|RcsIBd_da7G$2&gefYWYw z9?F1IY_*(wTO90uS1hUxM9z`Zos}*^N?y@%zLlF*mfvvmzQD3dPI18V&6_%Ft`h~k zQyvMTC*M||2#NB}!jvT+!00Kh-c2ah<#`4(u#&8gDD6KXcJ*H3OsC1=Ehp3)!lq;5 zMM8g{I=@F%X4ohDY-@n_(^O-ePMRALaqpx28RFJQ_4sjQWVR5@$iGuIk+jhhEq@6- z|LB7^X&`uzbOvFNcp_|M8S%QXzHr0Nl2zgCGp=!TpAhJw2m|}|0M;>s!YiC4H|RFZ zwp|`wrCn3FYM68L%eG{b$+n1qfOW2dLi4zm;JR(?Ght!P$jGz-!uafGnv9c(rs2n%VlcsQsSnW*yZoVW3KU$9y9q5ulxPj_QC ze2|9Fm1yby(UBtIFhp=pKa&DpD@BUqI|o;@dh zl{z~P^r@bFb*F;U3D3lt-dC%2dDrE@6TQxa#~F=S%yo~H%d=gK=y-iE_Z0@mO@Wlo zw(T_Ndl)~icG4NO@#t&HAXtQ{+&^908=rUV zq1VKd(_K&Wrcb*(~MHWS8U^;=d;o1r!K6oZK{{vHF41p^L8(pzUujYd)8@6hc zy!6SJ4!md)^hnN9O4YOjE=szW#viR1TDmEIP!x>4c?WMBpU!bZXKe<1)bK@pqmhi4 z{n6pcXW%o$R{wrBXcnj=Z5_qZqybn zN@<}=Pz)yMB-Blpt^tV5kBScR5w+^E?G1V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dUr7h&SoY~q2hub!{Q45+Y@nnrKjr{iJIIn*BzQGHH7m{R}V-wn*Ox$S4?|uG; z3^-QuRS%Z?VhbR9T5jb_`E_(UIH{7fn17wN;bvGs-H; zM!SMj%dJ;lxEBqRcE4XuEpaH5vyu@8VnZM=u_1Tgu>Ff2%y_5;! zz4`-z(>qqX;L(lRK+3)S3|_|QgFB0o^#S|VpA^3aj_&m^6&-gSrzuR((Mlef!tTMm$m$mi9o)Mqt_8swPmm=XUc z>#vr(Vp4l2!WzVWJl{<2DapF!vrBTY>ugJO~a z_?4znAy*5DR7HE>upk=18i1_+n9$(*4-@~x-X8xSP17*hi^}9s5cskq)`N=AG z_b)_-((wE5K9OiovEx^+e?}nm5`_DdUr34=P@BjbI)Ylzn52O|sFd*cAH;@b*4uga2LBBO=D4hB{ zv<>9;M}x@8Qs4C78ca^=KQstLiuzc8+d<@Hs1?rN8WbW+{kVT?Fj-mZ$NgJ_LgCbc z>u(K4ExrD)CJlj5tE0c|q#^MC)SwWmqy4e-bVob7;M{+%ycjzAQ{Nx81Tw(mss2Ip z0qTp?aMRgYixUAd-Ih>3g27LjGhGNlJj4a$<<^lvJCj+BS7L5S@cavZ4 X=HW?ojh`PxT1rX=C@id|s}B4h$}t2v literal 0 HcmV?d00001 diff --git a/Yep/ViewControllers/EditProfile/EditProfileViewController.swift b/Yep/ViewControllers/EditProfile/EditProfileViewController.swift index eb7b55b4..ad65fcde 100644 --- a/Yep/ViewControllers/EditProfile/EditProfileViewController.swift +++ b/Yep/ViewControllers/EditProfile/EditProfileViewController.swift @@ -10,10 +10,50 @@ import UIKit class EditProfileViewController: UIViewController { + @IBOutlet weak var avatarImageView: UIImageView! + @IBOutlet weak var avatarImageViewWidthConstraint: NSLayoutConstraint! + override func viewDidLoad() { super.viewDidLoad() title = NSLocalizedString("Edit Profile", comment: "") + + let avatarSize = YepConfig.editProfileAvatarSize() + avatarImageViewWidthConstraint.constant = avatarSize + + if let avatarURLString = YepUserDefaults.avatarURLString() { + AvatarCache.sharedInstance.roundAvatarWithAvatarURLString(avatarURLString, withRadius: avatarSize * 0.5) { image in + dispatch_async(dispatch_get_main_queue()) { + self.avatarImageView.image = image + UIView.animateWithDuration(0.2, delay: 0.0, options: .CurveEaseOut, animations: { () -> Void in + self.avatarImageView.alpha = 1 + }, completion: { (finished) -> Void in + }) + } + } + } } } + +extension EditProfileViewController: UITableViewDataSource, UITableViewDelegate { + func numberOfSectionsInTableView(tableView: UITableView) -> Int { + return 1 + } + + func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + switch section { + + default: + return 0 + } + } + + func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + switch indexPath.section { + + default: + return UITableViewCell() + } + } +} From f2cf00bf00761a19cb8e9c20323ad8282c5e14c4 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Fri, 24 Apr 2015 19:42:11 +0800 Subject: [PATCH 07/14] mobile in EditProfile --- Yep/Base.lproj/Main.storyboard | 27 +++++++++++++++++- .../icon_profile_phone.imageset/Contents.json | 12 ++++++++ .../icon_profile_phone.pdf | Bin 0 -> 4203 bytes .../EditProfileViewController.swift | 5 +++- 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 Yep/Images.xcassets/icon_profile_phone.imageset/Contents.json create mode 100644 Yep/Images.xcassets/icon_profile_phone.imageset/icon_profile_phone.pdf diff --git a/Yep/Base.lproj/Main.storyboard b/Yep/Base.lproj/Main.storyboard index 5dc21a30..3a67f41a 100644 --- a/Yep/Base.lproj/Main.storyboard +++ b/Yep/Base.lproj/Main.storyboard @@ -499,12 +499,35 @@ + + + + + + + + + + + - + + + + + + + + @@ -525,6 +548,7 @@ + @@ -658,6 +682,7 @@ + diff --git a/Yep/Images.xcassets/icon_profile_phone.imageset/Contents.json b/Yep/Images.xcassets/icon_profile_phone.imageset/Contents.json new file mode 100644 index 00000000..33ccf6e5 --- /dev/null +++ b/Yep/Images.xcassets/icon_profile_phone.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "icon_profile_phone.pdf" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Yep/Images.xcassets/icon_profile_phone.imageset/icon_profile_phone.pdf b/Yep/Images.xcassets/icon_profile_phone.imageset/icon_profile_phone.pdf new file mode 100644 index 0000000000000000000000000000000000000000..04d94437d35281283e37a1de92291480ffb83b0e GIT binary patch literal 4203 zcmai%c{o&W8^!yY%^xY^26A-kS%4`j2VnQdy6$o7}=XBgzRfkL_>C} z*CZhcO$^zWWS4iQ<^9$Bd#~#~*SY3A^F7aV-_LpO?;oFA*jQ6r5-J4)3%5~LD6@rM z?!Rv90K)+Y;E8qtD=7ie23QX#UuOV8l}rI?ZJe7g)|>itL-}Ggu@0UXEPzCUeSE#K zD0grmeZHAu1wWK+&M&r@G4PaWlli>V$c;FG=c*q;{-I1fi(9=N_J-^e@@X-5Pd7esn*B1jwu)6%In|;>Pu0a1W2w8KSm-=brwY z>nlxS{|9tC#UQHuf{@Q`0$XBX6+yNKUs9f)SuIZtag^wZfWD4d^0-%-mzl0KH7m?I z?ccbOcmqPfI!U-anoI3{e;#4ZwxFbdix%k_sybfhRV8ml-qVgdA}DaSTgk8;-}24x z`V}YB1BC?L4gI8+Y|RzC$l;K(3MC7h_<6-;`8gxk3?!;Xaj`?i?eO3Y@fxZ8qKe3P zKX&IHfqwNn@=QAmwb9lc;Ng-d4URRfk{s_x#CypFc(c)w9RV|>;o8^DhVCrgYj(Ra z6$zf$4zVQ8kz4$YR7qF(L($ofQ0cj0SH&1UfFO&lopm|cm2MWl24~s<7?DsQ< z{BJRS+E(HFEa`L9ZAz=rtm{GbEg-Fl^~X72O?A}&zoRp62b?z>;*KT}<%q8j3j)Hc zd{SEe1q|5hA=q~ z56ZE*BmB`R?>ZBfcwR4qj*}`ovdA1MOAVi8Ip#K3CQam~TNARnd#t)K z&77{reZMM&TxPTg(5>vFs~Nrb<#?2v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y~43f%O0_w13h`HY&=UmZzYd<_g*H~33w+-VWjZ(fnGUp&4<&* zt!B4g84kuz`M0^Zjl5GH+O69bKd65&Nhhu|wJ>FhkHl(slTdjv>0)JV@;Z9aWw8+X z7cvGJk37=o-&h(Xy@A?g*!ABU`7*dPwKceH1d<1pv3v$U0BM6RFdArL48NVKT?SW!Dh>~<#SX@0$wIEccsoeFgP#(B#GA2)M#taP3U^l zr4tv=t$I`Lk&aH0-Uv=?9cZF|QvR1o1 z8gs6SOVArmEgtl8b#-MHN5M;xom zU4{vQcD-NGFF(b8G7|ofJUeC?ba8X!)mp?nF@G(8JK&=~bHIm@>H04g>1a#4q1P23 zZObXIR&rNr8!pZ@UO-u2zH|_mfJvy4DSAXaTj`?HUpVt%CX6p3W0E*?t#&^1edq9C z)0lfmAALMyI}`Far@*t2u61MAay9pM)CY1|D`_@&roPE3#6CoGUUxZ(q!X!=-`SGj z*RS|?P_9TWRkkHQx#QvZK9J>q@*6Mdv_JG z1A{zcw=KE$ z&ZeuJ9W829*cw=KpTc~e=nKFt78J&gmNu%ah3)2SJFIplP0tx^7^P*$s{~wU*;xq` zad(^?TaWm%{ZFcGT8YeSXsX-$)IG{#uUKqd6=s2}Jn_G{nJUoFFF&A((IPy_@n1B1d~a0J{6 z0uiO&f6x4FKUC_+_&HFU%kMd<9fJn7r}V{ndT7#+{d-JW8{vuh{r}%P4fMu3f~k!K z3=H|t1;`>0Fa+QT{M2A_wAi!@@c5-c5O8WK{?uS_d1@o{rv`z@P(SOxG=vPbWdEhf z!l~u{Q=@)5_2mE5AacQ>gFs*uFZH!2kdN literal 0 HcmV?d00001 diff --git a/Yep/ViewControllers/EditProfile/EditProfileViewController.swift b/Yep/ViewControllers/EditProfile/EditProfileViewController.swift index ad65fcde..6166059a 100644 --- a/Yep/ViewControllers/EditProfile/EditProfileViewController.swift +++ b/Yep/ViewControllers/EditProfile/EditProfileViewController.swift @@ -13,6 +13,9 @@ class EditProfileViewController: UIViewController { @IBOutlet weak var avatarImageView: UIImageView! @IBOutlet weak var avatarImageViewWidthConstraint: NSLayoutConstraint! + @IBOutlet weak var mobileLabel: UILabel! + + override func viewDidLoad() { super.viewDidLoad() @@ -43,7 +46,7 @@ extension EditProfileViewController: UITableViewDataSource, UITableViewDelegate func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { switch section { - + default: return 0 } From f2cdd27538ae4bbe50afc9189b5ef94b5cb14593 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Fri, 24 Apr 2015 20:03:14 +0800 Subject: [PATCH 08/14] add EditProfileLessInfoCell --- Yep.xcodeproj/project.pbxproj | 16 +++++++ Yep/Base.lproj/Main.storyboard | 1 + .../EditProfileViewController.swift | 33 +++++++++++--- .../EditProfileLessInfoCell.swift | 29 ++++++++++++ .../EditProfileLessInfoCell.xib | 44 +++++++++++++++++++ 5 files changed, 117 insertions(+), 6 deletions(-) create mode 100644 Yep/Views/Cells/EditProfileLessInfo/EditProfileLessInfoCell.swift create mode 100644 Yep/Views/Cells/EditProfileLessInfo/EditProfileLessInfoCell.xib diff --git a/Yep.xcodeproj/project.pbxproj b/Yep.xcodeproj/project.pbxproj index 6072ce3e..9746c3da 100644 --- a/Yep.xcodeproj/project.pbxproj +++ b/Yep.xcodeproj/project.pbxproj @@ -100,6 +100,8 @@ 50894CFA1AEA54BA000981AF /* SettingsMoreCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50894CF81AEA54BA000981AF /* SettingsMoreCell.swift */; }; 50894CFB1AEA54BA000981AF /* SettingsMoreCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50894CF91AEA54BA000981AF /* SettingsMoreCell.xib */; }; 50894CFE1AEA5A78000981AF /* EditProfileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50894CFD1AEA5A78000981AF /* EditProfileViewController.swift */; }; + 50894D021AEA6433000981AF /* EditProfileLessInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50894D001AEA6433000981AF /* EditProfileLessInfoCell.swift */; }; + 50894D031AEA6433000981AF /* EditProfileLessInfoCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50894D011AEA6433000981AF /* EditProfileLessInfoCell.xib */; }; 508C2AA01AD648B2002B8097 /* SearchUsersViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 508C2A9F1AD648B2002B8097 /* SearchUsersViewController.swift */; }; 508C2AA41AD661B3002B8097 /* UserStateCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 508C2AA21AD661B3002B8097 /* UserStateCell.swift */; }; 508C2AA51AD661B3002B8097 /* UserStateCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 508C2AA31AD661B3002B8097 /* UserStateCell.xib */; }; @@ -253,6 +255,8 @@ 50894CF81AEA54BA000981AF /* SettingsMoreCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SettingsMoreCell.swift; path = Views/Cells/SettingsMore/SettingsMoreCell.swift; sourceTree = ""; }; 50894CF91AEA54BA000981AF /* SettingsMoreCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = SettingsMoreCell.xib; path = Views/Cells/SettingsMore/SettingsMoreCell.xib; sourceTree = ""; }; 50894CFD1AEA5A78000981AF /* EditProfileViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = EditProfileViewController.swift; path = ViewControllers/EditProfile/EditProfileViewController.swift; sourceTree = ""; }; + 50894D001AEA6433000981AF /* EditProfileLessInfoCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = EditProfileLessInfoCell.swift; path = Views/Cells/EditProfileLessInfo/EditProfileLessInfoCell.swift; sourceTree = ""; }; + 50894D011AEA6433000981AF /* EditProfileLessInfoCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = EditProfileLessInfoCell.xib; path = Views/Cells/EditProfileLessInfo/EditProfileLessInfoCell.xib; sourceTree = ""; }; 508C2A9F1AD648B2002B8097 /* SearchUsersViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SearchUsersViewController.swift; path = ViewControllers/SearchUsers/SearchUsersViewController.swift; sourceTree = ""; }; 508C2AA21AD661B3002B8097 /* UserStateCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UserStateCell.swift; path = Views/Cells/UserState/UserStateCell.swift; sourceTree = ""; }; 508C2AA31AD661B3002B8097 /* UserStateCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = UserStateCell.xib; path = Views/Cells/UserState/UserStateCell.xib; sourceTree = ""; }; @@ -540,6 +544,7 @@ 50EB8CC61AE89F15001AC1EE /* ChatRightVideo */, 50894CF71AEA4A04000981AF /* SettingsUser */, 50894CFC1AEA54BE000981AF /* SettingsMore */, + 50894D041AEA6439000981AF /* EditProfileLessInfo */, ); name = Cells; sourceTree = ""; @@ -808,6 +813,15 @@ name = EditProfile; sourceTree = ""; }; + 50894D041AEA6439000981AF /* EditProfileLessInfo */ = { + isa = PBXGroup; + children = ( + 50894D001AEA6433000981AF /* EditProfileLessInfoCell.swift */, + 50894D011AEA6433000981AF /* EditProfileLessInfoCell.xib */, + ); + name = EditProfileLessInfo; + sourceTree = ""; + }; 508C2AA11AD648BE002B8097 /* SearchUsers */ = { isa = PBXGroup; children = ( @@ -1106,6 +1120,7 @@ 508D174D1ACCF49B0092D666 /* ChatRightAudioCell.xib in Resources */, 50A9D44E1ACD382B000B2599 /* NSDateTimeAgo.bundle in Resources */, 503315981AC1017E0008A209 /* ChatLeftTextCell.xib in Resources */, + 50894D031AEA6433000981AF /* EditProfileLessInfoCell.xib in Resources */, 0AD7EA771AC3EEB000617758 /* PushConfig.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1206,6 +1221,7 @@ 502AE53D1AB87C0D005BD199 /* YepUserDefaults.swift in Sources */, 50EB8CC41AE89F12001AC1EE /* ChatRightVideoCell.swift in Sources */, 508D17471ACCF4710092D666 /* ChatLeftAudioCell.swift in Sources */, + 50894D021AEA6433000981AF /* EditProfileLessInfoCell.swift in Sources */, 50894CFA1AEA54BA000981AF /* SettingsMoreCell.swift in Sources */, 502AE51B1AB70DDB005BD199 /* WelcomeViewController.swift in Sources */, 50E114F41ABBF9CC00F13000 /* Models.swift in Sources */, diff --git a/Yep/Base.lproj/Main.storyboard b/Yep/Base.lproj/Main.storyboard index 3a67f41a..dce0b2d5 100644 --- a/Yep/Base.lproj/Main.storyboard +++ b/Yep/Base.lproj/Main.storyboard @@ -548,6 +548,7 @@ + diff --git a/Yep/ViewControllers/EditProfile/EditProfileViewController.swift b/Yep/ViewControllers/EditProfile/EditProfileViewController.swift index 6166059a..4c3eda35 100644 --- a/Yep/ViewControllers/EditProfile/EditProfileViewController.swift +++ b/Yep/ViewControllers/EditProfile/EditProfileViewController.swift @@ -15,6 +15,10 @@ class EditProfileViewController: UIViewController { @IBOutlet weak var mobileLabel: UILabel! + @IBOutlet weak var editProfileTableView: UITableView! + + + let editProfileLessInfoCellIdentifier = "EditProfileLessInfoCell" override func viewDidLoad() { super.viewDidLoad() @@ -35,28 +39,45 @@ class EditProfileViewController: UIViewController { } } } + + editProfileTableView.registerNib(UINib(nibName: editProfileLessInfoCellIdentifier, bundle: nil), forCellReuseIdentifier: editProfileLessInfoCellIdentifier) } } extension EditProfileViewController: UITableViewDataSource, UITableViewDelegate { + enum Row: Int { + case Name = 0 + case Intro + } + func numberOfSectionsInTableView(tableView: UITableView) -> Int { return 1 } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - switch section { - - default: - return 0 - } + return 1 } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { switch indexPath.section { - + case Row.Name.rawValue: + let cell = tableView.dequeueReusableCellWithIdentifier(editProfileLessInfoCellIdentifier) as! EditProfileLessInfoCell + cell.annotationLabel.text = NSLocalizedString("Nickname", comment: "") + cell.infoLabel.text = YepUserDefaults.nickname() + return cell + default: return UITableViewCell() } } + + func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { + switch indexPath.section { + case Row.Name.rawValue: + return 60 + default: + return 0 + } + } } diff --git a/Yep/Views/Cells/EditProfileLessInfo/EditProfileLessInfoCell.swift b/Yep/Views/Cells/EditProfileLessInfo/EditProfileLessInfoCell.swift new file mode 100644 index 00000000..58031c05 --- /dev/null +++ b/Yep/Views/Cells/EditProfileLessInfo/EditProfileLessInfoCell.swift @@ -0,0 +1,29 @@ +// +// EditProfileLessInfoCell.swift +// Yep +// +// Created by NIX on 15/4/24. +// Copyright (c) 2015年 Catch Inc. All rights reserved. +// + +import UIKit + +class EditProfileLessInfoCell: UITableViewCell { + + @IBOutlet weak var annotationLabel: UILabel! + + @IBOutlet weak var infoLabel: UILabel! + + + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + } + + override func setSelected(selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + + // Configure the view for the selected state + } + +} diff --git a/Yep/Views/Cells/EditProfileLessInfo/EditProfileLessInfoCell.xib b/Yep/Views/Cells/EditProfileLessInfo/EditProfileLessInfoCell.xib new file mode 100644 index 00000000..e183b690 --- /dev/null +++ b/Yep/Views/Cells/EditProfileLessInfo/EditProfileLessInfoCell.xib @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 3946ce4af49edef483f4da1a44f66d2d48d65d96 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Mon, 27 Apr 2015 13:30:03 +0800 Subject: [PATCH 09/14] add EditProfileMoreInfoCell --- Yep.xcodeproj/project.pbxproj | 16 +++++++ .../EditProfileViewController.swift | 16 +++++-- .../EditProfileLessInfoCell.xib | 6 +-- .../EditProfileMoreInfoCell.swift | 29 ++++++++++++ .../EditProfileMoreInfoCell.xib | 45 +++++++++++++++++++ 5 files changed, 106 insertions(+), 6 deletions(-) create mode 100644 Yep/Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.swift create mode 100644 Yep/Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.xib diff --git a/Yep.xcodeproj/project.pbxproj b/Yep.xcodeproj/project.pbxproj index 9746c3da..c5fcff26 100644 --- a/Yep.xcodeproj/project.pbxproj +++ b/Yep.xcodeproj/project.pbxproj @@ -102,6 +102,8 @@ 50894CFE1AEA5A78000981AF /* EditProfileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50894CFD1AEA5A78000981AF /* EditProfileViewController.swift */; }; 50894D021AEA6433000981AF /* EditProfileLessInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50894D001AEA6433000981AF /* EditProfileLessInfoCell.swift */; }; 50894D031AEA6433000981AF /* EditProfileLessInfoCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50894D011AEA6433000981AF /* EditProfileLessInfoCell.xib */; }; + 50894D071AEDFDA2000981AF /* EditProfileMoreInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50894D051AEDFDA2000981AF /* EditProfileMoreInfoCell.swift */; }; + 50894D081AEDFDA2000981AF /* EditProfileMoreInfoCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50894D061AEDFDA2000981AF /* EditProfileMoreInfoCell.xib */; }; 508C2AA01AD648B2002B8097 /* SearchUsersViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 508C2A9F1AD648B2002B8097 /* SearchUsersViewController.swift */; }; 508C2AA41AD661B3002B8097 /* UserStateCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 508C2AA21AD661B3002B8097 /* UserStateCell.swift */; }; 508C2AA51AD661B3002B8097 /* UserStateCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 508C2AA31AD661B3002B8097 /* UserStateCell.xib */; }; @@ -257,6 +259,8 @@ 50894CFD1AEA5A78000981AF /* EditProfileViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = EditProfileViewController.swift; path = ViewControllers/EditProfile/EditProfileViewController.swift; sourceTree = ""; }; 50894D001AEA6433000981AF /* EditProfileLessInfoCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = EditProfileLessInfoCell.swift; path = Views/Cells/EditProfileLessInfo/EditProfileLessInfoCell.swift; sourceTree = ""; }; 50894D011AEA6433000981AF /* EditProfileLessInfoCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = EditProfileLessInfoCell.xib; path = Views/Cells/EditProfileLessInfo/EditProfileLessInfoCell.xib; sourceTree = ""; }; + 50894D051AEDFDA2000981AF /* EditProfileMoreInfoCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = EditProfileMoreInfoCell.swift; path = Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.swift; sourceTree = ""; }; + 50894D061AEDFDA2000981AF /* EditProfileMoreInfoCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = EditProfileMoreInfoCell.xib; path = Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.xib; sourceTree = ""; }; 508C2A9F1AD648B2002B8097 /* SearchUsersViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SearchUsersViewController.swift; path = ViewControllers/SearchUsers/SearchUsersViewController.swift; sourceTree = ""; }; 508C2AA21AD661B3002B8097 /* UserStateCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UserStateCell.swift; path = Views/Cells/UserState/UserStateCell.swift; sourceTree = ""; }; 508C2AA31AD661B3002B8097 /* UserStateCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = UserStateCell.xib; path = Views/Cells/UserState/UserStateCell.xib; sourceTree = ""; }; @@ -545,6 +549,7 @@ 50894CF71AEA4A04000981AF /* SettingsUser */, 50894CFC1AEA54BE000981AF /* SettingsMore */, 50894D041AEA6439000981AF /* EditProfileLessInfo */, + 50894D091AEDFDA6000981AF /* EditProfileMoreInfo */, ); name = Cells; sourceTree = ""; @@ -822,6 +827,15 @@ name = EditProfileLessInfo; sourceTree = ""; }; + 50894D091AEDFDA6000981AF /* EditProfileMoreInfo */ = { + isa = PBXGroup; + children = ( + 50894D051AEDFDA2000981AF /* EditProfileMoreInfoCell.swift */, + 50894D061AEDFDA2000981AF /* EditProfileMoreInfoCell.xib */, + ); + name = EditProfileMoreInfo; + sourceTree = ""; + }; 508C2AA11AD648BE002B8097 /* SearchUsers */ = { isa = PBXGroup; children = ( @@ -1117,6 +1131,7 @@ 0A8F54B81AB67D11004AD60E /* Images.xcassets in Resources */, 50EB8CC51AE89F12001AC1EE /* ChatRightVideoCell.xib in Resources */, 502AE5191AB70D72005BD199 /* Intro.storyboard in Resources */, + 50894D081AEDFDA2000981AF /* EditProfileMoreInfoCell.xib in Resources */, 508D174D1ACCF49B0092D666 /* ChatRightAudioCell.xib in Resources */, 50A9D44E1ACD382B000B2599 /* NSDateTimeAgo.bundle in Resources */, 503315981AC1017E0008A209 /* ChatLeftTextCell.xib in Resources */, @@ -1224,6 +1239,7 @@ 50894D021AEA6433000981AF /* EditProfileLessInfoCell.swift in Sources */, 50894CFA1AEA54BA000981AF /* SettingsMoreCell.swift in Sources */, 502AE51B1AB70DDB005BD199 /* WelcomeViewController.swift in Sources */, + 50894D071AEDFDA2000981AF /* EditProfileMoreInfoCell.swift in Sources */, 50E114F41ABBF9CC00F13000 /* Models.swift in Sources */, 50A9D4571ACD393A000B2599 /* YepWaverView.swift in Sources */, 50165C451AC2860900C7AEBE /* ConversationLayout.swift in Sources */, diff --git a/Yep/ViewControllers/EditProfile/EditProfileViewController.swift b/Yep/ViewControllers/EditProfile/EditProfileViewController.swift index 4c3eda35..4c1da260 100644 --- a/Yep/ViewControllers/EditProfile/EditProfileViewController.swift +++ b/Yep/ViewControllers/EditProfile/EditProfileViewController.swift @@ -19,6 +19,7 @@ class EditProfileViewController: UIViewController { let editProfileLessInfoCellIdentifier = "EditProfileLessInfoCell" + let editProfileMoreInfoCellIdentifier = "EditProfileMoreInfoCell" override func viewDidLoad() { super.viewDidLoad() @@ -41,6 +42,7 @@ class EditProfileViewController: UIViewController { } editProfileTableView.registerNib(UINib(nibName: editProfileLessInfoCellIdentifier, bundle: nil), forCellReuseIdentifier: editProfileLessInfoCellIdentifier) + editProfileTableView.registerNib(UINib(nibName: editProfileMoreInfoCellIdentifier, bundle: nil), forCellReuseIdentifier: editProfileMoreInfoCellIdentifier) } } @@ -56,26 +58,34 @@ extension EditProfileViewController: UITableViewDataSource, UITableViewDelegate } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return 1 + return 2 } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { - switch indexPath.section { + switch indexPath.row { case Row.Name.rawValue: let cell = tableView.dequeueReusableCellWithIdentifier(editProfileLessInfoCellIdentifier) as! EditProfileLessInfoCell cell.annotationLabel.text = NSLocalizedString("Nickname", comment: "") cell.infoLabel.text = YepUserDefaults.nickname() return cell + case Row.Intro.rawValue: + let cell = tableView.dequeueReusableCellWithIdentifier(editProfileMoreInfoCellIdentifier) as! EditProfileMoreInfoCell + cell.annotationLabel.text = NSLocalizedString("Introduction", comment: "") + cell.infoLabel.text = "I'm good at iOS Development and Singing. Come here, let me teach you." + return cell + default: return UITableViewCell() } } func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { - switch indexPath.section { + switch indexPath.row { case Row.Name.rawValue: return 60 + case Row.Intro.rawValue: + return 120 default: return 0 } diff --git a/Yep/Views/Cells/EditProfileLessInfo/EditProfileLessInfoCell.xib b/Yep/Views/Cells/EditProfileLessInfo/EditProfileLessInfoCell.xib index e183b690..d8dd6a6b 100644 --- a/Yep/Views/Cells/EditProfileLessInfo/EditProfileLessInfoCell.xib +++ b/Yep/Views/Cells/EditProfileLessInfo/EditProfileLessInfoCell.xib @@ -14,13 +14,13 @@ - + diff --git a/Yep/Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.swift b/Yep/Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.swift new file mode 100644 index 00000000..0dfefbbd --- /dev/null +++ b/Yep/Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.swift @@ -0,0 +1,29 @@ +// +// EditProfileMoreInfoCell.swift +// Yep +// +// Created by NIX on 15/4/27. +// Copyright (c) 2015年 Catch Inc. All rights reserved. +// + +import UIKit + +class EditProfileMoreInfoCell: UITableViewCell { + + @IBOutlet weak var annotationLabel: UILabel! + + @IBOutlet weak var infoLabel: UILabel! + + + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + } + + override func setSelected(selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + + // Configure the view for the selected state + } + +} diff --git a/Yep/Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.xib b/Yep/Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.xib new file mode 100644 index 00000000..c8f4a2f3 --- /dev/null +++ b/Yep/Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.xib @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From e3834cec4c1f439f7e595602cff6b7939ac4e8ca Mon Sep 17 00:00:00 2001 From: nixzhu Date: Mon, 27 Apr 2015 13:44:13 +0800 Subject: [PATCH 10/14] add EditProfileColoredTitleCell --- Yep.xcodeproj/project.pbxproj | 16 ++++ .../EditProfileViewController.swift | 87 ++++++++++++++----- .../EditProfileColoredTitleCell.swift | 33 +++++++ .../EditProfileColoredTitleCell.xib | 34 ++++++++ .../EditProfileMoreInfoCell.xib | 2 +- 5 files changed, 150 insertions(+), 22 deletions(-) create mode 100644 Yep/Views/Cells/EditProfileColoredTitle/EditProfileColoredTitleCell.swift create mode 100644 Yep/Views/Cells/EditProfileColoredTitle/EditProfileColoredTitleCell.xib diff --git a/Yep.xcodeproj/project.pbxproj b/Yep.xcodeproj/project.pbxproj index c5fcff26..88034a2e 100644 --- a/Yep.xcodeproj/project.pbxproj +++ b/Yep.xcodeproj/project.pbxproj @@ -104,6 +104,8 @@ 50894D031AEA6433000981AF /* EditProfileLessInfoCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50894D011AEA6433000981AF /* EditProfileLessInfoCell.xib */; }; 50894D071AEDFDA2000981AF /* EditProfileMoreInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50894D051AEDFDA2000981AF /* EditProfileMoreInfoCell.swift */; }; 50894D081AEDFDA2000981AF /* EditProfileMoreInfoCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50894D061AEDFDA2000981AF /* EditProfileMoreInfoCell.xib */; }; + 50894D0C1AEE0177000981AF /* EditProfileColoredTitleCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50894D0A1AEE0177000981AF /* EditProfileColoredTitleCell.swift */; }; + 50894D0D1AEE0177000981AF /* EditProfileColoredTitleCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50894D0B1AEE0177000981AF /* EditProfileColoredTitleCell.xib */; }; 508C2AA01AD648B2002B8097 /* SearchUsersViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 508C2A9F1AD648B2002B8097 /* SearchUsersViewController.swift */; }; 508C2AA41AD661B3002B8097 /* UserStateCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 508C2AA21AD661B3002B8097 /* UserStateCell.swift */; }; 508C2AA51AD661B3002B8097 /* UserStateCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 508C2AA31AD661B3002B8097 /* UserStateCell.xib */; }; @@ -261,6 +263,8 @@ 50894D011AEA6433000981AF /* EditProfileLessInfoCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = EditProfileLessInfoCell.xib; path = Views/Cells/EditProfileLessInfo/EditProfileLessInfoCell.xib; sourceTree = ""; }; 50894D051AEDFDA2000981AF /* EditProfileMoreInfoCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = EditProfileMoreInfoCell.swift; path = Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.swift; sourceTree = ""; }; 50894D061AEDFDA2000981AF /* EditProfileMoreInfoCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = EditProfileMoreInfoCell.xib; path = Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.xib; sourceTree = ""; }; + 50894D0A1AEE0177000981AF /* EditProfileColoredTitleCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = EditProfileColoredTitleCell.swift; path = Views/Cells/EditProfileColoredTitle/EditProfileColoredTitleCell.swift; sourceTree = ""; }; + 50894D0B1AEE0177000981AF /* EditProfileColoredTitleCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = EditProfileColoredTitleCell.xib; path = Views/Cells/EditProfileColoredTitle/EditProfileColoredTitleCell.xib; sourceTree = ""; }; 508C2A9F1AD648B2002B8097 /* SearchUsersViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SearchUsersViewController.swift; path = ViewControllers/SearchUsers/SearchUsersViewController.swift; sourceTree = ""; }; 508C2AA21AD661B3002B8097 /* UserStateCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UserStateCell.swift; path = Views/Cells/UserState/UserStateCell.swift; sourceTree = ""; }; 508C2AA31AD661B3002B8097 /* UserStateCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = UserStateCell.xib; path = Views/Cells/UserState/UserStateCell.xib; sourceTree = ""; }; @@ -550,6 +554,7 @@ 50894CFC1AEA54BE000981AF /* SettingsMore */, 50894D041AEA6439000981AF /* EditProfileLessInfo */, 50894D091AEDFDA6000981AF /* EditProfileMoreInfo */, + 50894D0E1AEE017B000981AF /* EditProfileColoredTitle */, ); name = Cells; sourceTree = ""; @@ -836,6 +841,15 @@ name = EditProfileMoreInfo; sourceTree = ""; }; + 50894D0E1AEE017B000981AF /* EditProfileColoredTitle */ = { + isa = PBXGroup; + children = ( + 50894D0A1AEE0177000981AF /* EditProfileColoredTitleCell.swift */, + 50894D0B1AEE0177000981AF /* EditProfileColoredTitleCell.xib */, + ); + name = EditProfileColoredTitle; + sourceTree = ""; + }; 508C2AA11AD648BE002B8097 /* SearchUsers */ = { isa = PBXGroup; children = ( @@ -1123,6 +1137,7 @@ 505EC8181ADF8151001D27E0 /* SkillCategoryCell.xib in Resources */, 505EC81D1ADFBE1B001D27E0 /* SkillSelectionCell.xib in Resources */, 50EB8CC01AE89ED8001AC1EE /* ChatLeftVideoCell.xib in Resources */, + 50894D0D1AEE0177000981AF /* EditProfileColoredTitleCell.xib in Resources */, 50CDBE431ACA9B4200459CE0 /* ChatRightImageCell.xib in Resources */, 508C2AA51AD661B3002B8097 /* UserStateCell.xib in Resources */, 50E114FD1ABC549300F13000 /* ContactsCell.xib in Resources */, @@ -1304,6 +1319,7 @@ 505EC8171ADF8151001D27E0 /* SkillCategoryCell.swift in Sources */, 50894CF51AEA4A01000981AF /* SettingsUserCell.swift in Sources */, 504F415A1AD5028200FBB19A /* SkillCell.swift in Sources */, + 50894D0C1AEE0177000981AF /* EditProfileColoredTitleCell.swift in Sources */, 5023DE521AB6C51300B3EE96 /* CGRect+Yep.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Yep/ViewControllers/EditProfile/EditProfileViewController.swift b/Yep/ViewControllers/EditProfile/EditProfileViewController.swift index 4c1da260..b83e4587 100644 --- a/Yep/ViewControllers/EditProfile/EditProfileViewController.swift +++ b/Yep/ViewControllers/EditProfile/EditProfileViewController.swift @@ -20,6 +20,7 @@ class EditProfileViewController: UIViewController { let editProfileLessInfoCellIdentifier = "EditProfileLessInfoCell" let editProfileMoreInfoCellIdentifier = "EditProfileMoreInfoCell" + let editProfileColoredTitleCellIdentifier = "EditProfileColoredTitleCell" override func viewDidLoad() { super.viewDidLoad() @@ -43,36 +44,68 @@ class EditProfileViewController: UIViewController { editProfileTableView.registerNib(UINib(nibName: editProfileLessInfoCellIdentifier, bundle: nil), forCellReuseIdentifier: editProfileLessInfoCellIdentifier) editProfileTableView.registerNib(UINib(nibName: editProfileMoreInfoCellIdentifier, bundle: nil), forCellReuseIdentifier: editProfileMoreInfoCellIdentifier) + editProfileTableView.registerNib(UINib(nibName: editProfileColoredTitleCellIdentifier, bundle: nil), forCellReuseIdentifier: editProfileColoredTitleCellIdentifier) } } extension EditProfileViewController: UITableViewDataSource, UITableViewDelegate { - enum Row: Int { + + enum Section: Int { + case Info + case LogOut + } + + enum InfoRow: Int { case Name = 0 case Intro } func numberOfSectionsInTableView(tableView: UITableView) -> Int { - return 1 - } - - func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 2 } - func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { - switch indexPath.row { - case Row.Name.rawValue: - let cell = tableView.dequeueReusableCellWithIdentifier(editProfileLessInfoCellIdentifier) as! EditProfileLessInfoCell - cell.annotationLabel.text = NSLocalizedString("Nickname", comment: "") - cell.infoLabel.text = YepUserDefaults.nickname() - return cell + func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - case Row.Intro.rawValue: - let cell = tableView.dequeueReusableCellWithIdentifier(editProfileMoreInfoCellIdentifier) as! EditProfileMoreInfoCell - cell.annotationLabel.text = NSLocalizedString("Introduction", comment: "") - cell.infoLabel.text = "I'm good at iOS Development and Singing. Come here, let me teach you." + switch section { + + case Section.Info.rawValue: + return 2 + + case Section.LogOut.rawValue: + return 1 + + default: + return 0 + } + } + + func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + switch indexPath.section { + + case Section.Info.rawValue: + + switch indexPath.row { + case InfoRow.Name.rawValue: + let cell = tableView.dequeueReusableCellWithIdentifier(editProfileLessInfoCellIdentifier) as! EditProfileLessInfoCell + cell.annotationLabel.text = NSLocalizedString("Nickname", comment: "") + cell.infoLabel.text = YepUserDefaults.nickname() + return cell + + case InfoRow.Intro.rawValue: + let cell = tableView.dequeueReusableCellWithIdentifier(editProfileMoreInfoCellIdentifier) as! EditProfileMoreInfoCell + cell.annotationLabel.text = NSLocalizedString("Introduction", comment: "") + cell.infoLabel.text = "I'm good at iOS Development and Singing. Come here, let me teach you." + return cell + + default: + return UITableViewCell() + } + + case Section.LogOut.rawValue: + let cell = tableView.dequeueReusableCellWithIdentifier(editProfileColoredTitleCellIdentifier) as! EditProfileColoredTitleCell + cell.coloredTitleLabel.text = NSLocalizedString("Log out", comment: "") + cell.coloredTitleColor = UIColor.redColor() return cell default: @@ -81,11 +114,23 @@ extension EditProfileViewController: UITableViewDataSource, UITableViewDelegate } func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { - switch indexPath.row { - case Row.Name.rawValue: - return 60 - case Row.Intro.rawValue: - return 120 + switch indexPath.section { + case Section.Info.rawValue: + + switch indexPath.row { + case InfoRow.Name.rawValue: + return 60 + + case InfoRow.Intro.rawValue: + return 120 + + default: + return 0 + } + + case Section.LogOut.rawValue: + return 80 + default: return 0 } diff --git a/Yep/Views/Cells/EditProfileColoredTitle/EditProfileColoredTitleCell.swift b/Yep/Views/Cells/EditProfileColoredTitle/EditProfileColoredTitleCell.swift new file mode 100644 index 00000000..9b4a3ac8 --- /dev/null +++ b/Yep/Views/Cells/EditProfileColoredTitle/EditProfileColoredTitleCell.swift @@ -0,0 +1,33 @@ +// +// EditProfileColoredTitleCell.swift +// Yep +// +// Created by NIX on 15/4/27. +// Copyright (c) 2015年 Catch Inc. All rights reserved. +// + +import UIKit + +class EditProfileColoredTitleCell: UITableViewCell { + + var coloredTitleColor: UIColor = UIColor.redColor() { + willSet { + coloredTitleLabel.textColor = newValue + } + } + + @IBOutlet weak var coloredTitleLabel: UILabel! + + + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + } + + override func setSelected(selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + + // Configure the view for the selected state + } + +} diff --git a/Yep/Views/Cells/EditProfileColoredTitle/EditProfileColoredTitleCell.xib b/Yep/Views/Cells/EditProfileColoredTitle/EditProfileColoredTitleCell.xib new file mode 100644 index 00000000..d97d3e8f --- /dev/null +++ b/Yep/Views/Cells/EditProfileColoredTitle/EditProfileColoredTitleCell.xib @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Yep/Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.xib b/Yep/Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.xib index c8f4a2f3..137411a6 100644 --- a/Yep/Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.xib +++ b/Yep/Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.xib @@ -6,7 +6,7 @@ - + From 017e8518865d2a0412b95720391a11ec903070c6 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Mon, 27 Apr 2015 14:30:12 +0800 Subject: [PATCH 11/14] dynamic SettingsUserCell's height --- Yep/Configs/YepConfig.swift | 13 +++++++++---- .../Settings/SettingsViewController.swift | 17 ++++++++++++++++- .../Cells/SettingsUser/SettingsUserCell.swift | 4 ++-- .../Cells/SettingsUser/SettingsUserCell.xib | 12 ++++++------ 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/Yep/Configs/YepConfig.swift b/Yep/Configs/YepConfig.swift index e9bac5bc..eced1e0d 100644 --- a/Yep/Configs/YepConfig.swift +++ b/Yep/Configs/YepConfig.swift @@ -58,11 +58,16 @@ class YepConfig { return 1 } - class func settingsUserCellAvatarSize() -> CGFloat { - return 80 - } - class func editProfileAvatarSize() -> CGFloat { return 100 } + + + struct Settings { + static let userCellAvatarSize: CGFloat = 80 + + static let introFont = UIFont(name: "Helvetica-Light", size: 12)! + static let introInset: CGFloat = 20 + userCellAvatarSize + 20 + 11 + 20 + } + } \ No newline at end of file diff --git a/Yep/ViewControllers/Settings/SettingsViewController.swift b/Yep/ViewControllers/Settings/SettingsViewController.swift index 5b2313cc..7d55ed62 100644 --- a/Yep/ViewControllers/Settings/SettingsViewController.swift +++ b/Yep/ViewControllers/Settings/SettingsViewController.swift @@ -15,12 +15,15 @@ class SettingsViewController: UIViewController { let settingsUserCellIdentifier = "SettingsUserCell" let settingsMoreCellIdentifier = "SettingsMoreCell" + let intro = "I'm good at iOS Development and Singing. Come here, let me teach you." // TODO: User Intro let moreAnnotations: [String] = [ NSLocalizedString("Notifications", comment: ""), NSLocalizedString("Feedback", comment: ""), NSLocalizedString("About", comment: ""), ] + let introAttributes = [NSFontAttributeName: YepConfig.Settings.introFont] + override func viewDidLoad() { super.viewDidLoad() @@ -59,6 +62,7 @@ extension SettingsViewController: UITableViewDataSource, UITableViewDelegate { case Section.User.rawValue: let cell = tableView.dequeueReusableCellWithIdentifier(settingsUserCellIdentifier) as! SettingsUserCell + cell.introLabel.text = intro return cell case Section.More.rawValue: @@ -73,10 +77,21 @@ extension SettingsViewController: UITableViewDataSource, UITableViewDelegate { func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { switch indexPath.section { + case Section.User.rawValue: - return 120 + + let tableViewWidth = CGRectGetWidth(settingsTableView.bounds) + let introLabelMaxWidth = tableViewWidth - YepConfig.Settings.introInset + + let rect = intro.boundingRectWithSize(CGSize(width: introLabelMaxWidth, height: CGFloat(FLT_MAX)), options: .UsesLineFragmentOrigin | .UsesFontLeading, attributes: introAttributes, context: nil) + + let height = max(20 + 10 + 22 + 8 + ceil(rect.height) + 20, 20 + YepConfig.Settings.userCellAvatarSize + 20) + + return height + case Section.More.rawValue: return 60 + default: return 0 } diff --git a/Yep/Views/Cells/SettingsUser/SettingsUserCell.swift b/Yep/Views/Cells/SettingsUser/SettingsUserCell.swift index 0236bb5f..5c492bc6 100644 --- a/Yep/Views/Cells/SettingsUser/SettingsUserCell.swift +++ b/Yep/Views/Cells/SettingsUser/SettingsUserCell.swift @@ -23,7 +23,7 @@ class SettingsUserCell: UITableViewCell { override func awakeFromNib() { super.awakeFromNib() - let avatarSize = YepConfig.settingsUserCellAvatarSize() + let avatarSize = YepConfig.Settings.userCellAvatarSize avatarImageViewWidthConstraint.constant = avatarSize if let avatarURLString = YepUserDefaults.avatarURLString() { @@ -40,7 +40,7 @@ class SettingsUserCell: UITableViewCell { nameLabel.text = YepUserDefaults.nickname() - introLabel.text = "I'm good at iOS Development and Singing. Come here, let me teach you." + introLabel.font = YepConfig.Settings.introFont accessoryImageView.tintColor = UIColor.lightGrayColor() diff --git a/Yep/Views/Cells/SettingsUser/SettingsUserCell.xib b/Yep/Views/Cells/SettingsUser/SettingsUserCell.xib index aed36728..fa0e61be 100644 --- a/Yep/Views/Cells/SettingsUser/SettingsUserCell.xib +++ b/Yep/Views/Cells/SettingsUser/SettingsUserCell.xib @@ -15,26 +15,26 @@ - + - + @@ -48,8 +48,8 @@ - - + + From 77dfb04dc1cb7c3670f83b99ff12ef8a22dbc0b0 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Mon, 27 Apr 2015 14:37:12 +0800 Subject: [PATCH 12/14] dynamic EditProfileMoreInfoCell's height --- Yep/Configs/YepConfig.swift | 5 +++++ .../EditProfile/EditProfileViewController.swift | 16 +++++++++++++--- .../EditProfileMoreInfoCell.swift | 3 ++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Yep/Configs/YepConfig.swift b/Yep/Configs/YepConfig.swift index eced1e0d..624e75da 100644 --- a/Yep/Configs/YepConfig.swift +++ b/Yep/Configs/YepConfig.swift @@ -70,4 +70,9 @@ class YepConfig { static let introInset: CGFloat = 20 + userCellAvatarSize + 20 + 11 + 20 } + struct EditProfile { + static let introFont = UIFont(name: "Helvetica-Light", size: 15)! + static let introInset: CGFloat = 20 + 20 + } + } \ No newline at end of file diff --git a/Yep/ViewControllers/EditProfile/EditProfileViewController.swift b/Yep/ViewControllers/EditProfile/EditProfileViewController.swift index b83e4587..d437c560 100644 --- a/Yep/ViewControllers/EditProfile/EditProfileViewController.swift +++ b/Yep/ViewControllers/EditProfile/EditProfileViewController.swift @@ -21,7 +21,10 @@ class EditProfileViewController: UIViewController { let editProfileLessInfoCellIdentifier = "EditProfileLessInfoCell" let editProfileMoreInfoCellIdentifier = "EditProfileMoreInfoCell" let editProfileColoredTitleCellIdentifier = "EditProfileColoredTitleCell" - + + let intro = "I'm good at iOS Development and Singing. Come here, let me teach you." // TODO: User Intro + let introAttributes = [NSFontAttributeName: YepConfig.EditProfile.introFont] + override func viewDidLoad() { super.viewDidLoad() @@ -95,7 +98,7 @@ extension EditProfileViewController: UITableViewDataSource, UITableViewDelegate case InfoRow.Intro.rawValue: let cell = tableView.dequeueReusableCellWithIdentifier(editProfileMoreInfoCellIdentifier) as! EditProfileMoreInfoCell cell.annotationLabel.text = NSLocalizedString("Introduction", comment: "") - cell.infoLabel.text = "I'm good at iOS Development and Singing. Come here, let me teach you." + cell.infoLabel.text = intro return cell default: @@ -122,7 +125,14 @@ extension EditProfileViewController: UITableViewDataSource, UITableViewDelegate return 60 case InfoRow.Intro.rawValue: - return 120 + let tableViewWidth = CGRectGetWidth(editProfileTableView.bounds) + let introLabelMaxWidth = tableViewWidth - YepConfig.EditProfile.introInset + + let rect = intro.boundingRectWithSize(CGSize(width: introLabelMaxWidth, height: CGFloat(FLT_MAX)), options: .UsesLineFragmentOrigin | .UsesFontLeading, attributes: introAttributes, context: nil) + + let height = 20 + 22 + 20 + ceil(rect.height) + 20 + + return height default: return 0 diff --git a/Yep/Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.swift b/Yep/Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.swift index 0dfefbbd..3cdad17d 100644 --- a/Yep/Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.swift +++ b/Yep/Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.swift @@ -17,7 +17,8 @@ class EditProfileMoreInfoCell: UITableViewCell { override func awakeFromNib() { super.awakeFromNib() - // Initialization code + + infoLabel.font = YepConfig.EditProfile.introFont } override func setSelected(selected: Bool, animated: Bool) { From 76b91dcf8c53c5d4f9b753c2dd175717150f3045 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Mon, 27 Apr 2015 17:10:06 +0800 Subject: [PATCH 13/14] update avatar in EditProfileViewController instead of ProfileViewController --- Yep/Base.lproj/Main.storyboard | 13 ++- .../EditProfileViewController.swift | 98 ++++++++++++++++++- .../Profile/ProfileViewController.swift | 93 +++--------------- .../Settings/SettingsViewController.swift | 10 ++ .../ProfileHeader/ProfileHeaderCell.swift | 24 ++--- .../Cells/SettingsUser/SettingsUserCell.swift | 34 ++++--- 6 files changed, 157 insertions(+), 115 deletions(-) diff --git a/Yep/Base.lproj/Main.storyboard b/Yep/Base.lproj/Main.storyboard index dce0b2d5..2e59a44d 100644 --- a/Yep/Base.lproj/Main.storyboard +++ b/Yep/Base.lproj/Main.storyboard @@ -71,7 +71,7 @@ - + @@ -492,12 +492,16 @@ - + + + + + @@ -553,6 +557,11 @@ + + + + + diff --git a/Yep/ViewControllers/EditProfile/EditProfileViewController.swift b/Yep/ViewControllers/EditProfile/EditProfileViewController.swift index d437c560..88d746e2 100644 --- a/Yep/ViewControllers/EditProfile/EditProfileViewController.swift +++ b/Yep/ViewControllers/EditProfile/EditProfileViewController.swift @@ -7,6 +7,9 @@ // import UIKit +import Realm + +let YepUpdatedProfileAvatarNotification = "YepUpdatedProfileAvatarNotification" class EditProfileViewController: UIViewController { @@ -33,10 +36,23 @@ class EditProfileViewController: UIViewController { let avatarSize = YepConfig.editProfileAvatarSize() avatarImageViewWidthConstraint.constant = avatarSize + updateAvatar() + + editProfileTableView.registerNib(UINib(nibName: editProfileLessInfoCellIdentifier, bundle: nil), forCellReuseIdentifier: editProfileLessInfoCellIdentifier) + editProfileTableView.registerNib(UINib(nibName: editProfileMoreInfoCellIdentifier, bundle: nil), forCellReuseIdentifier: editProfileMoreInfoCellIdentifier) + editProfileTableView.registerNib(UINib(nibName: editProfileColoredTitleCellIdentifier, bundle: nil), forCellReuseIdentifier: editProfileColoredTitleCellIdentifier) + } + + func updateAvatar() { if let avatarURLString = YepUserDefaults.avatarURLString() { + + let avatarSize = YepConfig.editProfileAvatarSize() + + self.avatarImageView.alpha = 0 AvatarCache.sharedInstance.roundAvatarWithAvatarURLString(avatarURLString, withRadius: avatarSize * 0.5) { image in dispatch_async(dispatch_get_main_queue()) { self.avatarImageView.image = image + UIView.animateWithDuration(0.2, delay: 0.0, options: .CurveEaseOut, animations: { () -> Void in self.avatarImageView.alpha = 1 }, completion: { (finished) -> Void in @@ -44,10 +60,43 @@ class EditProfileViewController: UIViewController { } } } + } - editProfileTableView.registerNib(UINib(nibName: editProfileLessInfoCellIdentifier, bundle: nil), forCellReuseIdentifier: editProfileLessInfoCellIdentifier) - editProfileTableView.registerNib(UINib(nibName: editProfileMoreInfoCellIdentifier, bundle: nil), forCellReuseIdentifier: editProfileMoreInfoCellIdentifier) - editProfileTableView.registerNib(UINib(nibName: editProfileColoredTitleCellIdentifier, bundle: nil), forCellReuseIdentifier: editProfileColoredTitleCellIdentifier) + @IBAction func changeAvatar(sender: UITapGestureRecognizer) { + + + let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .ActionSheet) + + let choosePhotoAction: UIAlertAction = UIAlertAction(title: NSLocalizedString("Choose Photo", comment: ""), style: .Default) { action -> Void in + if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.SavedPhotosAlbum) { + let imagePicker = UIImagePickerController() + imagePicker.delegate = self + imagePicker.sourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum + imagePicker.allowsEditing = false + + self.presentViewController(imagePicker, animated: true, completion: nil) + } + } + alertController.addAction(choosePhotoAction) + + let takePhotoAction: UIAlertAction = UIAlertAction(title: NSLocalizedString("Take Photo", comment: ""), style: .Default) { action -> Void in + if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera){ + let imagePicker = UIImagePickerController() + imagePicker.delegate = self + imagePicker.sourceType = UIImagePickerControllerSourceType.Camera + imagePicker.allowsEditing = false + + self.presentViewController(imagePicker, animated: true, completion: nil) + } + } + alertController.addAction(takePhotoAction) + + let cancelAction: UIAlertAction = UIAlertAction(title: NSLocalizedString("Cancel", comment: ""), style: .Cancel) { action -> Void in + self.dismissViewControllerAnimated(true, completion: nil) + } + alertController.addAction(cancelAction) + + self.presentViewController(alertController, animated: true, completion: nil) } } @@ -146,3 +195,46 @@ extension EditProfileViewController: UITableViewDataSource, UITableViewDelegate } } } + +// MARK: UIImagePicker + +extension EditProfileViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate { + func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!) { + s3PublicUploadParams(failureHandler: nil) { s3UploadParams in + + let image = image.largestCenteredSquareImage().resizeToTargetSize(YepConfig.avatarMaxSize()) + + var imageData = UIImageJPEGRepresentation(image, YepConfig.avatarCompressionQuality()) + + // TODO: 等待的菊花 + uploadFileToS3(inFilePath: nil, orFileData: imageData, mimeType: "image/jpeg", s3UploadParams: s3UploadParams, completion: { (result, error) in + println("upload avatar to s3 result: \(result), error: \(error)") + + if (result) { + let newAvatarURLString = "\(s3UploadParams.url)\(s3UploadParams.key)" + + updateMyselfWithInfo(["avatar_url": newAvatarURLString], failureHandler: nil) { success in + dispatch_async(dispatch_get_main_queue()) { + YepUserDefaults.setAvatarURLString(newAvatarURLString) + + self.updateAvatar() + + if + let myUserID = YepUserDefaults.userID(), + let me = userWithUserID(myUserID) { + let realm = RLMRealm.defaultRealm() + realm.beginWriteTransaction() + me.avatarURLString = newAvatarURLString + realm.commitWriteTransaction() + } + + NSNotificationCenter.defaultCenter().postNotificationName(YepUpdatedProfileAvatarNotification, object: nil) + } + } + } + }) + } + + dismissViewControllerAnimated(true, completion: nil) + } +} diff --git a/Yep/ViewControllers/Profile/ProfileViewController.swift b/Yep/ViewControllers/Profile/ProfileViewController.swift index 1c09c274..3574f321 100644 --- a/Yep/ViewControllers/Profile/ProfileViewController.swift +++ b/Yep/ViewControllers/Profile/ProfileViewController.swift @@ -7,9 +7,7 @@ // import UIKit -import Realm -let YepUpdatedProfileAvatarNotification = "YepUpdatedProfileAvatarNotification" let profileAvatarAspectRatio: CGFloat = 12.0 / 16.0 class ProfileViewController: UIViewController { @@ -43,9 +41,16 @@ class ProfileViewController: UIViewController { return ceil(rect.height) + 4 }() + + deinit { + NSNotificationCenter.defaultCenter().removeObserver(self) + } + override func viewDidLoad() { super.viewDidLoad() + NSNotificationCenter.defaultCenter().addObserver(self, selector: "reloadProfileCollectionView", name: YepUpdatedProfileAvatarNotification, object: nil) + profileCollectionView.registerNib(UINib(nibName: skillCellIdentifier, bundle: nil), forCellWithReuseIdentifier: skillCellIdentifier) profileCollectionView.registerNib(UINib(nibName: headerCellIdentifier, bundle: nil), forCellWithReuseIdentifier: headerCellIdentifier) profileCollectionView.registerNib(UINib(nibName: footerCellIdentifier, bundle: nil), forCellWithReuseIdentifier: footerCellIdentifier) @@ -103,51 +108,9 @@ class ProfileViewController: UIViewController { override func preferredStatusBarStyle() -> UIStatusBarStyle { return UIStatusBarStyle.LightContent } -} -// MARK: UIImagePicker - -extension ProfileViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate { - func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!) { - s3PublicUploadParams(failureHandler: nil) { s3UploadParams in - - dispatch_async(dispatch_get_main_queue()) { - if let cell = self.profileCollectionView.cellForItemAtIndexPath(NSIndexPath(forItem: 0, inSection: 0)) as? ProfileHeaderCell { - cell.avatarImageView.image = image - } - } - - let image = image.largestCenteredSquareImage().resizeToTargetSize(YepConfig.avatarMaxSize()) - - var imageData = UIImageJPEGRepresentation(image, YepConfig.avatarCompressionQuality()) - - uploadFileToS3(inFilePath: nil, orFileData: imageData, mimeType: "image/jpeg", s3UploadParams: s3UploadParams, completion: { (result, error) in - println("upload avatar to s3 result: \(result), error: \(error)") - - if (result) { - let newAvatarURLString = "\(s3UploadParams.url)\(s3UploadParams.key)" - - updateMyselfWithInfo(["avatar_url": newAvatarURLString], failureHandler: nil) { success in - dispatch_async(dispatch_get_main_queue()) { - YepUserDefaults.setAvatarURLString(newAvatarURLString) - - if - let myUserID = YepUserDefaults.userID(), - let me = userWithUserID(myUserID) { - let realm = RLMRealm.defaultRealm() - realm.beginWriteTransaction() - me.avatarURLString = newAvatarURLString - realm.commitWriteTransaction() - } - - NSNotificationCenter.defaultCenter().postNotificationName(YepUpdatedProfileAvatarNotification, object: nil) - } - } - } - }) - } - - dismissViewControllerAnimated(true, completion: nil) + func reloadProfileCollectionView() { + profileCollectionView.reloadData() } } @@ -194,44 +157,10 @@ extension ProfileViewController: UICollectionViewDataSource, UICollectionViewDel case ProfileSection.Header.rawValue: let cell = collectionView.dequeueReusableCellWithReuseIdentifier(headerCellIdentifier, forIndexPath: indexPath) as! ProfileHeaderCell + cell.updateAvatar() + cell.nameLabel.text = YepUserDefaults.nickname() - cell.changeAvatarAction = { - - let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .ActionSheet) - - let choosePhotoAction: UIAlertAction = UIAlertAction(title: NSLocalizedString("Choose Photo", comment: ""), style: .Default) { action -> Void in - if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.SavedPhotosAlbum) { - let imagePicker = UIImagePickerController() - imagePicker.delegate = self - imagePicker.sourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum - imagePicker.allowsEditing = false - - self.presentViewController(imagePicker, animated: true, completion: nil) - } - } - alertController.addAction(choosePhotoAction) - - let takePhotoAction: UIAlertAction = UIAlertAction(title: NSLocalizedString("Take Photo", comment: ""), style: .Default) { action -> Void in - if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera){ - let imagePicker = UIImagePickerController() - imagePicker.delegate = self - imagePicker.sourceType = UIImagePickerControllerSourceType.Camera - imagePicker.allowsEditing = false - - self.presentViewController(imagePicker, animated: true, completion: nil) - } - } - alertController.addAction(takePhotoAction) - - let cancelAction: UIAlertAction = UIAlertAction(title: NSLocalizedString("Cancel", comment: ""), style: .Cancel) { action -> Void in - self.dismissViewControllerAnimated(true, completion: nil) - } - alertController.addAction(cancelAction) - - self.presentViewController(alertController, animated: true, completion: nil) - } - return cell case ProfileSection.Master.rawValue: diff --git a/Yep/ViewControllers/Settings/SettingsViewController.swift b/Yep/ViewControllers/Settings/SettingsViewController.swift index 7d55ed62..f669c74c 100644 --- a/Yep/ViewControllers/Settings/SettingsViewController.swift +++ b/Yep/ViewControllers/Settings/SettingsViewController.swift @@ -24,15 +24,24 @@ class SettingsViewController: UIViewController { let introAttributes = [NSFontAttributeName: YepConfig.Settings.introFont] + deinit { + NSNotificationCenter.defaultCenter().removeObserver(self) + } + override func viewDidLoad() { super.viewDidLoad() title = NSLocalizedString("Settings", comment: "") + NSNotificationCenter.defaultCenter().addObserver(self, selector: "reloadSettingsTableView", name: YepUpdatedProfileAvatarNotification, object: nil) + settingsTableView.registerNib(UINib(nibName: settingsUserCellIdentifier, bundle: nil), forCellReuseIdentifier: settingsUserCellIdentifier) settingsTableView.registerNib(UINib(nibName: settingsMoreCellIdentifier, bundle: nil), forCellReuseIdentifier: settingsMoreCellIdentifier) } + func reloadSettingsTableView() { + settingsTableView.reloadData() + } } extension SettingsViewController: UITableViewDataSource, UITableViewDelegate { @@ -63,6 +72,7 @@ extension SettingsViewController: UITableViewDataSource, UITableViewDelegate { case Section.User.rawValue: let cell = tableView.dequeueReusableCellWithIdentifier(settingsUserCellIdentifier) as! SettingsUserCell cell.introLabel.text = intro + cell.updateAvatar() return cell case Section.More.rawValue: diff --git a/Yep/Views/Cells/ProfileHeader/ProfileHeaderCell.swift b/Yep/Views/Cells/ProfileHeader/ProfileHeaderCell.swift index d5071a46..8b583fa4 100644 --- a/Yep/Views/Cells/ProfileHeader/ProfileHeaderCell.swift +++ b/Yep/Views/Cells/ProfileHeader/ProfileHeaderCell.swift @@ -10,9 +10,6 @@ import UIKit class ProfileHeaderCell: UICollectionViewCell { - var changeAvatarAction: (() -> Void)? - - @IBOutlet weak var avatarImageView: UIImageView! @IBOutlet weak var nameLabel: UILabel! @IBOutlet weak var joinedDateLabel: UILabel! @@ -24,11 +21,15 @@ class ProfileHeaderCell: UICollectionViewCell { nameLabel.hidden = true joinedDateLabel.hidden = true - - let tap = UITapGestureRecognizer(target: self, action: "tryChangeAvatar") - avatarImageView.userInteractionEnabled = true - avatarImageView.addGestureRecognizer(tap) + updateAvatar() + + YepLocationService.sharedManager + + NSNotificationCenter.defaultCenter().addObserver(self, selector: "updateAddress", name: "YepLocationUpdated", object: nil) + } + + func updateAvatar() { avatarImageView.alpha = 0 if let avatarURLString = YepUserDefaults.avatarURLString() { AvatarCache.sharedInstance.avatarFromURL(NSURL(string: avatarURLString)!) { image in @@ -41,10 +42,6 @@ class ProfileHeaderCell: UICollectionViewCell { } } } - - YepLocationService.sharedManager - - NSNotificationCenter.defaultCenter().addObserver(self, selector: "updateAddress", name: "YepLocationUpdated", object: nil) } func updateAddress() { @@ -54,9 +51,4 @@ class ProfileHeaderCell: UICollectionViewCell { self.locationLabel.text = YepLocationService.sharedManager.address } - func tryChangeAvatar() { - if let changeAvatarAction = changeAvatarAction { - changeAvatarAction() - } - } } diff --git a/Yep/Views/Cells/SettingsUser/SettingsUserCell.swift b/Yep/Views/Cells/SettingsUser/SettingsUserCell.swift index 5c492bc6..026a86ea 100644 --- a/Yep/Views/Cells/SettingsUser/SettingsUserCell.swift +++ b/Yep/Views/Cells/SettingsUser/SettingsUserCell.swift @@ -25,18 +25,8 @@ class SettingsUserCell: UITableViewCell { let avatarSize = YepConfig.Settings.userCellAvatarSize avatarImageViewWidthConstraint.constant = avatarSize - - if let avatarURLString = YepUserDefaults.avatarURLString() { - AvatarCache.sharedInstance.roundAvatarWithAvatarURLString(avatarURLString, withRadius: avatarSize * 0.5) { image in - dispatch_async(dispatch_get_main_queue()) { - self.avatarImageView.image = image - UIView.animateWithDuration(0.2, delay: 0.0, options: .CurveEaseOut, animations: { () -> Void in - self.avatarImageView.alpha = 1 - }, completion: { (finished) -> Void in - }) - } - } - } + + updateAvatar() nameLabel.text = YepUserDefaults.nickname() @@ -46,6 +36,26 @@ class SettingsUserCell: UITableViewCell { } + func updateAvatar() { + + if let avatarURLString = YepUserDefaults.avatarURLString() { + + let avatarSize = YepConfig.Settings.userCellAvatarSize + + avatarImageView.alpha = 0 + AvatarCache.sharedInstance.roundAvatarWithAvatarURLString(avatarURLString, withRadius: avatarSize * 0.5) { image in + dispatch_async(dispatch_get_main_queue()) { + self.avatarImageView.image = image + + UIView.animateWithDuration(0.2, delay: 0.0, options: .CurveEaseOut, animations: { () -> Void in + self.avatarImageView.alpha = 1 + }, completion: { (finished) -> Void in + }) + } + } + } + } + override func setSelected(selected: Bool, animated: Bool) { super.setSelected(selected, animated: animated) From 712a090d504d8f15c10772829a3afa49c25a95f1 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Mon, 27 Apr 2015 17:16:58 +0800 Subject: [PATCH 14/14] update avatar in cells --- .../Profile/ProfileViewController.swift | 11 ----------- .../Settings/SettingsViewController.swift | 11 +---------- Yep/Views/Cells/ProfileHeader/ProfileHeaderCell.swift | 4 ++++ Yep/Views/Cells/SettingsUser/SettingsUserCell.swift | 5 +++++ 4 files changed, 10 insertions(+), 21 deletions(-) diff --git a/Yep/ViewControllers/Profile/ProfileViewController.swift b/Yep/ViewControllers/Profile/ProfileViewController.swift index 3574f321..2e677778 100644 --- a/Yep/ViewControllers/Profile/ProfileViewController.swift +++ b/Yep/ViewControllers/Profile/ProfileViewController.swift @@ -41,16 +41,10 @@ class ProfileViewController: UIViewController { return ceil(rect.height) + 4 }() - - deinit { - NSNotificationCenter.defaultCenter().removeObserver(self) - } override func viewDidLoad() { super.viewDidLoad() - NSNotificationCenter.defaultCenter().addObserver(self, selector: "reloadProfileCollectionView", name: YepUpdatedProfileAvatarNotification, object: nil) - profileCollectionView.registerNib(UINib(nibName: skillCellIdentifier, bundle: nil), forCellWithReuseIdentifier: skillCellIdentifier) profileCollectionView.registerNib(UINib(nibName: headerCellIdentifier, bundle: nil), forCellWithReuseIdentifier: headerCellIdentifier) profileCollectionView.registerNib(UINib(nibName: footerCellIdentifier, bundle: nil), forCellWithReuseIdentifier: footerCellIdentifier) @@ -109,9 +103,6 @@ class ProfileViewController: UIViewController { return UIStatusBarStyle.LightContent } - func reloadProfileCollectionView() { - profileCollectionView.reloadData() - } } // MARK: UICollectionView @@ -157,8 +148,6 @@ extension ProfileViewController: UICollectionViewDataSource, UICollectionViewDel case ProfileSection.Header.rawValue: let cell = collectionView.dequeueReusableCellWithReuseIdentifier(headerCellIdentifier, forIndexPath: indexPath) as! ProfileHeaderCell - cell.updateAvatar() - cell.nameLabel.text = YepUserDefaults.nickname() return cell diff --git a/Yep/ViewControllers/Settings/SettingsViewController.swift b/Yep/ViewControllers/Settings/SettingsViewController.swift index f669c74c..c6a31f84 100644 --- a/Yep/ViewControllers/Settings/SettingsViewController.swift +++ b/Yep/ViewControllers/Settings/SettingsViewController.swift @@ -24,24 +24,16 @@ class SettingsViewController: UIViewController { let introAttributes = [NSFontAttributeName: YepConfig.Settings.introFont] - deinit { - NSNotificationCenter.defaultCenter().removeObserver(self) - } - + override func viewDidLoad() { super.viewDidLoad() title = NSLocalizedString("Settings", comment: "") - NSNotificationCenter.defaultCenter().addObserver(self, selector: "reloadSettingsTableView", name: YepUpdatedProfileAvatarNotification, object: nil) - settingsTableView.registerNib(UINib(nibName: settingsUserCellIdentifier, bundle: nil), forCellReuseIdentifier: settingsUserCellIdentifier) settingsTableView.registerNib(UINib(nibName: settingsMoreCellIdentifier, bundle: nil), forCellReuseIdentifier: settingsMoreCellIdentifier) } - func reloadSettingsTableView() { - settingsTableView.reloadData() - } } extension SettingsViewController: UITableViewDataSource, UITableViewDelegate { @@ -72,7 +64,6 @@ extension SettingsViewController: UITableViewDataSource, UITableViewDelegate { case Section.User.rawValue: let cell = tableView.dequeueReusableCellWithIdentifier(settingsUserCellIdentifier) as! SettingsUserCell cell.introLabel.text = intro - cell.updateAvatar() return cell case Section.More.rawValue: diff --git a/Yep/Views/Cells/ProfileHeader/ProfileHeaderCell.swift b/Yep/Views/Cells/ProfileHeader/ProfileHeaderCell.swift index 8b583fa4..7ab387aa 100644 --- a/Yep/Views/Cells/ProfileHeader/ProfileHeaderCell.swift +++ b/Yep/Views/Cells/ProfileHeader/ProfileHeaderCell.swift @@ -15,6 +15,9 @@ class ProfileHeaderCell: UICollectionViewCell { @IBOutlet weak var joinedDateLabel: UILabel! @IBOutlet weak var locationLabel: UILabel! + deinit { + NSNotificationCenter.defaultCenter().removeObserver(self) + } override func awakeFromNib() { super.awakeFromNib() @@ -23,6 +26,7 @@ class ProfileHeaderCell: UICollectionViewCell { joinedDateLabel.hidden = true updateAvatar() + NSNotificationCenter.defaultCenter().addObserver(self, selector: "updateAvatar", name: YepUpdatedProfileAvatarNotification, object: nil) YepLocationService.sharedManager diff --git a/Yep/Views/Cells/SettingsUser/SettingsUserCell.swift b/Yep/Views/Cells/SettingsUser/SettingsUserCell.swift index 026a86ea..dbbc823c 100644 --- a/Yep/Views/Cells/SettingsUser/SettingsUserCell.swift +++ b/Yep/Views/Cells/SettingsUser/SettingsUserCell.swift @@ -20,6 +20,10 @@ class SettingsUserCell: UITableViewCell { @IBOutlet weak var accessoryImageView: UIImageView! + deinit { + NSNotificationCenter.defaultCenter().removeObserver(self) + } + override func awakeFromNib() { super.awakeFromNib() @@ -27,6 +31,7 @@ class SettingsUserCell: UITableViewCell { avatarImageViewWidthConstraint.constant = avatarSize updateAvatar() + NSNotificationCenter.defaultCenter().addObserver(self, selector: "updateAvatar", name: YepUpdatedProfileAvatarNotification, object: nil) nameLabel.text = YepUserDefaults.nickname()