Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 86 additions & 33 deletions Example/KGFloatingDrawer-Example.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>KGFloatingDrawer-Example.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>3</integer>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
34 changes: 17 additions & 17 deletions Example/KGFloatingDrawer-Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
let kKGRightDrawerStoryboardId = "KGRightDrawerViewControllerStoryboardId"


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
// Override point for customization after application launch.
window = UIWindow(frame: UIScreen.mainScreen().bounds)
window = UIWindow(frame: UIScreen.main.bounds)

window?.rootViewController = drawerViewController

Expand All @@ -33,25 +33,25 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return true
}

func applicationWillResignActive(application: UIApplication) {
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 throttle down OpenGL ES frame rates. Games should use this method to pause the game.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the private game.
}

func applicationDidEnterBackground(application: UIApplication) {
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.
}

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

func applicationDidBecomeActive(application: UIApplication) {
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.
}

func applicationWillTerminate(application: UIApplication) {
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

Expand Down Expand Up @@ -84,38 +84,38 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

private func viewControllerForStoryboardId(storyboardId: String) -> UIViewController {
let viewController: UIViewController = drawerStoryboard().instantiateViewControllerWithIdentifier(storyboardId)
let viewController: UIViewController = drawerStoryboard().instantiateViewController(withIdentifier: storyboardId)
return viewController
}

func drawerSettingsViewController() -> UIViewController {
let viewController = viewControllerForStoryboardId(kKGDrawerSettingsViewControllerStoryboardId)
let viewController = viewControllerForStoryboardId(storyboardId: kKGDrawerSettingsViewControllerStoryboardId)
return viewController
}

func sourcePageViewController() -> UIViewController {
let viewController = viewControllerForStoryboardId(kKGDrawerWebViewViewControllerStoryboardId)
let viewController = viewControllerForStoryboardId(storyboardId: kKGDrawerWebViewViewControllerStoryboardId)
return viewController
}

private func leftViewController() -> UIViewController {
let viewController = viewControllerForStoryboardId(kKGLeftDrawerStoryboardId)
let viewController = viewControllerForStoryboardId(storyboardId: kKGLeftDrawerStoryboardId)
return viewController
}

private func rightViewController() -> UIViewController {
let viewController = viewControllerForStoryboardId(kKGRightDrawerStoryboardId)
let viewController = viewControllerForStoryboardId(storyboardId: kKGRightDrawerStoryboardId)
return viewController
}

func toggleLeftDrawer(sender:AnyObject, animated:Bool) {
_drawerViewController?.toggleDrawer(.Left, animated: true, complete: { (finished) -> Void in
func toggleLeftDrawer(_ sender:AnyObject, animated:Bool) {
_drawerViewController?.toggleDrawer(.left, animated: true, complete: { (finished) -> Void in
// do nothing
})
}

func toggleRightDrawer(sender:AnyObject, animated:Bool) {
_drawerViewController?.toggleDrawer(.Right, animated: true, complete: { (finished) -> Void in
func toggleRightDrawer(_ sender:AnyObject, animated:Bool) {
_drawerViewController?.toggleDrawer(.right, animated: true, complete: { (finished) -> Void in
// do nothing
})
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
Expand Down Expand Up @@ -36,6 +46,16 @@
"filename" : "icon-180.png",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "ipad",
Expand Down Expand Up @@ -71,6 +91,16 @@
"idiom" : "ipad",
"filename" : "icon-152.png",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import KGFloatingDrawer
class KGDrawerSettingsTableViewController: UITableViewController {

let resetRowIndex:Int = 4

@IBOutlet weak var durationLabel: UILabel!
@IBOutlet weak var delayLabel: UILabel!
@IBOutlet weak var springVelocityLabel: UILabel!
@IBOutlet weak var springDampingLabel: UILabel!

var animator: KGDrawerSpringAnimator?

var defaultDuration: NSTimeInterval?
var defaultDelay: NSTimeInterval?
var defaultDuration: TimeInterval?
var defaultDelay: TimeInterval?
var defaultSpringVelocity: CGFloat?
var defaultSpringDamping: CGFloat?

Expand All @@ -32,21 +32,21 @@ class KGDrawerSettingsTableViewController: UITableViewController {

override func viewDidLoad() {
super.viewDidLoad()

// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false

// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()

if let appDelegate: AppDelegate = UIApplication.sharedApplication().delegate as? AppDelegate {
if let appDelegate: AppDelegate = UIApplication.shared.delegate as? AppDelegate {
animator = appDelegate.drawerViewController.animator
captureDefaultValues(animator!)
reset()
}
}

func captureDefaultValues(animator:KGDrawerSpringAnimator) {
func captureDefaultValues(_ animator:KGDrawerSpringAnimator) {
defaultDuration = animator.animationDuration
defaultDelay = animator.animationDelay
defaultSpringVelocity = animator.initialSpringVelocity
Expand All @@ -61,8 +61,8 @@ class KGDrawerSettingsTableViewController: UITableViewController {

func updateAnimator() {
if let currentAnimator = animator {
currentAnimator.animationDuration = NSTimeInterval(defaultDuration!)
currentAnimator.animationDelay = NSTimeInterval(defaultDelay!)
currentAnimator.animationDuration = TimeInterval(defaultDuration!)
currentAnimator.animationDelay = TimeInterval(defaultDelay!)
currentAnimator.initialSpringVelocity = defaultSpringVelocity!
currentAnimator.springDamping = defaultSpringDamping!
}
Expand All @@ -82,22 +82,22 @@ class KGDrawerSettingsTableViewController: UITableViewController {
springDampingLabel.text = String(format: "%.2f", springDampingSlider.value)
}

@IBAction func durationSliderChanged(sender: UISlider) {
@IBAction func durationSliderChanged(_ sender: UISlider) {
durationLabel.text = String(format: "%.2f", sender.value)
animator?.animationDuration = NSTimeInterval(sender.value)
animator?.animationDuration = TimeInterval(sender.value)
}

@IBAction func delaySliderChanged(sender: UISlider) {
@IBAction func delaySliderChanged(_ sender: UISlider) {
delayLabel.text = String(format: "%.2f", sender.value)
animator?.animationDelay = NSTimeInterval(sender.value)
animator?.animationDelay = TimeInterval(sender.value)
}

@IBAction func springVelocitySliderChanged(sender: UISlider) {
@IBAction func springVelocitySliderChanged(_ sender: UISlider) {
springVelocityLabel.text = String(format: "%.2f", sender.value)
animator?.initialSpringVelocity = CGFloat(sender.value)
}

@IBAction func springDampingSliderChanged(sender: UISlider) {
@IBAction func springDampingSliderChanged(_ sender: UISlider) {
springDampingLabel.text = String(format: "%.2f", sender.value)
animator?.springDamping = CGFloat(sender.value)
}
Expand All @@ -106,18 +106,18 @@ class KGDrawerSettingsTableViewController: UITableViewController {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

@IBAction func toggleLeftDrawer(sender: AnyObject) {
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
@IBAction func toggleLeftDrawer(_ sender: AnyObject) {
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.toggleLeftDrawer(sender, animated: false)
}

@IBAction func toggleRightDrawer(sender: AnyObject) {
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
@IBAction func toggleRightDrawer(_ sender: AnyObject) {
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.toggleRightDrawer(sender, animated: true)
}

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let selectedRowIndex:Int = indexPath.section
if selectedRowIndex == resetRowIndex {
reset()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,42 @@
import UIKit

class KGDrawerWebViewViewController: UIViewController {

@IBOutlet weak var webView: UIWebView!

override func viewDidLoad() {
super.viewDidLoad()

// Do any additional setup after loading the view.
let url: NSURL = NSURL(string: "https://github.com/KyleGoddard/KGFloatingDrawer")!
let request = NSURLRequest(URL: url)
let url: URL = URL(string: "https://github.com/KyleGoddard/KGFloatingDrawer")!
let request = URLRequest(url: url)

webView.loadRequest(request)
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}


/*
// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/

@IBAction func toggleLeftDrawer(sender: AnyObject) {
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.toggleLeftDrawer(sender, animated: false)
}

@IBAction func toggleRightDrawer(sender: AnyObject) {
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.toggleRightDrawer(sender, animated: true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,34 @@
import UIKit

class LeftDrawerTableViewController: UITableViewController {

override func viewDidLoad() {
super.viewDidLoad()

// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false

// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

// MARK: <TableViewDataSource>

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let appDelegate = UIApplication.shared.delegate as! AppDelegate
if indexPath.row == 2 {
appDelegate.centerViewController = appDelegate.sourcePageViewController()

} else if indexPath.row == 3 {
appDelegate.centerViewController = appDelegate.drawerSettingsViewController()
}
}

override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
cell.backgroundColor = UIColor.clearColor()
override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
cell.backgroundColor = .clear
}

}
Loading