-
Notifications
You must be signed in to change notification settings - Fork 566
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Onboarding] Fixes blank gene images.
- Loading branch information
Showing
6 changed files
with
122 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...tages/5-_Onboarding_Personalization/AROnboardingPersonalizationGeneImageStateReconciler.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
@class Gene; | ||
|
||
|
||
@interface AROnboardingPersonalizationGeneImageStateReconciler : NSObject | ||
|
||
- (NSURL *)imageURLForGene:(Gene *)gene atIndexPath:(NSIndexPath *)indexPath; | ||
|
||
- (void)addReplacedGene:(NSIndexPath *)indexPath; | ||
- (void)reset; | ||
|
||
@end |
46 changes: 46 additions & 0 deletions
46
...tages/5-_Onboarding_Personalization/AROnboardingPersonalizationGeneImageStateReconciler.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#import "AROnboardingPersonalizationGeneImageStateReconciler.h" | ||
#import "Gene.h" | ||
|
||
|
||
@interface AROnboardingPersonalizationGeneImageStateReconciler () | ||
|
||
@property (nonatomic, strong) NSMutableSet *replacedGenes; | ||
|
||
@end | ||
|
||
|
||
@implementation AROnboardingPersonalizationGeneImageStateReconciler | ||
|
||
- (instancetype)init | ||
{ | ||
self = [super init]; | ||
if (!self) { | ||
return nil; | ||
} | ||
|
||
_replacedGenes = [NSMutableSet set]; | ||
|
||
return self; | ||
} | ||
|
||
- (NSURL *)imageURLForGene:(Gene *)gene atIndexPath:(NSIndexPath *)indexPath | ||
{ | ||
if ([self.replacedGenes containsObject:indexPath]) { | ||
return gene.smallImageURL; | ||
} else { | ||
return gene.onboardingImageURL; | ||
} | ||
} | ||
|
||
- (void)addReplacedGene:(NSIndexPath *)indexPath | ||
{ | ||
[self.replacedGenes addObject:indexPath]; | ||
} | ||
|
||
- (void)reset | ||
{ | ||
[self.replacedGenes removeAllObjects]; | ||
} | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ler_Tests/Login_and_Onboarding/AROnboardingPersonalizationGeneImageStateReconcilerTests.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#import "AROnboardingPersonalizationGeneImageStateReconciler.h" | ||
|
||
SpecBegin(AROnboardingPersonalizationGeneImageStateReconciler); | ||
|
||
__block AROnboardingPersonalizationGeneImageStateReconciler *subject; | ||
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0]; | ||
Gene *gene = [Gene modelWithJSON:@{ | ||
@"id" : @"some_gene", | ||
@"image_url" : @"http://example.com/:version.jpg", | ||
}]; | ||
|
||
beforeEach(^{ | ||
subject = [AROnboardingPersonalizationGeneImageStateReconciler new]; | ||
}); | ||
|
||
it(@"normally returns the onboarding URL", ^{ | ||
expect([subject imageURLForGene:gene atIndexPath:indexPath]).to.equal([NSURL URLWithString:@"https://d7hftxdivxxvm.cloudfront.net/?resize_to=fill&width=100&height=100&quality=85&src=http://example.com/:version.jpg"]); | ||
}); | ||
|
||
describe(@"added index path", ^{ | ||
beforeEach(^{ | ||
[subject addReplacedGene:indexPath]; | ||
}); | ||
|
||
it(@"returns the small URL", ^{ | ||
expect([subject imageURLForGene:gene atIndexPath:indexPath]).to.equal([NSURL URLWithString:@"http://example.com/thumb.jpg"]); | ||
}); | ||
|
||
describe(@"after being reset", ^{ | ||
beforeEach(^{ | ||
[subject reset]; | ||
}); | ||
|
||
it(@"returns the onboarding URL", ^{ | ||
expect([subject imageURLForGene:gene atIndexPath:indexPath]).to.equal([NSURL URLWithString:@"https://d7hftxdivxxvm.cloudfront.net/?resize_to=fill&width=100&height=100&quality=85&src=http://example.com/:version.jpg"]); | ||
}); | ||
}); | ||
}); | ||
|
||
SpecEnd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters