Commit 928ba8cb by Daniel Dahan

development: updated access rights and renamed ControlView to ContentView

parent 05b19fa0
......@@ -32,7 +32,7 @@
96BCB7A41CB40DC500C806FE /* CaptureSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB75B1CB40DC500C806FE /* CaptureSession.swift */; };
96BCB7A51CB40DC500C806FE /* Capture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB75C1CB40DC500C806FE /* Capture.swift */; };
96BCB7A61CB40DC500C806FE /* Card.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB75D1CB40DC500C806FE /* Card.swift */; };
96BCB7A71CB40DC500C806FE /* ControlView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB75E1CB40DC500C806FE /* ControlView.swift */; };
96BCB7A71CB40DC500C806FE /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB75E1CB40DC500C806FE /* ContentView.swift */; };
96BCB7A81CB40DC500C806FE /* FabButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB75F1CB40DC500C806FE /* FabButton.swift */; };
96BCB7A91CB40DC500C806FE /* FlatButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7601CB40DC500C806FE /* FlatButton.swift */; };
96BCB7AA1CB40DC500C806FE /* Grid.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7611CB40DC500C806FE /* Grid.swift */; };
......@@ -133,7 +133,7 @@
96BCB8351CB4115200C806FE /* MaterialTextLayer.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB78A1CB40DC500C806FE /* MaterialTextLayer.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8361CB4115200C806FE /* Grid.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7611CB40DC500C806FE /* Grid.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8371CB4115200C806FE /* Layout.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7811CB40DC500C806FE /* Layout.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8381CB4115200C806FE /* ControlView.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB75E1CB40DC500C806FE /* ControlView.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8381CB4115200C806FE /* ContentView.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB75E1CB40DC500C806FE /* ContentView.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8391CB4115200C806FE /* SearchBar.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7951CB40DC500C806FE /* SearchBar.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB83A1CB4115200C806FE /* SearchBarController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7961CB40DC500C806FE /* SearchBarController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB83B1CB4115200C806FE /* NavigationDrawerController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7971CB40DC500C806FE /* NavigationDrawerController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
......@@ -225,7 +225,7 @@
96BCB75B1CB40DC500C806FE /* CaptureSession.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaptureSession.swift; sourceTree = "<group>"; };
96BCB75C1CB40DC500C806FE /* Capture.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Capture.swift; sourceTree = "<group>"; };
96BCB75D1CB40DC500C806FE /* Card.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Card.swift; sourceTree = "<group>"; };
96BCB75E1CB40DC500C806FE /* ControlView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ControlView.swift; sourceTree = "<group>"; };
96BCB75E1CB40DC500C806FE /* ContentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentView.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>"; };
96BCB7611CB40DC500C806FE /* Grid.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Grid.swift; sourceTree = "<group>"; };
......@@ -342,6 +342,14 @@
name = Divider;
sourceTree = "<group>";
};
96264BE41D833C8400576F37 /* BarView */ = {
isa = PBXGroup;
children = (
96BCB7981CB40DC500C806FE /* BarView.swift */,
);
name = BarView;
sourceTree = "<group>";
};
962864601D5410FD00690B69 /* JSON */ = {
isa = PBXGroup;
children = (
......@@ -448,13 +456,12 @@
name = SearchBar;
sourceTree = "<group>";
};
963FBF061D669795008F8512 /* ControlView */ = {
963FBF061D669795008F8512 /* ContentView */ = {
isa = PBXGroup;
children = (
96BCB75E1CB40DC500C806FE /* ControlView.swift */,
96BCB7981CB40DC500C806FE /* BarView.swift */,
96BCB75E1CB40DC500C806FE /* ContentView.swift */,
);
name = ControlView;
name = ContentView;
sourceTree = "<group>";
};
9661222C1D3EC414008BB4CB /* macOS */ = {
......@@ -509,12 +516,13 @@
isa = PBXGroup;
children = (
96BCB8091CB4107700C806FE /* Animate */,
96264BE41D833C8400576F37 /* BarView */,
962DDD081D6FBBD0001C307C /* BottomTabBar */,
96BCB8031CB40F4B00C806FE /* Button */,
96BCB8021CB40F3B00C806FE /* Card */,
96BCB7FF1CB40EF000C806FE /* Capture */,
96BCB8051CB40F9C00C806FE /* Collection */,
963FBF061D669795008F8512 /* ControlView */,
963FBF061D669795008F8512 /* ContentView */,
96BCB8001CB40F0300C806FE /* Color */,
962A92581D42839100DBAF8E /* Data */,
96BCB80B1CB410CC00C806FE /* Device */,
......@@ -808,7 +816,7 @@
96BCB8351CB4115200C806FE /* MaterialTextLayer.swift in Headers */,
96BCB8361CB4115200C806FE /* Grid.swift in Headers */,
96BCB8371CB4115200C806FE /* Layout.swift in Headers */,
96BCB8381CB4115200C806FE /* ControlView.swift in Headers */,
96BCB8381CB4115200C806FE /* ContentView.swift in Headers */,
96BCB8391CB4115200C806FE /* SearchBar.swift in Headers */,
96BCB83A1CB4115200C806FE /* SearchBarController.swift in Headers */,
96BCB83B1CB4115200C806FE /* NavigationDrawerController.swift in Headers */,
......@@ -1101,7 +1109,7 @@
96BCB7D21CB40DC500C806FE /* TableViewCell.swift in Sources */,
96F1DC881D654FDF0025F925 /* Material+CALayer.swift in Sources */,
96BCB7B61CB40DC500C806FE /* Animation.swift in Sources */,
96BCB7A71CB40DC500C806FE /* ControlView.swift in Sources */,
96BCB7A71CB40DC500C806FE /* ContentView.swift in Sources */,
96BCB7DB1CB40DC500C806FE /* NavigationItem.swift in Sources */,
96BCB7E01CB40DC500C806FE /* NavigationDrawerController.swift in Sources */,
9628645F1D540AF300690B69 /* DynamicFontType.swift in Sources */,
......
......@@ -30,7 +30,7 @@
import UIKit
open class BarView: ControlView {
open class BarView: ContentView {
/// Divider layer.
open internal(set) var divider: Divider!
......
......@@ -42,7 +42,7 @@ open class Button: UIButton {
open private(set) lazy var visualLayer = CAShapeLayer()
/// An Array of pulse layers.
public private(set) lazy var pulseLayers = [CAShapeLayer]()
open private(set) lazy var pulseLayers = [CAShapeLayer]()
/// The opacity value for the pulse animation.
@IBInspectable
......
......@@ -221,19 +221,19 @@ open class Capture: View, UIGestureRecognizerDelegate {
}
/// A reference to the CapturePreview view.
open private(set) var previewView: CapturePreview!
open internal(set) var previewView: CapturePreview!
/// A reference to the CaptureSession.
open private(set) var captureSession: CaptureSession!
open internal(set) var captureSession: CaptureSession!
/// A reference to the focus layer used in focus animations.
open private(set) var focusLayer: Layer?
open internal(set) var focusLayer: Layer?
/// A reference to the exposure layer used in exposure animations.
open private(set) var exposureLayer: Layer?
open internal(set) var exposureLayer: Layer?
/// A reference to the reset layer used in reset animations.
open private(set) var resetLayer: Layer?
open internal(set) var resetLayer: Layer?
/// A reference to the cameraButton.
open var cameraButton: UIButton? {
......
......@@ -192,10 +192,10 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
internal var session: AVCaptureSession!
/// A boolean indicating if the session is running.
open private(set) var isRunning: Bool = false
open internal(set) var isRunning = false
/// A boolean indicating if the session is recording.
open private(set) var isRecording: Bool = false
open internal(set) var isRecording = false
/// A reference to the recorded time duration.
open var recordedDuration: CMTime {
......
......@@ -35,19 +35,19 @@ open class CollectionView: UICollectionView {
/// A preset wrapper around contentInset.
open var contentEdgeInsetsPreset: EdgeInsets {
get {
return (collectionViewLayout as? CollectionViewLayout)!.contentInset
return (collectionViewLayout as? CollectionViewLayout)!.contentEdgeInsets
}
set(value) {
(collectionViewLayout as? CollectionViewLayout)!.contentInset = value
(collectionViewLayout as? CollectionViewLayout)!.contentEdgeInsets = value
}
}
open override var contentInset: UIEdgeInsets {
get {
return (collectionViewLayout as? CollectionViewLayout)!.contentInset
return (collectionViewLayout as? CollectionViewLayout)!.contentEdgeInsets
}
set(value) {
(collectionViewLayout as? CollectionViewLayout)!.contentInset = value
(collectionViewLayout as? CollectionViewLayout)!.contentEdgeInsets = value
}
}
......
......@@ -37,27 +37,27 @@ open class CollectionViewLayout: UICollectionViewLayout {
/// The size of items.
open var itemSize = CGSize.zero
/// A preset wrapper around contentInset.
/// A preset wrapper around contentEdgeInsets.
open var contentEdgeInsetsPreset: EdgeInsetsPreset = .none {
didSet {
contentInset = EdgeInsetsPresetToValue(preset: contentEdgeInsetsPreset)
contentEdgeInsets = EdgeInsetsPresetToValue(preset: contentEdgeInsetsPreset)
}
}
/// A wrapper around grid.contentInset.
open var contentInset = EdgeInsets.zero
/// A wrapper around grid.contentEdgeInsets.
open var contentEdgeInsets = EdgeInsets.zero
/// Size of the content.
open private(set) var contentSize = CGSize.zero
open internal(set) var contentSize = CGSize.zero
/// Layout attribute items.
open private(set) var layoutItems = [(UICollectionViewLayoutAttributes, NSIndexPath)]()
open internal(set) lazy var layoutItems = [(UICollectionViewLayoutAttributes, NSIndexPath)]()
/// Cell data source items.
open private(set) var dataSourceItems: [DataSourceItem]?
open internal(set) var dataSourceItems: [DataSourceItem]?
/// Scroll direction.
open var scrollDirection: UICollectionViewScrollDirection = .vertical
open var scrollDirection = UICollectionViewScrollDirection.vertical
/// A preset wrapper around interimSpace.
open var interimSpacePreset = InterimSpacePreset.none {
......@@ -93,11 +93,11 @@ open class CollectionViewLayout: UICollectionViewLayout {
let item: DataSourceItem = dataSourceItems![indexPath.item]
if 0 < itemSize.width && 0 < itemSize.height {
attributes.frame = CGRect(x: offset.x, y: offset.y, width: itemSize.width - contentInset.left - contentInset.right, height: itemSize.height - contentInset.top - contentInset.bottom)
attributes.frame = CGRect(x: offset.x, y: offset.y, width: itemSize.width - contentEdgeInsets.left - contentEdgeInsets.right, height: itemSize.height - contentEdgeInsets.top - contentEdgeInsets.bottom)
} else if .vertical == scrollDirection {
attributes.frame = CGRect(x: contentInset.left, y: offset.y, width: collectionView!.bounds.width - contentInset.left - contentInset.right, height: item.height ?? collectionView!.bounds.height)
attributes.frame = CGRect(x: contentEdgeInsets.left, y: offset.y, width: collectionView!.bounds.width - contentEdgeInsets.left - contentEdgeInsets.right, height: item.height ?? collectionView!.bounds.height)
} else {
attributes.frame = CGRect(x: offset.x, y: contentInset.top, width: item.width ?? collectionView!.bounds.width, height: collectionView!.bounds.height - contentInset.top - contentInset.bottom)
attributes.frame = CGRect(x: offset.x, y: contentEdgeInsets.top, width: item.width ?? collectionView!.bounds.width, height: collectionView!.bounds.height - contentEdgeInsets.top - contentEdgeInsets.bottom)
}
return attributes
......@@ -131,8 +131,8 @@ open class CollectionViewLayout: UICollectionViewLayout {
self.dataSourceItems = dataSourceItems
layoutItems.removeAll()
offset.x = contentInset.left
offset.y = contentInset.top
offset.x = contentEdgeInsets.left
offset.y = contentEdgeInsets.top
for i in 0..<dataSourceItems.count {
let item: DataSourceItem = dataSourceItems[i]
......@@ -146,8 +146,8 @@ open class CollectionViewLayout: UICollectionViewLayout {
offset.y += nil == item.height ? itemSize.height : item.height!
}
offset.x += contentInset.right - interimSpace
offset.y += contentInset.bottom - interimSpace
offset.x += contentEdgeInsets.right - interimSpace
offset.y += contentEdgeInsets.bottom - interimSpace
if 0 < itemSize.width && 0 < itemSize.height {
contentSize = CGSize(width: offset.x, height: offset.y)
......
......@@ -36,7 +36,7 @@ public enum ContentViewAlignment: Int {
case center
}
open class ControlView: View {
open class ContentView: View {
/// Should center the contentView.
open var contentViewAlignment = ContentViewAlignment.any {
didSet {
......@@ -93,7 +93,8 @@ open class ControlView: View {
}
/// Grid cell factor.
@IBInspectable open var gridFactor: CGFloat = 24 {
@IBInspectable
open var gridFactor: CGFloat = 24 {
didSet {
assert(0 < gridFactor, "[Material Error: gridFactor must be greater than 0.]")
layoutSubviews()
......@@ -101,7 +102,7 @@ open class ControlView: View {
}
/// ContentView that holds the any desired subviews.
open private(set) lazy var contentView: UIView = UIView()
open private(set) lazy var contentView = UIView()
/// Left side UIControls.
open var leftControls = [UIView]() {
......@@ -196,6 +197,7 @@ open class ControlView: View {
}
contentView.grid.begin()
if .center == contentViewAlignment {
if lc < rc {
contentView.grid.columns = columns - 2 * rc
......
......@@ -46,11 +46,11 @@ public protocol MenuDelegate {
}
open class Menu: View {
/// A delegation reference.
open weak var delegate: MenuDelegate?
/// A Boolean that indicates if the menu is open or not.
open private(set) var isOpened = false
open internal(set) var isOpened = false
/// Enables the animations for the Menu.
open internal(set) var isEnabled = true
/// A preset wrapper around interimSpace.
open var interimSpacePreset = InterimSpacePreset.none {
......@@ -66,9 +66,6 @@ open class Menu: View {
}
}
/// Enables the animations for the Menu.
open private(set) var isEnabled = true
/// The direction in which the animation opens the menu.
open var direction = MenuDirection.up {
didSet {
......@@ -76,6 +73,9 @@ open class Menu: View {
}
}
/// A delegation reference.
open weak var delegate: MenuDelegate?
/// An Array of UIViews.
open var views = [UIView]() {
didSet {
......@@ -86,6 +86,7 @@ open class Menu: View {
for v in views {
addSubview(v)
}
reload()
}
}
......
......@@ -193,16 +193,16 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
opening and closing. Defaults to true.
*/
@IBInspectable
open var enabled: Bool {
open var isEnabled: Bool {
get {
return enabledLeftView || enabledRightView
return isLeftViewEnabled || isRightViewEnabled
}
set(value) {
if nil != leftView {
enabledLeftView = value
isLeftViewEnabled = value
}
if nil != rightView {
enabledRightView = value
isRightViewEnabled = value
}
}
}
......@@ -212,18 +212,18 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
opening and closing. Defaults to true.
*/
@IBInspectable
open var enabledLeftView = false {
open var isLeftViewEnabled = false {
didSet {
enabledLeftPanGesture = enabledLeftView
enabledLeftTapGesture = enabledLeftView
isLeftPanGestureEnabled = isLeftViewEnabled
isLeftTapGestureEnabled = isLeftViewEnabled
}
}
/// Enables the left pan gesture.
@IBInspectable
open var enabledLeftPanGesture = false {
open var isLeftPanGestureEnabled = false {
didSet {
if enabledLeftPanGesture {
if isLeftPanGestureEnabled {
prepareLeftPanGesture()
} else {
removeLeftPanGesture()
......@@ -233,9 +233,9 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
/// Enables the left tap gesture.
@IBInspectable
open var enabledLeftTapGesture = false {
open var isLeftTapGestureEnabled = false {
didSet {
if enabledLeftTapGesture {
if isLeftTapGestureEnabled {
prepareLeftTapGesture()
} else {
removeLeftTapGesture()
......@@ -248,18 +248,18 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
opening and closing. Defaults to true.
*/
@IBInspectable
open var enabledRightView = false {
open var isRightViewEnabled = false {
didSet {
enabledRightPanGesture = enabledRightView
enabledRightTapGesture = enabledRightView
isRightPanGestureEnabled = isRightViewEnabled
isRightTapGestureEnabled = isRightViewEnabled
}
}
/// Enables the right pan gesture.
@IBInspectable
open var enabledRightPanGesture = false {
open var isRightPanGestureEnabled = false {
didSet {
if enabledRightPanGesture {
if isRightPanGestureEnabled {
prepareRightPanGesture()
} else {
removeRightPanGesture()
......@@ -269,9 +269,9 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
/// Enables the right tap gesture.
@IBInspectable
open var enabledRightTapGesture = false {
open var isRightTapGestureEnabled = false {
didSet {
if enabledRightTapGesture {
if isRightTapGestureEnabled {
prepareRightTapGesture()
} else {
removeRightTapGesture()
......@@ -284,10 +284,10 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
when the leftView is opened. Defaults to true.
*/
@IBInspectable
open var enableHideStatusBar = true
open var isHiddenStatusBarEnabled = true
/// Sets the statusBar to hidden or not.
open private(set) var isStatusBarHidden = false
open internal(set) var isStatusBarHidden = false
/**
A DepthPreset property that is used to set the depth of the
......@@ -310,12 +310,12 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
open private(set) var rightView: View?
/// Indicates whether the leftView or rightView is opened.
open var opened: Bool {
return openedLeftView || openedRightView
open var isOpened: Bool {
return isLeftViewOpened || isRightViewOpened
}
/// indicates if the leftView is opened.
open var openedLeftView: Bool {
open var isLeftViewOpened: Bool {
guard nil != leftView else {
return false
}
......@@ -323,7 +323,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
}
/// Indicates if the rightView is opened.
open var openedRightView: Bool {
open var isRightViewOpened: Bool {
guard nil != rightView else {
return false
}
......@@ -337,7 +337,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
this, and to add a hidden transition viewController for complex
situations, the contentViewController was added.
*/
open private(set) lazy var contentViewController: UIViewController = UIViewController()
open private(set) lazy var contentViewController = UIViewController()
/**
A UIViewController property that references the
......@@ -413,7 +413,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
/// Layout subviews.
open override func layoutSubviews() {
if opened {
if isOpened {
hideStatusBar()
} else {
showStatusBar()
......@@ -446,7 +446,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
super.viewWillTransition(to: size, with: coordinator)
// Ensures the view is hidden.
if let v: View = rightView {
v.position.x = size.width + (openedRightView ? -v.width : v.width) / 2
v.position.x = size.width + (isRightViewOpened ? -v.width : v.width) / 2
}
}
......@@ -466,7 +466,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
var hide: Bool = hidden
if openedRightView {
if isRightViewOpened {
hide = true
}
......@@ -540,7 +540,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
var hide: Bool = hidden
if openedLeftView {
if isLeftViewOpened {
hide = true
}
......@@ -605,7 +605,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
leftView. Defaults to 0.
*/
open func toggleLeftView(velocity: CGFloat = 0) {
openedLeftView ? closeLeftView(velocity: velocity) : openLeftView(velocity: velocity)
isLeftViewOpened ? closeLeftView(velocity: velocity) : openLeftView(velocity: velocity)
}
/**
......@@ -616,7 +616,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
leftView. Defaults to 0.
*/
open func toggleRightView(velocity: CGFloat = 0) {
openedRightView ? closeRightView(velocity: velocity) : openRightView(velocity: velocity)
isRightViewOpened ? closeRightView(velocity: velocity) : openRightView(velocity: velocity)
}
/**
......@@ -626,7 +626,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
leftView. Defaults to 0.
*/
open func openLeftView(velocity: CGFloat = 0) {
if enabledLeftView {
if isLeftViewEnabled {
if let v: View = leftView {
hideStatusBar()
showView(container: v)
......@@ -652,7 +652,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
leftView. Defaults to 0.
*/
open func openRightView(velocity: CGFloat = 0) {
if enabledRightView {
if isRightViewEnabled {
if let v: View = rightView {
hideStatusBar()
showView(container: v)
......@@ -680,7 +680,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
leftView. Defaults to 0.
*/
open func closeLeftView(velocity: CGFloat = 0) {
if enabledLeftView {
if isLeftViewEnabled {
if let v: View = leftView {
isUserInteractionEnabled = true
delegate?.navigationDrawerWillClose?(navigationDrawerController: self, position: .left)
......@@ -708,7 +708,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
leftView. Defaults to 0.
*/
open func closeRightView(velocity: CGFloat = 0) {
if enabledRightView {
if isRightViewEnabled {
if let v: View = rightView {
isUserInteractionEnabled = true
delegate?.navigationDrawerWillClose?(navigationDrawerController: self, position: .right)
......@@ -736,16 +736,16 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
- Returns: A Boolean of whether to continue the gesture or not.
*/
open func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
if !openedRightView && gestureRecognizer == leftPanGesture && (openedLeftView || isPointContainedWithinLeftThreshold(point: touch.location(in: view))) {
if !isRightViewOpened && gestureRecognizer == leftPanGesture && (isLeftViewOpened || isPointContainedWithinLeftThreshold(point: touch.location(in: view))) {
return true
}
if !openedLeftView && gestureRecognizer == rightPanGesture && (openedRightView || isPointContainedWithinRighThreshold(point: touch.location(in: view))) {
if !isLeftViewOpened && gestureRecognizer == rightPanGesture && (isRightViewOpened || isPointContainedWithinRighThreshold(point: touch.location(in: view))) {
return true
}
if openedLeftView && gestureRecognizer == leftTapGesture {
if isLeftViewOpened && gestureRecognizer == leftTapGesture {
return true
}
if openedRightView && gestureRecognizer == rightTapGesture {
if isRightViewOpened && gestureRecognizer == rightTapGesture {
return true
}
return false
......@@ -759,7 +759,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
*/
@objc
internal func handleLeftViewPanGesture(recognizer: UIPanGestureRecognizer) {
if enabledLeftView && (openedLeftView || !openedRightView && isPointContainedWithinLeftThreshold(point: recognizer.location(in: view))) {
if isLeftViewEnabled && (isLeftViewOpened || !isRightViewOpened && isPointContainedWithinLeftThreshold(point: recognizer.location(in: view))) {
if let v: View = leftView {
let point: CGPoint = recognizer.location(in: view)
......@@ -808,7 +808,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
*/
@objc
internal func handleRightViewPanGesture(recognizer: UIPanGestureRecognizer) {
if enabledRightView && (openedRightView || !openedLeftView && isPointContainedWithinRighThreshold(point: recognizer.location(in: view))) {
if isRightViewEnabled && (isRightViewOpened || !isLeftViewOpened && isPointContainedWithinRighThreshold(point: recognizer.location(in: view))) {
if let v: View = rightView {
let point: CGPoint = recognizer.location(in: view)
......@@ -857,10 +857,10 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
*/
@objc
internal func handleLeftViewTapGesture(recognizer: UITapGestureRecognizer) {
if openedLeftView {
if isLeftViewOpened {
if let v: View = leftView {
delegate?.navigationDrawerDidTap?(navigationDrawerController: self, point: recognizer.location(in: view), position: .left)
if enabledLeftView && openedLeftView && !isPointContainedWithinView(container: v, point: recognizer.location(in: v)) {
if isLeftViewEnabled && isLeftViewOpened && !isPointContainedWithinView(container: v, point: recognizer.location(in: v)) {
closeLeftView()
}
}
......@@ -875,10 +875,10 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
*/
@objc
internal func handleRightViewTapGesture(recognizer: UITapGestureRecognizer) {
if openedRightView {
if isRightViewOpened {
if let v: View = rightView {
delegate?.navigationDrawerDidTap?(navigationDrawerController: self, point: recognizer.location(in: view), position: .right)
if enabledRightView && openedRightView && !isPointContainedWithinView(container: v, point: recognizer.location(in: v)) {
if isRightViewEnabled && isRightViewOpened && !isPointContainedWithinView(container: v, point: recognizer.location(in: v)) {
closeRightView()
}
}
......@@ -912,7 +912,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
return
}
enabledLeftView = true
isLeftViewEnabled = true
leftViewWidth = .phone == Device.userInterfaceIdiom ? 280 : 320
leftView = View()
......@@ -932,7 +932,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
return
}
enabledRightView = true
isRightViewEnabled = true
rightViewWidth = .phone == Device.userInterfaceIdiom ? 280 : 320
rightView = View()
......@@ -1046,7 +1046,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
/// Hides the statusBar.
private func hideStatusBar() {
if enableHideStatusBar {
if isHiddenStatusBarEnabled {
if !isStatusBarHidden {
isStatusBarHidden = true
DispatchQueue.main.async { [weak self] in
......@@ -1063,7 +1063,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
/// Toggles the statusBar
private func toggleStatusBar() {
if opened || Device.isLandscape && .phone == Device.userInterfaceIdiom {
if isOpened || Device.isLandscape && .phone == Device.userInterfaceIdiom {
hideStatusBar()
} else {
showStatusBar()
......
......@@ -32,17 +32,17 @@ import UIKit
open class SearchBar: BarView {
/// The UITextField for the searchBar.
open private(set) var textField: UITextField!
open private(set) lazy var textField = UITextField()
/// Reference to the clearButton.
open private(set) var clearButton: IconButton!
/// Handle the clearButton manually.
@IBInspectable
open var clearButtonAutoHandleEnabled: Bool = true {
open var isClearButtonAutoHandleEnabled = true {
didSet {
clearButton.removeTarget(self, action: #selector(handleClearButton), for: .touchUpInside)
if clearButtonAutoHandleEnabled {
if isClearButtonAutoHandleEnabled {
clearButton.addTarget(self, action: #selector(handleClearButton), for: .touchUpInside)
}
}
......@@ -82,7 +82,7 @@ open class SearchBar: BarView {
/// Placeholder textColor.
@IBInspectable
open var placeholderColor: UIColor = Color.darkText.others {
open var placeholderColor = Color.darkText.others {
didSet {
if let v: String = placeholder {
textField.attributedPlaceholder = NSAttributedString(string: v, attributes: [NSForegroundColorAttributeName: placeholderColor])
......@@ -142,7 +142,7 @@ open class SearchBar: BarView {
/// Layout the clearButton.
open func layoutClearButton() {
let h: CGFloat = textField.frame.height
let h = textField.frame.height
clearButton.frame = CGRect(x: textField.frame.width - h, y: 0, width: h, height: h)
}
......@@ -154,7 +154,6 @@ open class SearchBar: BarView {
/// Prepares the textField.
private func prepareTextField() {
textField = UITextField()
textField.contentScaleFactor = Device.scale
textField.font = RobotoFont.regular(with: 17)
textField.backgroundColor = Color.clear
......@@ -169,7 +168,7 @@ open class SearchBar: BarView {
private func prepareClearButton() {
clearButton = IconButton(image: Icon.cm.close, tintColor: placeholderColor)
clearButton.contentEdgeInsets = .zero
clearButtonAutoHandleEnabled = true
isClearButtonAutoHandleEnabled = true
textField.clearButtonMode = .never
textField.rightViewMode = .whileEditing
textField.rightView = clearButton
......
......@@ -30,39 +30,39 @@
import UIKit
@objc(SwitchStyle)
public enum SwitchStyle: Int {
@objc(SwitchControlStyle)
public enum SwitchControlStyle: Int {
case light
case dark
}
@objc(SwitchState)
public enum SwitchState: Int {
@objc(SwitchControlState)
public enum SwitchControlState: Int {
case on
case off
}
@objc(SwitchSize)
public enum SwitchSize: Int {
@objc(SwitchControlSize)
public enum SwitchControlSize: Int {
case small
case medium
case large
}
@objc(SwitchDelegate)
public protocol SwitchDelegate {
@objc(SwitchControlDelegate)
public protocol SwitchControlDelegate {
/**
A Switch delegate method for state changes.
- Parameter control: Switch control.
A SwitchControl delegate method for state changes.
- Parameter control: SwitchControl control.
*/
func switchStateChanged(control: Switch)
func switchStateChanged(control: SwitchControl)
}
@objc(Switch)
@objc(SwitchControl)
@IBDesignable
public class Switch: UIControl {
open class SwitchControl: UIControl {
/// An internal reference to the switchState public property.
private var internalSwitchState: SwitchState = .off
private var internalSwitchControlState: SwitchControlState = .off
/// Track thickness.
private var trackThickness: CGFloat = 0
......@@ -80,66 +80,75 @@ public class Switch: UIControl {
private var bounceOffset: CGFloat = 3
/// An Optional delegation method.
open weak var delegate: SwitchDelegate?
open weak var delegate: SwitchControlDelegate?
/// Indicates if the animation should bounce.
@IBInspectable public var bounceable: Bool = true {
@IBInspectable
public var bounceable = true {
didSet {
bounceOffset = bounceable ? 3 : 0
}
}
/// Button on color.
@IBInspectable public var buttonOnColor: UIColor = Color.clear {
@IBInspectable
public var buttonOnColor = Color.clear {
didSet {
styleForState(state: switchState)
}
}
/// Button off color.
@IBInspectable public var buttonOffColor: UIColor = Color.clear {
@IBInspectable
public var buttonOffColor = Color.clear {
didSet {
styleForState(state: switchState)
}
}
/// Track on color.
@IBInspectable public var trackOnColor: UIColor = Color.clear {
@IBInspectable
public var trackOnColor = Color.clear {
didSet {
styleForState(state: switchState)
}
}
/// Track off color.
@IBInspectable public var trackOffColor: UIColor = Color.clear {
@IBInspectable
public var trackOffColor = Color.clear {
didSet {
styleForState(state: switchState)
}
}
/// Button on disabled color.
@IBInspectable public var buttonOnDisabledColor: UIColor = Color.clear {
@IBInspectable
public var buttonOnDisabledColor = Color.clear {
didSet {
styleForState(state: switchState)
}
}
/// Track on disabled color.
@IBInspectable public var trackOnDisabledColor: UIColor = Color.clear {
@IBInspectable
public var trackOnDisabledColor = Color.clear {
didSet {
styleForState(state: switchState)
}
}
/// Button off disabled color.
@IBInspectable public var buttonOffDisabledColor: UIColor = Color.clear {
@IBInspectable
public var buttonOffDisabledColor = Color.clear {
didSet {
styleForState(state: switchState)
}
}
/// Track off disabled color.
@IBInspectable public var trackOffDisabledColor: UIColor = Color.clear {
@IBInspectable
public var trackOffDisabledColor = Color.clear {
didSet {
styleForState(state: switchState)
}
......@@ -159,36 +168,38 @@ public class Switch: UIControl {
}
}
@IBInspectable public override var isEnabled: Bool {
@IBInspectable
open override var isEnabled: Bool {
didSet {
styleForState(state: internalSwitchState)
styleForState(state: internalSwitchControlState)
}
}
/// A boolean indicating if the switch is on or not.
@IBInspectable public var on: Bool {
@IBInspectable
public var on: Bool {
get {
return .on == internalSwitchState
return .on == internalSwitchControlState
}
set(value) {
setOn(on: value, animated: true)
}
}
/// Switch state.
public var switchState: SwitchState {
/// SwitchControl state.
public var switchState: SwitchControlState {
get {
return internalSwitchState
return internalSwitchControlState
}
set(value) {
if value != internalSwitchState {
internalSwitchState = value
if value != internalSwitchControlState {
internalSwitchControlState = value
}
}
}
/// Switch style.
public var switchStyle: SwitchStyle = .dark {
/// SwitchControl style.
public var switchStyle: SwitchControlStyle = .dark {
didSet {
switch switchStyle {
case .light:
......@@ -213,8 +224,8 @@ public class Switch: UIControl {
}
}
/// Switch size.
public var switchSize: SwitchSize = .medium {
/// SwitchControl size.
public var switchSize: SwitchControlSize = .medium {
didSet {
switch switchSize {
case .small:
......@@ -233,19 +244,19 @@ public class Switch: UIControl {
}
}
public override var frame: CGRect {
open override var frame: CGRect {
didSet {
layoutSwitch()
layoutSwitchControl()
}
}
public override var bounds: CGRect {
open override var bounds: CGRect {
didSet {
layoutSwitch()
layoutSwitchControl()
}
}
public override var intrinsicContentSize: CGSize {
open override var intrinsicContentSize: CGSize {
switch switchSize {
case .small:
return CGSize(width: 30, height: 25)
......@@ -266,9 +277,9 @@ public class Switch: UIControl {
super.init(coder: aDecoder)
prepareTrack()
prepareButton()
prepareSwitchSize(size: .medium)
prepareSwitchStyle(style: .light)
prepareSwitchState(state: .off)
prepareSwitchControlSize(size: .medium)
prepareSwitchControlStyle(style: .light)
prepareSwitchControlState(state: .off)
}
/**
......@@ -284,39 +295,39 @@ public class Switch: UIControl {
super.init(frame: frame)
prepareTrack()
prepareButton()
prepareSwitchSize(size: .medium)
prepareSwitchStyle(style: .light)
prepareSwitchState(state: .off)
prepareSwitchControlSize(size: .medium)
prepareSwitchControlStyle(style: .light)
prepareSwitchControlState(state: .off)
}
/**
An initializer that sets the state, style, and size of the Switch instance.
- Parameter state: A SwitchState value.
- Parameter style: A SwitchStyle value.
- Parameter size: A SwitchSize value.
An initializer that sets the state, style, and size of the SwitchControl instance.
- Parameter state: A SwitchControlState value.
- Parameter style: A SwitchControlStyle value.
- Parameter size: A SwitchControlSize value.
*/
public init(state: SwitchState = .off, style: SwitchStyle = .dark, size: SwitchSize = .medium) {
public init(state: SwitchControlState = .off, style: SwitchControlStyle = .dark, size: SwitchControlSize = .medium) {
trackLayer = CAShapeLayer()
button = FabButton()
super.init(frame: CGRect.null)
prepareTrack()
prepareButton()
prepareSwitchSize(size: size)
prepareSwitchStyle(style: style)
prepareSwitchState(state: state)
prepareSwitchControlSize(size: size)
prepareSwitchControlStyle(style: style)
prepareSwitchControlState(state: state)
}
public override func willMove(toSuperview newSuperview: UIView?) {
open override func willMove(toSuperview newSuperview: UIView?) {
super.willMove(toSuperview: newSuperview)
styleForState(state: internalSwitchState)
styleForState(state: internalSwitchControlState)
}
/**
Toggle the Switch state, if On will be Off, and if Off will be On.
Toggle the SwitchControl state, if On will be Off, and if Off will be On.
- Parameter completion: An Optional completion block.
*/
public func toggle(completion: ((Switch) -> Void)? = nil) {
setSwitchState(state: .on == internalSwitchState ? .off : .on, animated: true, completion: completion)
public func toggle(completion: ((SwitchControl) -> Void)? = nil) {
setSwitchControlState(state: .on == internalSwitchControlState ? .off : .on, animated: true, completion: completion)
}
/**
......@@ -324,22 +335,22 @@ public class Switch: UIControl {
- Parameter on: A bool of whether the switch should be in the on state or not.
- Parameter animated: A Boolean indicating to set the animation or not.
*/
public func setOn(on: Bool, animated: Bool, completion: ((Switch) -> Void)? = nil) {
setSwitchState(state: on ? .on : .off, animated: animated, completion: completion)
public func setOn(on: Bool, animated: Bool, completion: ((SwitchControl) -> Void)? = nil) {
setSwitchControlState(state: on ? .on : .off, animated: animated, completion: completion)
}
/**
Set the switchState property with an option to animate.
- Parameter state: The SwitchState to set.
- Parameter state: The SwitchControlState to set.
- Parameter animated: A Boolean indicating to set the animation or not.
- Parameter completion: An Optional completion block.
*/
public func setSwitchState(state: SwitchState, animated: Bool = true, completion: ((Switch) -> Void)? = nil) {
if isEnabled && internalSwitchState != state {
internalSwitchState = state
public func setSwitchControlState(state: SwitchControlState, animated: Bool = true, completion: ((SwitchControl) -> Void)? = nil) {
if isEnabled && internalSwitchControlState != state {
internalSwitchControlState = state
if animated {
animateToState(state: state) { [weak self] _ in
if let s: Switch = self {
if let s: SwitchControl = self {
s.sendActions(for: .valueChanged)
completion?(s)
s.delegate?.switchStateChanged(control: s)
......@@ -364,7 +375,7 @@ public class Switch: UIControl {
internal func handleTouchUpOutsideOrCanceled(sender: FabButton, event: UIEvent) {
if let v: UITouch = event.touches(for: sender)?.first {
let q: CGFloat = sender.x + v.location(in: sender).x - v.previousLocation(in: sender).x
setSwitchState(state: q > (width - button.width) / 2 ? .on : .off, animated: true)
setSwitchControlState(state: q > (width - button.width) / 2 ? .on : .off, animated: true)
}
}
......@@ -389,9 +400,9 @@ public class Switch: UIControl {
}
}
public override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
open override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
if true == trackLayer.frame.contains(layer.convert(touches.first!.location(in: self), from: layer)) {
setOn(on: .on != internalSwitchState, animated: true)
setOn(on: .on != internalSwitchControlState, animated: true)
}
}
......@@ -413,35 +424,35 @@ public class Switch: UIControl {
/**
Prepares the switchState property. This is used mainly to allow
init to set the state value and have an effect.
- Parameter state: The SwitchState to set.
- Parameter state: The SwitchControlState to set.
*/
private func prepareSwitchState(state: SwitchState) {
setSwitchState(state: state, animated: false)
private func prepareSwitchControlState(state: SwitchControlState) {
setSwitchControlState(state: state, animated: false)
}
/**
Prepares the switchStyle property. This is used mainly to allow
init to set the state value and have an effect.
- Parameter style: The SwitchStyle to set.
- Parameter style: The SwitchControlStyle to set.
*/
private func prepareSwitchStyle(style: SwitchStyle) {
private func prepareSwitchControlStyle(style: SwitchControlStyle) {
switchStyle = style
}
/**
Prepares the switchSize property. This is used mainly to allow
init to set the size value and have an effect.
- Parameter size: The SwitchSize to set.
- Parameter size: The SwitchControlSize to set.
*/
private func prepareSwitchSize(size: SwitchSize) {
private func prepareSwitchControlSize(size: SwitchControlSize) {
switchSize = size
}
/**
Updates the style based on the state.
- Parameter state: The SwitchState to set the style to.
- Parameter state: The SwitchControlState to set the style to.
*/
private func styleForState(state: SwitchState) {
private func styleForState(state: SwitchControlState) {
if isEnabled {
updateColorForState(state: state)
} else {
......@@ -451,9 +462,9 @@ public class Switch: UIControl {
/**
Updates the coloring for the enabled state.
- Parameter state: SwitchState.
- Parameter state: SwitchControlState.
*/
private func updateColorForState(state: SwitchState) {
private func updateColorForState(state: SwitchControlState) {
if .on == state {
button.backgroundColor = buttonOnColor
trackLayer.backgroundColor = trackOnColor.cgColor
......@@ -465,9 +476,9 @@ public class Switch: UIControl {
/**
Updates the coloring for the disabled state.
- Parameter state: SwitchState.
- Parameter state: SwitchControlState.
*/
private func updateColorForDisabledState(state: SwitchState) {
private func updateColorForDisabledState(state: SwitchControlState) {
if .on == state {
button.backgroundColor = buttonOnDisabledColor
trackLayer.backgroundColor = trackOnDisabledColor.cgColor
......@@ -478,7 +489,7 @@ public class Switch: UIControl {
}
/// Laout the button and track views.
private func layoutSwitch() {
private func layoutSwitchControl() {
var w: CGFloat = 0
switch switchSize {
case .small:
......@@ -498,34 +509,34 @@ public class Switch: UIControl {
onPosition = width - px - buttonDiameter
offPosition = px
if .on == internalSwitchState {
if .on == internalSwitchControlState {
button.x = onPosition
}
}
/**
Set the switchState property with an animate.
- Parameter state: The SwitchState to set.
- Parameter state: The SwitchControlState to set.
- Parameter completion: An Optional completion block.
*/
private func animateToState(state: SwitchState, completion: ((Switch) -> Void)? = nil) {
private func animateToState(state: SwitchControlState, completion: ((SwitchControl) -> Void)? = nil) {
isUserInteractionEnabled = false
UIView.animate(withDuration: 0.15,
delay: 0.05,
options: [.curveEaseIn, .curveEaseOut],
animations: { [weak self] in
if let s: Switch = self {
if let s: SwitchControl = self {
s.button.x = .on == state ? s.onPosition + s.bounceOffset : s.offPosition - s.bounceOffset
s.styleForState(state: state)
}
}) { [weak self] _ in
UIView.animate(withDuration: 0.15,
animations: { [weak self] in
if let s: Switch = self {
if let s: SwitchControl = self {
s.button.x = .on == state ? s.onPosition : s.offPosition
}
}) { [weak self] _ in
if let s: Switch = self {
if let s: SwitchControl = self {
s.isUserInteractionEnabled = true
completion?(s)
}
......
......@@ -40,7 +40,7 @@ open class TextField: UITextField {
}
/// A Boolean that indicates if the TextField is in an animating state.
open private(set) var animating = false
open internal(set) var isAnimating = false
/// A property that accesses the backing layer's backgroundColor.
@IBInspectable
......@@ -199,7 +199,7 @@ open class TextField: UITextField {
/// Enables the clearIconButton.
@IBInspectable
open var enableClearIconButton: Bool {
open var isClearIconButtonEnable: Bool {
get {
return nil != clearIconButton
}
......@@ -234,7 +234,7 @@ open class TextField: UITextField {
/// Enables the visibilityIconButton.
@IBInspectable
open var enableVisibilityIconButton: Bool {
open var isVisibilityIconButtonEnable: Bool {
get {
return nil != visibilityIconButton
}
......@@ -379,7 +379,7 @@ open class TextField: UITextField {
/// Ensures that the components are sized correctly.
open func layoutToSize() {
if !animating {
if !isAnimating {
layoutPlaceholderLabel()
layoutDetailLabel()
layoutClearIconButton()
......@@ -461,7 +461,7 @@ open class TextField: UITextField {
/// The animation for the placeholder when editing begins.
open func placeholderEditingDidBeginAnimation() {
if placeholderLabel.transform.isIdentity {
animating = true
isAnimating = true
UIView.animate(withDuration: 0.15, animations: { [weak self] in
if let s = self {
s.placeholderLabel.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
......@@ -476,7 +476,7 @@ open class TextField: UITextField {
s.placeholderLabel.textColor = s.placeholderActiveColor
}
}) { [weak self] _ in
self?.animating = false
self?.isAnimating = false
}
} else if isEditing {
placeholderLabel.textColor = placeholderActiveColor
......@@ -486,7 +486,7 @@ open class TextField: UITextField {
/// The animation for the placeholder when editing ends.
open func placeholderEditingDidEndAnimation() {
if !placeholderLabel.transform.isIdentity && true == text?.isEmpty {
animating = true
isAnimating = true
UIView.animate(withDuration: 0.15, animations: { [weak self] in
if let s = self {
s.placeholderLabel.transform = CGAffineTransform.identity
......@@ -495,7 +495,7 @@ open class TextField: UITextField {
s.placeholderLabel.textColor = s.placeholderColor
}
}) { [weak self] _ in
self?.animating = false
self?.isAnimating = false
}
} else if !isEditing {
placeholderLabel.textColor = placeholderColor
......
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