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