diff options
-rw-r--r-- | ios/iosremote/WalkThroughContainerViewController.h | 15 | ||||
-rw-r--r-- | ios/iosremote/WalkThroughContainerViewController.m | 114 |
2 files changed, 129 insertions, 0 deletions
diff --git a/ios/iosremote/WalkThroughContainerViewController.h b/ios/iosremote/WalkThroughContainerViewController.h new file mode 100644 index 000000000000..ee5dff01ee1a --- /dev/null +++ b/ios/iosremote/WalkThroughContainerViewController.h @@ -0,0 +1,15 @@ +// +// WalkThroughContainerViewController.h +// iosremote +// +// Created by Siqi Liu on 8/27/13. +// Copyright (c) 2013 libreoffice. All rights reserved. +// + +#import <UIKit/UIKit.h> + +@interface WalkThroughContainerViewController : UIViewController <UIPageViewControllerDataSource> + +@property (strong, nonatomic) UIPageViewController *pageController; + +@end diff --git a/ios/iosremote/WalkThroughContainerViewController.m b/ios/iosremote/WalkThroughContainerViewController.m new file mode 100644 index 000000000000..75bc6549e19f --- /dev/null +++ b/ios/iosremote/WalkThroughContainerViewController.m @@ -0,0 +1,114 @@ +// +// WalkThroughContainerViewController.m +// iosremote +// +// Created by Siqi Liu on 8/27/13. +// Copyright (c) 2013 libreoffice. All rights reserved. +// + +#import "WalkThroughContainerViewController.h" +#import "WalkThroughPageViewController.h" +#import <QuartzCore/QuartzCore.h> + +@interface WalkThroughContainerViewController () + +@end + +@implementation WalkThroughContainerViewController + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + self.pageController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil]; + + self.pageController.dataSource = self; + [[self.pageController view] setFrame:[[self view] bounds]]; + WalkThroughPageViewController *initialPageViewController = [self viewControllerAtIndex:0]; + NSArray *viewControllers = [NSArray arrayWithObject:initialPageViewController]; + + [self.pageController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil]; + [self addChildViewController:self.pageController]; + [[self view] addSubview:self.pageController.view]; + [self.pageController didMoveToParentViewController:self]; + + UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Ok, thanks", nil) style:UIBarButtonItemStyleBordered target:self action:@selector(handleBack)]; + [backButton setBackgroundImage:[UIImage imageNamed:@"backButton"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; + self.navigationItem.leftBarButtonItem = backButton; + + [self setTitle:NSLocalizedString(@"How-to", nil)]; + + CAGradientLayer *gradient = [CAGradientLayer layer]; + gradient.frame = self.view.bounds; + gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor whiteColor] CGColor], (id)[[UIColor orangeColor] CGColor], nil]; + gradient.startPoint = CGPointMake(0.5, 0.7); + gradient.endPoint = CGPointMake(0.5, 1.0); +// [self.view.layer insertSublayer:gradient atIndex:0]; +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +#pragma mark UIPageViewControllerDataSource methods + +- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController +{ + NSUInteger index = [(WalkThroughPageViewController *)viewController index]; + + if (index == 0) { + return nil; + } + + index--; + + return [self viewControllerAtIndex:index]; +} + +- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController +{ + NSUInteger index = [(WalkThroughPageViewController *)viewController index]; + + index++; + + if (index == 3) { + return nil; + } + + return [self viewControllerAtIndex:index]; +} + +- (WalkThroughPageViewController *)viewControllerAtIndex:(NSUInteger)index { + + WalkThroughPageViewController *childViewController; + if (index == 2) { + childViewController = [[WalkThroughPageViewController alloc] initWithNibName:@"WalkThroughPageViewMainImageController" bundle:nil]; + } else { + childViewController = [[WalkThroughPageViewController alloc] initWithNibName:@"WalkThroughPageViewController" bundle:nil]; + } + childViewController.index = index; + + return childViewController; +} + +- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController { + // The number of items reflected in the page indicator. + return 3; +} + +- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController { + // The selected item reflected in the page indicator. + return 0; +} + +@end |