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 @@ - +