Skip to content

Commit 3a7b254

Browse files
committed
Merge pull request #125 from mamaral/refactor
Refactor
2 parents cef8682 + 325ba1a commit 3a7b254

8 files changed

+489
-417
lines changed

Demo/Demo Files/AppDelegate.m

+20-108
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
2929

3030
// otherwise set the root view controller to the onboarding view controller
3131
else {
32-
self.window.rootViewController = [self generateFirstDemoVC];
33-
// self.window.rootViewController = [self generateSecondDemoVC];
34-
// self.window.rootViewController = [self generateThirdDemoVC];
35-
// self.window.rootViewController = [self generateFourthDemoVC];
36-
// self.window.rootViewController = [self generateFifthDemoVC];
37-
32+
self.window.rootViewController = [self generateStandardOnboardingVC];
33+
// self.window.rootViewController = [self generateMovieOnboardingVC];
34+
3835
// __weak typeof(self) weakSelf = self;
3936
//
4037
// self.window.rootViewController = [[MyOnboardingViewController alloc] initWithCompletionHandler:^{
@@ -68,7 +65,7 @@ - (void)handleOnboardingCompletion {
6865
[self setupNormalRootViewController];
6966
}
7067

71-
- (OnboardingViewController *)generateFirstDemoVC {
68+
- (OnboardingViewController *)generateStandardOnboardingVC {
7269
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:^{
7370
[[[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];
7471
}];
@@ -100,39 +97,35 @@ - (OnboardingViewController *)generateFirstDemoVC {
10097
return onboardingVC;
10198
}
10299

103-
- (OnboardingViewController *)generateSecondDemoVC {
100+
- (OnboardingViewController *)generateMovieOnboardingVC {
104101
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];
105102
firstPage.topPadding = -15;
106103
firstPage.underTitlePadding = 160;
107-
firstPage.titleTextColor = [UIColor colorWithRed:239/255.0 green:88/255.0 blue:35/255.0 alpha:1.0];
108-
firstPage.titleFontName = @"SFOuterLimitsUpright";
109-
firstPage.bodyTextColor = [UIColor colorWithRed:239/255.0 green:88/255.0 blue:35/255.0 alpha:1.0];
110-
firstPage.bodyFontName = @"NasalizationRg-Regular";
111-
firstPage.bodyFontSize = 18;
104+
firstPage.titleLabel.textColor = [UIColor colorWithRed:239/255.0 green:88/255.0 blue:35/255.0 alpha:1.0];
105+
firstPage.titleLabel.font = [UIFont fontWithName:@"SFOuterLimitsUpright" size:38.0];
106+
firstPage.bodyLabel.textColor = [UIColor colorWithRed:239/255.0 green:88/255.0 blue:35/255.0 alpha:1.0];
107+
firstPage.bodyLabel.font = [UIFont fontWithName:@"NasalizationRg-Regular" size:18.0];
112108

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

122117
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:^{
123118
[self handleOnboardingCompletion];
124119
}];
125120
thirdPage.topPadding = 10;
126121
thirdPage.underTitlePadding = 160;
127122
thirdPage.bottomPadding = -10;
128-
thirdPage.titleFontName = @"SFOuterLimitsUpright";
129-
thirdPage.titleTextColor = [UIColor colorWithRed:58/255.0 green:105/255.0 blue:136/255.0 alpha:1.0];
130-
thirdPage.bodyTextColor = [UIColor colorWithRed:58/255.0 green:105/255.0 blue:136/255.0 alpha:1.0];
131-
thirdPage.buttonTextColor = [UIColor colorWithRed:239/255.0 green:88/255.0 blue:35/255.0 alpha:1.0];
132-
thirdPage.bodyFontName = @"NasalizationRg-Regular";
133-
thirdPage.bodyFontSize = 15;
134-
thirdPage.buttonFontName = @"SpaceAge";
135-
thirdPage.buttonFontSize = 17;
123+
thirdPage.titleLabel.font = [UIFont fontWithName:@"SFOuterLimitsUpright" size:38.0];
124+
thirdPage.titleLabel.textColor = [UIColor colorWithRed:58/255.0 green:105/255.0 blue:136/255.0 alpha:1.0];
125+
thirdPage.bodyLabel.textColor = [UIColor colorWithRed:58/255.0 green:105/255.0 blue:136/255.0 alpha:1.0];
126+
thirdPage.bodyLabel.font = [UIFont fontWithName:@"NasalizationRg-Regular" size:15.0];
127+
[thirdPage.actionButton setTitleColor:[UIColor colorWithRed:239/255.0 green:88/255.0 blue:35/255.0 alpha:1.0] forState:UIControlStateNormal];
128+
thirdPage.actionButton.titleLabel.font = [UIFont fontWithName:@"SpaceAge" size:17.0];
136129

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

149-
- (OnboardingViewController *)generateThirdDemoVC {
150-
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];
151-
firstPage.bodyFontSize = 25;
152-
153-
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];
154-
secondPage.bodyFontSize = 24;
155-
156-
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];
157-
158-
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];
159-
160-
OnboardingViewController *onboardingVC = [[OnboardingViewController alloc] initWithBackgroundImage:[UIImage imageNamed:@"milky_way.jpg"] contents:@[firstPage, secondPage, thirdPage, fourthPage]];
161-
onboardingVC.shouldMaskBackground = NO;
162-
onboardingVC.shouldBlurBackground = YES;
163-
return onboardingVC;
164-
}
165-
166-
- (OnboardingViewController *)generateFourthDemoVC {
167-
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];
168-
169-
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];
170-
secondPage.topPadding = 0;
171-
172-
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];
173-
thirdPage.titleFontSize = 33;
174-
thirdPage.bodyFontSize = 25;
175-
176-
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];
177-
fourthPage.titleFontSize = 28;
178-
fourthPage.bodyFontSize = 24;
179-
180-
OnboardingViewController *onboardingVC = [[OnboardingViewController alloc] initWithBackgroundImage:[UIImage imageNamed:@"yellowbg"] contents:@[firstPage, secondPage, thirdPage, fourthPage]];
181-
onboardingVC.shouldMaskBackground = NO;
182-
onboardingVC.titleTextColor = [UIColor colorWithRed:57/255.0 green:57/255.0 blue:57/255.0 alpha:1.0];;
183-
onboardingVC.bodyTextColor = [UIColor colorWithRed:244/255.0 green:64/255.0 blue:40/255.0 alpha:1.0];
184-
onboardingVC.fontName = @"HelveticaNeue-Italic";
185-
return onboardingVC;
186-
}
187-
188-
- (OnboardingViewController *)generateFifthDemoVC {
189-
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];
190-
firstPage.topPadding = -15;
191-
firstPage.underTitlePadding = 160;
192-
firstPage.titleTextColor = [UIColor colorWithRed:239/255.0 green:88/255.0 blue:35/255.0 alpha:1.0];
193-
firstPage.titleFontName = @"SFOuterLimitsUpright";
194-
firstPage.bodyTextColor = [UIColor colorWithRed:239/255.0 green:88/255.0 blue:35/255.0 alpha:1.0];
195-
firstPage.bodyFontName = @"NasalizationRg-Regular";
196-
firstPage.bodyFontSize = 18;
197-
198-
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];
199-
secondPage.titleFontName = @"SFOuterLimitsUpright";
200-
secondPage.underTitlePadding = 170;
201-
secondPage.topPadding = 0;
202-
secondPage.titleTextColor = [UIColor colorWithRed:251/255.0 green:176/255.0 blue:59/255.0 alpha:1.0];
203-
secondPage.bodyTextColor = [UIColor colorWithRed:251/255.0 green:176/255.0 blue:59/255.0 alpha:1.0];
204-
secondPage.bodyFontName = @"NasalizationRg-Regular";
205-
secondPage.bodyFontSize = 18;
206-
207-
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:^{
208-
[self handleOnboardingCompletion];
209-
}];
210-
thirdPage.topPadding = 10;
211-
thirdPage.underTitlePadding = 160;
212-
thirdPage.bottomPadding = -10;
213-
thirdPage.titleFontName = @"SFOuterLimitsUpright";
214-
thirdPage.titleTextColor = [UIColor colorWithRed:58/255.0 green:105/255.0 blue:136/255.0 alpha:1.0];
215-
thirdPage.bodyTextColor = [UIColor colorWithRed:58/255.0 green:105/255.0 blue:136/255.0 alpha:1.0];
216-
thirdPage.buttonTextColor = [UIColor colorWithRed:239/255.0 green:88/255.0 blue:35/255.0 alpha:1.0];
217-
thirdPage.bodyFontName = @"NasalizationRg-Regular";
218-
thirdPage.bodyFontSize = 15;
219-
thirdPage.buttonFontName = @"SpaceAge";
220-
thirdPage.buttonFontSize = 17;
221-
222-
OnboardingViewController *onboardingVC = [[OnboardingViewController alloc] initWithBackgroundImage:[UIImage imageNamed:@"milky_way.jpg"] contents:@[firstPage, secondPage, thirdPage]];
223-
onboardingVC.shouldFadeTransitions = YES;
224-
onboardingVC.shouldMaskBackground = NO;
225-
onboardingVC.pageControl.currentPageIndicatorTintColor = [UIColor colorWithRed:239/255.0 green:88/255.0 blue:35/255.0 alpha:1.0];
226-
onboardingVC.pageControl.pageIndicatorTintColor = [UIColor whiteColor];
227-
return onboardingVC;
228-
}
229-
230-
@end
142+
@end

