Commit e67a843a by Daniel Dahan

development: initial commit for FAB updates, and update for issue-644 where…

development: initial commit for FAB updates, and update for issue-644 where Switch can now be adjusted using the switchState property
parent 5a50bc7a
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
965E80CB1DD4C50600D61E4B /* MotionBasic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E3C39D1D3A1D0C0086A024 /* MotionBasic.swift */; }; 965E80CB1DD4C50600D61E4B /* MotionBasic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E3C39D1D3A1D0C0086A024 /* MotionBasic.swift */; };
965E80CC1DD4C50600D61E4B /* Bar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7981CB40DC500C806FE /* Bar.swift */; }; 965E80CC1DD4C50600D61E4B /* Bar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7981CB40DC500C806FE /* Bar.swift */; };
965E80CD1DD4C50600D61E4B /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7701CB40DC500C806FE /* Button.swift */; }; 965E80CD1DD4C50600D61E4B /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7701CB40DC500C806FE /* Button.swift */; };
965E80CE1DD4C50600D61E4B /* FabButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB75F1CB40DC500C806FE /* FabButton.swift */; }; 965E80CE1DD4C50600D61E4B /* FABButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB75F1CB40DC500C806FE /* FABButton.swift */; };
965E80CF1DD4C50600D61E4B /* FlatButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7601CB40DC500C806FE /* FlatButton.swift */; }; 965E80CF1DD4C50600D61E4B /* FlatButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7601CB40DC500C806FE /* FlatButton.swift */; };
965E80D01DD4C50600D61E4B /* RaisedButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7931CB40DC500C806FE /* RaisedButton.swift */; }; 965E80D01DD4C50600D61E4B /* RaisedButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7931CB40DC500C806FE /* RaisedButton.swift */; };
965E80D11DD4C50600D61E4B /* IconButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9658F2161CD6FA4700B902C1 /* IconButton.swift */; }; 965E80D11DD4C50600D61E4B /* IconButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9658F2161CD6FA4700B902C1 /* IconButton.swift */; };
...@@ -138,6 +138,9 @@ ...@@ -138,6 +138,9 @@
9697F7CB1D8F2573004741EC /* Snackbar.swift in Headers */ = {isa = PBXBuildFile; fileRef = 963FBEFC1D669510008F8512 /* Snackbar.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 9697F7CB1D8F2573004741EC /* Snackbar.swift in Headers */ = {isa = PBXBuildFile; fileRef = 963FBEFC1D669510008F8512 /* Snackbar.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9697F7CC1D8F2573004741EC /* SnackbarController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 961EFC571D738FF600E84652 /* SnackbarController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 9697F7CC1D8F2573004741EC /* SnackbarController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 961EFC571D738FF600E84652 /* SnackbarController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9697F7CD1D8F2582004741EC /* Color.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9661222D1D3EC414008BB4CB /* Color.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 9697F7CD1D8F2582004741EC /* Color.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9661222D1D3EC414008BB4CB /* Color.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96A183631E0C6CE200083C30 /* FABMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A183621E0C6CE200083C30 /* FABMenu.swift */; };
96A183651E0C6DD400083C30 /* FABMenuController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A183641E0C6DD400083C30 /* FABMenuController.swift */; };
96A183671E0C6DE100083C30 /* FABToToolbarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A183661E0C6DE100083C30 /* FABToToolbarController.swift */; };
96BCB7F31CB40DE900C806FE /* Roboto-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 96BCB7EE1CB40DE900C806FE /* Roboto-Bold.ttf */; }; 96BCB7F31CB40DE900C806FE /* Roboto-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 96BCB7EE1CB40DE900C806FE /* Roboto-Bold.ttf */; };
96BCB7F41CB40DE900C806FE /* Roboto-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 96BCB7EE1CB40DE900C806FE /* Roboto-Bold.ttf */; }; 96BCB7F41CB40DE900C806FE /* Roboto-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 96BCB7EE1CB40DE900C806FE /* Roboto-Bold.ttf */; };
96BCB7F51CB40DE900C806FE /* Roboto-Light.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 96BCB7EF1CB40DE900C806FE /* Roboto-Light.ttf */; }; 96BCB7F51CB40DE900C806FE /* Roboto-Light.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 96BCB7EF1CB40DE900C806FE /* Roboto-Light.ttf */; };
...@@ -152,7 +155,7 @@ ...@@ -152,7 +155,7 @@
96BCB8111CB4115200C806FE /* Motion.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB76D1CB40DC500C806FE /* Motion.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCB8111CB4115200C806FE /* Motion.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB76D1CB40DC500C806FE /* Motion.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8131CB4115200C806FE /* MotionKeyframe.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB77E1CB40DC500C806FE /* MotionKeyframe.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCB8131CB4115200C806FE /* MotionKeyframe.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB77E1CB40DC500C806FE /* MotionKeyframe.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8141CB4115200C806FE /* MotionPulse.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7821CB40DC500C806FE /* MotionPulse.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCB8141CB4115200C806FE /* MotionPulse.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7821CB40DC500C806FE /* MotionPulse.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8151CB4115200C806FE /* FabButton.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB75F1CB40DC500C806FE /* FabButton.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCB8151CB4115200C806FE /* FABButton.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB75F1CB40DC500C806FE /* FABButton.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8161CB4115200C806FE /* FlatButton.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7601CB40DC500C806FE /* FlatButton.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCB8161CB4115200C806FE /* FlatButton.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7601CB40DC500C806FE /* FlatButton.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8171CB4115200C806FE /* Button.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7701CB40DC500C806FE /* Button.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCB8171CB4115200C806FE /* Button.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7701CB40DC500C806FE /* Button.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8181CB4115200C806FE /* RaisedButton.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7931CB40DC500C806FE /* RaisedButton.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCB8181CB4115200C806FE /* RaisedButton.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7931CB40DC500C806FE /* RaisedButton.swift */; settings = {ATTRIBUTES = (Public, ); }; };
...@@ -262,10 +265,13 @@ ...@@ -262,10 +265,13 @@
967A48181D0F425A00B8CEB7 /* StatusBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBarController.swift; sourceTree = "<group>"; }; 967A48181D0F425A00B8CEB7 /* StatusBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBarController.swift; sourceTree = "<group>"; };
968C99461D377849000074FF /* Offset.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Offset.swift; sourceTree = "<group>"; }; 968C99461D377849000074FF /* Offset.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Offset.swift; sourceTree = "<group>"; };
9697F7B61D8F22A4004741EC /* MenuItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MenuItem.swift; sourceTree = "<group>"; }; 9697F7B61D8F22A4004741EC /* MenuItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MenuItem.swift; sourceTree = "<group>"; };
96A183621E0C6CE200083C30 /* FABMenu.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FABMenu.swift; sourceTree = "<group>"; };
96A183641E0C6DD400083C30 /* FABMenuController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FABMenuController.swift; sourceTree = "<group>"; };
96A183661E0C6DE100083C30 /* FABToToolbarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FABToToolbarController.swift; sourceTree = "<group>"; };
96BCB7581CB40DC500C806FE /* BottomNavigationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BottomNavigationController.swift; sourceTree = "<group>"; }; 96BCB7581CB40DC500C806FE /* BottomNavigationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BottomNavigationController.swift; sourceTree = "<group>"; };
96BCB7591CB40DC500C806FE /* BottomTabBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BottomTabBar.swift; sourceTree = "<group>"; }; 96BCB7591CB40DC500C806FE /* BottomTabBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BottomTabBar.swift; sourceTree = "<group>"; };
96BCB75D1CB40DC500C806FE /* Card.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Card.swift; sourceTree = "<group>"; }; 96BCB75D1CB40DC500C806FE /* Card.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Card.swift; sourceTree = "<group>"; };
96BCB75F1CB40DC500C806FE /* FabButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FabButton.swift; sourceTree = "<group>"; }; 96BCB75F1CB40DC500C806FE /* FABButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FABButton.swift; sourceTree = "<group>"; };
96BCB7601CB40DC500C806FE /* FlatButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FlatButton.swift; sourceTree = "<group>"; }; 96BCB7601CB40DC500C806FE /* FlatButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FlatButton.swift; sourceTree = "<group>"; };
96BCB7611CB40DC500C806FE /* Grid.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Grid.swift; sourceTree = "<group>"; }; 96BCB7611CB40DC500C806FE /* Grid.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Grid.swift; sourceTree = "<group>"; };
96BCB7621CB40DC500C806FE /* ImageCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageCard.swift; sourceTree = "<group>"; }; 96BCB7621CB40DC500C806FE /* ImageCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageCard.swift; sourceTree = "<group>"; };
...@@ -543,6 +549,9 @@ ...@@ -543,6 +549,9 @@
96BCB78E1CB40DC500C806FE /* Menu.swift */, 96BCB78E1CB40DC500C806FE /* Menu.swift */,
9697F7B61D8F22A4004741EC /* MenuItem.swift */, 9697F7B61D8F22A4004741EC /* MenuItem.swift */,
96BCB78F1CB40DC500C806FE /* MenuController.swift */, 96BCB78F1CB40DC500C806FE /* MenuController.swift */,
96A183621E0C6CE200083C30 /* FABMenu.swift */,
96A183641E0C6DD400083C30 /* FABMenuController.swift */,
96A183661E0C6DE100083C30 /* FABToToolbarController.swift */,
); );
name = Menu; name = Menu;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -715,7 +724,7 @@ ...@@ -715,7 +724,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96BCB7701CB40DC500C806FE /* Button.swift */, 96BCB7701CB40DC500C806FE /* Button.swift */,
96BCB75F1CB40DC500C806FE /* FabButton.swift */, 96BCB75F1CB40DC500C806FE /* FABButton.swift */,
96BCB7601CB40DC500C806FE /* FlatButton.swift */, 96BCB7601CB40DC500C806FE /* FlatButton.swift */,
96BCB7931CB40DC500C806FE /* RaisedButton.swift */, 96BCB7931CB40DC500C806FE /* RaisedButton.swift */,
9658F2161CD6FA4700B902C1 /* IconButton.swift */, 9658F2161CD6FA4700B902C1 /* IconButton.swift */,
...@@ -864,7 +873,7 @@ ...@@ -864,7 +873,7 @@
96BCB8111CB4115200C806FE /* Motion.swift in Headers */, 96BCB8111CB4115200C806FE /* Motion.swift in Headers */,
96BCB8131CB4115200C806FE /* MotionKeyframe.swift in Headers */, 96BCB8131CB4115200C806FE /* MotionKeyframe.swift in Headers */,
96BCB8141CB4115200C806FE /* MotionPulse.swift in Headers */, 96BCB8141CB4115200C806FE /* MotionPulse.swift in Headers */,
96BCB8151CB4115200C806FE /* FabButton.swift in Headers */, 96BCB8151CB4115200C806FE /* FABButton.swift in Headers */,
96BCB8161CB4115200C806FE /* FlatButton.swift in Headers */, 96BCB8161CB4115200C806FE /* FlatButton.swift in Headers */,
96BCB8171CB4115200C806FE /* Button.swift in Headers */, 96BCB8171CB4115200C806FE /* Button.swift in Headers */,
96BCB8181CB4115200C806FE /* RaisedButton.swift in Headers */, 96BCB8181CB4115200C806FE /* RaisedButton.swift in Headers */,
...@@ -1160,6 +1169,7 @@ ...@@ -1160,6 +1169,7 @@
965E810D1DD4D5C800D61E4B /* Menu.swift in Sources */, 965E810D1DD4D5C800D61E4B /* Menu.swift in Sources */,
965E810E1DD4D5C800D61E4B /* MenuItem.swift in Sources */, 965E810E1DD4D5C800D61E4B /* MenuItem.swift in Sources */,
965E810F1DD4D5C800D61E4B /* MenuController.swift in Sources */, 965E810F1DD4D5C800D61E4B /* MenuController.swift in Sources */,
96A183651E0C6DD400083C30 /* FABMenuController.swift in Sources */,
965E81101DD4D5C800D61E4B /* NavigationBar.swift in Sources */, 965E81101DD4D5C800D61E4B /* NavigationBar.swift in Sources */,
965E81111DD4D5C800D61E4B /* NavigationController.swift in Sources */, 965E81111DD4D5C800D61E4B /* NavigationController.swift in Sources */,
965E81121DD4D5C800D61E4B /* NavigationItem.swift in Sources */, 965E81121DD4D5C800D61E4B /* NavigationItem.swift in Sources */,
...@@ -1181,6 +1191,7 @@ ...@@ -1181,6 +1191,7 @@
965E81211DD4D5C800D61E4B /* TextStorage.swift in Sources */, 965E81211DD4D5C800D61E4B /* TextStorage.swift in Sources */,
965E81221DD4D5C800D61E4B /* TextView.swift in Sources */, 965E81221DD4D5C800D61E4B /* TextView.swift in Sources */,
965E80E61DD4C55200D61E4B /* Material+Obj-C.swift in Sources */, 965E80E61DD4C55200D61E4B /* Material+Obj-C.swift in Sources */,
96A183671E0C6DE100083C30 /* FABToToolbarController.swift in Sources */,
965E80E71DD4C55200D61E4B /* Material+UIView.swift in Sources */, 965E80E71DD4C55200D61E4B /* Material+UIView.swift in Sources */,
965E80FA1DD4D59500D61E4B /* PageTabBarController.swift in Sources */, 965E80FA1DD4D59500D61E4B /* PageTabBarController.swift in Sources */,
965E80E81DD4C55200D61E4B /* Material+CALayer.swift in Sources */, 965E80E81DD4C55200D61E4B /* Material+CALayer.swift in Sources */,
...@@ -1203,9 +1214,10 @@ ...@@ -1203,9 +1214,10 @@
965E80CB1DD4C50600D61E4B /* MotionBasic.swift in Sources */, 965E80CB1DD4C50600D61E4B /* MotionBasic.swift in Sources */,
965E80CC1DD4C50600D61E4B /* Bar.swift in Sources */, 965E80CC1DD4C50600D61E4B /* Bar.swift in Sources */,
965E80CD1DD4C50600D61E4B /* Button.swift in Sources */, 965E80CD1DD4C50600D61E4B /* Button.swift in Sources */,
965E80CE1DD4C50600D61E4B /* FabButton.swift in Sources */, 965E80CE1DD4C50600D61E4B /* FABButton.swift in Sources */,
965E80CF1DD4C50600D61E4B /* FlatButton.swift in Sources */, 965E80CF1DD4C50600D61E4B /* FlatButton.swift in Sources */,
965E80D01DD4C50600D61E4B /* RaisedButton.swift in Sources */, 965E80D01DD4C50600D61E4B /* RaisedButton.swift in Sources */,
96A183631E0C6CE200083C30 /* FABMenu.swift in Sources */,
965E80D11DD4C50600D61E4B /* IconButton.swift in Sources */, 965E80D11DD4C50600D61E4B /* IconButton.swift in Sources */,
965E80D21DD4C50600D61E4B /* Color.swift in Sources */, 965E80D21DD4C50600D61E4B /* Color.swift in Sources */,
965E80D31DD4C50600D61E4B /* Device.swift in Sources */, 965E80D31DD4C50600D61E4B /* Device.swift in Sources */,
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
import UIKit import UIKit
open class FabButton: Button { open class FABButton: Button {
/** /**
Prepares the view instance when intialized. When subclassing, Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method it is recommended to override the prepare method
......
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.com>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import UIKit
@objc(FABMenuDelegate)
public protocol FABMenuDelegate: MenuDelegate {
/**
Gets called when the user taps while the menu is opened.
- Parameter menu: A FABMenu.
- Parameter tappedAt point: A CGPoint.
- Parameter isOutside: A boolean indicating whether the tap
was outside the menu button area.
*/
@objc
optional func fabMenu(fabMenu: FABMenu, tappedAt point: CGPoint, isOutside: Bool)
}
@objc(FABMenu)
open class FABMenu: Menu {
/// A reference to the MenuItems
open var buttons: [MenuItem] {
get {
return views as! [MenuItem]
}
set(value) {
views = value
}
}
open override func prepare() {
super.prepare()
}
}
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.com>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import UIKit
extension UIViewController {
/**
A convenience property that provides access to the FABMenuController.
This is the recommended method of accessing the FABMenuController
through child UIViewControllers.
*/
public var fabMenuController: FABMenuController? {
var viewController: UIViewController? = self
while nil != viewController {
if viewController is FABMenuController {
return viewController as? FABMenuController
}
viewController = viewController?.parent
}
return nil
}
}
open class FABMenuController: RootController {
/// Reference to the MenuView.
@IBInspectable
open let menu = FABMenu()
open override func layoutSubviews() {
super.layoutSubviews()
rootViewController.view.frame = view.bounds
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
open override func prepare() {
super.prepare()
prepareMenu()
}
}
extension FABMenuController {
/// Prepares the Menu.
fileprivate func prepareMenu() {
menu.zPosition = 1000
view.addSubview(menu)
}
}
extension FABMenuController {
/**
Opens the menu with a callback.
- Parameter completion: An Optional callback that is executed when
all menu items have been opened.
*/
open func openMenu(completion: ((UIView) -> Void)? = nil) {
if true == isUserInteractionEnabled {
isUserInteractionEnabled = false
UIView.animate(withDuration: 0.15, animations: { [weak self] in
guard let s = self else {
return
}
s.rootViewController.view.alpha = 0.15
})
menu.open { [completion = completion] (view) in
completion?(view)
}
}
}
/**
Opens the menu with a callback.
- Parameter completion: An Optional callback that is executed when
all menu items have been closed.
*/
open func closeMenu(completion: ((UIView) -> Void)? = nil) {
if false == isUserInteractionEnabled {
UIView.animate(withDuration: 0.15, animations: { [weak self] in
guard let s = self else {
return
}
s.rootViewController.view.alpha = 1
})
menu.close { [weak self] (view) in
guard let s = self else {
return
}
completion?(view)
if view == s.menu.views.last {
s.isUserInteractionEnabled = true
}
}
}
}
}
//
// FABToToolbarController.swift
// Material
//
// Created by Daniel Dahan on 2016-12-22.
// Copyright © 2016 CosmicMind, Inc. All rights reserved.
//
import Foundation
...@@ -51,7 +51,7 @@ extension UIViewController { ...@@ -51,7 +51,7 @@ extension UIViewController {
open class MenuController: RootController { open class MenuController: RootController {
/// Reference to the MenuView. /// Reference to the MenuView.
@IBInspectable @IBInspectable
open let menu = Menu() open let menu = FABMenu()
open override func layoutSubviews() { open override func layoutSubviews() {
super.layoutSubviews() super.layoutSubviews()
...@@ -94,7 +94,7 @@ extension MenuController { ...@@ -94,7 +94,7 @@ extension MenuController {
} }
s.rootViewController.view.alpha = 0.15 s.rootViewController.view.alpha = 0.15
}) })
menu.open { [completion = completion] (view) in menu.open(usingSpringWithDamping: 0) { [completion = completion] (view) in
completion?(view) completion?(view)
} }
} }
...@@ -113,7 +113,7 @@ extension MenuController { ...@@ -113,7 +113,7 @@ extension MenuController {
} }
s.rootViewController.view.alpha = 1 s.rootViewController.view.alpha = 1
}) })
menu.close { [weak self] (view) in menu.close(usingSpringWithDamping: 0) { [weak self] (view) in
guard let s = self else { guard let s = self else {
return return
} }
......
...@@ -35,7 +35,7 @@ open class MenuItem: View { ...@@ -35,7 +35,7 @@ open class MenuItem: View {
open let titleLabel = UILabel() open let titleLabel = UILabel()
/// A reference to the button. /// A reference to the button.
open let button = FabButton() open let button = FABButton()
/** /**
Prepares the view instance when intialized. When subclassing, Prepares the view instance when intialized. When subclassing,
......
...@@ -166,7 +166,7 @@ open class Switch: UIControl { ...@@ -166,7 +166,7 @@ open class Switch: UIControl {
} }
/// Button view reference. /// Button view reference.
open fileprivate(set) var button: FabButton { open fileprivate(set) var button: FABButton {
didSet { didSet {
prepareButton() prepareButton()
} }
...@@ -196,9 +196,7 @@ open class Switch: UIControl { ...@@ -196,9 +196,7 @@ open class Switch: UIControl {
return internalSwitchState return internalSwitchState
} }
set(value) { set(value) {
if value != internalSwitchState { updateSwitchState(state: .on, animated: true, isTriggeredByUserInteraction: false)
internalSwitchState = value
}
} }
} }
...@@ -264,7 +262,7 @@ open class Switch: UIControl { ...@@ -264,7 +262,7 @@ open class Switch: UIControl {
*/ */
public required init?(coder aDecoder: NSCoder) { public required init?(coder aDecoder: NSCoder) {
track = UIView() track = UIView()
button = FabButton() button = FABButton()
super.init(coder: aDecoder) super.init(coder: aDecoder)
prepare() prepare()
} }
...@@ -278,7 +276,7 @@ open class Switch: UIControl { ...@@ -278,7 +276,7 @@ open class Switch: UIControl {
*/ */
public override init(frame: CGRect) { public override init(frame: CGRect) {
track = UIView() track = UIView()
button = FabButton() button = FABButton()
super.init(frame: frame) super.init(frame: frame)
prepare() prepare()
} }
...@@ -291,7 +289,7 @@ open class Switch: UIControl { ...@@ -291,7 +289,7 @@ open class Switch: UIControl {
*/ */
public init(state: SwitchState = .off, style: SwitchStyle = .dark, size: SwitchSize = .medium) { public init(state: SwitchState = .off, style: SwitchStyle = .dark, size: SwitchSize = .medium) {
track = UIView() track = UIView()
button = FabButton() button = FABButton()
super.init(frame: .zero) super.init(frame: .zero)
prepare() prepare()
prepareSwitchState(state: state) prepareSwitchState(state: state)
...@@ -505,7 +503,7 @@ extension Switch { ...@@ -505,7 +503,7 @@ extension Switch {
- Parameter event: A UIEvent. - Parameter event: A UIEvent.
*/ */
@objc @objc
fileprivate func handleTouchUpOutsideOrCanceled(sender: FabButton, event: UIEvent) { fileprivate func handleTouchUpOutsideOrCanceled(sender: FABButton, event: UIEvent) {
guard let v = event.touches(for: sender)?.first else { guard let v = event.touches(for: sender)?.first else {
return return
} }
...@@ -526,7 +524,7 @@ extension Switch { ...@@ -526,7 +524,7 @@ extension Switch {
- Parameter event: A UIEvent. - Parameter event: A UIEvent.
*/ */
@objc @objc
fileprivate func handleTouchDragInside(sender: FabButton, event: UIEvent) { fileprivate func handleTouchDragInside(sender: FABButton, event: UIEvent) {
guard let v = event.touches(for: sender)?.first else { guard let v = event.touches(for: sender)?.first else {
return return
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment