Skip to content

Commit

Permalink
Merge pull request #14 from OceanLabs/add-more-photos
Browse files Browse the repository at this point in the history
Add more photos in review screen.
  • Loading branch information
dbotha committed Feb 11, 2015
2 parents dd42242 + 640c141 commit a4fd10a
Show file tree
Hide file tree
Showing 25 changed files with 382 additions and 145 deletions.
13 changes: 0 additions & 13 deletions Kite SDK/PSPrintSDK/OLAddressSelectionViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,6 @@ - (void)viewDidLoad {
- (void)setAllowMultipleSelection:(BOOL)allowMultipleSelection {
_allowMultipleSelection = allowMultipleSelection;
self.tableView.allowsMultipleSelection = _allowMultipleSelection;
UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 20)];
[doneButton addTarget:self action:@selector(onButtonDoneClicked) forControlEvents:UIControlEventTouchUpInside];
[doneButton setTitle:NSLocalizedString(@"Done", @"") forState:UIControlStateNormal];
[doneButton setTitleColor:self.view.tintColor forState:UIControlStateNormal];
[doneButton.titleLabel setFont:[UIFont boldSystemFontOfSize:18]];
[doneButton sizeToFit];
if (_allowMultipleSelection) {
[doneButton addTarget:self action:@selector(onButtonCancelClicked) forControlEvents:UIControlEventTouchUpInside];
} else {
[doneButton addTarget:self action:@selector(onButtonDoneClicked) forControlEvents:UIControlEventTouchUpInside];
}
UIBarButtonItem *item =[[UIBarButtonItem alloc] initWithCustomView:doneButton];
self.navigationItem.rightBarButtonItem = item;
}

- (void)viewDidAppear:(BOOL)animated {
Expand Down
7 changes: 5 additions & 2 deletions Kite SDK/PSPrintSDK/OLAsset.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@

#import <Foundation/Foundation.h>

@class ALAsset;

typedef void (^GetDataLengthHandler)(long long dataLength, NSError *error);
typedef void (^GetDataHandler)(NSData *data, NSError *error);
typedef void (^LoadAssetCompletionHandler)(ALAsset *asset, NSError *error);

static NSString *const kOLMimeTypeJPEG = @"image/jpeg";
static NSString *const kOLMimeTypePNG = @"image/png";
Expand All @@ -22,8 +25,6 @@ static NSString *const kOLMimeTypePNG = @"image/png";
- (void)cancelAnyLoadingOfData;
@end

@class ALAsset;

@interface OLAsset : NSObject <NSCoding>

+ (OLAsset *)assetWithImageAsJPEG:(UIImage *)image;
Expand All @@ -48,4 +49,6 @@ static NSString *const kOLMimeTypePNG = @"image/png";

@property (nonatomic, readonly, getter = isCropBoxSet) BOOL cropboxSet;

- (void)loadALAssetWithCompletionHandler:(LoadAssetCompletionHandler)handler;

@end
2 changes: 0 additions & 2 deletions Kite SDK/PSPrintSDK/OLAsset.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
static NSString *const kKeyDataSource = @"co.oceanlabs.pssdk.kKeyDataSource";
static NSString *const kKeyImageURL = @"co.oceanlabs.pssdk.kKeyImageURL";

typedef void (^LoadAssetCompletionHandler)(ALAsset *asset, NSError *error);

@interface OLAsset ()
@property (nonatomic, strong) NSString *imageFilePath;
@property (nonatomic, strong) NSData *imageData;
Expand Down
2 changes: 2 additions & 0 deletions Kite SDK/PSPrintSDK/OLCheckoutViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import <UIKit/UIKit.h>
#import "OLPrintEnvironment.h"
#import "OLCheckoutDelegate.h"
#import "OLKiteViewController.h"
@class OLPrintOrder;

NSString *const kOLNotificationUserSuppliedShippingDetails;
Expand All @@ -19,6 +20,7 @@ NSString *const kOLKeyUserInfoPrintOrder;
@interface OLCheckoutViewController : UITableViewController

@property (weak, nonatomic) id<OLCheckoutDelegate> delegate;
@property (weak, nonatomic) id<OLKiteDelegate> kiteDelegate;

- (id)initWithPrintOrder:(OLPrintOrder *)printOrder;
- (id)initWithAPIKey:(NSString *)apiKey environment:(OLKitePrintSDKEnvironment)env printOrder:(OLPrintOrder *)printOrder;
Expand Down
79 changes: 59 additions & 20 deletions Kite SDK/PSPrintSDK/OLFrameOrderReviewViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#import "OLProduct.h"
#import "OLAsset+Private.h"
#import <SDWebImageManager.h>
#import "UITableViewController+ScreenWidthFactor.h"

@interface OLFrameOrderReviewViewController () <OLScrollCropViewControllerDelegate>

Expand Down Expand Up @@ -113,6 +114,10 @@ -(void) doCheckout{
[super doCheckout];
}

- (BOOL)shouldShowAddMorePhotos{
return NO;
}

#pragma mark Button Actions

- (IBAction)onButtonUpArrowClicked:(UIButton *)sender {
Expand Down Expand Up @@ -169,33 +174,67 @@ - (IBAction)onButtonNextClicked:(UIBarButtonItem *)sender {
#pragma mark UITableView data source and delegate methods

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
int incompleteFrame = ([self.framePhotos count] % self.product.quantityToFulfillOrder) != 0 ? 1 : 0;
return [self.framePhotos count]/self.product.quantityToFulfillOrder + incompleteFrame + 1;
if (section == 0){
int incompleteFrame = ([self.framePhotos count] % self.product.quantityToFulfillOrder) != 0 ? 1 : 0;
return [self.framePhotos count]/self.product.quantityToFulfillOrder + incompleteFrame + 1;
}
else{
return 1;
}
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row == 0){
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"reviewTitle"];
if (indexPath.section == 0){
if (indexPath.row == 0){
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"reviewTitle"];

return cell;
}

UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"reviewPhotoCell"];
if (!cell) {
cell = [[UITableViewCell alloc] init];
}

UILabel *countLabel = (UILabel *)[cell.contentView viewWithTag:30];
[countLabel setText: [NSString stringWithFormat:@"%lu", (unsigned long) (1+[((NSNumber*)[self.extraCopiesOfAssets objectAtIndex:indexPath.row-1]) integerValue])]];

UICollectionView* collectionView = (UICollectionView*)[cell.contentView viewWithTag:100];
collectionView.dataSource = self;
collectionView.delegate = self;

UITapGestureRecognizer* doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTapGestureThumbnailTapped:)];
[collectionView addGestureRecognizer:doubleTap];

