Skip to content

Commit

Permalink
Merge pull request #3 from AppsComTr/code-style-fix
Browse files Browse the repository at this point in the history
more fixes
  • Loading branch information
mertsimsek authored Oct 31, 2018
2 parents 7b7f06e + 7788162 commit 1b82556
Show file tree
Hide file tree
Showing 23 changed files with 443 additions and 153 deletions.
126 changes: 99 additions & 27 deletions APFancyPager/APFancyPagerViewController.swift

Large diffs are not rendered by default.

89 changes: 58 additions & 31 deletions APFancyPager/Protocols/APFancyPagerDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,54 +11,81 @@ import UIKit
/// Data source protocol for APFancyPager
@objc public protocol APFancyPagerDataSource: class {
/**
You should implement this function in order to tell the number of your view controllers that will be used in the APFancyPager.
- parameter fancyPagerViewController: APFancyPagerViewController object of currently using.

- returns: Number of view controllers that will be used in the APFancyPager
You should implement this function in order to tell the
number of your view controllers that will be used in the
APFancyPager.
- parameter fancyPagerViewController:
APFancyPagerViewController object of currently using.

- returns: Number of view controllers that will be used in
the APFancyPager
*/
func numberOfViewControllers(_ fancyPagerViewController: APFancyPagerViewController) -> Int

/**
You should implement this function in order to tell the view controllers that will be used in the APFancyPager.
- parameter fancyPagerViewController: APFancyPagerViewController object of currently using.
- parameter viewControllerForIndex: Index parameter of the view controller that will be used in the APFancyPager.

- returns: View controller that will be used in the APFancyPager
You should implement this function in order to tell the view
controllers that will be used in the APFancyPager.
- parameter fancyPagerViewController:
APFancyPagerViewController object of currently using.
- parameter viewControllerForIndex: Index parameter of the
view controller that will be used in the APFancyPager.

- returns: View controller that will be used in the
APFancyPager
*/
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController, viewControllerForIndex index: Int) -> UIViewController
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController,
viewControllerForIndex index: Int) -> UIViewController

/**
You should implement this function in order to tell the header height of the APFancyPager.
- parameter fancyPagerViewController: APFancyPagerViewController object of currently using.

You should implement this function in order to tell the
header height of the APFancyPager.
- parameter fancyPagerViewController:
APFancyPagerViewController object of currently using.

- returns: Header height of the APFancyPager
*/
func heightForHeader(_ fancyPagerViewController: APFancyPagerViewController) -> CGFloat

/**
You should implement this function in order to tell the header string at the given index of the APFancyPager.
- parameter fancyPagerViewController: APFancyPagerViewController object of currently using.
- parameter headerStringForIndex: Index parameter of the header that used in the APFancyPager.

- returns: Header string of the given index of the APFancyPager
You should implement this function in order to tell the
header string at the given index of the APFancyPager.
- parameter fancyPagerViewController:
APFancyPagerViewController object of currently using.
- parameter headerStringForIndex: Index parameter of the
header that used in the APFancyPager.

- returns: Header string of the given index of the
APFancyPager
*/
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController, headerStringForIndex index: Int) -> String
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController,
headerStringForIndex index: Int) -> String

/**
You should implement this function in order to tell the header background color at the given index of the APFancyPager.
- parameter fancyPagerViewController: APFancyPagerViewController object of currently using.
- parameter headerBackgroundColorForIndex: Index parameter of the header that used in the APFancyPager.

- returns: Header background color of the given index of the APFancyPager
You should implement this function in order to tell the
header background color at the given index of the
APFancyPager.
- parameter fancyPagerViewController:
APFancyPagerViewController object of currently using.
- parameter headerBackgroundColorForIndex: Index parameter
of the header that used in the APFancyPager.

- returns: Header background color of the given index of the
APFancyPager
*/
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController, headerBackgroundColorForIndex index: Int) -> UIColor
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController,
headerBackgroundColorForIndex index: Int) -> UIColor

