Created
July 6, 2015 20:08
-
-
Save donholly/7ccef03a20ab70ae71de to your computer and use it in GitHub Desktop.
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
// App Delegate: | |
BOOL delayTaplyticsLoad = (![EAAppState sharedInstance].currentlySignedIn || ![EAAppState sharedInstance].walkthroughDisplayed); | |
NSDictionary *options; | |
if (delayTaplyticsLoad) { | |
options = @{@"delayLoad": @7}; | |
} | |
[Taplytics startTaplyticsAPIKey:[EAAppState sharedInstance].appSettings.taplyticsAPIKey | |
options:options]; | |
[Taplytics getRunningExperimentsAndVariations:^(NSDictionary *experimentsAndVariations) { | |
[EAAppState sharedInstance].userTaplyticsExperiments = [experimentsAndVariations copy]; | |
}]; | |
[self launchAppropriateViewController]; | |
// Where the test is run | |
#define EA_AB_TEST_RETURN_BLOCK(val) if (returnBlock) { returnBlock(val); } return; | |
+ (void)feedStoryPrintExperimentEnabled:(EAABTestManagerReturnBlockBool)returnBlock { | |
BOOL defaultValue = NO; | |
[Taplytics runCodeExperiment:@"Print photo button on feed stories" withBaseline:^(NSDictionary *variables) { | |
EA_AB_TEST_RETURN_BLOCK(defaultValue); | |
} variations:@{@"Print button visible": ^(NSDictionary *variables) { | |
EA_AB_TEST_RETURN_BLOCK(YES); | |
}}]; | |
} | |
// Where the test is invoked | |
- (id)initWithFrame:(CGRect)frame { | |
if (self = [super initWithFrame:frame]) { | |
_memorableShareButton = [EAButton sharePhotoButton]; | |
[_memorableShareButton addTarget:self action:@selector(didPressShareButton:) forControlEvents:UIControlEventTouchUpInside]; | |
_memorablePrintButton = [EAButton printPhotoButton]; | |
_memorablePrintButton.hidden = YES; | |
[_memorablePrintButton addTarget:self action:@selector(didPressPrintButton:) forControlEvents:UIControlEventTouchUpInside]; | |
[EAABTestManager feedStoryPrintExperimentEnabled:^(BOOL value) { | |
self.printExperimentEnabled = value; | |
self.memorablePrintButton.hidden = !value; | |
if (value) { | |
[self.contentView addSubview:_memorablePrintButton]; | |
} | |
[self.contentView addSubview:_memorableShareButton]; | |
[self setNeedsLayout]; | |
}]; | |
_annotationLabel = [[UILabel alloc] initWithFrame:CGRectZero]; | |
_annotationLabel.clipsToBounds = YES; | |
_annotationLabel.backgroundColor = EA_STORY_COLLECTION_VIEW_CONSTANTS_ANNOTATION_BG_COLOR; | |
_annotationLabel.textColor = [UIColor whiteColor]; | |
_annotationLabel.textAlignment = NSTextAlignmentCenter; | |
_annotationLabel.font = [UIFont smallestMediumFont]; | |
_annotationLabel.numberOfLines = 0; | |
self.layer.cornerRadius = EA_STORY_COLLECTION_VIEW_CONSTANTS_CORNER_RADIUS; | |
self.layer.borderWidth = EA_STORY_COLLECTION_VIEW_CONSTANTS_STORY_BORDER_WIDTH; | |
self.layer.borderColor = EA_STORY_COLLECTION_VIEW_CONSTANTS_STORY_BORDER_COLOR.CGColor; | |
self.backgroundColor = [UIColor gray00]; | |
self.imageView.showSyncIndicator = NO; | |
self.imageView.autoPlay = YES; | |
self.imageView.loop = YES; | |
self.imageView.showPlayPauseFlipbookButton = YES; | |
self.imageView.showFlipbookProgressBar = YES; | |
} | |
return self; | |
} | |
- (void)layoutSubviews { | |
[super layoutSubviews]; | |
CGRect fullSizeButtonFrame = CGRectIntegral(CGRectMake(0, | |
self.frame.size.height - EA_MEMORABLE_SHARE_BAR_HEIGHT, | |
self.frame.size.width, | |
EA_MEMORABLE_SHARE_BAR_HEIGHT)); | |
_memorableShareButton.frame = fullSizeButtonFrame; | |
_memorablePrintButton.frame = fullSizeButtonFrame; | |
// If we're showing both buttons, cut width in half. | |
if (self.printExperimentEnabled && | |
!_memorableShareButton.hidden && !_memorablePrintButton.hidden) { | |
CGRect buttonFrame = fullSizeButtonFrame; | |
buttonFrame.size.width = buttonFrame.size.width / 2; | |
_memorablePrintButton.frame = buttonFrame; | |
[_memorablePrintButton addRightBorderWithColor:[UIColor gray02] andWidth:.5f]; | |
buttonFrame.origin.x += buttonFrame.size.width; | |
_memorableShareButton.frame = buttonFrame; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment