Skip to content

Commit

Permalink
Hotted up news and fixed collapse bug in events
Browse files Browse the repository at this point in the history
  • Loading branch information
purmonen committed Jun 8, 2015
1 parent 0b36973 commit 1fcada4
Show file tree
Hide file tree
Showing 18 changed files with 845 additions and 92 deletions.
Binary file not shown.
6 changes: 3 additions & 3 deletions Teststs/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import UIKit

let armadaBlue = 0x273760
let armadaGreen = 0x1C6965
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

let armadaBlue = 0x273760
let armadaGreen = 0x1C6965


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

Expand Down
1 change: 0 additions & 1 deletion Teststs/ArmadaEventDetailTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class ArmadaEventDetailTableViewController: UITableViewController {
if let selectedArmadaEvent=selectedArmadaEvent{
cell.titleLabel.text = selectedArmadaEvent.title


let monthFormatter = NSDateFormatter()
monthFormatter.dateFormat = "MMM"

Expand Down
11 changes: 9 additions & 2 deletions Teststs/ArmadaEventTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ import UIKit

var selectedArmadaEvent: ArmadaEvent? = nil

class ArmadaEventTableViewController: UITableViewController {
class ArmadaEventTableViewController: UITableViewController, UISplitViewControllerDelegate {

let armadaEvents = [ArmadaEvent]() //DataDude.eventsFromServer() ?? [ArmadaEvent]()
let armadaEvents = DataDude.eventsFromServer() ?? [ArmadaEvent]()
var readArmadaEvents = [String]()

override func viewDidLoad() {
super.viewDidLoad()

splitViewController?.delegate = self

//self.tableView.rowHeight = UITableViewAutomaticDimension
//self.tableView.estimatedRowHeight = 220
//tableView.reloadData()
Expand All @@ -28,6 +31,10 @@ class ArmadaEventTableViewController: UITableViewController {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

func splitViewController(splitViewController: UISplitViewController, collapseSecondaryViewController secondaryViewController: UIViewController!, ontoPrimaryViewController primaryViewController: UIViewController!) -> Bool {
return true
}

// MARK: - Table view data source

Expand Down
661 changes: 640 additions & 21 deletions Teststs/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions Teststs/Images.xcassets/background-1.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "[email protected]"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions Teststs/Images.xcassets/cookies.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "cookies.png"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions Teststs/Images.xcassets/heart-1.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x",
Expand Down
8 changes: 8 additions & 0 deletions Teststs/Images.xcassets/heart.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x",
Expand Down
21 changes: 21 additions & 0 deletions Teststs/Images.xcassets/light_bulb-2.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "light_bulb.png"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions Teststs/Images.xcassets/trees.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "trees.png"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file added Teststs/Images.xcassets/trees.imageset/trees.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions Teststs/Images.xcassets/trees2.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "trees2.png"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
137 changes: 72 additions & 65 deletions Teststs/NewsTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,111 @@ var selectedNewsItem:News!

class NewsTableViewController: UITableViewController {
var readArmadaNews = [String]()
let news = [News]() //DataDude.newsFromServer()!
let news = DataDude.newsFromServer()!


var imageView: UIImageView!

var headerView: UIView!

let headerHeight: CGFloat = 200+64

var headerMaskLayer: CAShapeLayer!

func updateHeaderView() {
var headerRect = CGRect(x: 0, y: -headerHeight, width: tableView.bounds.width, height: headerHeight)
if tableView.contentOffset.y < -headerHeight {
headerRect.origin.y = tableView.contentOffset.y
headerRect.size.height = -tableView.contentOffset.y
}
headerView.frame = headerRect

let path = UIBezierPath()
path.moveToPoint(CGPoint(x: 0, y: 0))
path.addLineToPoint(CGPoint(x: headerRect.width, y: 0))
path.addLineToPoint(CGPoint(x: headerRect.width, y: headerRect.height))
path.addLineToPoint(CGPoint(x: 0, y: headerRect.height-50))
headerMaskLayer?.path = path.CGPath
}

override func scrollViewDidScroll(scrollView: UIScrollView) {
updateHeaderView()
}

override func viewDidLoad() {
super.viewDidLoad()
self.tableView.rowHeight = UITableViewAutomaticDimension
self.tableView.estimatedRowHeight = 200

headerView = tableView.tableHeaderView
tableView.tableHeaderView = nil
tableView.addSubview(headerView)
tableView.sendSubviewToBack(headerView)
tableView.contentInset = UIEdgeInsets(top: headerHeight, left: 0, bottom: 0, right: 0)
tableView.contentOffset = CGPoint(x: 0, y: -headerHeight)
headerMaskLayer = CAShapeLayer()
headerMaskLayer.fillColor = UIColor.blackColor().CGColor
headerView.layer.mask = headerMaskLayer
updateHeaderView()



// Uncomment the following line to preserve selection between presentations
self.clearsSelectionOnViewWillAppear = true

self.clearsSelectionOnViewWillAppear = true
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
}


override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}

override func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}


// override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
// return tableView.dequeueReusableCellWithIdentifier("NewsBackgroundTableViewCell") as! UITableViewCell
// }

// override func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
// return 203
// }

override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
tableView.reloadData()
}
// MARK: - Table view data source

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Potentially incomplete method implementation.
// Return the number of sections.
return 1
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
return news.count
}


override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {


// if indexPath.row == 0 {
// let cell = tableView.dequeueReusableCellWithIdentifier("NewsBackgroundTableViewCell", forIndexPath: indexPath) as! UITableViewCell
// return cell
// }

let cell = tableView.dequeueReusableCellWithIdentifier("NewsTableViewCell", forIndexPath: indexPath) as! NewsTableViewCell

let newsItem = news[indexPath.row]
cell.titleLabel.text = newsItem.title
cell.descriptionLabel.text = newsItem.content


let monthFormatter = NSDateFormatter()
monthFormatter.dateFormat = "MMM"
Expand All @@ -62,12 +119,8 @@ class NewsTableViewController: UITableViewController {
cell.descriptionLabel.text = dayFormatter.stringFromDate(newsItem.publishedDate) + " " + monthFormatter.stringFromDate(newsItem.publishedDate)

cell.isReadLabel.hidden = contains(readArmadaNews, newsItem.title)

// cell.dayLabel.text = dayFormatter.stringFromDate(newsItem.publishedDate)
// cell.monthLabel.text = monthFormatter.stringFromDate(newsItem.publishedDate)

return cell

}

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
Expand All @@ -79,52 +132,6 @@ class NewsTableViewController: UITableViewController {
let contentWithoutHtml = NSAttributedString(data: selectedNewsItem.content.dataUsingEncoding(NSUTF8StringEncoding)!, options: [NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute:NSUTF8StringEncoding], documentAttributes: nil, error: nil)!.string

selectedArmadaEvent = ArmadaEvent(title: selectedNewsItem.title, summary: contentWithoutHtml, location: "", startDate: selectedNewsItem.publishedDate, endDate: selectedNewsItem.publishedDate, signupLink: "")

}

/*
// Override to support conditional editing of the table view.
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
// Return NO if you do not want the specified item to be editable.
return true
}
*/

/*
// Override to support editing the table view.
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == .Delete {
// Delete the row from the data source
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
} else if editingStyle == .Insert {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/

/*
// Override to support rearranging the table view.
override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) {
}
*/

/*
// Override to support conditional rearranging of the table view.
override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
// Return NO if you do not want the item to be re-orderable.
return true
}
*/

/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.

}
*/

}

0 comments on commit 1fcada4

Please sign in to comment.