/**
You should implement this function in order to tell the header text color at the given index of the APFancyPager.
- parameter fancyPagerViewController: APFancyPagerViewController object of currently using.
- parameter headerTextColorForIndex: Index parameter of the header that used in the APFancyPager.

- returns: Header text color of the given index of the APFancyPager
You should implement this function in order to tell the
header text color at the given index of the APFancyPager.
- parameter fancyPagerViewController:
APFancyPagerViewController object of currently using.
- parameter headerTextColorForIndex: Index parameter of the
header that used in the APFancyPager.

- returns: Header text color of the given index of the
APFancyPager
*/
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController, headerTextColorForIndex index: Int) -> UIColor
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController,
headerTextColorForIndex index: Int) -> UIColor
}
34 changes: 23 additions & 11 deletions APFancyPager/Protocols/APFancyPagerDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,40 @@ import UIKit
/// Delegate protocol for APFancyPager
@objc public protocol APFancyPagerDelegate: class {
/**
You can implement this function in order to get information while the user is scrolling through the APFancyPager.
- parameter fancyPagerViewController: APFancyPagerViewController object of currently using.
- parameter isScrollingFromIndex: Index parameter that user started to scrolling **from** in the APFancyPager.
- parameter toIndex: Index parameter that user started to scrolling **to** in the APFancyPager.
You can implement this function in order to get information
while the user is scrolling through the APFancyPager.
- parameter fancyPagerViewController:
APFancyPagerViewController object of currently using.
- parameter isScrollingFromIndex: Index parameter that user
started to scrolling **from** in the APFancyPager.
- parameter toIndex: Index parameter that user started to
scrolling **to** in the APFancyPager.
- parameter progress: Progress of the scrolling.
*/
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController, isScrollingFromIndex fromIndex: Int, toIndex: Int, progress: CGFloat)
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController,
isScrollingFromIndex fromIndex: Int, toIndex: Int, progress: CGFloat)

/**
You can implement this function in order to get information when the user did scroll successfully through the APFancyPager.
- parameter fancyPagerViewController: APFancyPagerViewController object of currently using.
- parameter didScrollToIndex: Index parameter that user scrolled in the APFancyPager.
You can implement this function in order to get information
when the user did scroll successfully through the
APFancyPager.
- parameter fancyPagerViewController:
APFancyPagerViewController object of currently using.
- parameter didScrollToIndex: Index parameter that user
scrolled in the APFancyPager.
*/
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController, didScrollToIndex index: Int)
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController,
didScrollToIndex index: Int)
}

public extension APFancyPagerDelegate {
public func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController, isScrollingFromIndex fromIndex: Int, toIndex: Int, progress: CGFloat) {
public func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController,
isScrollingFromIndex fromIndex: Int, toIndex: Int, progress: CGFloat) {
return
}

public func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController, didScrollToIndex index: Int) {
public func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController,
didScrollToIndex index: Int) {
return
}
}
11 changes: 9 additions & 2 deletions APFancyPager/Util/Util.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,19 @@ open class Util {
}

extension UIColor {
var rgba: (red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) {
var rgba: (red: CGFloat,
green: CGFloat,
blue: CGFloat,
alpha: CGFloat) {

var red: CGFloat = 0
var green: CGFloat = 0
var blue: CGFloat = 0
var alpha: CGFloat = 0
getRed(&red, green: &green, blue: &blue, alpha: &alpha)
getRed(&red,
green: &green,
blue: &blue,
alpha: &alpha)

return (red, green, blue, alpha)
}
Expand Down
36 changes: 28 additions & 8 deletions APFancyPagerDemo/APFancyPagerDemo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,50 @@ import UIKit
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
// Sent when the application is about to move from active to
// inactive state. This can occur for certain types of
// temporary interruptions (such as an incoming phone call or
// SMS message) or when the user quits the application and it
// begins the transition to the background state.

// Use this method to pause ongoing tasks, disable timers, and
// invalidate graphics rendering callbacks. Games should use
// this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
// Use this method to release shared resources, save user data,
// invalidate timers, and store enough application state
// information to restore your application to its current state
// in case it is terminated later.

// If your application supports background execution, this
// method is called instead of applicationWillTerminate: when
// the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
// Called as part of the transition from the background to the
// active state; here you can undo many of the changes made on
// entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
// Restart any tasks that were paused (or not yet started)
// while the application was inactive. If the application was
// previously in the background, optionally refresh the user
// interface.
}

func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
// Called when the application is about to terminate. Save data
// if appropriate. See also applicationDidEnterBackground:.
}
}
18 changes: 12 additions & 6 deletions APFancyPagerDemo/APFancyPagerDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class ViewController: APFancyPagerViewController, APFancyPagerDelegate, APFancyP
return 100.0
}

