Skip to content

Commit

Permalink
Merge pull request #125 from mamaral/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
mamaral committed May 8, 2016
2 parents cef8682 + 325ba1a commit 3a7b254
Show file tree
Hide file tree
Showing 8 changed files with 489 additions and 417 deletions.
128 changes: 20 additions & 108 deletions Demo/Demo Files/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(

// otherwise set the root view controller to the onboarding view controller
else {
self.window.rootViewController = [self generateFirstDemoVC];
// self.window.rootViewController = [self generateSecondDemoVC];
// self.window.rootViewController = [self generateThirdDemoVC];
// self.window.rootViewController = [self generateFourthDemoVC];
// self.window.rootViewController = [self generateFifthDemoVC];

self.window.rootViewController = [self generateStandardOnboardingVC];
// self.window.rootViewController = [self generateMovieOnboardingVC];

// __weak typeof(self) weakSelf = self;
//
// self.window.rootViewController = [[MyOnboardingViewController alloc] initWithCompletionHandler:^{
Expand Down Expand Up @@ -68,7 +65,7 @@ - (void)handleOnboardingCompletion {
[self setupNormalRootViewController];
}

- (OnboardingViewController *)generateFirstDemoVC {
- (OnboardingViewController *)generateStandardOnboardingVC {
OnboardingContentViewController *firstPage = [OnboardingContentViewController contentWithTitle:@"What A Beautiful Photo" body:@"This city background image is so beautiful." image:[UIImage imageNamed:@"blue"] buttonText:@"Enable Location Services" action:^{
[[[UIAlertView alloc] initWithTitle:nil message:@"Here you can prompt users for various application permissions, providing them useful information about why you'd like those permissions to enhance their experience, increasing your chances they will grant those permissions." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
}];
Expand Down Expand Up @@ -100,39 +97,35 @@ - (OnboardingViewController *)generateFirstDemoVC {
return onboardingVC;
}

- (OnboardingViewController *)generateSecondDemoVC {
- (OnboardingViewController *)generateMovieOnboardingVC {
OnboardingContentViewController *firstPage = [[OnboardingContentViewController alloc] initWithTitle:@"Everything Under The Sun" body:@"The temperature of the photosphere is over 10,000°F." image:nil buttonText:nil action:nil];
firstPage.topPadding = -15;
firstPage.underTitlePadding = 160;
firstPage.titleTextColor = [UIColor colorWithRed:239/255.0 green:88/255.0 blue:35/255.0 alpha:1.0];
firstPage.titleFontName = @"SFOuterLimitsUpright";
firstPage.bodyTextColor = [UIColor colorWithRed:239/255.0 green:88/255.0 blue:35/255.0 alpha:1.0];
firstPage.bodyFontName = @"NasalizationRg-Regular";
firstPage.bodyFontSize = 18;
firstPage.titleLabel.textColor = [UIColor colorWithRed:239/255.0 green:88/255.0 blue:35/255.0 alpha:1.0];
firstPage.titleLabel.font = [UIFont fontWithName:@"SFOuterLimitsUpright" size:38.0];
firstPage.bodyLabel.textColor = [UIColor colorWithRed:239/255.0 green:88/255.0 blue:35/255.0 alpha:1.0];
firstPage.bodyLabel.font = [UIFont fontWithName:@"NasalizationRg-Regular" size:18.0];

OnboardingContentViewController *secondPage = [[OnboardingContentViewController alloc] initWithTitle:@"Every Second" body:@"600 million tons of protons are converted into helium atoms." image:nil buttonText:nil action:nil];
secondPage.titleFontName = @"SFOuterLimitsUpright";
secondPage.titleLabel.font = [UIFont fontWithName:@"SFOuterLimitsUpright" size:38.0];
secondPage.underTitlePadding = 170;
secondPage.topPadding = 0;
secondPage.titleTextColor = [UIColor colorWithRed:251/255.0 green:176/255.0 blue:59/255.0 alpha:1.0];
secondPage.bodyTextColor = [UIColor colorWithRed:251/255.0 green:176/255.0 blue:59/255.0 alpha:1.0];
secondPage.bodyFontName = @"NasalizationRg-Regular";
secondPage.bodyFontSize = 18;
secondPage.titleLabel.textColor = [UIColor colorWithRed:251/255.0 green:176/255.0 blue:59/255.0 alpha:1.0];
secondPage.bodyLabel.textColor = [UIColor colorWithRed:251/255.0 green:176/255.0 blue:59/255.0 alpha:1.0];
secondPage.bodyLabel.font = [UIFont fontWithName:@"NasalizationRg-Regular" size:18.0];

OnboardingContentViewController *thirdPage = [[OnboardingContentViewController alloc] initWithTitle:@"We're All Star Stuff" body:@"Our very bodies consist of the same chemical elements found in the most distant nebulae, and our activities are guided by the same universal rules." image:nil buttonText:@"Explore the universe" action:^{
[self handleOnboardingCompletion];
}];
thirdPage.topPadding = 10;
thirdPage.underTitlePadding = 160;
thirdPage.bottomPadding = -10;
thirdPage.titleFontName = @"SFOuterLimitsUpright";
thirdPage.titleTextColor = [UIColor colorWithRed:58/255.0 green:105/255.0 blue:136/255.0 alpha:1.0];
thirdPage.bodyTextColor = [UIColor colorWithRed:58/255.0 green:105/255.0 blue:136/255.0 alpha:1.0];
thirdPage.buttonTextColor = [UIColor colorWithRed:239/255.0 green:88/255.0 blue:35/255.0 alpha:1.0];
thirdPage.bodyFontName = @"NasalizationRg-Regular";
thirdPage.bodyFontSize = 15;
thirdPage.buttonFontName = @"SpaceAge";
thirdPage.buttonFontSize = 17;
thirdPage.titleLabel.font = [UIFont fontWithName:@"SFOuterLimitsUpright" size:38.0];
thirdPage.titleLabel.textColor = [UIColor colorWithRed:58/255.0 green:105/255.0 blue:136/255.0 alpha:1.0];
thirdPage.bodyLabel.textColor = [UIColor colorWithRed:58/255.0 green:105/255.0 blue:136/255.0 alpha:1.0];
thirdPage.bodyLabel.font = [UIFont fontWithName:@"NasalizationRg-Regular" size:15.0];
[thirdPage.actionButton setTitleColor:[UIColor colorWithRed:239/255.0 green:88/255.0 blue:35/255.0 alpha:1.0] forState:UIControlStateNormal];
thirdPage.actionButton.titleLabel.font = [UIFont fontWithName:@"SpaceAge" size:17.0];

NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"sun" ofType:@"mp4"];
Expand All @@ -146,85 +139,4 @@ - (OnboardingViewController *)generateSecondDemoVC {
return onboardingVC;
}

- (OnboardingViewController *)generateThirdDemoVC {
OnboardingContentViewController *firstPage = [[OnboardingContentViewController alloc] initWithTitle:@"It's one small step for a man..." body:@"The first man on the moon, Buzz Aldrin, only had one photo taken of him while on the lunar surface due to an unexpected call from Dick Nixon." image:[UIImage imageNamed:@"space1"] buttonText:nil action:nil];
firstPage.bodyFontSize = 25;

OnboardingContentViewController *secondPage = [[OnboardingContentViewController alloc] initWithTitle:@"The Drake Equation" body:@"In 1961, Frank Drake proposed a probabilistic formula to help estimate the number of potential active and radio-capable extraterrestrial civilizations in the Milky Way Galaxy." image:[UIImage imageNamed:@"space2"] buttonText:nil action:nil];
secondPage.bodyFontSize = 24;

OnboardingContentViewController *thirdPage = [[OnboardingContentViewController alloc] initWithTitle:@"Cold Welding" body:@"Two pieces of metal without any coating on them will form into one piece in the vacuum of space." image:[UIImage imageNamed:@"space3"] buttonText:nil action:nil];

OnboardingContentViewController *fourthPage = [[OnboardingContentViewController alloc] initWithTitle:@"Goodnight Moon" body:@"Every year the moon moves about 3.8cm further away from the Earth." image:[UIImage imageNamed:@"space4"] buttonText:@"See Ya Later!" action:nil];

OnboardingViewController *onboardingVC = [[OnboardingViewController alloc] initWithBackgroundImage:[UIImage imageNamed:@"milky_way.jpg"] contents:@[firstPage, secondPage, thirdPage, fourthPage]];
onboardingVC.shouldMaskBackground = NO;
onboardingVC.shouldBlurBackground = YES;
return onboardingVC;
}

- (OnboardingViewController *)generateFourthDemoVC {
OnboardingContentViewController *firstPage = [[OnboardingContentViewController alloc] initWithTitle:@"\"If you can't explain it simply, you don't know it well enough.\"" body:@" - Einsten" image:[UIImage imageNamed:@""] buttonText:nil action:nil];

OnboardingContentViewController *secondPage = [[OnboardingContentViewController alloc] initWithTitle:@"\"If you wish to make an apple pie from scratch, you must first invent the universe.\"" body:@" - Sagan" image:nil buttonText:nil action:nil];
secondPage.topPadding = 0;

OnboardingContentViewController *thirdPage = [[OnboardingContentViewController alloc] initWithTitle:@"\"That which can be asserted without evidence, can be dismissed without evidence.\"" body:@" - Hitchens" image:nil buttonText:nil action:nil];
thirdPage.titleFontSize = 33;
thirdPage.bodyFontSize = 25;

OnboardingContentViewController *fourthPage = [[OnboardingContentViewController alloc] initWithTitle:@"\"Scientists have become the bearers of the torch of discovery in our quest for knowledge.\"" body:@" - Hawking" image:nil buttonText:nil action:nil];
fourthPage.titleFontSize = 28;
fourthPage.bodyFontSize = 24;

OnboardingViewController *onboardingVC = [[OnboardingViewController alloc] initWithBackgroundImage:[UIImage imageNamed:@"yellowbg"] contents:@[firstPage, secondPage, thirdPage, fourthPage]];
onboardingVC.shouldMaskBackground = NO;
onboardingVC.titleTextColor = [UIColor colorWithRed:57/255.0 green:57/255.0 blue:57/255.0 alpha:1.0];;
onboardingVC.bodyTextColor = [UIColor colorWithRed:244/255.0 green:64/255.0 blue:40/255.0 alpha:1.0];
onboardingVC.fontName = @"HelveticaNeue-Italic";
return onboardingVC;
}

- (OnboardingViewController *)generateFifthDemoVC {
OnboardingContentViewController *firstPage = [[OnboardingContentViewController alloc] initWithTitle:@"Tri-tip bacon shankle" body:@"Bacon ipsum dolor amet cow filet mignon porchetta ham hamburger pork chop venison landjaeger ribeye drumstick beef ribs tongue." videoURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"video1" ofType:@"mp4"]] buttonText:nil action:nil];
firstPage.topPadding = -15;
firstPage.underTitlePadding = 160;
firstPage.titleTextColor = [UIColor colorWithRed:239/255.0 green:88/255.0 blue:35/255.0 alpha:1.0];
firstPage.titleFontName = @"SFOuterLimitsUpright";
firstPage.bodyTextColor = [UIColor colorWithRed:239/255.0 green:88/255.0 blue:35/255.0 alpha:1.0];
firstPage.bodyFontName = @"NasalizationRg-Regular";
firstPage.bodyFontSize = 18;

OnboardingContentViewController *secondPage = [[OnboardingContentViewController alloc] initWithTitle:@"Ball tip hamburger" body:@"Bacon ipsum dolor amet kielbasa landjaeger ham fatback frankfurter pork beef pig strip steak pancetta tenderloin pork chop." videoURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"video2" ofType:@"mp4"]] buttonText:nil action:nil];
secondPage.titleFontName = @"SFOuterLimitsUpright";
secondPage.underTitlePadding = 170;
secondPage.topPadding = 0;
secondPage.titleTextColor = [UIColor colorWithRed:251/255.0 green:176/255.0 blue:59/255.0 alpha:1.0];
secondPage.bodyTextColor = [UIColor colorWithRed:251/255.0 green:176/255.0 blue:59/255.0 alpha:1.0];
secondPage.bodyFontName = @"NasalizationRg-Regular";
secondPage.bodyFontSize = 18;

OnboardingContentViewController *thirdPage = [[OnboardingContentViewController alloc] initWithTitle:@"Sausage prosciutto flank capicola" body:@"Bacon ipsum dolor amet tail sausage salami filet mignon spare ribs hamburger." videoURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"video3" ofType:@"mp4"]] buttonText:@"Tap me" action:^{
[self handleOnboardingCompletion];
}];
thirdPage.topPadding = 10;
thirdPage.underTitlePadding = 160;
thirdPage.bottomPadding = -10;
thirdPage.titleFontName = @"SFOuterLimitsUpright";
thirdPage.titleTextColor = [UIColor colorWithRed:58/255.0 green:105/255.0 blue:136/255.0 alpha:1.0];
thirdPage.bodyTextColor = [UIColor colorWithRed:58/255.0 green:105/255.0 blue:136/255.0 alpha:1.0];
thirdPage.buttonTextColor = [UIColor colorWithRed:239/255.0 green:88/255.0 blue:35/255.0 alpha:1.0];
thirdPage.bodyFontName = @"NasalizationRg-Regular";
thirdPage.bodyFontSize = 15;
thirdPage.buttonFontName = @"SpaceAge";
thirdPage.buttonFontSize = 17;

OnboardingViewController *onboardingVC = [[OnboardingViewController alloc] initWithBackgroundImage:[UIImage imageNamed:@"milky_way.jpg"] contents:@[firstPage, secondPage, thirdPage]];
onboardingVC.shouldFadeTransitions = YES;
onboardingVC.shouldMaskBackground = NO;
onboardingVC.pageControl.currentPageIndicatorTintColor = [UIColor colorWithRed:239/255.0 green:88/255.0 blue:35/255.0 alpha:1.0];
onboardingVC.pageControl.pageIndicatorTintColor = [UIColor whiteColor];
return onboardingVC;
}

@end
@end
41 changes: 0 additions & 41 deletions Demo/Demo Files/OnboardTests/OnboardTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,47 +76,6 @@ - (void)testDefaultValues {
XCTAssertFalse(onboardingVC.shouldBlurBackground, @"The background should not be blurred by default.");
}

- (void)testConvenienceSetters {
// This tests that when we use the convenience setter methods on the master onboaring view controller,
// the properties correctly trickle down to each of the child content view controllers.
OnboardingViewController *onboardingVC = [[OnboardingViewController alloc] initWithBackgroundImage:nil contents:[self generateStockContentVCS]];

CGFloat testIconSize = 80;
onboardingVC.iconSize = testIconSize;

UIColor *testColor = [UIColor purpleColor];
onboardingVC.titleTextColor = testColor;
onboardingVC.bodyTextColor = testColor;
onboardingVC.buttonTextColor = testColor;

NSString *testFontName = @"Helvetica-LightOblique";
onboardingVC.fontName = testFontName;

CGFloat testFontSize = 12;
onboardingVC.titleFontSize = testFontSize;
onboardingVC.bodyFontSize = testFontSize;

CGFloat testPadding = 22;
onboardingVC.topPadding = testPadding;
onboardingVC.underIconPadding = testPadding;
onboardingVC.underTitlePadding = testPadding;
onboardingVC.bottomPadding = testPadding;

NSArray *contentsFromController = onboardingVC.viewControllers;

for (OnboardingContentViewController *contentVC in contentsFromController) {
XCTAssert(contentVC.titleTextColor == testColor, @"The content view controller's title text color is invalid.");
XCTAssert(contentVC.bodyTextColor == testColor, @"The content view controller's body text color is invalid.");
XCTAssert(contentVC.buttonTextColor == testColor, @"The content view controller's button test color is invalid.");
XCTAssert(contentVC.titleFontSize == testFontSize, @"The content view controller's title fotn size is invalid.");
XCTAssert(contentVC.bodyFontSize == testFontSize, @"The content view controller's body font size is invalid.");
XCTAssert(contentVC.topPadding == testPadding, @"The content view controller's top padding is invalid.");
XCTAssert(contentVC.underIconPadding == testPadding, @"The content view controller's under icon padding is invalid.");
XCTAssert(contentVC.underTitlePadding == testPadding, @"The content view controller's under title padding is invalid.");
XCTAssert(contentVC.bottomPadding == testPadding, @"The content view controller's bottom padding is invalid.");
}
}

- (void)testActionHandler {
XCTestExpectation *expectation = [self expectationWithDescription:@"callback"];
OnboardingContentViewController *contentVC = [[OnboardingContentViewController alloc] initWithTitle:@"T1" body:@"B1" image:nil buttonText:nil action:^{
Expand Down
4 changes: 2 additions & 2 deletions Onboard.podspec
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Pod::Spec.new do |s|

s.name = "Onboard"
s.version = "2.1.9"
s.version = "2.2.0"
s.summary = "Create a beautiful and engaging onboarding experience with only a few lines of code."
s.homepage = "https://github.com/mamaral/Onboard"
s.license = "MIT"
s.author = { "Mike Amaral" => "mike.amaral36@gmail.com" }
s.social_media_url = "http://twitter.com/MikeAmaral"
s.platform = :ios
s.source = { :git => "https://github.com/mamaral/Onboard.git", :tag => "v2.1.9" }
s.source = { :git => "https://github.com/mamaral/Onboard.git", :tag => "v2.2.0" }
s.source_files = "Source/OnboardingViewController.{h,m}", "Source/OnboardingContentViewController.{h,m}"
s.requires_arc = true

Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,9 @@ With only a few lines of code you have a beautiful, end-to-end onboarding proces
Customization
=============

The content pages can be customized by setting the provided padding, font, and size properties on either the pages individually (if you want something different on each) or on the OnboardingViewController itself, which will pass those properties to all of the content view controllers.
The `iconImageView`, `titleLabel`, `bodyLabel`, and `actionButton` properties are exposed for customizing fonts, sizing, etc., and the spacing between elements on the content pages can be customized as well:

```objective-c
OnboardingViewController *onboardingVC = [OnboardingViewController onboardWithBackgroundImage contents:yourContentsArray];
onboardingVC.fontName = @"Helvetica-Light";
onboardingVC.titleFontSize = 28;
onboardingVC.bodyFontSize = 22;
onboardingVC.topPadding = 20;
onboardingVC.underIconPadding = 10;
onboardingVC.underTitlePadding = 15;
Expand Down
Loading

0 comments on commit 3a7b254

Please sign in to comment.