Skip to content

Commit

Permalink
Reindented the whole project using spaces instead of tabs.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanceriu committed Nov 23, 2017
1 parent 3413dca commit 284b5af
Show file tree
Hide file tree
Showing 16 changed files with 1,683 additions and 1,683 deletions.
8 changes: 4 additions & 4 deletions Demo/ObjCDemo/SCAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ @implementation SCAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = [[SCRootViewController alloc] initWithNibName:NSStringFromClass([SCRootViewController class]) bundle:nil];
[self.window makeKeyAndVisible];
return YES;
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = [[SCRootViewController alloc] initWithNibName:NSStringFromClass([SCRootViewController class]) bundle:nil];
[self.window makeKeyAndVisible];
return YES;
}

@end
10 changes: 5 additions & 5 deletions Demo/ObjCDemo/SCMainViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
#import "SCEasingFunction.h"

typedef enum {
SCPageLayouterTypePlain,
SCPageLayouterTypeSliding,
SCPageLayouterTypeParallax,
SCPageLayouterTypeCards,
SCPageLayouterTypeCount
SCPageLayouterTypePlain,
SCPageLayouterTypeSliding,
SCPageLayouterTypeParallax,
SCPageLayouterTypeCards,
SCPageLayouterTypeCount
} SCPageLayouterType;

@protocol SCMainViewControllerDelegate;
Expand Down
270 changes: 135 additions & 135 deletions Demo/ObjCDemo/SCMainViewController.m

Large diffs are not rendered by default.

198 changes: 99 additions & 99 deletions Demo/ObjCDemo/SCRootViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,24 @@ @implementation SCRootViewController

- (void)viewDidLoad
{
[super viewDidLoad];

self.viewControllers = [NSMutableArray array];
for(int i=0; i < kDefaultNumberOfPages; i++) {
[self.viewControllers addObject:[NSNull null]];
}

self.pageViewController = [[SCPageViewController alloc] init];
[self.pageViewController setDataSource:self];
[self.pageViewController setDelegate:self];

[self.pageViewController setLayouter:[[SCPageLayouter alloc] init] animated:NO completion:nil];
[self.pageViewController setEasingFunction:[SCEasingFunction easingFunctionWithType:SCEasingFunctionTypeLinear]];
[super viewDidLoad];

[self addChildViewController:self.pageViewController];
[self.pageViewController.view setFrame:self.view.bounds];
[self.view addSubview:self.pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];
self.viewControllers = [NSMutableArray array];
for(int i=0; i < kDefaultNumberOfPages; i++) {
[self.viewControllers addObject:[NSNull null]];
}

self.pageViewController = [[SCPageViewController alloc] init];
[self.pageViewController setDataSource:self];
[self.pageViewController setDelegate:self];

[self.pageViewController setLayouter:[[SCPageLayouter alloc] init] animated:NO completion:nil];
[self.pageViewController setEasingFunction:[SCEasingFunction easingFunctionWithType:SCEasingFunctionTypeLinear]];

[self addChildViewController:self.pageViewController];
[self.pageViewController.view setFrame:self.view.bounds];
[self.view addSubview:self.pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];

[self _updateViewControllerDetails];
}
Expand All @@ -60,23 +60,23 @@ - (void)viewDidLoad

- (NSUInteger)numberOfPagesInPageViewController:(SCPageViewController *)pageViewController
{
return self.viewControllers.count;
return self.viewControllers.count;
}

- (UIViewController *)pageViewController:(SCPageViewController *)pageViewController viewControllerForPageAtIndex:(NSUInteger)pageIndex
{
SCMainViewController *viewController = self.viewControllers[pageIndex];
if([viewController isEqual:[NSNull null]]) {
viewController = [[SCMainViewController alloc] init];
[viewController.view setFrame:self.view.bounds];
[viewController setDelegate:self];
[viewController.contentView setBackgroundColor:[UIColor randomColor]];
[self.viewControllers replaceObjectAtIndex:pageIndex withObject:viewController];
}
return viewController;
SCMainViewController *viewController = self.viewControllers[pageIndex];
if([viewController isEqual:[NSNull null]]) {
viewController = [[SCMainViewController alloc] init];
[viewController.view setFrame:self.view.bounds];
[viewController setDelegate:self];
[viewController.contentView setBackgroundColor:[UIColor randomColor]];
[self.viewControllers replaceObjectAtIndex:pageIndex withObject:viewController];
}
return viewController;
}