func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController, viewControllerForIndex index: Int) -> UIViewController {
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController,
viewControllerForIndex index: Int) -> UIViewController {
let viewController = UIViewController()
let button = UIButton(frame: CGRect(x: 0.0, y: 0.0, width: 100.0, height: 100.0))
button.center = viewController.view.center
Expand All @@ -50,7 +51,8 @@ class ViewController: APFancyPagerViewController, APFancyPagerDelegate, APFancyP
return viewController
}

func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController, headerStringForIndex index: Int) -> String {
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController,
headerStringForIndex index: Int) -> String {
switch index {
case 0:
return "Wow really?"
Expand All @@ -65,7 +67,8 @@ class ViewController: APFancyPagerViewController, APFancyPagerDelegate, APFancyP
}
}

func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController, headerTextColorForIndex index: Int) -> UIColor {
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController,
headerTextColorForIndex index: Int) -> UIColor {
switch index {
case 0:
return UIColor.orange
Expand All @@ -80,7 +83,8 @@ class ViewController: APFancyPagerViewController, APFancyPagerDelegate, APFancyP
}
}

func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController, headerBackgroundColorForIndex index: Int) -> UIColor {
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController,
headerBackgroundColorForIndex index: Int) -> UIColor {
switch index {
case 0:
return UIColor.blue
Expand All @@ -95,11 +99,13 @@ class ViewController: APFancyPagerViewController, APFancyPagerDelegate, APFancyP
}
}

func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController, didScrollToIndex index: Int) {
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController,
didScrollToIndex index: Int) {
print("DidScroll: \(index)")
}

func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController, isScrollingFromIndex fromIndex: Int, toIndex: Int, progress: CGFloat) {
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController,
isScrollingFromIndex fromIndex: Int, toIndex: Int, progress: CGFloat) {
print("IsScrolling: \(fromIndex) to: \(toIndex) WithProgress: \(progress)")
}

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# APFancyPager
A fancy pager view controller framework for Swift/Objective-C

Expand Down Expand Up @@ -44,7 +43,7 @@ func heightForHeader(_ fancyPagerViewController: APFancyPagerViewController) ->

You should return related view controller into pages by using
```swift
fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController, viewControllerForIndex index: Int) -> UIViewController
func fancyPagerViewController(_ fancyPagerViewController: APFancyPagerViewController, viewControllerForIndex index: Int) -> UIViewController
```
Just return your view controller for related index.

Expand Down
5 changes: 3 additions & 2 deletions docs/Classes.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ <h1>Classes</h1>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Our almighty class which is simply a UIViewController. Everything starts by using this view controller.</p>
<p>Our almighty class which is simply a UIViewController.
Everything starts by using this view controller.</p>

<a href="Classes/APFancyPagerViewController.html" class="slightly-smaller">See more</a>
</div>
Expand Down Expand Up @@ -125,7 +126,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="https://github.com/AppsComTr/APFancyPager" target="_blank" rel="external">Orhun Mert Simsek</a>. All rights reserved. (Last updated: 2018-10-10)</p>
<p>&copy; 2018 <a class="link" href="https://github.com/AppsComTr/APFancyPager" target="_blank" rel="external">Orhun Mert Simsek</a>. All rights reserved. (Last updated: 2018-10-31)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
Loading

0 comments on commit 1b82556

Please sign in to comment.