Skip to content

Commit

Permalink
basket viewing and editing
Browse files Browse the repository at this point in the history
  • Loading branch information
ebaizel committed Jan 28, 2014
1 parent 6a4c2fe commit d59f533
Show file tree
Hide file tree
Showing 52 changed files with 3,228 additions and 328 deletions.
2 changes: 1 addition & 1 deletion PLALaCarteItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import "PLMenuItem.h"

@interface PLALaCarteItem : PLMenuItem
@interface PLALaCarteItem : PLMenuItem <NSCopying>

@property (nonatomic) int quantity;
@end
11 changes: 11 additions & 0 deletions PLALaCarteItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,15 @@

@implementation PLALaCarteItem

@synthesize quantity;

-(id)copyWithZone:(NSZone *)zone
{
PLALaCarteItem *another = (PLALaCarteItem *)[super copyWithZone:zone];
// another.quantity = 5;

// [another setQuantity:self.quantity];
another.quantity = self.quantity;
return another;
}
@end
17 changes: 7 additions & 10 deletions PLALaCarteSummaryViewController.xib
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4514" systemVersion="13A603" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4514" systemVersion="13B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3747"/>
</dependencies>
Expand All @@ -13,15 +13,9 @@
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="1">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="A La Carte Items" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="S0P-Z9-ghP">
<rect key="frame" x="20" y="20" width="129" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Beef Stroganoff: Qty 1" lineBreakMode="tailTruncation" numberOfLines="4" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="280" translatesAutoresizingMaskIntoConstraints="NO" id="ZxU-yH-GdE">
<rect key="frame" x="20" y="100" width="280" height="89"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
Expand All @@ -47,9 +41,10 @@
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="mkI-cy-yNW">
<rect key="frame" x="111" y="381" width="98" height="30"/>
<rect key="frame" x="111" y="397" width="98" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Add to Basket">
<color key="titleColor" red="0.52549019607843139" green="0.77647058823529413" blue="0.48627450980392156" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
Expand All @@ -59,7 +54,9 @@
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
<simulatedTabBarMetrics key="simulatedBottomBarMetrics"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics"/>
</view>
</objects>
</document>
23 changes: 20 additions & 3 deletions PLALaCarteViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#import "PLALaCarteItem.h"
#import "PLMenuItemTableViewCell.h"
#import "PLBasketStore.h"
#import "Colours.h"

@interface PLALaCarteViewController ()

Expand Down Expand Up @@ -149,15 +150,23 @@ - (void)viewDidLoad
UINib *nib = [UINib nibWithNibName:@"PLMenuItemTableViewCell" bundle:nil];
[[self alaCarteMains] registerNib:nib forCellReuseIdentifier:@"PLMenuItemTableViewCell"];
[[self alaCarteSides] registerNib:nib forCellReuseIdentifier:@"PLMenuItemTableViewCell"];

[self setTitle:@"A La Carte"];
[self fetchALaCarteItems];

// Setup the navigation bar
[[self navigationItem] setTitle:@"A La Carte"];
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont
fontWithName:@"Helvetica" size:24], NSFontAttributeName,
[UIColor whiteColor], NSForegroundColorAttributeName, nil];
self.navigationController.navigationBar.titleTextAttributes = attributes;


// Setup the bottom toolbar
UIBarButtonItem *flexibleSpaceLeft = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithTitle:@"Continue" style:UIBarButtonItemStylePlain target:self action:@selector(actionContinue:)];
[barButton setTitleTextAttributes:@{
NSFontAttributeName: [UIFont fontWithName:@"Helvetica" size:24.0],
NSForegroundColorAttributeName: [UIColor blackColor]
NSFontAttributeName: [UIFont fontWithName:@"Helvetica" size:18.0],
NSForegroundColorAttributeName: [UIColor moneyGreenColor]
} forState:UIControlStateNormal];

self.toolbarItems = [NSArray arrayWithObjects: flexibleSpaceLeft, barButton, nil];
Expand All @@ -183,6 +192,14 @@ - (void)fetchALaCarteItems
[sideItems addObject:[[PLALaCarteItem alloc] initWithName:@"Side of Artichokes" itemType:MenuItemSide itemId:@"10"]];
[sideItems addObject:[[PLALaCarteItem alloc] initWithName:@"Side of Sardines" itemType:MenuItemSide itemId:@"11"]];

for (PLALaCarteItem *item in mainItems) {
item.price = 10.0;
}

for (PLALaCarteItem *item in sideItems) {
item.price = 4.0;
}

[self setMains:mainItems];
[self setSides:sideItems];

Expand Down
45 changes: 21 additions & 24 deletions PLALaCarteViewController.xib
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4514" systemVersion="13A603" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4514" systemVersion="13B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3747"/>
</dependencies>
Expand All @@ -13,50 +13,47 @@
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="1">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Mains $10" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rS9-m7-f2V">
<rect key="frame" x="20" y="76" width="80" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.52549019610000003" green="0.77647058820000003" blue="0.48627450979999998" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="TKP-iV-IK0">
<rect key="frame" x="0.0" y="121" width="320" height="151"/>
<rect key="frame" x="0.0" y="105" width="320" height="155"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<connections>
<outlet property="dataSource" destination="-1" id="KRT-OY-s2w"/>
<outlet property="delegate" destination="-1" id="jNB-up-aRE"/>
</connections>
</tableView>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Sides $4" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="kI5-qB-4Fp">
<rect key="frame" x="20" y="268" width="67" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.52549019610000003" green="0.77647058820000003" blue="0.48627450979999998" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="tas-nm-peU">
<rect key="frame" x="0.0" y="342" width="320" height="139"/>
<rect key="frame" x="0.0" y="297" width="320" height="123"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<connections>
<outlet property="dataSource" destination="-1" id="i9B-I5-AMo"/>
<outlet property="delegate" destination="-1" id="8jZ-F5-s9l"/>
</connections>
</tableView>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Add A La Carte items" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="INJ-cJ-kDo">
<rect key="frame" x="20" y="40" width="164" 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="Mains $10" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rS9-m7-f2V">
<rect key="frame" x="20" y="92" width="80" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Sides $4" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="kI5-qB-4Fp">
<rect key="frame" x="20" y="313" width="67" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
<simulatedTabBarMetrics key="simulatedBottomBarMetrics"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics"/>
</view>
</objects>
</document>
Loading

0 comments on commit d59f533

Please sign in to comment.