- (NSUInteger)initialPageInPageViewController:(SCPageViewController *)pageViewController
Expand All @@ -88,127 +88,127 @@ - (NSUInteger)initialPageInPageViewController:(SCPageViewController *)pageViewCo

- (void)pageViewController:(SCPageViewController *)pageViewController didNavigateToOffset:(CGPoint)offset
{
[self _updateViewControllerDetails];
[self _updateViewControllerDetails];
}

#pragma mark - SCMainViewControllerDelegate

- (void)mainViewControllerDidChangeLayouterType:(SCMainViewController *)mainViewController
{
static NSDictionary *typeToLayouter;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
typeToLayouter = (@{@(SCPageLayouterTypePlain) : [SCPageLayouter class],
@(SCPageLayouterTypeSliding) : [SCSlidingPageLayouter class],
@(SCPageLayouterTypeParallax) : [SCParallaxPageLayouter class],
@(SCPageLayouterTypeCards) : [SCCardsPageLayouter class]});
});
id<SCPageLayouterProtocol> pageLayouter = [[typeToLayouter[@(mainViewController.layouterType)] alloc] init];
[self.pageViewController setLayouter:pageLayouter animated:YES completion:nil];
[self _updateViewControllerDetails];
static NSDictionary *typeToLayouter;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
typeToLayouter = (@{@(SCPageLayouterTypePlain) : [SCPageLayouter class],
@(SCPageLayouterTypeSliding) : [SCSlidingPageLayouter class],
@(SCPageLayouterTypeParallax) : [SCParallaxPageLayouter class],
@(SCPageLayouterTypeCards) : [SCCardsPageLayouter class]});
});
id<SCPageLayouterProtocol> pageLayouter = [[typeToLayouter[@(mainViewController.layouterType)] alloc] init];
[self.pageViewController setLayouter:pageLayouter animated:YES completion:nil];
[self _updateViewControllerDetails];
}

- (void)mainViewControllerDidChangeAnimationType:(SCMainViewController *)mainViewController
{
[self.pageViewController setEasingFunction:[SCEasingFunction easingFunctionWithType:mainViewController.easingFunctionType]];
self.selectedEasingFunctionType = mainViewController.easingFunctionType;
[self _updateViewControllerDetails];
[self.pageViewController setEasingFunction:[SCEasingFunction easingFunctionWithType:mainViewController.easingFunctionType]];
self.selectedEasingFunctionType = mainViewController.easingFunctionType;
[self _updateViewControllerDetails];
}

- (void)mainViewControllerDidChangeAnimationDuration:(SCMainViewController *)mainViewController
{
[self.pageViewController setAnimationDuration:mainViewController.duration];
[self.pageViewController setAnimationDuration:mainViewController.duration];
}

- (void)mainViewControllerDidRequestNavigationToNextPage:(SCMainViewController *)mainViewController
{
[self.pageViewController navigateToPageAtIndex:MIN(self.pageViewController.numberOfPages, self.pageViewController.currentPage + 1) animated:YES completion:nil];
[self.pageViewController navigateToPageAtIndex:MIN(self.pageViewController.numberOfPages, self.pageViewController.currentPage + 1) animated:YES completion:nil];
}

- (void)mainViewControllerDidRequestNavigationToPreviousPage:(SCMainViewController *)mainViewController
{
[self.pageViewController navigateToPageAtIndex:MAX(0, self.pageViewController.currentPage - 1) animated:YES completion:nil];
[self.pageViewController navigateToPageAtIndex:MAX(0, self.pageViewController.currentPage - 1) animated:YES completion:nil];
}

