Skip to content

Commit

Permalink
WOO THINGS LOOK AWESOME WITH A NEW FAVORITES TAB AND MOST RATED TAB
Browse files Browse the repository at this point in the history
  • Loading branch information
Pascal Sturmfels committed Oct 28, 2016
1 parent 67c5772 commit 4991a8b
Show file tree
Hide file tree
Showing 14 changed files with 154 additions and 131 deletions.
22 changes: 5 additions & 17 deletions Anonymouse/Anonymouse.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@
1A692BBB1DAE964D00C03E1A /* AnonymouseDataController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A692BBA1DAE964D00C03E1A /* AnonymouseDataController.swift */; };
1A932A551DB3CAC7004294A9 /* AnonymouseMessageSentCore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A932A541DB3CAC7004294A9 /* AnonymouseMessageSentCore.swift */; };
1A932A591DB3D37A004294A9 /* AnonymouseDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A932A581DB3D37A004294A9 /* AnonymouseDetailViewController.swift */; };
1A95BFBB1D98B29D00A4CF92 /* AnonymouseComposeNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A95BFBA1D98B29D00A4CF92 /* AnonymouseComposeNavigationController.swift */; };
1A9CE5A71DAFBEC8000AD6C0 /* DefaultPreferences.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1A9CE5A61DAFBEC8000AD6C0 /* DefaultPreferences.plist */; };
1AA4D8701D9AAEE0007AB8D1 /* AnonymouseSettingsNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AA4D86F1D9AAEE0007AB8D1 /* AnonymouseSettingsNavigationController.swift */; };
1ABE12D51C9744D0005923BA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ABE12D41C9744D0005923BA /* AppDelegate.swift */; };
1ABE12D71C9744D0005923BA /* AnonymouseTableNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ABE12D61C9744D0005923BA /* AnonymouseTableNavigationController.swift */; };
1ABE12DE1C9744D0005923BA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1ABE12DD1C9744D0005923BA /* Assets.xcassets */; };
1ABE12E11C9744D0005923BA /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1ABE12DF1C9744D0005923BA /* LaunchScreen.storyboard */; };
1ABE12EA1C9750A6005923BA /* AnonymouseTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ABE12E91C9750A6005923BA /* AnonymouseTableViewController.swift */; };
Expand Down Expand Up @@ -85,12 +82,9 @@
1A692BBA1DAE964D00C03E1A /* AnonymouseDataController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnonymouseDataController.swift; sourceTree = "<group>"; };
1A932A541DB3CAC7004294A9 /* AnonymouseMessageSentCore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnonymouseMessageSentCore.swift; sourceTree = "<group>"; };
1A932A581DB3D37A004294A9 /* AnonymouseDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnonymouseDetailViewController.swift; sourceTree = "<group>"; };
1A95BFBA1D98B29D00A4CF92 /* AnonymouseComposeNavigationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnonymouseComposeNavigationController.swift; sourceTree = "<group>"; };
1A9CE5A61DAFBEC8000AD6C0 /* DefaultPreferences.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = DefaultPreferences.plist; sourceTree = "<group>"; };
1AA4D86F1D9AAEE0007AB8D1 /* AnonymouseSettingsNavigationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnonymouseSettingsNavigationController.swift; sourceTree = "<group>"; };
1ABE12D11C9744D0005923BA /* Anonymouse.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Anonymouse.app; sourceTree = BUILT_PRODUCTS_DIR; };
1ABE12D41C9744D0005923BA /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
1ABE12D61C9744D0005923BA /* AnonymouseTableNavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnonymouseTableNavigationController.swift; sourceTree = "<group>"; };
1ABE12DD1C9744D0005923BA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
1ABE12E01C9744D0005923BA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
1ABE12E21C9744D0005923BA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -130,7 +124,6 @@
children = (
1A5BA78D1D999FD1005000D5 /* AnonymouseSettingsViewController.swift */,
172EA8A11D9788DA00D2E127 /* AnonymouseProfileViewController.swift */,
1ABE12ED1C97521C005923BA /* AnonymouseTableViewCell.swift */,
1AF2D0661C97856300670C89 /* AnonymouseComposeViewController.swift */,
1ABE12E91C9750A6005923BA /* AnonymouseTableViewController.swift */,
1A932A581DB3D37A004294A9 /* AnonymouseDetailViewController.swift */,
Expand Down Expand Up @@ -158,15 +151,12 @@
name = Connection;
sourceTree = "<group>";
};
1A932A571DB3CB4A004294A9 /* NavigationControllers */ = {
1A932A571DB3CB4A004294A9 /* Views */ = {
isa = PBXGroup;
children = (
1AFEDAE51D986BBC00690EB5 /* AnonymouseTabBarController.swift */,
1ABE12D61C9744D0005923BA /* AnonymouseTableNavigationController.swift */,
1A95BFBA1D98B29D00A4CF92 /* AnonymouseComposeNavigationController.swift */,
1AA4D86F1D9AAEE0007AB8D1 /* AnonymouseSettingsNavigationController.swift */,
1ABE12ED1C97521C005923BA /* AnonymouseTableViewCell.swift */,
);
name = NavigationControllers;
name = Views;
sourceTree = "<group>";
};
1ABE12C81C9744D0005923BA = {
Expand All @@ -191,9 +181,10 @@
children = (
1ABE12D41C9744D0005923BA /* AppDelegate.swift */,
1AD52A951D9964A9000F13DE /* AnonymouseNavigationStyleController.swift */,
1AFEDAE51D986BBC00690EB5 /* AnonymouseTabBarController.swift */,
1A932A521DB3CA7A004294A9 /* ViewControllers */,
1A932A501DB3CA58004294A9 /* Model */,
1A932A571DB3CB4A004294A9 /* NavigationControllers */,
1A932A571DB3CB4A004294A9 /* Views */,
1ABE12DD1C9744D0005923BA /* Assets.xcassets */,
1ABE12DF1C9744D0005923BA /* LaunchScreen.storyboard */,
1ABE12E21C9744D0005923BA /* Info.plist */,
Expand Down Expand Up @@ -315,7 +306,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
1AA4D8701D9AAEE0007AB8D1 /* AnonymouseSettingsNavigationController.swift in Sources */,
1A692BBB1DAE964D00C03E1A /* AnonymouseDataController.swift in Sources */,
1ABE12EE1C97521C005923BA /* AnonymouseTableViewCell.swift in Sources */,
1AD52A961D9964A9000F13DE /* AnonymouseNavigationStyleController.swift in Sources */,
Expand All @@ -326,8 +316,6 @@
1AF2D0671C97856300670C89 /* AnonymouseComposeViewController.swift in Sources */,
1ABE12D51C9744D0005923BA /* AppDelegate.swift in Sources */,
1ABE12F21C9756A2005923BA /* AnonymouseConnectivityController.swift in Sources */,
1A95BFBB1D98B29D00A4CF92 /* AnonymouseComposeNavigationController.swift in Sources */,
1ABE12D71C9744D0005923BA /* AnonymouseTableNavigationController.swift in Sources */,
1ABE12EA1C9750A6005923BA /* AnonymouseTableViewController.swift in Sources */,
172EA8A21D9788DA00D2E127 /* AnonymouseProfileViewController.swift in Sources */,
1A932A551DB3CAC7004294A9 /* AnonymouseMessageSentCore.swift in Sources */,
Expand Down
38 changes: 0 additions & 38 deletions Anonymouse/Anonymouse/AnonymouseComposeNavigationController.swift

This file was deleted.

19 changes: 19 additions & 0 deletions Anonymouse/Anonymouse/AnonymouseComposeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class AnonymouseComposeViewController: UIViewController, UITextViewDelegate {
weak var dataController: AnonymouseDataController!
weak var connectivityController: AnonymouseConnectivityController!

//MARK: Navigation
override func viewDidLoad() {
self.view.backgroundColor = UIColor.white

Expand All @@ -31,6 +32,11 @@ class AnonymouseComposeViewController: UIViewController, UITextViewDelegate {

self.title = "Post to Feed"

self.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.cancel, target: self, action: #selector(AnonymouseComposeViewController.cancelTapped))

self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Post", style: .done, target: self, action: #selector(AnonymouseComposeViewController.postTapped))
self.navigationItem.rightBarButtonItem!.isEnabled = false

composeTextView.frame = CGRect(x: CGFloat(textViewMargins), y: 0, width: self.view.bounds.width - CGFloat(textViewMargins), height: self.view.bounds.height)
composeTextView.delegate = self
composeTextView.text = ""
Expand Down Expand Up @@ -60,6 +66,19 @@ class AnonymouseComposeViewController: UIViewController, UITextViewDelegate {
composeTextView.resignFirstResponder()
}

func cancelTapped() {
self.dismiss(animated: true) { () -> Void in
self.clearText()
}
}

func postTapped() {
self.dismiss(animated: true) { () -> Void in
self.post()
}
}

//MARK: TextView Methods
func textViewDidChange(_ textView: UITextView) {
placeholderLabel.isHidden = !textView.text.isEmpty
if textView.text.characters.count > 0 {
Expand Down
8 changes: 6 additions & 2 deletions Anonymouse/Anonymouse/AnonymouseDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ class AnonymouseDetailViewController: UIViewController {
}

override func viewWillDisappear(_ animated: Bool) {
if let parentNavigationController = self.navigationController as? AnonymouseTableNavigationController {
parentNavigationController.tableViewController.tableView.reloadData()
if let parentNavigationController = self.navigationController as? AnonymouseNavigationStyleController {
if let tableVC = parentNavigationController.viewControllers[0] as? AnonymouseTableViewController {
tableVC.tableView.reloadData()
return
}
}
abort()
}
}
20 changes: 0 additions & 20 deletions Anonymouse/Anonymouse/AnonymouseSettingsNavigationController.swift

This file was deleted.

74 changes: 61 additions & 13 deletions Anonymouse/Anonymouse/AnonymouseTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,71 @@
//

import UIKit
import CoreData

class AnonymouseTabBarController: UITabBarController, UITabBarControllerDelegate {
var tableNavigationController: AnonymouseTableNavigationController = AnonymouseTableNavigationController()
var settingsNavigationController: AnonymouseSettingsNavigationController = AnonymouseSettingsNavigationController()
var composeNavigationController: AnonymouseNavigationStyleController = AnonymouseNavigationStyleController()

override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self

let composeViewController: AnonymouseComposeViewController = AnonymouseComposeViewController()
composeNavigationController.viewControllers = [composeViewController]

let mostRecentFetchRequest: NSFetchRequest<AnonymouseMessageCore> = NSFetchRequest<AnonymouseMessageCore>(entityName: "AnonymouseMessageCore")
let mostRecentSortDescriptor: NSSortDescriptor = NSSortDescriptor(key: "date", ascending: false)
mostRecentFetchRequest.sortDescriptors = [mostRecentSortDescriptor]

let favoriteFetchRequest: NSFetchRequest<AnonymouseMessageCore> = NSFetchRequest<AnonymouseMessageCore>(entityName: "AnonymouseMessageCore")
let favoriteSortDescriptor: NSSortDescriptor = NSSortDescriptor(key: "date", ascending: false)
favoriteFetchRequest.sortDescriptors = [favoriteSortDescriptor]
let favoritePredicate: NSPredicate = NSPredicate(format: "isFavorite == %@", NSNumber(booleanLiteral: true))
favoriteFetchRequest.predicate = favoritePredicate

let bestRatedFetchRequest: NSFetchRequest<AnonymouseMessageCore> = NSFetchRequest<AnonymouseMessageCore>(entityName: "AnonymouseMessageCore")
let bestRatedSortDescriptor: NSSortDescriptor = NSSortDescriptor(key: "rating", ascending: false)
bestRatedFetchRequest.sortDescriptors = [bestRatedSortDescriptor, mostRecentSortDescriptor]

let mostRecentTableViewController: AnonymouseTableViewController = AnonymouseTableViewController(withFetchRequest: mostRecentFetchRequest)
let favoriteTableViewController: AnonymouseTableViewController = AnonymouseTableViewController(withFetchRequest: favoriteFetchRequest)
let bestRatedTableViewController: AnonymouseTableViewController = AnonymouseTableViewController(withFetchRequest: bestRatedFetchRequest)

mostRecentTableViewController.title = "Most Recent"
favoriteTableViewController.title = "Favorites"
bestRatedTableViewController.title = "Top Rated"

let composeButtonA = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.compose, target: self, action: #selector(AnonymouseTabBarController.compose))
let composeButtonB = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.compose, target: self, action: #selector(AnonymouseTabBarController.compose))
let composeButtonC = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.compose, target: self, action: #selector(AnonymouseTabBarController.compose))
mostRecentTableViewController.navigationItem.rightBarButtonItem = composeButtonA
favoriteTableViewController.navigationItem.rightBarButtonItem = composeButtonB
bestRatedTableViewController.navigationItem.rightBarButtonItem = composeButtonC

let mostRecentNavigationController: AnonymouseNavigationStyleController = AnonymouseNavigationStyleController()
let favoriteNavigationController: AnonymouseNavigationStyleController = AnonymouseNavigationStyleController()
let bestRatedNavigationController: AnonymouseNavigationStyleController = AnonymouseNavigationStyleController()
mostRecentNavigationController.viewControllers = [mostRecentTableViewController]
favoriteNavigationController.viewControllers = [favoriteTableViewController]
bestRatedNavigationController.viewControllers = [bestRatedTableViewController]

mostRecentNavigationController.tabBarItem = UITabBarItem(tabBarSystemItem: UITabBarSystemItem.mostRecent, tag: 0)
favoriteNavigationController.tabBarItem = UITabBarItem(tabBarSystemItem: UITabBarSystemItem.favorites, tag: 1)

let bestRatedTabBarItem = UITabBarItem(title: "Top Rated", image: UIImage(named: "upvoteEmptyTab"), selectedImage: UIImage(named: "upvoteFilledTab"))
bestRatedTabBarItem.tag = 2
bestRatedNavigationController.tabBarItem = bestRatedTabBarItem

let settingsTabBarItem = UITabBarItem(title: "Settings", image: UIImage(named: "settingsIconEmpty"), selectedImage: UIImage(named: "settingsIconFilled"))
settingsTabBarItem.tag = 3
let settingsNavigationController: AnonymouseNavigationStyleController = AnonymouseNavigationStyleController()
let settingsViewController: AnonymouseSettingsViewController = AnonymouseSettingsViewController(style: UITableViewStyle.grouped)
settingsNavigationController.viewControllers = [settingsViewController]
settingsNavigationController.tabBarItem = settingsTabBarItem

self.viewControllers = [mostRecentNavigationController, favoriteNavigationController, bestRatedNavigationController, settingsNavigationController]
self.selectedIndex = 0

let gradientLayer: CAGradientLayer = CAGradientLayer()
gradientLayer.frame = self.tabBar.bounds

Expand All @@ -30,19 +86,11 @@ class AnonymouseTabBarController: UITabBarController, UITabBarControllerDelegate
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()


self.tabBar.backgroundImage = image
self.tabBar.tintColor = UIColor.white

tableNavigationController.tabBarItem = UITabBarItem(tabBarSystemItem: UITabBarSystemItem.mostRecent, tag: 0)

let settingsTabBarItem = UITabBarItem(title: "Settings", image: UIImage(named: "settingsIconEmpty"), selectedImage: UIImage(named: "settingsIconFilled"))
settingsTabBarItem.tag = 1

settingsNavigationController.tabBarItem = settingsTabBarItem

self.viewControllers = [tableNavigationController, settingsNavigationController]
self.selectedIndex = 0
}

func compose() {
self.present(composeNavigationController, animated: true, completion: nil)
}
}
32 changes: 0 additions & 32 deletions Anonymouse/Anonymouse/AnonymouseTableNavigationController.swift

This file was deleted.

Loading

0 comments on commit 4991a8b

Please sign in to comment.