diff --git a/Yep.xcodeproj/project.pbxproj b/Yep.xcodeproj/project.pbxproj index ad8b8868..45f09558 100644 --- a/Yep.xcodeproj/project.pbxproj +++ b/Yep.xcodeproj/project.pbxproj @@ -181,6 +181,8 @@ 50A640E01B6F38CF0050E4A3 /* NotificationsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A640DF1B6F38CF0050E4A3 /* NotificationsViewController.swift */; }; 50A640E51B6F41E00050E4A3 /* DoNotDisturbSwitchCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A640E31B6F41E00050E4A3 /* DoNotDisturbSwitchCell.swift */; }; 50A640E61B6F41E00050E4A3 /* DoNotDisturbSwitchCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50A640E41B6F41E00050E4A3 /* DoNotDisturbSwitchCell.xib */; }; + 50A640E91B6F45FA0050E4A3 /* DoNotDisturbPeriodCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A640E71B6F45FA0050E4A3 /* DoNotDisturbPeriodCell.swift */; }; + 50A640EA1B6F45FA0050E4A3 /* DoNotDisturbPeriodCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50A640E81B6F45FA0050E4A3 /* DoNotDisturbPeriodCell.xib */; }; 50A9D44B1ACD37A8000B2599 /* NSFileManager+Yep.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A9D44A1ACD37A8000B2599 /* NSFileManager+Yep.swift */; }; 50A9D44E1ACD382B000B2599 /* NSDateTimeAgo.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 50A9D44C1ACD382B000B2599 /* NSDateTimeAgo.bundle */; }; 50A9D4511ACD383E000B2599 /* NSDate+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A9D4501ACD383E000B2599 /* NSDate+Extension.swift */; }; @@ -413,6 +415,8 @@ 50A640DF1B6F38CF0050E4A3 /* NotificationsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NotificationsViewController.swift; path = ViewControllers/Notifications/NotificationsViewController.swift; sourceTree = ""; }; 50A640E31B6F41E00050E4A3 /* DoNotDisturbSwitchCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DoNotDisturbSwitchCell.swift; path = Views/Cells/DoNotDisturb/DoNotDisturbSwitchCell.swift; sourceTree = ""; }; 50A640E41B6F41E00050E4A3 /* DoNotDisturbSwitchCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = DoNotDisturbSwitchCell.xib; path = Views/Cells/DoNotDisturb/DoNotDisturbSwitchCell.xib; sourceTree = ""; }; + 50A640E71B6F45FA0050E4A3 /* DoNotDisturbPeriodCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DoNotDisturbPeriodCell.swift; path = Views/Cells/DoNotDisturb/DoNotDisturbPeriodCell.swift; sourceTree = ""; }; + 50A640E81B6F45FA0050E4A3 /* DoNotDisturbPeriodCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = DoNotDisturbPeriodCell.xib; path = Views/Cells/DoNotDisturb/DoNotDisturbPeriodCell.xib; sourceTree = ""; }; 50A9D44A1ACD37A8000B2599 /* NSFileManager+Yep.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "NSFileManager+Yep.swift"; path = "Extensions/NSFileManager+Yep.swift"; sourceTree = ""; }; 50A9D44C1ACD382B000B2599 /* NSDateTimeAgo.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = NSDateTimeAgo.bundle; path = Extensions/NSDateTimeAgo.bundle; sourceTree = ""; }; 50A9D4501ACD383E000B2599 /* NSDate+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "NSDate+Extension.swift"; path = "Extensions/NSDate+Extension.swift"; sourceTree = ""; }; @@ -1369,6 +1373,8 @@ children = ( 50A640E31B6F41E00050E4A3 /* DoNotDisturbSwitchCell.swift */, 50A640E41B6F41E00050E4A3 /* DoNotDisturbSwitchCell.xib */, + 50A640E71B6F45FA0050E4A3 /* DoNotDisturbPeriodCell.swift */, + 50A640E81B6F45FA0050E4A3 /* DoNotDisturbPeriodCell.xib */, ); name = DoNotDisturb; sourceTree = ""; @@ -1657,6 +1663,7 @@ 508F8FDF1B049ACF00461B0B /* InstagramMediaCell.xib in Resources */, 50E114FD1ABC549300F13000 /* ContactsCell.xib in Resources */, 502AE54F1AB93175005BD199 /* ProfileHeaderCell.xib in Resources */, + 50A640EA1B6F45FA0050E4A3 /* DoNotDisturbPeriodCell.xib in Resources */, 0A8F54BB1AB67D11004AD60E /* LaunchScreen.xib in Resources */, 5053AD511AF82A1700B3CBFA /* PickLocationCell.xib in Resources */, 5053AD5B1AF83B4200B3CBFA /* ChatLeftLocationCell.xib in Resources */, @@ -1890,6 +1897,7 @@ 0A90187E1B01152800AE4B7F /* ProfileSocialAccountCell.swift in Sources */, 50894CF51AEA4A01000981AF /* SettingsUserCell.swift in Sources */, 5053AD5A1AF83B4200B3CBFA /* ChatLeftLocationCell.swift in Sources */, + 50A640E91B6F45FA0050E4A3 /* DoNotDisturbPeriodCell.swift in Sources */, 508F8FD01B01D04400461B0B /* GithubRepoCell.swift in Sources */, 50F2B97B1B2EEAF800F840CC /* NavigationTitleLabel.swift in Sources */, 504F415A1AD5028200FBB19A /* SkillCell.swift in Sources */, diff --git a/Yep/ViewControllers/Notifications/NotificationsViewController.swift b/Yep/ViewControllers/Notifications/NotificationsViewController.swift index 6beb91f7..1c583263 100644 --- a/Yep/ViewControllers/Notifications/NotificationsViewController.swift +++ b/Yep/ViewControllers/Notifications/NotificationsViewController.swift @@ -15,13 +15,14 @@ class NotificationsViewController: UIViewController { struct DoNotDisturbPeriod { var isOn: Bool = false - var start: String = "22:00" - var end: String = "07:00" + var from: String = "22:00" + var to: String = "07:00" } var doNotDisturbPeriod = DoNotDisturbPeriod() let DoNotDisturbSwitchCellID = "DoNotDisturbSwitchCell" + let DoNotDisturbPeriodCellID = "DoNotDisturbPeriodCell" override func viewDidLoad() { super.viewDidLoad() @@ -29,6 +30,7 @@ class NotificationsViewController: UIViewController { title = NSLocalizedString("Notifications", comment: "") tableView.registerNib(UINib(nibName: DoNotDisturbSwitchCellID, bundle: nil), forCellReuseIdentifier: DoNotDisturbSwitchCellID) + tableView.registerNib(UINib(nibName: DoNotDisturbPeriodCellID, bundle: nil), forCellReuseIdentifier: DoNotDisturbPeriodCellID) } } @@ -36,21 +38,59 @@ class NotificationsViewController: UIViewController { extension NotificationsViewController: UITableViewDataSource, UITableViewDelegate { + enum DoNotDisturbPeriodRow: Int { + case Switch + case Period + } + func numberOfSectionsInTableView(tableView: UITableView) -> Int { return 1 } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return doNotDisturbPeriod.isOn ? 2 : 1 + return 2 +// return doNotDisturbPeriod.isOn ? 2 : 1 } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCellWithIdentifier(DoNotDisturbSwitchCellID) as! DoNotDisturbSwitchCell - cell.promptLabel.text = NSLocalizedString("Do Not Disturb", comment: "") - cell.toggleSwitch.on = doNotDisturbPeriod.isOn + switch indexPath.row { - return cell + case DoNotDisturbPeriodRow.Switch.rawValue: + let cell = tableView.dequeueReusableCellWithIdentifier(DoNotDisturbSwitchCellID) as! DoNotDisturbSwitchCell + cell.promptLabel.text = NSLocalizedString("Do Not Disturb", comment: "") + cell.toggleSwitch.on = doNotDisturbPeriod.isOn + + return cell + + case DoNotDisturbPeriodRow.Period.rawValue: + let cell = tableView.dequeueReusableCellWithIdentifier(DoNotDisturbPeriodCellID) as! DoNotDisturbPeriodCell + cell.fromPromptLabel.text = NSLocalizedString("From", comment: "") + cell.toPromptLabel.text = NSLocalizedString("To", comment: "") + + cell.fromLabel.text = doNotDisturbPeriod.from + cell.toLabel.text = doNotDisturbPeriod.to + + return cell + + default: + return UITableViewCell() + } + } + + func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { + + switch indexPath.row { + + case DoNotDisturbPeriodRow.Switch.rawValue: + return 44 + + case DoNotDisturbPeriodRow.Period.rawValue: + return 60 + + default: + return 0 + } } } diff --git a/Yep/Views/Cells/DoNotDisturb/DoNotDisturbPeriodCell.swift b/Yep/Views/Cells/DoNotDisturb/DoNotDisturbPeriodCell.swift new file mode 100644 index 00000000..cb772f1b --- /dev/null +++ b/Yep/Views/Cells/DoNotDisturb/DoNotDisturbPeriodCell.swift @@ -0,0 +1,34 @@ +// +// DoNotDisturbPeriodCell.swift +// +// +// Created by NIX on 15/8/3. +// +// + +import UIKit + +class DoNotDisturbPeriodCell: UITableViewCell { + + @IBOutlet weak var fromPromptLabel: UILabel! + + @IBOutlet weak var toPromptLabel: UILabel! + + @IBOutlet weak var fromLabel: UILabel! + + @IBOutlet weak var toLabel: 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/DoNotDisturb/DoNotDisturbPeriodCell.xib b/Yep/Views/Cells/DoNotDisturb/DoNotDisturbPeriodCell.xib new file mode 100644 index 00000000..362a85c0 --- /dev/null +++ b/Yep/Views/Cells/DoNotDisturb/DoNotDisturbPeriodCell.xib @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +