From 60840fc124e3561cd83cb0f20b5825d7c9f7f477 Mon Sep 17 00:00:00 2001 From: Mike Amaral Date: Thu, 11 Aug 2016 23:38:15 -0400 Subject: [PATCH] Major cleanup and refactor. --- Demo/Demo Files/AppDelegate.m | 44 +++++++ Demo/Demo Files/OnboardTests/OnboardTests.m | 26 ---- Source/OnboardingContentViewController.h | 24 ++-- Source/OnboardingContentViewController.m | 104 ++++++--------- Source/OnboardingViewController.h | 29 ----- Source/OnboardingViewController.m | 133 ++++---------------- 6 files changed, 112 insertions(+), 248 deletions(-) diff --git a/Demo/Demo Files/AppDelegate.m b/Demo/Demo Files/AppDelegate.m index f5b76f7..bff77ed 100644 --- a/Demo/Demo Files/AppDelegate.m +++ b/Demo/Demo Files/AppDelegate.m @@ -31,6 +31,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( else { self.window.rootViewController = [self generateStandardOnboardingVC]; // self.window.rootViewController = [self generateMovieOnboardingVC]; +// self.window.rootViewController = [self generateContentVideoOnboardingVC]; // __weak typeof(self) weakSelf = self; // @@ -139,4 +140,47 @@ - (OnboardingViewController *)generateMovieOnboardingVC { return onboardingVC; } +- (OnboardingViewController *)generateContentVideoOnboardingVC { + NSBundle *bundle = [NSBundle mainBundle]; + NSString *moviePath = [bundle pathForResource:@"sun" ofType:@"mp4"]; + NSURL *movieURL = [NSURL fileURLWithPath:moviePath]; + + OnboardingContentViewController *firstPage = [OnboardingContentViewController contentWithTitle:@"Everything Under The Sun" body:@"The temperature of the photosphere is over 10,000°F." videoURL:movieURL buttonText:nil action:nil]; + firstPage.topPadding = -15; + firstPage.underTitlePadding = 160; + 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 contentWithTitle:@"Every Second" body:@"600 million tons of protons are converted into helium atoms." videoURL:movieURL buttonText:nil action:nil]; + secondPage.titleLabel.font = [UIFont fontWithName:@"SFOuterLimitsUpright" size:38.0]; + secondPage.underTitlePadding = 170; + secondPage.topPadding = 0; + 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 contentWithTitle:@"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." videoURL:movieURL buttonText:nil action:^{ + [self handleOnboardingCompletion]; + }]; + thirdPage.topPadding = 10; + thirdPage.underTitlePadding = 160; + thirdPage.bottomPadding = -10; + 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]; + + OnboardingViewController *onboardingVC = [[OnboardingViewController alloc] initWithBackgroundImage:nil contents:@[firstPage, secondPage, thirdPage]]; + onboardingVC.view.backgroundColor = [UIColor blackColor]; + 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 diff --git a/Demo/Demo Files/OnboardTests/OnboardTests.m b/Demo/Demo Files/OnboardTests/OnboardTests.m index 78ef634..40e799a 100644 --- a/Demo/Demo Files/OnboardTests/OnboardTests.m +++ b/Demo/Demo Files/OnboardTests/OnboardTests.m @@ -17,10 +17,6 @@ @interface OnboardTests : XCTestCase @interface OnboardingContentViewController (Testing) -@property (nonatomic, strong) MPMoviePlayerController *moviePlayerController; -@property (nonatomic, strong) NSURL *videoURL; -- (UIImage *)thumbnailImageForVideo:(NSURL *)videoURL; - @end @implementation OnboardTests @@ -47,28 +43,6 @@ - (void)testContentViewControllers { } } -- (void)testContentViewControllerWithVideo { - // This tests that when we create an onboarding content view controller with a video url - - OnboardingContentViewController *contentVC = [[OnboardingContentViewController alloc] initWithTitle:@"T1" body:@"B1" videoURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"sun" ofType:@"mp4"]] buttonText:nil action:nil]; - [contentVC view];//trick to call viewDidLoad - - XCTAssertNotNil(contentVC.moviePlayerController, @"The moviePlayerController should exist."); - XCTAssertNotNil(contentVC.videoURL, @"The videoURL should exist."); -} - -- (void)testGetThumbnailImageForVideo { - // This tests that when we try to get the video thumbnail on an onboarding content view controller with a video url - - OnboardingContentViewController *contentVC = [[OnboardingContentViewController alloc] initWithTitle:@"T1" body:@"B1" videoURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"sun" ofType:@"mp4"]] buttonText:nil action:nil]; - - UIImage *thumbnail = [contentVC thumbnailImageForVideo:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"sun" ofType:@"mp4"]]]; - UIImage *nilThumbnail = [contentVC thumbnailImageForVideo:nil]; - - XCTAssertNotNil(thumbnail, @"The video thumbnail should exist."); - XCTAssertNil(nilThumbnail, @"The video thumbnail should not exist for a nil URL."); -} - - (void)testDefaultValues { // This tests that the default values on the onboarding view controller are set properly. OnboardingViewController *onboardingVC = [[OnboardingViewController alloc] initWithBackgroundImage:nil contents:nil]; diff --git a/Source/OnboardingContentViewController.h b/Source/OnboardingContentViewController.h index 6f60d84..417dc83 100644 --- a/Source/OnboardingContentViewController.h +++ b/Source/OnboardingContentViewController.h @@ -7,7 +7,7 @@ // #import -@import MediaPlayer; +@import AVKit; @class OnboardingViewController; @class OnboardingContentViewController; @@ -133,6 +133,12 @@ typedef void (^action_callback)(OnboardingViewController *onboardController); @property (nonatomic, copy) dispatch_block_t viewDidDisappearBlock; +/** + * @brief The movie player controller used to play background movies. + */ +@property (nonatomic, strong) AVPlayerViewController *moviePlayerController; + + /** * @brief Convenience class initializer for creating an onboarding content view controller. * @return An instance of OnboardingViewController with the provided information. @@ -194,20 +200,4 @@ typedef void (^action_callback)(OnboardingViewController *onboardController); */ - (void)updateAlphas:(CGFloat)newAlpha; - -// The following properties are all deprecated, and will be removed in the next release of Onboard. -// -// -@property (nonatomic, strong) UIColor *titleTextColor __attribute__((deprecated("Set titleLabel.textColor instead. This property will be removed in the next update."))); -@property (nonatomic, strong) NSString *titleFontName __attribute__((deprecated("Set titleLabel.font instead. This property will be removed in the next update."))); -@property (nonatomic) CGFloat titleFontSize __attribute__((deprecated("Set titleLabel.font instead. This property will be removed in the next update."))); - -@property (nonatomic, strong) UIColor *bodyTextColor __attribute__((deprecated("Set bodyLabel.textColor instead. This property will be removed in the next update."))); -@property (nonatomic, strong) NSString *bodyFontName __attribute__((deprecated("Set bodyLabel.font instead. This property will be removed in the next update."))); -@property (nonatomic) CGFloat bodyFontSize __attribute__((deprecated("Set bodyLabel.font instead. This property will be removed in the next update."))); - -@property (nonatomic, strong) UIColor *buttonTextColor __attribute__((deprecated("Modify the actionButton property directly. This property will be removed in the next update."))); -@property (nonatomic, strong) NSString *buttonFontName __attribute__((deprecated("Modify the actionButton property directly. This property will be removed in the next update."))); -@property (nonatomic) CGFloat buttonFontSize __attribute__((deprecated("Modify the actionButton property directly. This property will be removed in the next update."))); - @end diff --git a/Source/OnboardingContentViewController.m b/Source/OnboardingContentViewController.m index 2a47ca1..1e9272d 100644 --- a/Source/OnboardingContentViewController.m +++ b/Source/OnboardingContentViewController.m @@ -8,7 +8,7 @@ #import "OnboardingContentViewController.h" #import "OnboardingViewController.h" -#import +@import AVFoundation; static NSString * const kDefaultOnboardingFont = @"Helvetica-Light"; @@ -34,10 +34,11 @@ @interface OnboardingContentViewController () -@property (nonatomic, strong) UIImageView *thumbnailImageView; -@property (nonatomic, strong) MPMoviePlayerController *moviePlayerController; +@property (nonatomic, strong) AVPlayer *player; @property (nonatomic, strong) NSURL *videoURL; +@property (nonatomic) BOOL wasPreviouslyVisible; + @end @implementation OnboardingContentViewController @@ -46,6 +47,9 @@ - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; } + +#pragma mark - Initializers + + (instancetype)contentWithTitle:(NSString *)title body:(NSString *)body image:(UIImage *)image buttonText:(NSString *)buttonText action:(dispatch_block_t)action { return [[self alloc] initWithTitle:title body:body image:image buttonText:buttonText action:action]; } @@ -123,18 +127,8 @@ - (instancetype)initWithTitle:(NSString *)title body:(NSString *)body image:(UII self.buttonActionHandler = actionBlock ?: ^(OnboardingViewController *controller){}; // Movie player - if (videoURL) { - self.videoURL = videoURL; + self.videoURL = videoURL; - self.moviePlayerController = [MPMoviePlayerController new]; - self.moviePlayerController.contentURL = self.videoURL; - self.moviePlayerController.repeatMode = MPMovieRepeatModeOne; - self.moviePlayerController.controlStyle = MPMovieControlStyleNone; - - self.thumbnailImageView = [[UIImageView alloc] initWithImage:[self thumbnailImageForVideo:self.videoURL]]; - self.thumbnailImageView.contentMode = UIViewContentModeScaleAspectFit; - } - // Auto-navigation self.movesToNextViewController = NO; @@ -160,14 +154,18 @@ - (instancetype)initWithTitle:(NSString *)title body:(NSString *)body image:(UII - (void)viewDidLoad { [super viewDidLoad]; - // Handle when the app enters the foreground. - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleAppEnteredForeground) name:UIApplicationWillEnterForegroundNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleAppEnteredForeground) name:UIApplicationDidBecomeActiveNotification object:nil]; self.view.backgroundColor = [UIColor clearColor]; // Add all our subviews - if (self.videoURL != nil) { - [self.moviePlayerController.backgroundView addSubview:self.thumbnailImageView]; + if (self.videoURL) { + self.player = [[AVPlayer alloc] initWithURL:self.videoURL]; + + self.moviePlayerController = [AVPlayerViewController new]; + self.moviePlayerController.player = self.player; + self.moviePlayerController.showsPlaybackControls = NO; + [self.view addSubview:self.moviePlayerController.view]; } @@ -185,6 +183,11 @@ - (void)viewWillAppear:(BOOL)animated { if (self.delegate) { [self.delegate setNextPage:self]; } + + // If we have a video URL, start playing + if (self.videoURL) { + [self.player play]; + } // Call our view will appear block if (self.viewWillAppearBlock) { @@ -192,6 +195,8 @@ - (void)viewWillAppear:(BOOL)animated { self.viewWillAppearBlock(); }); } + + self.wasPreviouslyVisible = YES; } - (void)viewDidAppear:(BOOL)animated { @@ -209,12 +214,6 @@ - (void)viewDidAppear:(BOOL)animated { self.viewDidAppearBlock(); }); } - - // If we have a video, start playing - if (self.moviePlayerController.playbackState != MPMoviePlaybackStatePlaying) { - self.moviePlayerController.currentPlaybackTime = 0.0; - [self.moviePlayerController play]; - } } - (void)viewWillDisappear:(BOOL)animated { @@ -226,6 +225,8 @@ - (void)viewWillDisappear:(BOOL)animated { self.viewWillDisappearBlock(); }); } + + self.wasPreviouslyVisible = NO; } - (void)viewDidDisappear:(BOOL)animated { @@ -237,10 +238,21 @@ - (void)viewDidDisappear:(BOOL)animated { self.viewDidDisappearBlock(); }); } - - // If we have a video, stop playing - if (self.moviePlayerController.playbackState != MPMoviePlaybackStateStopped) { - [self.moviePlayerController stop]; + + // Pause our video if we have one. + if ((self.player.rate != 0.0) && !self.player.error) { + [self.player pause]; + } +} + + +#pragma mark - App life cycle + +- (void)handleAppEnteredForeground { + // If we have a video URL and this view controller was previously on screen + // restart it as it will be paused when the app enters the foreground. + if (self.videoURL && self.wasPreviouslyVisible) { + [self.player play]; } } @@ -254,10 +266,6 @@ - (void)viewWillLayoutSubviews { self.moviePlayerController.view.frame = self.view.frame; } - if (self.thumbnailImageView) { - self.thumbnailImageView.frame = self.view.frame; - } - CGFloat viewWidth = CGRectGetWidth(self.view.frame); CGFloat contentWidth = viewWidth * kContentWidthMultiplier; CGFloat xPadding = (viewWidth - contentWidth) / 2.0; @@ -280,16 +288,6 @@ - (void)viewWillLayoutSubviews { } -#pragma mark - App state - -- (void)handleAppEnteredForeground { - //If the movie player is paused, as it does by default when backgrounded, start playing again. - if (self.moviePlayerController.playbackState == MPMoviePlaybackStatePaused) { - [self.moviePlayerController play]; - } -} - - #pragma mark - Transition alpha - (void)updateAlphas:(CGFloat)newAlpha { @@ -315,26 +313,4 @@ - (void)handleButtonPressed { } } - -#pragma mark - Utils - -- (UIImage *)thumbnailImageForVideo:(NSURL *)videoURL { - - AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:videoURL options:nil]; - AVAssetImageGenerator *assetIG = [[AVAssetImageGenerator alloc] initWithAsset:asset]; - assetIG.appliesPreferredTrackTransform = YES; - assetIG.apertureMode = AVAssetImageGeneratorApertureModeEncodedPixels; - - NSError *error = nil; - CGImageRef thumbnailImageRef = [assetIG copyCGImageAtTime:CMTimeMake(0, 60) actualTime:NULL error:&error]; - - if (!error) { - UIImage *thumbnailImage = [[UIImage alloc] initWithCGImage:thumbnailImageRef]; - return thumbnailImage; - } else { - NSLog(@"thumbnailImageGenerationError %@", error); - return nil; - } -} - @end diff --git a/Source/OnboardingViewController.h b/Source/OnboardingViewController.h index 49f3d4c..2f73d67 100644 --- a/Source/OnboardingViewController.h +++ b/Source/OnboardingViewController.h @@ -135,33 +135,4 @@ */ - (void)moveNextPage; - -// The following properties are all deprecated, and will be removed in the next release of Onboard. -// -// -@property (nonatomic) BOOL hidePageControl __attribute__((deprecated("Modify the pageControl property directly. This property will be removed in the next update."))); - -@property (nonatomic) CGFloat iconSize __attribute__((deprecated("Modify the content view controller's iconSize directly. This property will be removed in the next update."))); -@property (nonatomic) CGFloat iconHeight __attribute__((deprecated("Modify the content view controller's iconHeight directly. This property will be removed in the next update."))); -@property (nonatomic) CGFloat iconWidth __attribute__((deprecated("Modify the content view controller's iconWidth directly. This property will be removed in the next update."))); - -@property (nonatomic, strong) UIColor *titleTextColor __attribute__((deprecated("Modify the content view controller's titleLabel directly. This property will be removed in the next update."))); -@property (nonatomic, strong) NSString *titleFontName __attribute__((deprecated("Modify the content view controller's titleLabel directly. This property will be removed in the next update."))); -@property (nonatomic) CGFloat titleFontSize __attribute__((deprecated("Modify the content view controller's titleLabel directly. This property will be removed in the next update."))); - -@property (nonatomic, strong) UIColor *bodyTextColor __attribute__((deprecated("Modify the content view controller's bodyLabel directly. This property will be removed in the next update."))); -@property (nonatomic, strong) NSString *bodyFontName __attribute__((deprecated("Modify the content view controller's bodyLabel directly. This property will be removed in the next update."))); -@property (nonatomic) CGFloat bodyFontSize __attribute__((deprecated("Modify the content view controller's bodyLabel directly."))); - -@property (nonatomic, strong) UIColor *buttonTextColor __attribute__((deprecated("Modify the content view controller's actionButton directly. This property will be removed in the next update."))); -@property (nonatomic, strong) NSString *buttonFontName __attribute__((deprecated("Modify the content view controller's actionButton directly. This property will be removed in the next update."))); -@property (nonatomic) CGFloat buttonFontSize __attribute__((deprecated("Modify the content view controller's actionButton directly. This property will be removed in the next update."))); - -@property (nonatomic, strong) NSString *fontName __attribute__((deprecated("Modify the content view controller's labels directly. This property will be removed in the next update."))); - -@property (nonatomic) CGFloat topPadding __attribute__((deprecated("Modify the content view controller's topPadding directly. This property will be removed in the next update."))); -@property (nonatomic) CGFloat underIconPadding __attribute__((deprecated("Modify the content view controller's underIconPadding directly. This property will be removed in the next update."))); -@property (nonatomic) CGFloat underTitlePadding __attribute__((deprecated("Modify the content view controller's underTitlePadding directly. This property will be removed in the next update."))); -@property (nonatomic) CGFloat bottomPadding __attribute__((deprecated("Modify the content view controller's bottomPadding directly. This property will be removed in the next update."))); - @end diff --git a/Source/OnboardingViewController.m b/Source/OnboardingViewController.m index 5a09712..1c50a98 100644 --- a/Source/OnboardingViewController.m +++ b/Source/OnboardingViewController.m @@ -48,7 +48,7 @@ + (instancetype)onboardWithBackgroundImage:(UIImage *)backgroundImage contents:( - (instancetype)initWithBackgroundImage:(UIImage *)backgroundImage contents:(NSArray *)contents { self = [self initWithContents:contents]; - if (self == nil) { + if (!self) { return nil; } @@ -67,7 +67,7 @@ + (instancetype)onboardWithBackgroundVideoURL:(NSURL *)backgroundVideoURL conten - (instancetype)initWithBackgroundVideoURL:(NSURL *)backgroundVideoURL contents:(NSArray *)contents { self = [self initWithContents:contents]; - if (self == nil) { + if (!self) { return nil; } @@ -82,7 +82,7 @@ - (instancetype)initWithBackgroundVideoURL:(NSURL *)backgroundVideoURL contents: - (instancetype)initWithContents:(NSArray *)contents { self = [super init]; - if (self == nil) { + if (!self) { return nil; } @@ -118,6 +118,8 @@ - (instancetype)initWithContents:(NSArray *)contents { - (void)viewDidLoad { [super viewDidLoad]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleAppEnteredForeground) name:UIApplicationDidBecomeActiveNotification object:nil]; // now that the view has loaded, we can generate the content [self generateView]; @@ -135,13 +137,14 @@ - (void)viewWillAppear:(BOOL)animated { - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; - if ((self.player.rate != 0.0) && (self.player.error == nil) && self.stopMoviePlayerWhenDisappear) { + if ((self.player.rate != 0.0) && !self.player.error && self.stopMoviePlayerWhenDisappear) { [self.player pause]; } } - (void)viewWillLayoutSubviews { [super viewWillLayoutSubviews]; + self.pageVC.view.frame = self.view.frame; self.moviePlayerController.view.frame = self.view.frame; self.skipButton.frame = CGRectMake(CGRectGetMaxX(self.view.frame) - kSkipButtonWidth, CGRectGetMaxY(self.view.frame) - self.underPageControlPadding - kSkipButtonHeight, kSkipButtonWidth, kSkipButtonHeight); @@ -235,119 +238,22 @@ - (void)generateView { } -#pragma mark - Skipping - -- (void)handleSkipButtonPressed { - if (self.skipHandler) { - self.skipHandler(); - } -} - - -#pragma mark - Convenience setters for content pages +#pragma mark - App life cycle -- (void)setIconSize:(CGFloat)iconSize { - for (OnboardingContentViewController *contentVC in self.viewControllers) { - contentVC.iconWidth = iconSize; - contentVC.iconHeight = iconSize; - } -} - -- (void)setIconWidth:(CGFloat)iconWidth { - for (OnboardingContentViewController *contentVC in self.viewControllers) { - contentVC.iconWidth = iconWidth; - } -} - -- (void)setIconHeight:(CGFloat)iconHeight { - for (OnboardingContentViewController *contentVC in self.viewControllers) { - contentVC.iconHeight = iconHeight; - } -} - -- (void)setTitleTextColor:(UIColor *)titleTextColor { - for (OnboardingContentViewController *contentVC in self.viewControllers) { - contentVC.titleTextColor = titleTextColor; - } -} - -- (void)setBodyTextColor:(UIColor *)bodyTextColor { - for (OnboardingContentViewController *contentVC in self.viewControllers) { - contentVC.bodyTextColor = bodyTextColor; - } -} - -- (void)setButtonTextColor:(UIColor *)buttonTextColor { - for (OnboardingContentViewController *contentVC in self.viewControllers) { - contentVC.buttonTextColor = buttonTextColor; - } -} - -- (void)setFontName:(NSString *)fontName { - for (OnboardingContentViewController *contentVC in self.viewControllers) { - contentVC.titleFontName = fontName; - contentVC.bodyFontName = fontName; - contentVC.buttonFontName = fontName; - } -} - -- (void)setTitleFontName:(NSString *)fontName { - for (OnboardingContentViewController *contentVC in self.viewControllers) { - contentVC.titleFontName = fontName; - } -} - -- (void)setTitleFontSize:(CGFloat)titleFontSize { - for (OnboardingContentViewController *contentVC in self.viewControllers) { - contentVC.titleFontSize = titleFontSize; - } -} - -- (void)setBodyFontName:(NSString *)fontName { - for (OnboardingContentViewController *contentVC in self.viewControllers) { - contentVC.bodyFontName = fontName; - } -} - -- (void)setBodyFontSize:(CGFloat)bodyFontSize { - for (OnboardingContentViewController *contentVC in self.viewControllers) { - contentVC.bodyFontSize = bodyFontSize; - } -} - -- (void)setButtonFontName:(NSString *)fontName { - for (OnboardingContentViewController *contentVC in self.viewControllers) { - contentVC.buttonFontName = fontName; - } -} - -- (void)setButtonFontSize:(CGFloat)bodyFontSize { - for (OnboardingContentViewController *contentVC in self.viewControllers) { - contentVC.buttonFontSize = bodyFontSize; - } -} - -- (void)setTopPadding:(CGFloat)topPadding { - for (OnboardingContentViewController *contentVC in self.viewControllers) { - contentVC.topPadding = topPadding; +- (void)handleAppEnteredForeground { + // If we have a video URL, restart it as it will be paused when + // the app enters the foreground. + if (self.videoURL) { + [self.player play]; } } -- (void)setUnderIconPadding:(CGFloat)underIconPadding { - for (OnboardingContentViewController *contentVC in self.viewControllers) { - contentVC.underIconPadding = underIconPadding; - } -} -- (void)setUnderTitlePadding:(CGFloat)underTitlePadding { - for (OnboardingContentViewController *contentVC in self.viewControllers) { - contentVC.underTitlePadding = underTitlePadding; - } -} +#pragma mark - Skipping -- (void)setBottomPadding:(CGFloat)bottomPadding { - for (OnboardingContentViewController *contentVC in self.viewControllers) { - contentVC.bottomPadding = bottomPadding; +- (void)handleSkipButtonPressed { + if (self.skipHandler) { + self.skipHandler(); } } @@ -407,7 +313,7 @@ - (void)moveNextPage { } -#pragma mark - Page scroll status +#pragma mark - Onboarding content view controller delegate - (void)setCurrentPage:(OnboardingContentViewController *)currentPage { _currentPage = currentPage; @@ -417,6 +323,9 @@ - (void)setNextPage:(OnboardingContentViewController *)nextPage { _upcomingPage = nextPage; } + +#pragma mark - Page scroll status + - (void)scrollViewDidScroll:(UIScrollView *)scrollView { // calculate the percent complete of the transition of the current page given the // scrollview's offset and the width of the screen