first screen (schedule) now has the right information

This commit is contained in:
Senad Uka
2014-09-02 20:00:02 +02:00
parent e176c70f18
commit 61cfcc173c
10 changed files with 422 additions and 11 deletions

View File

@@ -25,34 +25,82 @@
</objects>
<point key="canvasLocation" x="132" y="180"/>
</scene>
<!--Table View Controller - Root View Controller-->
<!--Schedule Table View Controller - 2014-->
<scene sceneID="Gwb-IZ-cXq">
<objects>
<tableViewController id="aNc-F9-0cW" sceneMemberID="viewController">
<tableViewController id="aNc-F9-0cW" customClass="FESScheduleTableViewController" sceneMemberID="viewController">
<tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="HpO-cG-BkW">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="g68-Qd-9Ij">
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="scheduleEntryCell" id="g68-Qd-9Ij" customClass="FESScheduleEntryCell">
<rect key="frame" x="0.0" y="86" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="g68-Qd-9Ij" id="6f9-Rs-ptT">
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Fri" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hgY-f8-EeZ">
<rect key="frame" x="20" y="11" width="42" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="15. August" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="CXi-kA-ow8">
<rect key="frame" x="70" y="11" width="83" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<outlet property="scheduleDate" destination="CXi-kA-ow8" id="4wi-Xj-rhe"/>
<outlet property="scheduleDayOfWeek" destination="hgY-f8-EeZ" id="bVi-Sl-f8D"/>
<segue destination="0t7-N6-wZY" kind="push" id="WWo-rm-Zb3"/>
</connections>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="aNc-F9-0cW" id="B8w-3G-bqo"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="2014" id="oPc-a0-wbv"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="4Vp-c3-FnG" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1333" y="-242"/>
</scene>
<!--Table View Controller-->
<scene sceneID="2yk-lz-VwC">
<objects>
<tableViewController id="0t7-N6-wZY" sceneMemberID="viewController">
<tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="as4-4p-NwJ">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="NlW-xg-4gy">
<rect key="frame" x="0.0" y="86" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="NlW-xg-4gy" id="qGp-By-vBv">
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="aNc-F9-0cW" id="B8w-3G-bqo"/>
<outlet property="delegate" destination="aNc-F9-0cW" id="rxE-QR-e9r"/>
<outlet property="dataSource" destination="0t7-N6-wZY" id="v20-t2-JHd"/>
<outlet property="delegate" destination="0t7-N6-wZY" id="bdD-jF-UpC"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Root View Controller" id="oPc-a0-wbv"/>
<navigationItem key="navigationItem" id="zkS-4H-eLi"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="4Vp-c3-FnG" userLabel="First Responder" sceneMemberID="firstResponder"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="2Po-QA-1an" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1333" y="-242"/>
<point key="canvasLocation" x="1894" y="-235"/>
</scene>
<!--Table View Controller - Root View Controller-->
<scene sceneID="CX5-hP-Yrk">

View File

@@ -43,8 +43,6 @@
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

View File

@@ -14,3 +14,9 @@
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
#if(URL_LOCAL==1)
#define SCHEDULE_URL @"http://127.0.0.1:8080/sff2014/schedule.json"
#else
#define SCHEDULE_URL @"http://localhost:8080/sff2014/schedule.json"
#endif

View File

@@ -0,0 +1,17 @@
//
// FESScheduleEntryCell.h
// FestivalHelper
//
// Created by Hamo Hapic on 02/09/14.
// Copyright (c) 2014 Senad Uka. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface FESScheduleEntryCell : UITableViewCell
@property (weak, nonatomic)IBOutlet UILabel *scheduleDayOfWeek;
@property (weak, nonatomic)IBOutlet UILabel *scheduleDate;
@end

View File

@@ -0,0 +1,34 @@
//
// FESScheduleEntryCell.m
// FestivalHelper
//
// Created by Hamo Hapic on 02/09/14.
// Copyright (c) 2014 Senad Uka. All rights reserved.
//
#import "FESScheduleEntryCell.h"
@implementation FESScheduleEntryCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (void)awakeFromNib
{
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end

View File

@@ -0,0 +1,15 @@
//
// FESScheduleTableViewController.h
// FestivalHelper
//
// Created by Hamo Hapic on 02/09/14.
// Copyright (c) 2014 Senad Uka. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface FESScheduleTableViewController : UITableViewController
@property (strong)NSMutableArray *scheduleArray;
@end

View File

@@ -0,0 +1,173 @@
//
// FESScheduleTableViewController.m
// FestivalHelper
//
// Created by Hamo Hapic on 02/09/14.
// Copyright (c) 2014 Senad Uka. All rights reserved.
//
#import "FESScheduleTableViewController.h"
#import "FESSCheduleEntry.h"
#import "FESScheduleEntryCell.h"
@interface FESScheduleTableViewController ()
@end
@implementation FESScheduleTableViewController
@synthesize scheduleArray;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.tableView.delegate = self;
self.tableView.dataSource = self;
[self getScheduleDataFromServer];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [self.scheduleArray count];
}
-(void)getScheduleDataFromServer {
NSLog(@"Getting data");
NSURL *url = [[NSURL alloc] initWithString:SCHEDULE_URL];
[NSURLConnection sendAsynchronousRequest:[[NSURLRequest alloc] initWithURL:url] queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
if(connectionError) {
NSLog(@"Error getting %@ schedule data: - %@", SCHEDULE_URL, [connectionError localizedDescription]);
}
else {
NSLog(@"Parsing data.");
[self setupScheduleFromJSONArray:data];
[self.tableView reloadData];
}
}];
}
-(void)setupScheduleFromJSONArray:(NSData*)dataFromServerArray{
NSError *error;
self.scheduleArray = [[NSMutableArray alloc] init];
NSArray *arrayFromServer = [NSJSONSerialization JSONObjectWithData:dataFromServerArray options:0 error:&error];
if(error){
NSLog(@"error parsing the json data from server with error description - %@", [error localizedDescription]);
}
else {
self.scheduleArray = [[NSMutableArray alloc] init];
for(NSDictionary *scheduleData in arrayFromServer)
{
FESSCheduleEntry *entry = [[FESSCheduleEntry alloc] initWithJSONData:scheduleData];
[self.scheduleArray addObject:entry];
}
NSLog(@"success!");
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *retrievedCell = [tableView dequeueReusableCellWithIdentifier:@"scheduleEntryCell" forIndexPath:indexPath];
FESScheduleEntryCell *cell = (FESScheduleEntryCell *)retrievedCell;
if(cell)
{
//The beauty of this is that you have all your data in one object and grab WHATEVER you like
//This way in the future you can add another field without doing much.
FESSCheduleEntry *scheduleEntry = [scheduleArray objectAtIndex:indexPath.row];
cell.scheduleDate.text = [scheduleEntry scheduleDate];
cell.scheduleDayOfWeek.text = [scheduleEntry scheduleDayOfWeek];
}
return cell;
}
/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the specified item to be editable.
return YES;
}
*/
/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
} else if (editingStyle == UITableViewCellEditingStyleInsert) {
// 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.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/
/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the item to be re-orderable.
return YES;
}
*/
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end