Skip to content

Commit

Permalink
Issue #27: Add open and close delegate
Browse files Browse the repository at this point in the history
  • Loading branch information
kciter committed Apr 1, 2016
1 parent 3869fbf commit 8d0ad43
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
5 changes: 4 additions & 1 deletion KCFloatingActionButton/KCFloatingActionButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ public class KCFloatingActionButton: UIView {
}
}

fabDelegate?.KCFABOpened?(self)
closed = false
}

Expand Down Expand Up @@ -302,6 +303,8 @@ public class KCFloatingActionButton: UIView {
noneAnimationWithClose()
}
}

fabDelegate?.KCFABClosed?(self)
closed = true
}

Expand All @@ -316,7 +319,7 @@ public class KCFloatingActionButton: UIView {
close()
}
} else {
fabDelegate?.emptyKCFABSelected(self)
fabDelegate?.emptyKCFABSelected?(self)
}
}

Expand Down
6 changes: 5 additions & 1 deletion KCFloatingActionButton/KCFloatingActionButtonDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@ import Foundation
contain any defined sub items.
- parameter fab: The FAB widget that was selected by the user.
*/
func emptyKCFABSelected(fab: KCFloatingActionButton)
optional func emptyKCFABSelected(fab: KCFloatingActionButton)

optional func KCFABOpened(fab: KCFloatingActionButton)

optional func KCFABClosed(fab: KCFloatingActionButton)
}
4 changes: 2 additions & 2 deletions Sample/KCFloatingActionButton/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<scenes>
<!--View Controller-->
Expand Down
11 changes: 10 additions & 1 deletion Sample/KCFloatingActionButton/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import UIKit

class ViewController: UIViewController {
class ViewController: UIViewController, KCFloatingActionButtonDelegate {

override func viewDidLoad() {
super.viewDidLoad()
Expand Down Expand Up @@ -43,6 +43,7 @@ class ViewController: UIViewController {
fab.close()
})
fab.addItem(item: item)
fab.fabDelegate = self
self.view.addSubview(fab)
}

Expand All @@ -54,4 +55,12 @@ class ViewController: UIViewController {
@IBAction func endEditing() {
view.endEditing(true)
}

func KCFABOpened(fab: KCFloatingActionButton) {
print("FAB Opened")
}

func KCFABClosed(fab: KCFloatingActionButton) {
print("FAB Closed")
}
}

0 comments on commit 8d0ad43

Please sign in to comment.