Skip to content

Commit

Permalink
Expose simple delegate. Initially to capture hide event
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Arnberg committed Dec 22, 2015
1 parent 5c6fd49 commit 5b99234
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 4 deletions.
8 changes: 7 additions & 1 deletion Demo/ViewController.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit
import Dodo

class ViewController: UIViewController {
class ViewController: UIViewController, DodoDelegate {

@IBOutlet weak var testToolbar: UIToolbar!
@IBOutlet weak var topSwitch: UISwitch!
Expand Down Expand Up @@ -56,6 +56,7 @@ class ViewController: UIViewController {
}

private func show() {
view.dodo.delegate = self
view.dodo.style.bar.locationTop = topSwitch.on
view.dodo.style.bar.hideAfterDelaySeconds = hideAfterDelaySwitch.on ? 3 : 0
view.dodo.style.bar.debugMode = debugModeSwitch.on
Expand Down Expand Up @@ -269,5 +270,10 @@ class ViewController: UIViewController {
}
)
}


func dodoDidHide() {
print("Dodo Did Hide 🌻🌼🐁🍃")
}
}

31 changes: 30 additions & 1 deletion Distrib/DodoDistrib.swift
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,9 @@ final class Dodo: DodoInterface, DodoButtonViewDelegate {
/// Specify optional layout guide for positioning the bar view.
var bottomLayoutGuide: UILayoutSupport?

/// Specify optional delegate
var delegate: DodoDelegate?

/// Defines styles for the bar.
var style = DodoStyle(parentStyle: DodoPresets.defaultPreset.style)

Expand Down Expand Up @@ -684,7 +687,9 @@ final class Dodo: DodoInterface, DodoButtonViewDelegate {
func hide() {
hideTimer?.cancel()

toolbar?.hide(onAnimationCompleted: {})
toolbar?.hide(onAnimationCompleted: {
self.delegate?.dodoDidHide()
})
}

func listenForKeyboard() {
Expand Down Expand Up @@ -757,6 +762,24 @@ final class Dodo: DodoInterface, DodoButtonViewDelegate {
public typealias DodoBarOnTap = ()->()


// ----------------------------
//
// DodoDelegate.swift
//
// ----------------------------

//
// DodoDelegate.swift
// Dodo
//
// Created by Martin Arnberg on 12/22/15.
// Copyright © 2015 Marketplacer. All rights reserved.
//
public protocol DodoDelegate {
func dodoDidHide()
}


// ----------------------------
//
// DodoInterface.swift
Expand Down Expand Up @@ -785,6 +808,9 @@ public protocol DodoInterface: class {
/// Specify optional layout guide for positioning the bar view.
var bottomLayoutGuide: UILayoutSupport? { get set }

/// Specify optional delegate
var delegate: DodoDelegate? { get set }

/// Defines styles for the bar.
var style: DodoStyle { get set }

Expand Down Expand Up @@ -1154,6 +1180,9 @@ public class DodoMock: DodoInterface {

public var topLayoutGuide: UILayoutSupport?
public var bottomLayoutGuide: UILayoutSupport?

public var delegate: DodoDelegate?

public var style = DodoStyle(parentStyle: DodoPresets.defaultPreset.style)

public init() { }
Expand Down
6 changes: 6 additions & 0 deletions Dodo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
2B5589691B60755D008CA494 /* UnderKeyboardDistrib.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B5589671B60753E008CA494 /* UnderKeyboardDistrib.swift */; };
2B6CA4531B5F74480003B836 /* DodoKeyboardListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B6CA4521B5F74480003B836 /* DodoKeyboardListener.swift */; };
2B6CA4551B5F77B40003B836 /* DodoKeyboardListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B6CA4521B5F74480003B836 /* DodoKeyboardListener.swift */; };
5BDA0ACF1C29CBDC00C6150A /* DodoDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BDA0ACE1C29CBDC00C6150A /* DodoDelegate.swift */; };
5BDA0AD01C29CBDC00C6150A /* DodoDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BDA0ACE1C29CBDC00C6150A /* DodoDelegate.swift */; };
7E34D3791B605B6A00BECDCA /* XCTest+postKeyboardNotification.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E34D3781B605B6A00BECDCA /* XCTest+postKeyboardNotification.swift */; };
7E34D3801B60654E00BECDCA /* LayoutGuideMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E34D37F1B60654E00BECDCA /* LayoutGuideMock.swift */; };
7E4066B61B212BCB00E0AC41 /* DodoAnimation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E4066B51B212BCB00E0AC41 /* DodoAnimation.swift */; };
Expand Down Expand Up @@ -145,6 +147,7 @@
2B05999B1BABBA8300F36AED /* DodoBarOnTap.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DodoBarOnTap.swift; sourceTree = "<group>"; };
2B5589671B60753E008CA494 /* UnderKeyboardDistrib.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnderKeyboardDistrib.swift; sourceTree = "<group>"; };
2B6CA4521B5F74480003B836 /* DodoKeyboardListener.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DodoKeyboardListener.swift; sourceTree = "<group>"; };
5BDA0ACE1C29CBDC00C6150A /* DodoDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DodoDelegate.swift; sourceTree = "<group>"; };
7E34D3781B605B6A00BECDCA /* XCTest+postKeyboardNotification.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "XCTest+postKeyboardNotification.swift"; sourceTree = "<group>"; };
7E34D37F1B60654E00BECDCA /* LayoutGuideMock.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LayoutGuideMock.swift; sourceTree = "<group>"; };
7E4066B51B212BCB00E0AC41 /* DodoAnimation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DodoAnimation.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -292,6 +295,7 @@
7EDF78941B21068800A9597E /* Utils */,
7EDF78861B21068800A9597E /* DodoToolbar.swift */,
7EDF78901B21068800A9597E /* Dodo.swift */,
5BDA0ACE1C29CBDC00C6150A /* DodoDelegate.swift */,
7EF94B9D1B29207F006B4429 /* DodoInterface.swift */,
2B05999B1BABBA8300F36AED /* DodoBarOnTap.swift */,
2B6CA4521B5F74480003B836 /* DodoKeyboardListener.swift */,
Expand Down Expand Up @@ -698,6 +702,7 @@
7EDF78A31B21068800A9597E /* DodoBarDefaultStyles.swift in Sources */,
7E4946541B26942000915DB3 /* DodoButtonViewDelegate.swift in Sources */,
7EDF78B11B21068800A9597E /* DodoColor.swift in Sources */,
5BDA0ACF1C29CBDC00C6150A /* DodoDelegate.swift in Sources */,
7EDF78A91B21068800A9597E /* DodoPresets.swift in Sources */,
7EC51DA41B215C070070019F /* DodoAnimationsShow.swift in Sources */,
7EF94B9E1B29207F006B4429 /* DodoInterface.swift in Sources */,
Expand Down Expand Up @@ -727,6 +732,7 @@
7E4946551B26942C00915DB3 /* DodoButtonViewDelegate.swift in Sources */,
7EDF78E21B21071500A9597E /* DodoButtonDefaultStyles.swift in Sources */,
7E49464F1B2666DF00915DB3 /* DodoIcons.swift in Sources */,
5BDA0AD01C29CBDC00C6150A /* DodoDelegate.swift in Sources */,
2B6CA4551B5F77B40003B836 /* DodoKeyboardListener.swift in Sources */,
7EDF78E91B21072200A9597E /* OnTap.swift in Sources */,
7EC51DA71B215D450070019F /* DodoAnimationsShow.swift in Sources */,
Expand Down
9 changes: 7 additions & 2 deletions Dodo/Dodo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ final class Dodo: DodoInterface, DodoButtonViewDelegate {
/// Specify optional layout guide for positioning the bar view.
var bottomLayoutGuide: UILayoutSupport?

/// Specify optional delegate
var delegate: DodoDelegate?

/// Defines styles for the bar.
var style = DodoStyle(parentStyle: DodoPresets.defaultPreset.style)

Expand Down Expand Up @@ -114,9 +117,11 @@ final class Dodo: DodoInterface, DodoButtonViewDelegate {
func hide() {
hideTimer?.cancel()

toolbar?.hide(onAnimationCompleted: {})
toolbar?.hide(onAnimationCompleted: {
self.delegate?.dodoDidHide()
})
}

func listenForKeyboard() {

}
Expand Down
10 changes: 10 additions & 0 deletions Dodo/DodoDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// DodoDelegate.swift
// Dodo
//
// Created by Martin Arnberg on 12/22/15.
// Copyright © 2015 Marketplacer. All rights reserved.
//
public protocol DodoDelegate: class {
func dodoDidHide()
}
3 changes: 3 additions & 0 deletions Dodo/DodoInterface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public protocol DodoInterface: class {
/// Specify optional layout guide for positioning the bar view.
var bottomLayoutGuide: UILayoutSupport? { get set }

/// Specify optional delegate
var delegate: DodoDelegate? { get set }

/// Defines styles for the bar.
var style: DodoStyle { get set }

Expand Down
3 changes: 3 additions & 0 deletions Dodo/Mock/DodoMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public class DodoMock: DodoInterface {

public var topLayoutGuide: UILayoutSupport?
public var bottomLayoutGuide: UILayoutSupport?

public var delegate: DodoDelegate?

public var style = DodoStyle(parentStyle: DodoPresets.defaultPreset.style)

public init() { }
Expand Down

0 comments on commit 5b99234

Please sign in to comment.