- (void)mainViewControllerDidRequestPageInsertion:(SCMainViewController *)mainViewController
{
[self _insertPagesAtIndexes:[NSIndexSet indexSetWithIndex:[self.viewControllers indexOfObject:mainViewController]]];
[self _updateViewControllerDetails];
[self _insertPagesAtIndexes:[NSIndexSet indexSetWithIndex:[self.viewControllers indexOfObject:mainViewController]]];
[self _updateViewControllerDetails];
}

- (void)mainViewControllerDidRequestPageDeletion:(SCMainViewController *)mainViewController
{
[self _deletePagesAtIndexes:[NSIndexSet indexSetWithIndex:[self.viewControllers indexOfObject:mainViewController]]];
[self _updateViewControllerDetails];
[self _deletePagesAtIndexes:[NSIndexSet indexSetWithIndex:[self.viewControllers indexOfObject:mainViewController]]];
[self _updateViewControllerDetails];
}

#pragma mark - Private

- (void)_reloadPagesAtIndexes:(NSIndexSet *)indexes
{
[indexes enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
[self.viewControllers replaceObjectAtIndex:idx withObject:[NSNull null]];
}];
[self.pageViewController reloadPagesAtIndexes:indexes animated:YES completion:nil];
[indexes enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
[self.viewControllers replaceObjectAtIndex:idx withObject:[NSNull null]];
}];
[self.pageViewController reloadPagesAtIndexes:indexes animated:YES completion:nil];
}

- (void)_insertPagesAtIndexes:(NSIndexSet *)indexes
{
[indexes enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
[self.viewControllers insertObject:[NSNull null] atIndex:idx];
}];
[self.pageViewController insertPagesAtIndexes:indexes animated:YES completion:nil];
[indexes enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
[self.viewControllers insertObject:[NSNull null] atIndex:idx];
}];
[self.pageViewController insertPagesAtIndexes:indexes animated:YES completion:nil];
}

- (void)_deletePagesAtIndexes:(NSIndexSet *)indexes
{
[indexes enumerateIndexesWithOptions:NSEnumerationReverse usingBlock:^(NSUInteger idx, BOOL *stop) {
[self.viewControllers removeObjectAtIndex:idx];
}];
[self.pageViewController deletePagesAtIndexes:indexes animated:YES completion:nil];
[indexes enumerateIndexesWithOptions:NSEnumerationReverse usingBlock:^(NSUInteger idx, BOOL *stop) {
[self.viewControllers removeObjectAtIndex:idx];
}];
[self.pageViewController deletePagesAtIndexes:indexes animated:YES completion:nil];
}

- (void)_movePageFromIndex:(NSUInteger)fromIndex toIndex:(NSUInteger)toIndex
{
UIViewController *viewController = [self.viewControllers objectAtIndex:fromIndex];
[self.viewControllers removeObjectAtIndex:fromIndex];
[self.viewControllers insertObject:viewController atIndex:toIndex];
[self.pageViewController movePageAtIndex:fromIndex toIndex:toIndex animated:YES completion:nil];
UIViewController *viewController = [self.viewControllers objectAtIndex:fromIndex];
[self.viewControllers removeObjectAtIndex:fromIndex];
[self.viewControllers insertObject:viewController atIndex:toIndex];
[self.pageViewController movePageAtIndex:fromIndex toIndex:toIndex animated:YES completion:nil];
}

