diff --git a/Yep.xcodeproj/project.pbxproj b/Yep.xcodeproj/project.pbxproj index 13ea51d7..88034a2e 100644 --- a/Yep.xcodeproj/project.pbxproj +++ b/Yep.xcodeproj/project.pbxproj @@ -94,6 +94,18 @@ 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 */; }; + 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 */; }; + 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 */; }; + 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 */; }; @@ -241,6 +253,18 @@ 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 = ""; }; + 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 = ""; }; + 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 = ""; }; + 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 = ""; }; @@ -433,6 +457,8 @@ 502AE51F1AB712D6005BD199 /* Register */, 502AE5361AB864A3005BD199 /* Login */, 0A5D83951AC5D3CD000045BF /* TabBar */, + 50894CF21AEA472B000981AF /* Settings */, + 50894CFF1AEA5A7E000981AF /* EditProfile */, ); name = ViewControllers; sourceTree = ""; @@ -524,6 +550,11 @@ 505EC81E1ADFBE1F001D27E0 /* SkillSelection */, 50EB8CC11AE89EDE001AC1EE /* ChatLeftVideo */, 50EB8CC61AE89F15001AC1EE /* ChatRightVideo */, + 50894CF71AEA4A04000981AF /* SettingsUser */, + 50894CFC1AEA54BE000981AF /* SettingsMore */, + 50894D041AEA6439000981AF /* EditProfileLessInfo */, + 50894D091AEDFDA6000981AF /* EditProfileMoreInfo */, + 50894D0E1AEE017B000981AF /* EditProfileColoredTitle */, ); name = Cells; sourceTree = ""; @@ -758,6 +789,67 @@ name = SkillAnnotationHeader; sourceTree = ""; }; + 50894CF21AEA472B000981AF /* Settings */ = { + isa = PBXGroup; + children = ( + 50894CF01AEA4726000981AF /* SettingsViewController.swift */, + ); + name = Settings; + sourceTree = ""; + }; + 50894CF71AEA4A04000981AF /* SettingsUser */ = { + isa = PBXGroup; + children = ( + 50894CF31AEA4A01000981AF /* SettingsUserCell.swift */, + 50894CF41AEA4A01000981AF /* SettingsUserCell.xib */, + ); + name = SettingsUser; + sourceTree = ""; + }; + 50894CFC1AEA54BE000981AF /* SettingsMore */ = { + isa = PBXGroup; + children = ( + 50894CF81AEA54BA000981AF /* SettingsMoreCell.swift */, + 50894CF91AEA54BA000981AF /* SettingsMoreCell.xib */, + ); + name = SettingsMore; + sourceTree = ""; + }; + 50894CFF1AEA5A7E000981AF /* EditProfile */ = { + isa = PBXGroup; + children = ( + 50894CFD1AEA5A78000981AF /* EditProfileViewController.swift */, + ); + name = EditProfile; + sourceTree = ""; + }; + 50894D041AEA6439000981AF /* EditProfileLessInfo */ = { + isa = PBXGroup; + children = ( + 50894D001AEA6433000981AF /* EditProfileLessInfoCell.swift */, + 50894D011AEA6433000981AF /* EditProfileLessInfoCell.xib */, + ); + name = EditProfileLessInfo; + sourceTree = ""; + }; + 50894D091AEDFDA6000981AF /* EditProfileMoreInfo */ = { + isa = PBXGroup; + children = ( + 50894D051AEDFDA2000981AF /* EditProfileMoreInfoCell.swift */, + 50894D061AEDFDA2000981AF /* EditProfileMoreInfoCell.xib */, + ); + name = EditProfileMoreInfo; + sourceTree = ""; + }; + 50894D0E1AEE017B000981AF /* EditProfileColoredTitle */ = { + isa = PBXGroup; + children = ( + 50894D0A1AEE0177000981AF /* EditProfileColoredTitleCell.swift */, + 50894D0B1AEE0177000981AF /* EditProfileColoredTitleCell.xib */, + ); + name = EditProfileColoredTitle; + sourceTree = ""; + }; 508C2AA11AD648BE002B8097 /* SearchUsers */ = { isa = PBXGroup; children = ( @@ -1037,12 +1129,15 @@ 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 */, + 50894CFB1AEA54BA000981AF /* SettingsMoreCell.xib in Resources */, 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 */, @@ -1051,9 +1146,11 @@ 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 */, + 50894D031AEA6433000981AF /* EditProfileLessInfoCell.xib in Resources */, 0AD7EA771AC3EEB000617758 /* PushConfig.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1133,6 +1230,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 */, @@ -1153,7 +1251,10 @@ 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 */, + 50894D071AEDFDA2000981AF /* EditProfileMoreInfoCell.swift in Sources */, 50E114F41ABBF9CC00F13000 /* Models.swift in Sources */, 50A9D4571ACD393A000B2599 /* YepWaverView.swift in Sources */, 50165C451AC2860900C7AEBE /* ConversationLayout.swift in Sources */, @@ -1196,6 +1297,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 */, @@ -1215,7 +1317,9 @@ 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 */, + 50894D0C1AEE0177000981AF /* EditProfileColoredTitleCell.swift in Sources */, 5023DE521AB6C51300B3EE96 /* CGRect+Yep.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Yep/Base.lproj/Main.storyboard b/Yep/Base.lproj/Main.storyboard index 67aeb9a1..2e59a44d 100644 --- a/Yep/Base.lproj/Main.storyboard +++ b/Yep/Base.lproj/Main.storyboard @@ -2,6 +2,7 @@ + @@ -70,7 +71,7 @@ - + @@ -412,7 +413,13 @@ - + + + + + + + @@ -421,6 +428,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -548,5 +692,8 @@ + + + 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 { diff --git a/Yep/Configs/YepConfig.swift b/Yep/Configs/YepConfig.swift index c81b685c..624e75da 100644 --- a/Yep/Configs/YepConfig.swift +++ b/Yep/Configs/YepConfig.swift @@ -57,4 +57,22 @@ class YepConfig { class func audioSampleGap() -> CGFloat { return 1 } + + 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 + } + + 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/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 00000000..ececd720 Binary files /dev/null and b/Yep/Images.xcassets/icon_accessory.imageset/icon_accessory.pdf differ 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 00000000..04d94437 Binary files /dev/null and b/Yep/Images.xcassets/icon_profile_phone.imageset/icon_profile_phone.pdf differ 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 00000000..8ccca620 Binary files /dev/null and b/Yep/Images.xcassets/icon_settings.imageset/icon_settings.pdf differ 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 00000000..042970cd Binary files /dev/null and b/Yep/Images.xcassets/profile_avatar_frame.imageset/profile_avatar_frame.pdf differ diff --git a/Yep/ViewControllers/EditProfile/EditProfileViewController.swift b/Yep/ViewControllers/EditProfile/EditProfileViewController.swift new file mode 100644 index 00000000..88d746e2 --- /dev/null +++ b/Yep/ViewControllers/EditProfile/EditProfileViewController.swift @@ -0,0 +1,240 @@ +// +// EditProfileViewController.swift +// Yep +// +// Created by NIX on 15/4/24. +// Copyright (c) 2015年 Catch Inc. All rights reserved. +// + +import UIKit +import Realm + +let YepUpdatedProfileAvatarNotification = "YepUpdatedProfileAvatarNotification" + +class EditProfileViewController: UIViewController { + + @IBOutlet weak var avatarImageView: UIImageView! + @IBOutlet weak var avatarImageViewWidthConstraint: NSLayoutConstraint! + + @IBOutlet weak var mobileLabel: UILabel! + + @IBOutlet weak var editProfileTableView: UITableView! + + + 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() + + title = NSLocalizedString("Edit Profile", comment: "") + + 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 + }) + } + } + } + } + + @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) + } + +} + +extension EditProfileViewController: UITableViewDataSource, UITableViewDelegate { + + enum Section: Int { + case Info + case LogOut + } + + enum InfoRow: Int { + case Name = 0 + case Intro + } + + func numberOfSectionsInTableView(tableView: UITableView) -> Int { + return 2 + } + + func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + + 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 = intro + 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: + return UITableViewCell() + } + } + + func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { + switch indexPath.section { + case Section.Info.rawValue: + + switch indexPath.row { + case InfoRow.Name.rawValue: + return 60 + + case InfoRow.Intro.rawValue: + 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 + } + + case Section.LogOut.rawValue: + return 80 + + default: + return 0 + } + } +} + +// 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 f616f3b3..2e677778 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,6 +41,7 @@ class ProfileViewController: UIViewController { return ceil(rect.height) + 4 }() + override func viewDidLoad() { super.viewDidLoad() @@ -74,6 +73,8 @@ class ProfileViewController: UIViewController { navigationController.navigationBar.titleTextAttributes = textAttributes + navigationItem.rightBarButtonItem?.tintColor = UIColor.whiteColor() + navigationItem.title = YepUserDefaults.nickname() } @@ -101,52 +102,7 @@ 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) - } } // MARK: UICollectionView @@ -194,42 +150,6 @@ extension ProfileViewController: UICollectionViewDataSource, UICollectionViewDel 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 new file mode 100644 index 00000000..c6a31f84 --- /dev/null +++ b/Yep/ViewControllers/Settings/SettingsViewController.swift @@ -0,0 +1,114 @@ +// +// 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! + + 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() + + title = NSLocalizedString("Settings", comment: "") + + settingsTableView.registerNib(UINib(nibName: settingsUserCellIdentifier, bundle: nil), forCellReuseIdentifier: settingsUserCellIdentifier) + settingsTableView.registerNib(UINib(nibName: settingsMoreCellIdentifier, bundle: nil), forCellReuseIdentifier: settingsMoreCellIdentifier) + } + +} + +extension SettingsViewController: UITableViewDataSource, UITableViewDelegate { + + enum Section: Int { + case User = 0 + case More + } + + func numberOfSectionsInTableView(tableView: UITableView) -> Int { + return 2 + } + + func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + switch section { + case Section.User.rawValue: + return 1 + case Section.More.rawValue: + return moreAnnotations.count + 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 + cell.introLabel.text = intro + return cell + + case Section.More.rawValue: + let cell = tableView.dequeueReusableCellWithIdentifier(settingsMoreCellIdentifier) as! SettingsMoreCell + cell.annotationLabel.text = moreAnnotations[indexPath.row] + return cell + + default: + return UITableViewCell() + } + } + + func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { + switch indexPath.section { + + case Section.User.rawValue: + + 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 + } + } + + 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 + } + } +} + 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/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..d8dd6a6b --- /dev/null +++ b/Yep/Views/Cells/EditProfileLessInfo/EditProfileLessInfoCell.xib @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Yep/Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.swift b/Yep/Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.swift new file mode 100644 index 00000000..3cdad17d --- /dev/null +++ b/Yep/Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.swift @@ -0,0 +1,30 @@ +// +// 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() + + infoLabel.font = YepConfig.EditProfile.introFont + } + + 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..137411a6 --- /dev/null +++ b/Yep/Views/Cells/EditProfileMoreInfo/EditProfileMoreInfoCell.xib @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Yep/Views/Cells/ProfileHeader/ProfileHeaderCell.swift b/Yep/Views/Cells/ProfileHeader/ProfileHeaderCell.swift index d5071a46..7ab387aa 100644 --- a/Yep/Views/Cells/ProfileHeader/ProfileHeaderCell.swift +++ b/Yep/Views/Cells/ProfileHeader/ProfileHeaderCell.swift @@ -10,25 +10,30 @@ import UIKit class ProfileHeaderCell: UICollectionViewCell { - var changeAvatarAction: (() -> Void)? - - @IBOutlet weak var avatarImageView: UIImageView! @IBOutlet weak var nameLabel: UILabel! @IBOutlet weak var joinedDateLabel: UILabel! @IBOutlet weak var locationLabel: UILabel! + deinit { + NSNotificationCenter.defaultCenter().removeObserver(self) + } override func awakeFromNib() { super.awakeFromNib() nameLabel.hidden = true joinedDateLabel.hidden = true - - let tap = UITapGestureRecognizer(target: self, action: "tryChangeAvatar") - avatarImageView.userInteractionEnabled = true - avatarImageView.addGestureRecognizer(tap) + updateAvatar() + NSNotificationCenter.defaultCenter().addObserver(self, selector: "updateAvatar", name: YepUpdatedProfileAvatarNotification, object: nil) + + 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 +46,6 @@ class ProfileHeaderCell: UICollectionViewCell { } } } - - YepLocationService.sharedManager - - NSNotificationCenter.defaultCenter().addObserver(self, selector: "updateAddress", name: "YepLocationUpdated", object: nil) } func updateAddress() { @@ -54,9 +55,4 @@ class ProfileHeaderCell: UICollectionViewCell { self.locationLabel.text = YepLocationService.sharedManager.address } - func tryChangeAvatar() { - if let changeAvatarAction = changeAvatarAction { - changeAvatarAction() - } - } } 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Yep/Views/Cells/SettingsUser/SettingsUserCell.swift b/Yep/Views/Cells/SettingsUser/SettingsUserCell.swift new file mode 100644 index 00000000..dbbc823c --- /dev/null +++ b/Yep/Views/Cells/SettingsUser/SettingsUserCell.swift @@ -0,0 +1,70 @@ +// +// 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! + + + deinit { + NSNotificationCenter.defaultCenter().removeObserver(self) + } + + override func awakeFromNib() { + super.awakeFromNib() + + let avatarSize = YepConfig.Settings.userCellAvatarSize + avatarImageViewWidthConstraint.constant = avatarSize + + updateAvatar() + NSNotificationCenter.defaultCenter().addObserver(self, selector: "updateAvatar", name: YepUpdatedProfileAvatarNotification, object: nil) + + nameLabel.text = YepUserDefaults.nickname() + + introLabel.font = YepConfig.Settings.introFont + + accessoryImageView.tintColor = UIColor.lightGrayColor() + + } + + 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) + + // 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..fa0e61be --- /dev/null +++ b/Yep/Views/Cells/SettingsUser/SettingsUserCell.xib @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +