From c122629e38a49606cc293dded2da7c1e445b4b25 Mon Sep 17 00:00:00 2001 From: Kostas Karayannis Date: Tue, 6 Dec 2016 18:21:05 +0200 Subject: [PATCH] Fixed issues with template collections --- Kite-Print-SDK.podspec | 2 +- Kite-SDK/PSPrintSDK/OLConstants.m | 2 +- Kite-SDK/PSPrintSDK/OLImageEditViewController.m | 1 + Kite-SDK/PSPrintSDK/OLProductTemplateCollection.h | 3 ++- Kite-SDK/PSPrintSDK/OLProductTemplateCollection.m | 3 ++- Kite-SDK/PSPrintSDK/OLProductTemplateOption.m | 3 ++- Kite-SDK/PSPrintSDK/OLProductTemplateSyncRequest.m | 3 ++- 7 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Kite-Print-SDK.podspec b/Kite-Print-SDK.podspec index 8b3d65e6..d347fab4 100644 --- a/Kite-Print-SDK.podspec +++ b/Kite-Print-SDK.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'Kite-Print-SDK' - spec.version = '6.1.5' + spec.version = '6.1.6' spec.license = { :type => 'MIT', :file => 'Kite-SDK/LICENSE' } spec.homepage = 'https://github.com/OceanLabs/iOS-Print-SDK' spec.authors = {'Deon Botha' => 'deon@oceanlabs.co'} diff --git a/Kite-SDK/PSPrintSDK/OLConstants.m b/Kite-SDK/PSPrintSDK/OLConstants.m index 5ce3617d..2edb19c2 100644 --- a/Kite-SDK/PSPrintSDK/OLConstants.m +++ b/Kite-SDK/PSPrintSDK/OLConstants.m @@ -29,7 +29,7 @@ #import "OLConstants.h" -NSString *const kOLKiteSDKVersion = @"6.1.5"; +NSString *const kOLKiteSDKVersion = @"6.1.6"; NSString *const kOLKiteSDKErrorDomain = @"co.oceanlabs.kOLKiteSDKErrorDomain"; NSString *const kNotificationTemplateSyncComplete = @"co.oceanlabs.pssdk.notification.kNotificationSyncComplete"; NSString *const kNotificationKeyTemplateSyncError = @"co.oceanlabs.pssdk.notification.kNotificationKeyTemplateSyncError"; diff --git a/Kite-SDK/PSPrintSDK/OLImageEditViewController.m b/Kite-SDK/PSPrintSDK/OLImageEditViewController.m index 3f073682..24957528 100644 --- a/Kite-SDK/PSPrintSDK/OLImageEditViewController.m +++ b/Kite-SDK/PSPrintSDK/OLImageEditViewController.m @@ -1502,6 +1502,7 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPa OLProduct *product = [OLProduct productWithTemplateId:templateId]; product.uuid = self.product.uuid; + [product.selectedOptions removeObjectForKey:self.selectedOption.code]; if (self.navigationController.viewControllers.count > 1){ OLProductOverviewViewController *vc = self.navigationController.viewControllers[self.navigationController.viewControllers.count - 2]; diff --git a/Kite-SDK/PSPrintSDK/OLProductTemplateCollection.h b/Kite-SDK/PSPrintSDK/OLProductTemplateCollection.h index 1a54c413..a7607794 100644 --- a/Kite-SDK/PSPrintSDK/OLProductTemplateCollection.h +++ b/Kite-SDK/PSPrintSDK/OLProductTemplateCollection.h @@ -33,8 +33,9 @@ @property (strong, nonatomic) NSString *_Nonnull name; @property (strong, nonatomic) NSURL *_Nullable icon; +@property (strong, nonatomic) NSString *_Nonnull code; @property (strong, nonatomic) NSArray *> *_Nonnull templates; -- (_Nonnull instancetype)initWithName:(NSString *_Nonnull)name templates:(NSArray *> *_Nonnull )templates; +- (_Nonnull instancetype)initWithName:(NSString *_Nonnull)name code:(NSString *_Nonnull)code templates:(NSArray *> *_Nonnull )templates; - (BOOL)containsTemplateIdentifier:(NSString *_Nonnull)identifier; @end diff --git a/Kite-SDK/PSPrintSDK/OLProductTemplateCollection.m b/Kite-SDK/PSPrintSDK/OLProductTemplateCollection.m index e8edad11..793e2a54 100644 --- a/Kite-SDK/PSPrintSDK/OLProductTemplateCollection.m +++ b/Kite-SDK/PSPrintSDK/OLProductTemplateCollection.m @@ -31,10 +31,11 @@ @implementation OLProductTemplateCollection -- (_Nonnull instancetype)initWithName:(NSString *_Nonnull)name templates:(NSArray *> *_Nonnull )templates{ +- (_Nonnull instancetype)initWithName:(NSString *_Nonnull)name code:(NSString *)code templates:(NSArray *> *_Nonnull )templates{ if (self = [super init]){ self.name = name; self.templates = templates; + self.code = code; } return self; diff --git a/Kite-SDK/PSPrintSDK/OLProductTemplateOption.m b/Kite-SDK/PSPrintSDK/OLProductTemplateOption.m index 89a8df04..f6496847 100644 --- a/Kite-SDK/PSPrintSDK/OLProductTemplateOption.m +++ b/Kite-SDK/PSPrintSDK/OLProductTemplateOption.m @@ -86,6 +86,7 @@ - (instancetype)initWithTemplateCollection:(OLProductTemplateCollection *)collec self.name = collection.name; self.iconURL = collection.icon; self.type = OLProductTemplateOptionTypeTemplateCollection; + self.code = collection.code; NSMutableArray *choices = [[NSMutableArray alloc] init]; for (NSDictionary *template in collection.templates){ OLProductTemplateOptionChoice *choice = [[OLProductTemplateOptionChoice alloc] init]; @@ -122,7 +123,7 @@ - (UIImage *)fallbackIcon{ return [UIImage imageNamedInKiteBundle:self.iconImageName]; } else{ //Match known options with embedded assets - if ([self.code isEqualToString:@"case_style"]){ + if ([self.code isEqualToString:@"case_style"] || [self.code isEqualToString:@"Phone Cases"]){ return [UIImage imageNamedInKiteBundle:@"case-options"]; } } diff --git a/Kite-SDK/PSPrintSDK/OLProductTemplateSyncRequest.m b/Kite-SDK/PSPrintSDK/OLProductTemplateSyncRequest.m index 0cb52ef5..e8c9c221 100644 --- a/Kite-SDK/PSPrintSDK/OLProductTemplateSyncRequest.m +++ b/Kite-SDK/PSPrintSDK/OLProductTemplateSyncRequest.m @@ -126,8 +126,9 @@ - (void)fetchTemplatesWithURL:(NSURL *)url templateAccumulator:(NSMutableArray * for (NSDictionary *collection in collections){ if ([collection isKindOfClass:[NSDictionary class]]){ NSString *name = collection[@"option_label"]; + NSString *code = collection[@"name"]; NSArray *templates = collection[@"templates"]; - OLProductTemplateCollection *templateCollection = [[OLProductTemplateCollection alloc] initWithName:name templates:templates]; + OLProductTemplateCollection *templateCollection = [[OLProductTemplateCollection alloc] initWithName:name code:code templates:templates]; [templateCollections addObject:templateCollection]; } }