- (void)_updateViewControllerDetails
{
[self.viewControllers enumerateObjectsUsingBlock:^(SCMainViewController *controller, NSUInteger index, BOOL *stop) {
if([controller isEqual:[NSNull null]]) {
return;
}
[controller.visiblePercentageLabel setText:[NSString stringWithFormat:@"%.2f%%", [self.pageViewController visiblePercentageForViewController:controller]]];
[controller.pageNumberLabel setText:[NSString stringWithFormat:@"Page %lu of %lu", (unsigned long)index, (unsigned long)self.pageViewController.numberOfPages]];
[controller setEasingFunctionType:self.selectedEasingFunctionType];
[controller setDuration:self.pageViewController.animationDuration];
static NSDictionary *layouterToType;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
layouterToType = (@{NSStringFromClass([SCPageLayouter class]) : @(SCPageLayouterTypePlain),
NSStringFromClass([SCSlidingPageLayouter class]) : @(SCPageLayouterTypeSliding),
NSStringFromClass([SCParallaxPageLayouter class]) : @(SCPageLayouterTypeParallax),
NSStringFromClass([SCCardsPageLayouter class]) : @(SCPageLayouterTypeCards)});
});
[controller setLayouterType:(SCPageLayouterType)[layouterToType[NSStringFromClass([self.pageViewController.layouter class])] unsignedIntegerValue]];
}];
[self.viewControllers enumerateObjectsUsingBlock:^(SCMainViewController *controller, NSUInteger index, BOOL *stop) {
if([controller isEqual:[NSNull null]]) {
return;
}
[controller.visiblePercentageLabel setText:[NSString stringWithFormat:@"%.2f%%", [self.pageViewController visiblePercentageForViewController:controller]]];
[controller.pageNumberLabel setText:[NSString stringWithFormat:@"Page %lu of %lu", (unsigned long)index, (unsigned long)self.pageViewController.numberOfPages]];
[controller setEasingFunctionType:self.selectedEasingFunctionType];
[controller setDuration:self.pageViewController.animationDuration];
static NSDictionary *layouterToType;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
layouterToType = (@{NSStringFromClass([SCPageLayouter class]) : @(SCPageLayouterTypePlain),
NSStringFromClass([SCSlidingPageLayouter class]) : @(SCPageLayouterTypeSliding),
NSStringFromClass([SCParallaxPageLayouter class]) : @(SCPageLayouterTypeParallax),
NSStringFromClass([SCCardsPageLayouter class]) : @(SCPageLayouterTypeCards)});
});
[controller setLayouterType:(SCPageLayouterType)[layouterToType[NSStringFromClass([self.pageViewController.layouter class])] unsignedIntegerValue]];
}];
}

@end
4 changes: 2 additions & 2 deletions Demo/SwiftDemo/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ enum PageLayouterType : Int {
}

class MainViewController: UIViewController, UIPickerViewDataSource, UIPickerViewDelegate {

@IBOutlet var pickerView:UIPickerView!

var delegate:MainViewControllerDelegate?
Expand All @@ -40,7 +40,7 @@ class MainViewController: UIViewController, UIPickerViewDataSource, UIPickerView
}

func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {

let layouterType = PageLayouterType.init(rawValue: row)!
switch(layouterType) {
case .plain:
Expand Down
6 changes: 3 additions & 3 deletions Demo/SwiftDemo/RootViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class RootViewController : UIViewController , SCPageViewControllerDataSource, SC

self.pageViewController.dataSource = self;
self.pageViewController.delegate = self;

self.addChildViewController(self.pageViewController)
self.pageViewController.view.frame = self.view.bounds
self.view.addSubview(self.pageViewController.view)
Expand All @@ -43,7 +43,7 @@ class RootViewController : UIViewController , SCPageViewControllerDataSource, SC
}

func pageViewController(_ pageViewController: SCPageViewController!, viewControllerForPageAt pageIndex: UInt) -> UIViewController! {


if let viewController = self.viewControllers[Int(pageIndex)] {
return viewController
Expand All @@ -69,7 +69,7 @@ class RootViewController : UIViewController , SCPageViewControllerDataSource, SC
//MARK: - SCPageViewControllerDelegate

func pageViewController(_ pageViewController: SCPageViewController!, didNavigateToOffset offset: CGPoint) {

func layouterToType(layouter: SCPageLayouterProtocol) -> PageLayouterType {
switch layouter {
case is SCSlidingPageLayouter:
Expand Down
Loading

0 comments on commit 284b5af

Please sign in to comment.