Demo/Demo Files/OnboardTests/OnboardTests.m

-41
Original file line numberDiff line numberDiff line change
@@ -76,47 +76,6 @@ - (void)testDefaultValues {
7676
XCTAssertFalse(onboardingVC.shouldBlurBackground, @"The background should not be blurred by default.");
7777
}
7878

79-
- (void)testConvenienceSetters {
80-
// This tests that when we use the convenience setter methods on the master onboaring view controller,
81-
// the properties correctly trickle down to each of the child content view controllers.
82-
OnboardingViewController *onboardingVC = [[OnboardingViewController alloc] initWithBackgroundImage:nil contents:[self generateStockContentVCS]];
83-
84-
CGFloat testIconSize = 80;
85-
onboardingVC.iconSize = testIconSize;
86-
87-
UIColor *testColor = [UIColor purpleColor];
88-
onboardingVC.titleTextColor = testColor;
89-
onboardingVC.bodyTextColor = testColor;
90-
onboardingVC.buttonTextColor = testColor;
91-
92-
NSString *testFontName = @"Helvetica-LightOblique";
93-
onboardingVC.fontName = testFontName;
94-
95-
CGFloat testFontSize = 12;
96-
onboardingVC.titleFontSize = testFontSize;
97-
onboardingVC.bodyFontSize = testFontSize;
98-
99-
CGFloat testPadding = 22;
100-
onboardingVC.topPadding = testPadding;
101-
onboardingVC.underIconPadding = testPadding;
102-
onboardingVC.underTitlePadding = testPadding;
103-
onboardingVC.bottomPadding = testPadding;
104-
105-
NSArray *contentsFromController = onboardingVC.viewControllers;
106-
107-
for (OnboardingContentViewController *contentVC in contentsFromController) {
108-
XCTAssert(contentVC.titleTextColor == testColor, @"The content view controller's title text color is invalid.");
109-
XCTAssert(contentVC.bodyTextColor == testColor, @"The content view controller's body text color is invalid.");
110-
XCTAssert(contentVC.buttonTextColor == testColor, @"The content view controller's button test color is invalid.");
111-
XCTAssert(contentVC.titleFontSize == testFontSize, @"The content view controller's title fotn size is invalid.");
112-
XCTAssert(contentVC.bodyFontSize == testFontSize, @"The content view controller's body font size is invalid.");
113-
XCTAssert(contentVC.topPadding == testPadding, @"The content view controller's top padding is invalid.");
114-
XCTAssert(contentVC.underIconPadding == testPadding, @"The content view controller's under icon padding is invalid.");
115-
XCTAssert(contentVC.underTitlePadding == testPadding, @"The content view controller's under title padding is invalid.");
116-
XCTAssert(contentVC.bottomPadding == testPadding, @"The content view controller's bottom padding is invalid.");
117-
}
118-
}
119-
12079
- (void)testActionHandler {
12180
XCTestExpectation *expectation = [self expectationWithDescription:@"callback"];
12281
OnboardingContentViewController *contentVC = [[OnboardingContentViewController alloc] initWithTitle:@"T1" body:@"B1" image:nil buttonText:nil action:^{

Onboard.podspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
Pod::Spec.new do |s|
22

33
s.name = "Onboard"
4-
s.version = "2.1.9"
4+
s.version = "2.2.0"
55
s.summary = "Create a beautiful and engaging onboarding experience with only a few lines of code."
66
s.homepage = "https://github.com/mamaral/Onboard"
77
s.license = "MIT"
88
s.author = { "Mike Amaral" => "[email protected]" }
99
s.social_media_url = "http://twitter.com/MikeAmaral"
1010
s.platform = :ios
11-
s.source = { :git => "https://github.com/mamaral/Onboard.git", :tag => "v2.1.9" }
11+
s.source = { :git => "https://github.com/mamaral/Onboard.git", :tag => "v2.2.0" }
1212
s.source_files = "Source/OnboardingViewController.{h,m}", "Source/OnboardingContentViewController.{h,m}"
1313
s.requires_arc = true
1414

README.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,9 @@ With only a few lines of code you have a beautiful, end-to-end onboarding proces
7575
Customization
7676
=============
7777

78-
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.
78+
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:
7979

8080
```objective-c
81-
OnboardingViewController *onboardingVC = [OnboardingViewController onboardWithBackgroundImage contents:yourContentsArray];
82-
onboardingVC.fontName = @"Helvetica-Light";
83-
onboardingVC.titleFontSize = 28;
84-
onboardingVC.bodyFontSize = 22;
8581
onboardingVC.topPadding = 20;
8682
onboardingVC.underIconPadding = 10;
8783
onboardingVC.underTitlePadding = 15;

0 commit comments

Comments
 (0)