Commit 9cdaed1f by Daniel Dahan

development: updated loading calls for control variables and added boolean for…

development: updated loading calls for control variables and added boolean for StatusBar rotation handling
parent 27b14361
...@@ -377,6 +377,14 @@ ...@@ -377,6 +377,14 @@
name = Screen; name = Screen;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
961E6BEF1DDA4B04004E6C93 /* NavigationDrawer */ = {
isa = PBXGroup;
children = (
96BCB7971CB40DC500C806FE /* NavigationDrawerController.swift */,
);
name = NavigationDrawer;
sourceTree = "<group>";
};
96230AB61D6A51FD00AF47DC /* Divider */ = { 96230AB61D6A51FD00AF47DC /* Divider */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -584,6 +592,7 @@ ...@@ -584,6 +592,7 @@
963FBF021D6696D0008F8512 /* Menu */, 963FBF021D6696D0008F8512 /* Menu */,
96BCB8091CB4107700C806FE /* Motion */, 96BCB8091CB4107700C806FE /* Motion */,
96BCB8011CB40F1700C806FE /* Navigation */, 96BCB8011CB40F1700C806FE /* Navigation */,
961E6BEF1DDA4B04004E6C93 /* NavigationDrawer */,
962DDD071D6FBBB7001C307C /* Page */, 962DDD071D6FBBB7001C307C /* Page */,
96717B151DBE6B1800DA84DB /* Photos */, 96717B151DBE6B1800DA84DB /* Photos */,
9626CA951DAB5370003E2611 /* Root */, 9626CA951DAB5370003E2611 /* Root */,
...@@ -637,7 +646,6 @@ ...@@ -637,7 +646,6 @@
96BCB7901CB40DC500C806FE /* NavigationBar.swift */, 96BCB7901CB40DC500C806FE /* NavigationBar.swift */,
96BCB7911CB40DC500C806FE /* NavigationController.swift */, 96BCB7911CB40DC500C806FE /* NavigationController.swift */,
96BCB7921CB40DC500C806FE /* NavigationItem.swift */, 96BCB7921CB40DC500C806FE /* NavigationItem.swift */,
96BCB7971CB40DC500C806FE /* NavigationDrawerController.swift */,
); );
name = Navigation; name = Navigation;
sourceTree = "<group>"; sourceTree = "<group>";
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>2.3.8</string> <string>2.3.9</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
......
...@@ -31,6 +31,11 @@ ...@@ -31,6 +31,11 @@
import UIKit import UIKit
public struct Application { public struct Application {
/// A reference to the main UIWindow.
public static var keyWindow: UIWindow? {
return UIApplication.shared.keyWindow
}
/// A Boolean indicating if the device is in Landscape mode. /// A Boolean indicating if the device is in Landscape mode.
public static var isLandscape: Bool { public static var isLandscape: Bool {
return UIApplication.shared.statusBarOrientation.isLandscape return UIApplication.shared.statusBarOrientation.isLandscape
...@@ -65,4 +70,12 @@ public struct Application { ...@@ -65,4 +70,12 @@ public struct Application {
UIApplication.shared.isStatusBarHidden = value UIApplication.shared.isStatusBarHidden = value
} }
} }
/**
A boolean that indicates based on iPhone rules if the
status bar should be shown.
*/
public static var shouldStatusBarBeHidden: Bool {
return isLandscape && .phone == Device.userInterfaceIdiom
}
} }
...@@ -52,7 +52,7 @@ extension UIViewController { ...@@ -52,7 +52,7 @@ extension UIViewController {
open class CaptureController: ToolbarController { open class CaptureController: ToolbarController {
/// A reference to the Capture instance. /// A reference to the Capture instance.
@IBInspectable @IBInspectable
open private(set) lazy var capture: Capture = Capture() open private(set) var capture = Capture()
open override var supportedInterfaceOrientations: UIInterfaceOrientationMask { open override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.portrait return UIInterfaceOrientationMask.portrait
......
...@@ -37,7 +37,7 @@ open class Card: PulseView { ...@@ -37,7 +37,7 @@ open class Card: PulseView {
} }
/// A container view for subviews. /// A container view for subviews.
open private(set) lazy var container = UIView() open private(set) var container = UIView()
@IBInspectable @IBInspectable
open override var cornerRadiusPreset: CornerRadiusPreset { open override var cornerRadiusPreset: CornerRadiusPreset {
......
...@@ -62,19 +62,23 @@ public enum DeviceModel { ...@@ -62,19 +62,23 @@ public enum DeviceModel {
} }
public struct Device { public struct Device {
/// Gets the model name for the device. /// Gets the Device identifier String.
public static var identifier: String {
var systemInfo = utsname()
uname(&systemInfo)
let machineMirror = Mirror(reflecting: systemInfo.machine)
let identifier = machineMirror.children.reduce("") { (identifier, element) in
guard let value = element.value as? Int8, value != 0 else {
return identifier
}
return identifier + String(UnicodeScalar(UInt8(value)))
}
return identifier
}
/// Gets the model name for the device.
public static var model: DeviceModel { public static var model: DeviceModel {
var systemInfo = utsname()
uname(&systemInfo)
let machineMirror = Mirror(reflecting: systemInfo.machine)
let identifier = machineMirror.children.reduce("") { (identifier, element) in
guard let value = element.value as? Int8, value != 0 else {
return identifier
}
return identifier + String(UnicodeScalar(UInt8(value)))
}
switch identifier { switch identifier {
case "iPod5,1": return .iPodTouch5 case "iPod5,1": return .iPodTouch5
case "iPod7,1": return .iPodTouch6 case "iPod7,1": return .iPodTouch6
......
...@@ -52,7 +52,7 @@ extension UIViewController { ...@@ -52,7 +52,7 @@ extension UIViewController {
open class EditorController: ToolbarController { open class EditorController: ToolbarController {
/// A reference to the Editor instance. /// A reference to the Editor instance.
@IBInspectable @IBInspectable
open private(set) lazy var editor: Editor = Editor() open private(set) var editor = Editor()
/** /**
Prepares the view instance when intialized. When subclassing, Prepares the view instance when intialized. When subclassing,
......
...@@ -50,7 +50,7 @@ extension UIViewController { ...@@ -50,7 +50,7 @@ extension UIViewController {
open class MenuController: RootController { open class MenuController: RootController {
/// Reference to the MenuView. /// Reference to the MenuView.
open private(set) lazy var menu: Menu = Menu() open private(set) var menu = Menu()
/** /**
Opens the menu with a callback. Opens the menu with a callback.
......
...@@ -32,10 +32,10 @@ import UIKit ...@@ -32,10 +32,10 @@ import UIKit
open class MenuItem: View { open class MenuItem: View {
/// A reference to the titleLabel. /// A reference to the titleLabel.
open private(set) lazy var titleLabel = UILabel() open private(set) var titleLabel = UILabel()
/// A reference to the button. /// A reference to the button.
open private(set) lazy var button: FabButton = FabButton() open private(set) var button = FabButton()
/** /**
Prepares the view instance when intialized. When subclassing, Prepares the view instance when intialized. When subclassing,
......
...@@ -101,7 +101,7 @@ public protocol PageTabBarControllerDelegate { ...@@ -101,7 +101,7 @@ public protocol PageTabBarControllerDelegate {
@objc(PageTabBarController) @objc(PageTabBarController)
open class PageTabBarController: RootController { open class PageTabBarController: RootController {
/// Reference to the PageTabBar. /// Reference to the PageTabBar.
open private(set) lazy var pageTabBar: PageTabBar = PageTabBar() open private(set) var pageTabBar = PageTabBar()
/// A boolean that indicates whether bounce is enabled. /// A boolean that indicates whether bounce is enabled.
open var isBounceEnabled: Bool { open var isBounceEnabled: Bool {
......
...@@ -50,7 +50,7 @@ extension UIViewController { ...@@ -50,7 +50,7 @@ extension UIViewController {
open class PhotoLibraryController: UIViewController { open class PhotoLibraryController: UIViewController {
/// A reference to a PhotoLibrary. /// A reference to a PhotoLibrary.
open private(set) lazy var photoLibrary: PhotoLibrary = PhotoLibrary() open private(set) var photoLibrary = PhotoLibrary()
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
......
...@@ -62,7 +62,7 @@ public protocol SearchBarDelegate { ...@@ -62,7 +62,7 @@ public protocol SearchBarDelegate {
open class SearchBar: Bar { open class SearchBar: Bar {
/// The UITextField for the searchBar. /// The UITextField for the searchBar.
open private(set) lazy var textField = UITextField() open private(set) var textField = UITextField()
/// Reference to the clearButton. /// Reference to the clearButton.
open private(set) var clearButton: IconButton! open private(set) var clearButton: IconButton!
......
...@@ -61,13 +61,12 @@ open class SearchBarController: StatusBarController { ...@@ -61,13 +61,12 @@ open class SearchBarController: StatusBarController {
} }
/// Reference to the SearchBar. /// Reference to the SearchBar.
open private(set) lazy var searchBar: SearchBar = SearchBar() open private(set) var searchBar = SearchBar()
open override func layoutSubviews() { open override func layoutSubviews() {
super.layoutSubviews() super.layoutSubviews()
statusBar.layoutIfNeeded()
let y = statusBar.isHidden ? 0 : statusBar.height let y = Application.shouldStatusBarBeHidden || statusBar.isHidden ? 0 : statusBar.height
let p = y + searchBar.height let p = y + searchBar.height
searchBar.y = y searchBar.y = y
...@@ -91,13 +90,21 @@ open class SearchBarController: StatusBarController { ...@@ -91,13 +90,21 @@ open class SearchBarController: StatusBarController {
*/ */
open override func prepare() { open override func prepare() {
super.prepare() super.prepare()
prepareStatusBar()
prepareSearchBar() prepareSearchBar()
} }
}
/// Prepares the searchBar.
private func prepareSearchBar() { extension SearchBarController {
/// Prepares the statusBar.
fileprivate func prepareStatusBar() {
shouldHideStatusBarOnRotation = false
}
/// Prepares the searchBar.
fileprivate func prepareSearchBar() {
searchBar.depthPreset = .depth1 searchBar.depthPreset = .depth1
searchBar.zPosition = 1000 searchBar.zPosition = 1000
view.addSubview(searchBar) view.addSubview(searchBar)
} }
} }
...@@ -91,7 +91,7 @@ extension UIViewController { ...@@ -91,7 +91,7 @@ extension UIViewController {
open class SnackbarController: RootController { open class SnackbarController: RootController {
/// Reference to the Snackbar. /// Reference to the Snackbar.
open private(set) lazy var snackbar: Snackbar = Snackbar() open private(set) var snackbar = Snackbar()
/// A boolean indicating if the Snacbar is animating. /// A boolean indicating if the Snacbar is animating.
open internal(set) var isAnimating = false open internal(set) var isAnimating = false
......
...@@ -50,8 +50,11 @@ extension UIViewController { ...@@ -50,8 +50,11 @@ extension UIViewController {
open class StatusBarController: RootController { open class StatusBarController: RootController {
/// A reference to the statusBar. /// A reference to the statusBar.
open private(set) lazy var statusBar: View = View() open private(set) var statusBar = UIView()
/// A boolean that indicates to hide the statusBar on rotation.
open var shouldHideStatusBarOnRotation = true
open override var isStatusBarHidden: Bool { open override var isStatusBarHidden: Bool {
didSet { didSet {
statusBar.isHidden = isStatusBarHidden statusBar.isHidden = isStatusBarHidden
...@@ -65,9 +68,12 @@ open class StatusBarController: RootController { ...@@ -65,9 +68,12 @@ open class StatusBarController: RootController {
*/ */
open override func layoutSubviews() { open override func layoutSubviews() {
super.layoutSubviews() super.layoutSubviews()
if shouldHideStatusBarOnRotation {
statusBar.isHidden = Application.shouldStatusBarBeHidden
}
statusBar.width = view.width statusBar.width = view.width
statusBar.zPosition = Application.isLandscape && .phone == Device.userInterfaceIdiom ? 0 : 3000 rootViewController.view.frame = view.bounds
rootViewController.view.frame = view.bounds
} }
/** /**
......
...@@ -171,7 +171,7 @@ open class TextField: UITextField { ...@@ -171,7 +171,7 @@ open class TextField: UITextField {
/// The placeholder UILabel. /// The placeholder UILabel.
@IBInspectable @IBInspectable
open private(set) lazy var placeholderLabel = UILabel() open private(set) var placeholderLabel = UILabel()
/// Placeholder normal text /// Placeholder normal text
@IBInspectable @IBInspectable
...@@ -196,7 +196,7 @@ open class TextField: UITextField { ...@@ -196,7 +196,7 @@ open class TextField: UITextField {
/// The detailLabel UILabel that is displayed. /// The detailLabel UILabel that is displayed.
@IBInspectable @IBInspectable
open private(set) lazy var detailLabel = UILabel() open private(set) var detailLabel = UILabel()
/// The detailLabel text value. /// The detailLabel text value.
@IBInspectable @IBInspectable
......
...@@ -138,7 +138,6 @@ open class Toolbar: Bar { ...@@ -138,7 +138,6 @@ open class Toolbar: Bar {
*/ */
open override func prepare() { open override func prepare() {
super.prepare() super.prepare()
zPosition = 1000
contentViewAlignment = .center contentViewAlignment = .center
prepareTitleLabel() prepareTitleLabel()
prepareDetailLabel() prepareDetailLabel()
......
...@@ -81,7 +81,7 @@ open class ToolbarController: StatusBarController { ...@@ -81,7 +81,7 @@ open class ToolbarController: StatusBarController {
} }
/// Reference to the Toolbar. /// Reference to the Toolbar.
open private(set) lazy var toolbar: Toolbar = Toolbar() open private(set) var toolbar = Toolbar()
/// Internal reference to the floatingViewController. /// Internal reference to the floatingViewController.
private var internalFloatingViewController: UIViewController? private var internalFloatingViewController: UIViewController?
...@@ -102,25 +102,31 @@ open class ToolbarController: StatusBarController { ...@@ -102,25 +102,31 @@ open class ToolbarController: StatusBarController {
internalFloatingViewController = nil internalFloatingViewController = nil
UIView.animate(withDuration: 0.5, UIView.animate(withDuration: 0.5,
animations: { [weak self] in animations: { [weak self] in
if let s = self { guard let s = self else {
v.view.center.y = 2 * s.view.bounds.height return
s.toolbar.alpha = 1 }
s.rootViewController.view.alpha = 1
} v.view.center.y = 2 * s.view.bounds.height
s.toolbar.alpha = 1
s.rootViewController.view.alpha = 1
}) { [weak self] _ in }) { [weak self] _ in
if let s = self { guard let s = self else {
v.willMove(toParentViewController: nil) return
v.view.removeFromSuperview() }
v.removeFromParentViewController()
v.view.layer.shouldRasterize = false v.willMove(toParentViewController: nil)
s.isUserInteractionEnabled = true v.view.removeFromSuperview()
s.toolbar.isUserInteractionEnabled = true v.removeFromParentViewController()
DispatchQueue.main.async { [weak self] in v.view.layer.shouldRasterize = false
if let s = self { s.isUserInteractionEnabled = true
s.delegate?.toolbarControllerDidCloseFloatingViewController?(toolbarController: s) s.toolbar.isUserInteractionEnabled = true
} DispatchQueue.main.async { [weak self] in
} guard let s = self else {
} return
}
s.delegate?.toolbarControllerDidCloseFloatingViewController?(toolbarController: s)
}
} }
} }
...@@ -159,9 +165,11 @@ open class ToolbarController: StatusBarController { ...@@ -159,9 +165,11 @@ open class ToolbarController: StatusBarController {
v.view.layer.shouldRasterize = false v.view.layer.shouldRasterize = false
s.view.layer.shouldRasterize = false s.view.layer.shouldRasterize = false
DispatchQueue.main.async { [weak self] in DispatchQueue.main.async { [weak self] in
if let s = self { guard let s = self else {
s.delegate?.toolbarControllerDidOpenFloatingViewController?(toolbarController: s) return
} }
s.delegate?.toolbarControllerDidOpenFloatingViewController?(toolbarController: s)
} }
} }
} }
...@@ -171,9 +179,8 @@ open class ToolbarController: StatusBarController { ...@@ -171,9 +179,8 @@ open class ToolbarController: StatusBarController {
open override func layoutSubviews() { open override func layoutSubviews() {
super.layoutSubviews() super.layoutSubviews()
statusBar.layoutIfNeeded()
let y = 0 == statusBar.zPosition || statusBar.isHidden ? 0 : statusBar.height let y = Application.shouldStatusBarBeHidden || statusBar.isHidden ? 0 : statusBar.height
let p = y + toolbar.height let p = y + toolbar.height
toolbar.y = y toolbar.y = y
...@@ -197,12 +204,20 @@ open class ToolbarController: StatusBarController { ...@@ -197,12 +204,20 @@ open class ToolbarController: StatusBarController {
*/ */
open override func prepare() { open override func prepare() {
super.prepare() super.prepare()
prepareToolbar() prepareStatusBar()
prepareToolbar()
} }
}
/// Prepares the toolbar.
private func prepareToolbar() { extension ToolbarController {
/// Prepares the statusBar.
fileprivate func prepareStatusBar() {
shouldHideStatusBarOnRotation = false
}
/// Prepares the toolbar.
fileprivate func prepareToolbar() {
toolbar.depthPreset = .depth1 toolbar.depthPreset = .depth1
view.addSubview(toolbar) view.addSubview(toolbar)
} }
} }
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