return cell;
}

UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"reviewPhotoCell"];
if (!cell) {
cell = [[UITableViewCell alloc] init];
else{
return [tableView dequeueReusableCellWithIdentifier:@"dummyCell"];
}
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section == 0){
if (indexPath.row == 0){
NSNumber *labelHeight;
if (!labelHeight) {
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"reviewTitle"];
labelHeight = @(cell.bounds.size.height);
}
return [labelHeight floatValue];
}
else{
NSNumber *reviewPhotoCellHeight;
if (!reviewPhotoCellHeight) {
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"reviewPhotoCell"];
reviewPhotoCellHeight = @(cell.bounds.size.height);
}
return [reviewPhotoCellHeight floatValue] * [self screenWidthFactor];
}
}
else{
return 46;
}

UILabel *countLabel = (UILabel *)[cell.contentView viewWithTag:30];
[countLabel setText: [NSString stringWithFormat:@"%lu", (unsigned long) (1+[((NSNumber*)[self.extraCopiesOfAssets objectAtIndex:indexPath.row-1]) integerValue])]];

UICollectionView* collectionView = (UICollectionView*)[cell.contentView viewWithTag:100];
collectionView.dataSource = self;
collectionView.delegate = self;

UITapGestureRecognizer* doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTapGestureThumbnailTapped:)];
[collectionView addGestureRecognizer:doubleTap];

return cell;
}

#pragma mark UICollectionView data source
Expand Down
2 changes: 2 additions & 0 deletions Kite SDK/PSPrintSDK/OLFrameSelectionViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
//

#import <UIKit/UIKit.h>
#import "OLKiteViewController.h"

@class OLPrintOrder;

@interface OLFrameSelectionViewController : UITableViewController

@property (strong, nonatomic) NSArray *assets;
@property (weak, nonatomic) id<OLKiteDelegate> delegate;

@end
2 changes: 1 addition & 1 deletion Kite SDK/PSPrintSDK/OLFrameSelectionViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
NSArray *products = [OLProduct products];

