Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to swift 3 #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
Binary file added Example/.DS_Store
Binary file not shown.
125 changes: 96 additions & 29 deletions Example/KGFloatingDrawer-Example.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -14,10 +14,10 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9956EAB19AAE15D26E47B28E"
BuildableName = "KGFloatingDrawer.framework"
BlueprintName = "Pods-KGFloatingDrawer-Example-KGFloatingDrawer"
ReferencedContainer = "container:Pods.xcodeproj">
BlueprintIdentifier = "1F441BEC1AA6A745005772A1"
BuildableName = "KGFloatingDrawer-Example.app"
BlueprintName = "KGFloatingDrawer-Example"
ReferencedContainer = "container:KGFloatingDrawer-Example.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
Expand All @@ -28,7 +28,26 @@
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1F441C011AA6A745005772A1"
BuildableName = "KGFloatingDrawer-ExampleTests.xctest"
BlueprintName = "KGFloatingDrawer-ExampleTests"
ReferencedContainer = "container:KGFloatingDrawer-Example.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1F441BEC1AA6A745005772A1"
BuildableName = "KGFloatingDrawer-Example.app"
BlueprintName = "KGFloatingDrawer-Example"
ReferencedContainer = "container:KGFloatingDrawer-Example.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
Expand All @@ -42,15 +61,16 @@
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9956EAB19AAE15D26E47B28E"
BuildableName = "KGFloatingDrawer.framework"
BlueprintName = "Pods-KGFloatingDrawer-Example-KGFloatingDrawer"
ReferencedContainer = "container:Pods.xcodeproj">
BlueprintIdentifier = "1F441BEC1AA6A745005772A1"
BuildableName = "KGFloatingDrawer-Example.app"
BlueprintName = "KGFloatingDrawer-Example"
ReferencedContainer = "container:KGFloatingDrawer-Example.xcodeproj">
</BuildableReference>
</MacroExpansion>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
Expand All @@ -60,15 +80,16 @@
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9956EAB19AAE15D26E47B28E"
BuildableName = "KGFloatingDrawer.framework"
BlueprintName = "Pods-KGFloatingDrawer-Example-KGFloatingDrawer"
ReferencedContainer = "container:Pods.xcodeproj">
BlueprintIdentifier = "1F441BEC1AA6A745005772A1"
BuildableName = "KGFloatingDrawer-Example.app"
BlueprintName = "KGFloatingDrawer-Example"
ReferencedContainer = "container:KGFloatingDrawer-Example.xcodeproj">
</BuildableReference>
</MacroExpansion>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,20 @@
<dict>
<key>SchemeUserState</key>
<dict>
<key>Pods-KGFloatingDrawer-Example-KGFloatingDrawer.xcscheme</key>
<key>KGFloatingDrawer-Example.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
</dict>
<key>Pods-KGFloatingDrawer-Example.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>0E1A9D9B69C48841FDBA5609</key>
<key>1F441BEC1AA6A745005772A1</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>9956EAB19AAE15D26E47B28E</key>
<key>1F441C011AA6A745005772A1</key>
<dict>
<key>primary</key>
<true/>
Expand Down
Binary file not shown.
36 changes: 18 additions & 18 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: [UIApplicationLaunchOptionsKey: Any]?) -> 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,29 +33,29 @@ 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.
}

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:.
}

private var _drawerViewController: KGDrawerViewController?
fileprivate var _drawerViewController: KGDrawerViewController?
var drawerViewController: KGDrawerViewController {
get {
if let viewController = _drawerViewController {
Expand All @@ -78,13 +78,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return drawerViewController
}

private func drawerStoryboard() -> UIStoryboard {
fileprivate func drawerStoryboard() -> UIStoryboard {
let storyboard = UIStoryboard(name: kKGDrawersStoryboardName, bundle: nil)
return storyboard
}

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

Expand All @@ -98,29 +98,29 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return viewController
}

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

private func rightViewController() -> UIViewController {
fileprivate func rightViewController() -> UIViewController {
let viewController = viewControllerForStoryboardId(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
})
}

private var _centerViewController: UIViewController?
fileprivate var _centerViewController: UIViewController?
var centerViewController: UIViewController {
get {
if let viewController = _centerViewController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class KGDrawerSettingsTableViewController: UITableViewController {

var animator: KGDrawerSpringAnimator?

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

Expand All @@ -39,14 +39,14 @@ class KGDrawerSettingsTableViewController: UITableViewController {
// 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 @@ -107,17 +107,17 @@ class KGDrawerSettingsTableViewController: UITableViewController {
// 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 @@ -16,8 +16,8 @@ class KGDrawerWebViewViewController: UIViewController {
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)
}
Expand All @@ -38,13 +38,13 @@ class KGDrawerWebViewViewController: UIViewController {
}
*/

@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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ class LeftDrawerTableViewController: UITableViewController {

// 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 = UIColor.clear
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class KGFloatingDrawer_ExampleTests: XCTestCase {

func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock() {
self.measure() {
// Put the code you want to measure the time of here.
}
}
Expand Down
8 changes: 8 additions & 0 deletions Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ end
target 'KGFloatingDrawer-ExampleTests' do

end

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0.2'
end
end
end
Loading