OLFrameOrderReviewViewController *vc = segue.destinationViewController;
vc.assets = self.assets;
vc.assets = [self.assets mutableCopy];
if ([segue.identifier isEqualToString:@"Selected2x2FrameStyleSegue"]) {
for (OLProduct *product in products){
if (product.productTemplate.templateClass == kOLTemplateClassFrame && product.productTemplate.quantityPerSheet == 4){
Expand Down
33 changes: 27 additions & 6 deletions Kite SDK/PSPrintSDK/OLKiteStoryboard.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="FREE POSTAGE" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" adjustsLetterSpacingToFitWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jHu-F3-y31">
<rect key="frame" x="213" y="523" width="107" height="45"/>
<color key="backgroundColor" red="0.24313725490196078" green="0.7803921568627451" blue="0.61568627450980395" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" red="0.24313725490196078" green="0.7803921568627451" blue="0.61568627450980395" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="11"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
Expand Down Expand Up @@ -415,7 +415,7 @@
<tableView key="view" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" allowsSelection="NO" showsSelectionImmediatelyOnTouchBegin="NO" rowHeight="362" sectionHeaderHeight="22" sectionFooterHeight="22" id="9dZ-sG-0UL">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="0.92549019607843142" green="0.93725490196078431" blue="0.94901960784313721" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" red="0.92549019607843142" green="0.93725490196078431" blue="0.94901960784313721" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="reviewTitle" rowHeight="40" id="Wcm-yg-Yah">
<rect key="frame" x="0.0" y="22" width="320" height="40"/>
Expand All @@ -438,7 +438,7 @@
<constraint firstItem="65S-WP-jrl" firstAttribute="leading" secondItem="MJf-Wl-VDr" secondAttribute="leading" constant="8" id="sbK-bx-3EM"/>
</constraints>
</tableViewCellContentView>
<color key="backgroundColor" red="0.92549019610000005" green="0.93725490199999995" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" red="0.92549019607843142" green="0.93725490196078431" blue="0.94901960784313721" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="reviewPhotoCell" rowHeight="349" id="Nfs-D8-uSC" customClass="OLCircleMaskTableViewCell">
<rect key="frame" x="0.0" y="62" width="320" height="349"/>
Expand Down Expand Up @@ -523,7 +523,7 @@
</connections>
</button>
</subviews>
<color key="backgroundColor" red="0.92549019610000005" green="0.93725490199999995" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" red="0.92549019607843142" green="0.93725490196078431" blue="0.94901960784313721" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="47f-lx-1I2" firstAttribute="centerX" secondItem="TYP-hs-JYh" secondAttribute="centerX" id="90o-Fy-xrX"/>
<constraint firstAttribute="trailing" secondItem="4J1-qF-jS9" secondAttribute="trailing" constant="20" id="A9x-M7-gRd"/>
Expand All @@ -549,7 +549,15 @@
<constraint firstItem="TYP-hs-JYh" firstAttribute="top" secondItem="yvX-sN-w8r" secondAttribute="top" constant="15" id="ylw-tj-jpv"/>
</constraints>
</tableViewCellContentView>
<color key="backgroundColor" red="0.92549019610000005" green="0.93725490199999995" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" red="0.92549019607843142" green="0.93725490196078431" blue="0.94901960784313721" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="dummyCell" rowHeight="46" id="cga-Ss-CNM">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="cga-Ss-CNM" id="3qj-lB-8Qn">
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
<color key="backgroundColor" red="0.92549019607843142" green="0.93725490196078431" blue="0.94901960784313721" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</tableViewCell>
</prototypes>
<connections>
Expand Down Expand Up @@ -712,6 +720,13 @@
</tableViewCellContentView>
<color key="backgroundColor" red="0.92549019610000005" green="0.93725490199999995" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="dummyCell" id="cj5-SE-dP4">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="cj5-SE-dP4" id="gAt-UH-uiz">
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="xas-Kj-aIZ" id="WGO-8T-bgy"/>
Expand Down Expand Up @@ -767,7 +782,13 @@
<constraint firstItem="uNG-6s-nO8" firstAttribute="top" relation="greaterThanOrEqual" secondItem="nok-mW-saD" secondAttribute="bottom" constant="8" id="yAk-ch-LPF"/>
</constraints>
</view>
<navigationItem key="navigationItem" id="NhS-TZ-HPH"/>
<navigationItem key="navigationItem" id="NhS-TZ-HPH">
<barButtonItem key="rightBarButtonItem" systemItem="done" id="QM2-5z-9jC">
<connections>
<action selector="onBarButtonDoneTapped:" destination="lkU-BR-804" id="lm7-Az-QlR"/>
</connections>
</barButtonItem>
</navigationItem>
<connections>
<outlet property="aspectRatioConstraint" destination="ImC-Qv-Ju3" id="p9Y-jB-by8"/>
<outlet property="cropView" destination="nok-mW-saD" id="qFn-PP-Pwf"/>
Expand Down
9 changes: 9 additions & 0 deletions Kite SDK/PSPrintSDK/OLKiteViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,17 @@

@class OLPrintOrder;

@protocol OLKiteDelegate <NSObject>

@optional
- (BOOL)shouldShowAddMorePhotosInReview;

@end

@interface OLKiteViewController : UIViewController

@property (weak, nonatomic) id<OLKiteDelegate> delegate;

- (id)initWithAssets:(NSArray *)assets;

@end
44 changes: 35 additions & 9 deletions Kite SDK/PSPrintSDK/OLKiteViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ @interface OLKiteViewController () <UIAlertViewDelegate>
@property (strong, nonatomic) NSArray *assets;
@property (weak, nonatomic) IBOutlet UINavigationBar *navigationBar;
@property (assign, nonatomic) BOOL alreadyTransitioned;
@property (assign, nonatomic) BOOL presentLater;

@end

Expand Down Expand Up @@ -55,9 +56,36 @@ -(void)viewDidLoad{
}
}

-(void) viewWillAppear:(BOOL)animated{
if (self.presentLater){
self.presentLater = NO;
UIView *view = [[UIView alloc] initWithFrame:self.view.bounds];
view.backgroundColor = [UIColor whiteColor];
[self.nextVc.view addSubview:view];
[self presentViewController:self.nextVc animated:NO completion:^(void){
[UIView animateWithDuration:0.15 animations:^(void){
view.alpha = 0;
} completion:^(BOOL b){
[view removeFromSuperview];
}];

}];
}
}

-(IBAction) dismiss{
[self dismissViewControllerAnimated:YES completion:^{
}];
if (self.presentedViewController){
UIView *dummy = [self.presentedViewController.view snapshotViewAfterScreenUpdates:YES];
[self.view addSubview:dummy];
[self.presentedViewController dismissViewControllerAnimated:NO completion:^{
[self dismissViewControllerAnimated:YES completion:^{
}];
}];
}
else{
[self dismissViewControllerAnimated:YES completion:^{
}];
}

}

Expand Down Expand Up @@ -105,21 +133,19 @@ - (void)transitionToNextScreen:(BOOL)animated{

if (!self.navigationController){
self.nextVc = [sb instantiateViewControllerWithIdentifier:nextVcNavIdentifier];
[(OLProductHomeViewController *)((UINavigationController *)self.nextVc).topViewController setDelegate:self.delegate];
((UINavigationController *)self.nextVc).topViewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(dismiss)];
[(id)((UINavigationController *)self.nextVc).topViewController setAssets:self.assets];
[(id)((UINavigationController *)self.nextVc).topViewController setAssets:[self.assets mutableCopy]];
if (product){
[(id)((UINavigationController *)self.nextVc).topViewController setProduct:product];
}
self.nextVc.view.alpha = 0;
[self.view addSubview:self.nextVc.view];
[UIView animateWithDuration:0.15 animations:^(void){
self.nextVc.view.alpha = 1;
}];
self.presentLater = YES;
}
else{
CGFloat standardiOSBarsHeight = self.navigationController.navigationBar.frame.size.height + [UIApplication sharedApplication].statusBarFrame.size.height;
self.nextVc = [sb instantiateViewControllerWithIdentifier:nextVcIdentifier];
[(id)self.nextVc setAssets:self.assets];
[(OLProductHomeViewController *)((UINavigationController *)self.nextVc).topViewController setDelegate:self.delegate];
[(id)self.nextVc setAssets:[self.assets mutableCopy]];
if (product){
[(id)self.nextVc setProduct:product];
}
Expand Down
Loading

0 comments on commit a4fd10a

Please sign in to comment.