Commit 4fd30c70 by Daniel Dahan

development: divided Device into Application, Device, and Screen to expand their APIs

parent f9d43a00
......@@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
961E6BDF1DDA2A95004E6C93 /* Application.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961E6BDE1DDA2A95004E6C93 /* Application.swift */; };
961E6BE21DDA2AF3004E6C93 /* Screen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961E6BE11DDA2AF3004E6C93 /* Screen.swift */; };
96334EF61C8B84660083986B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96334EF51C8B84660083986B /* Assets.xcassets */; };
963832421B88DFD80015F710 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 963832361B88DFD80015F710 /* Material.framework */; };
965E80C81DD4C50600D61E4B /* Motion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB76D1CB40DC500C806FE /* Motion.swift */; };
......@@ -198,6 +200,8 @@
961276621DCD8B1800A7D920 /* CharacterAttribute.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CharacterAttribute.swift; sourceTree = "<group>"; };
961DED451DCC40C500F425B6 /* Editor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Editor.swift; sourceTree = "<group>"; };
961DED4A1DCC546100F425B6 /* EditorController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EditorController.swift; sourceTree = "<group>"; };
961E6BDE1DDA2A95004E6C93 /* Application.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Application.swift; sourceTree = "<group>"; };
961E6BE11DDA2AF3004E6C93 /* Screen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Screen.swift; sourceTree = "<group>"; };
961EFC571D738FF600E84652 /* SnackbarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SnackbarController.swift; sourceTree = "<group>"; };
961F18E71CD93E3E008927C5 /* ErrorTextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ErrorTextField.swift; sourceTree = "<group>"; };
96230AB71D6A520C00AF47DC /* Divider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Divider.swift; sourceTree = "<group>"; };
......@@ -357,6 +361,22 @@
name = Editor;
sourceTree = "<group>";
};
961E6BDD1DDA2A7E004E6C93 /* Application */ = {
isa = PBXGroup;
children = (
961E6BDE1DDA2A95004E6C93 /* Application.swift */,
);
name = Application;
sourceTree = "<group>";
};
961E6BE01DDA2ADD004E6C93 /* Screen */ = {
isa = PBXGroup;
children = (
961E6BE11DDA2AF3004E6C93 /* Screen.swift */,
);
name = Screen;
sourceTree = "<group>";
};
96230AB61D6A51FD00AF47DC /* Divider */ = {
isa = PBXGroup;
children = (
......@@ -543,7 +563,7 @@
96BCB7571CB40DC500C806FE /* iOS */ = {
isa = PBXGroup;
children = (
96BCB8091CB4107700C806FE /* Motion */,
961E6BDD1DDA2A7E004E6C93 /* Application */,
96264BE41D833C8400576F37 /* Bar */,
962DDD081D6FBBD0001C307C /* BottomTabBar */,
96BCB8031CB40F4B00C806FE /* Button */,
......@@ -562,10 +582,12 @@
96BCB80D1CB410FD00C806FE /* Layer */,
96BCB8041CB40F6C00C806FE /* Layout */,
963FBF021D6696D0008F8512 /* Menu */,
96BCB8091CB4107700C806FE /* Motion */,
96BCB8011CB40F1700C806FE /* Navigation */,
962DDD071D6FBBB7001C307C /* Page */,
96717B151DBE6B1800DA84DB /* Photos */,
9626CA951DAB5370003E2611 /* Root */,
961E6BE01DDA2ADD004E6C93 /* Screen */,
963FBF031D6696EF008F8512 /* SearchBar */,
963FBEFB1D6694E8008F8512 /* Snackbar */,
967A48171D0F424B00B8CEB7 /* StatusBar */,
......@@ -1040,6 +1062,7 @@
965E81231DD4D7C800D61E4B /* BottomTabBar.swift in Sources */,
965E81241DD4D7C800D61E4B /* Editor.swift in Sources */,
965E81251DD4D7C800D61E4B /* EditorController.swift in Sources */,
961E6BE21DDA2AF3004E6C93 /* Screen.swift in Sources */,
965E81261DD4D7C800D61E4B /* CharacterAttribute.swift in Sources */,
965E80FF1DD4D5C800D61E4B /* BottomNavigationController.swift in Sources */,
965E81001DD4D5C800D61E4B /* Capture.swift in Sources */,
......@@ -1107,6 +1130,7 @@
965E80D41DD4C50600D61E4B /* Divider.swift in Sources */,
965E80D51DD4C50600D61E4B /* Grid.swift in Sources */,
965E80D61DD4C50600D61E4B /* HeightPreset.swift in Sources */,
961E6BDF1DDA2A95004E6C93 /* Application.swift in Sources */,
965E80D71DD4C50600D61E4B /* Icon.swift in Sources */,
965E80FC1DD4D59500D61E4B /* SearchBarController.swift in Sources */,
965E80D81DD4C50600D61E4B /* Layer.swift in Sources */,
......
/*
* 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
public struct Application {
/// A Boolean indicating if the device is in Landscape mode.
public static var isLandscape: Bool {
return UIApplication.shared.statusBarOrientation.isLandscape
}
/// A Boolean indicating if the device is in Portrait mode.
public static var isPortrait: Bool {
return !isLandscape
}
/// The current UIInterfaceOrientation value.
public static var orientation: UIInterfaceOrientation {
return UIApplication.shared.statusBarOrientation
}
/// Retrieves the device status bar style.
public static var statusBarStyle: UIStatusBarStyle {
get {
return UIApplication.shared.statusBarStyle
}
set(value) {
UIApplication.shared.statusBarStyle = value
}
}
/// Retrieves the device status bar hidden state.
public static var isStatusBarHidden: Bool {
get {
return UIApplication.shared.isStatusBarHidden
}
set(value) {
UIApplication.shared.isStatusBarHidden = value
}
}
}
......@@ -140,7 +140,7 @@ open class BottomNavigationController: UITabBarController, UITabBarControllerDel
*/
open func prepare() {
view.clipsToBounds = true
view.contentScaleFactor = Device.scale
view.contentScaleFactor = Screen.scale
view.backgroundColor = Color.white
delegate = self
prepareTabBar()
......
......@@ -127,7 +127,7 @@ open class BottomTabBar: UITabBar {
heightPreset = .normal
depthPreset = .depth1
dividerAlignment = .top
contentScaleFactor = Device.scale
contentScaleFactor = Screen.scale
backgroundColor = .white
let image = UIImage.image(with: .clear, size: CGSize(width: 1, height: 1))
shadowImage = image
......
......@@ -240,7 +240,7 @@ open class Button: UIButton, Pulseable {
when subclassing.
*/
open func prepare() {
contentScaleFactor = Device.scale
contentScaleFactor = Screen.scale
prepareVisualLayer()
preparePulse()
}
......
......@@ -118,7 +118,7 @@ open class CollectionReusableView: UICollectionReusableView, Pulseable {
/**
A floating point value that defines a ratio between the pixel
dimensions of the visualLayer's contents property and the size
of the view. By default, this value is set to the Device.scale.
of the view. By default, this value is set to the Screen.scale.
*/
@IBInspectable open var contentsScale: CGFloat {
get {
......@@ -286,7 +286,7 @@ open class CollectionReusableView: UICollectionReusableView, Pulseable {
when subclassing.
*/
open func prepare() {
contentScaleFactor = Device.scale
contentScaleFactor = Screen.scale
pulseAnimation = .none
prepareVisualLayer()
preparePulse()
......
......@@ -119,7 +119,7 @@ open class CollectionView: UICollectionView {
when subclassing.
*/
open func prepare() {
contentScaleFactor = Device.scale
contentScaleFactor = Screen.scale
backgroundColor = .clear
contentEdgeInsets = .zero
}
......
......@@ -120,7 +120,7 @@ open class CollectionViewCell: UICollectionViewCell, Pulseable {
/**
A floating point value that defines a ratio between the pixel
dimensions of the visualLayer's contents property and the size
of the view. By default, this value is set to the Device.scale.
of the view. By default, this value is set to the Screen.scale.
*/
@IBInspectable
open var contentsScale: CGFloat {
......@@ -293,7 +293,7 @@ open class CollectionViewCell: UICollectionViewCell, Pulseable {
when subclassing.
*/
open func prepare() {
contentScaleFactor = Device.scale
contentScaleFactor = Screen.scale
prepareVisualLayer()
preparePulse()
}
......
......@@ -107,59 +107,4 @@ public struct Device {
public static var userInterfaceIdiom: UIUserInterfaceIdiom {
return UIDevice.current.userInterfaceIdiom
}
/// A Boolean indicating if the device is in Landscape mode.
public static var isLandscape: Bool {
return UIApplication.shared.statusBarOrientation.isLandscape
}
/// A Boolean indicating if the device is in Portrait mode.
public static var isPortrait: Bool {
return !isLandscape
}
/// The current UIInterfaceOrientation value.
public static var orientation: UIInterfaceOrientation {
return UIApplication.shared.statusBarOrientation
}
/// Retrieves the device status bar style.
public static var statusBarStyle: UIStatusBarStyle {
get {
return UIApplication.shared.statusBarStyle
}
set(value) {
UIApplication.shared.statusBarStyle = value
}
}
/// Retrieves the device status bar hidden state.
public static var isStatusBarHidden: Bool {
get {
return UIApplication.shared.isStatusBarHidden
}
set(value) {
UIApplication.shared.isStatusBarHidden = value
}
}
/// Retrieves the device bounds.
public static var bounds: CGRect {
return UIScreen.main.bounds
}
/// Retrieves the device width.
public static var width: CGFloat {
return bounds.width
}
/// Retrieves the device height.
public static var height: CGFloat {
return bounds.height
}
/// Retrieves the device scale.
public static var scale: CGFloat {
return UIScreen.main.scale
}
}
......@@ -77,7 +77,7 @@ open class Layer: CAShapeLayer {
/**
A floating point value that defines a ratio between the pixel
dimensions of the visualLayer's contents property and the size
of the layer. By default, this value is set to the Device.scale.
of the layer. By default, this value is set to the Screen.scale.
*/
@IBInspectable
open override var contentsScale: CGFloat {
......
......@@ -86,7 +86,7 @@ extension UIImage {
let g: UIImage?
let t: CGRect = CGRect(x: 0, y: 0, width: w ?? tw, height: h ?? th)
UIGraphicsBeginImageContextWithOptions(t.size, false, Device.scale)
UIGraphicsBeginImageContextWithOptions(t.size, false, Screen.scale)
draw(in: t, blendMode: .normal, alpha: 1)
g = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
......@@ -102,7 +102,7 @@ extension UIImage {
- Returns: A UIImage that is the color passed in.
*/
open func tint(with color: UIColor) -> UIImage? {
UIGraphicsBeginImageContextWithOptions(size, false, Device.scale)
UIGraphicsBeginImageContextWithOptions(size, false, Screen.scale)
guard let context = UIGraphicsGetCurrentContext() else {
return nil
}
......@@ -284,7 +284,7 @@ extension UIImage {
open func blur(radius: CGFloat = 0, tintColor: UIColor? = nil, saturationDeltaFactor: CGFloat = 0) -> UIImage? {
var effectImage = self
let screenScale = Device.scale
let screenScale = Screen.scale
let imageRect = CGRect(origin: .zero, size: size)
let hasBlur = radius > CGFloat(FLT_EPSILON)
let hasSaturationChange = fabs(saturationDeltaFactor - 1.0) > CGFloat(FLT_EPSILON)
......
......@@ -36,7 +36,7 @@ extension UIWindow {
- Returns: An optional UIImage.
*/
open func capture() -> UIImage? {
UIGraphicsBeginImageContextWithOptions(frame.size, isOpaque, Device.scale)
UIGraphicsBeginImageContextWithOptions(frame.size, isOpaque, Screen.scale)
layer.render(in: UIGraphicsGetCurrentContext()!)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
......
......@@ -37,7 +37,7 @@ open class NavigationBar: UINavigationBar {
}
open override var intrinsicContentSize: CGSize {
return CGSize(width: Device.width, height: height)
return CGSize(width: Screen.width, height: height)
}
/// A preset wrapper around contentEdgeInsets.
......@@ -295,7 +295,7 @@ open class NavigationBar: UINavigationBar {
depthPreset = .depth1
interimSpacePreset = .interimSpace3
contentEdgeInsetsPreset = .square1
contentScaleFactor = Device.scale
contentScaleFactor = Screen.scale
backButtonImage = Icon.cm.arrowBack
let image = UIImage.image(with: .clear, size: CGSize(width: 1, height: 1))
shadowImage = image
......
......@@ -34,10 +34,10 @@ extension UINavigationController {
/// Device status bar style.
open var statusBarStyle: UIStatusBarStyle {
get {
return Device.statusBarStyle
return Application.statusBarStyle
}
set(value) {
Device.statusBarStyle = value
Application.statusBarStyle = value
}
}
}
......@@ -118,7 +118,7 @@ open class NavigationController: UINavigationController {
view.clipsToBounds = true
view.backgroundColor = .white
view.contentScaleFactor = Device.scale
view.contentScaleFactor = Screen.scale
// This ensures the panning gesture is available when going back between views.
if let v = interactivePopGestureRecognizer {
......
......@@ -345,7 +345,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
guard nil != rightView else {
return false
}
return rightView!.x != Device.width
return rightView!.x != Screen.width
}
/**
......@@ -1197,7 +1197,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
/// Toggles the statusBar
private func toggleStatusBar() {
if isOpened || Device.isLandscape && .phone == Device.userInterfaceIdiom {
if isOpened || Application.isLandscape && .phone == Device.userInterfaceIdiom {
hideStatusBar()
} else {
showStatusBar()
......
......@@ -115,7 +115,7 @@ public class NavigationItem: NSObject {
/// Prepares the titleLabel.
private func prepareTitleLabel() {
titleLabel.textAlignment = .center
titleLabel.contentScaleFactor = Device.scale
titleLabel.contentScaleFactor = Screen.scale
titleLabel.font = RobotoFont.medium(with: 17)
titleLabel.textColor = Color.darkText.primary
addObserver(self, forKeyPath: "titleLabel.textAlignment", options: [], context: &NavigationItemContext)
......@@ -124,7 +124,7 @@ public class NavigationItem: NSObject {
/// Prepares the detailLabel.
private func prepareDetailLabel() {
detailLabel.textAlignment = .center
titleLabel.contentScaleFactor = Device.scale
titleLabel.contentScaleFactor = Screen.scale
detailLabel.font = RobotoFont.regular(with: 12)
detailLabel.textColor = Color.darkText.secondary
}
......
......@@ -67,7 +67,7 @@ open class PhotoLibraryController: UIViewController {
open func prepare() {
view.clipsToBounds = true
view.backgroundColor = .white
view.contentScaleFactor = Device.scale
view.contentScaleFactor = Screen.scale
preparePhotoLibrary()
}
......
......@@ -34,20 +34,20 @@ open class RootController: UIViewController {
/// Device status bar style.
open var statusBarStyle: UIStatusBarStyle {
get {
return Device.statusBarStyle
return Application.statusBarStyle
}
set(value) {
Device.statusBarStyle = value
Application.statusBarStyle = value
}
}
/// Device visibility state.
open var isStatusBarHidden: Bool {
get {
return Device.isStatusBarHidden
return Application.isStatusBarHidden
}
set(value) {
Device.isStatusBarHidden = value
Application.isStatusBarHidden = value
}
}
......@@ -141,7 +141,7 @@ open class RootController: UIViewController {
s.rootViewController = viewController
s.rootViewController.view.clipsToBounds = true
s.rootViewController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
s.rootViewController.view.contentScaleFactor = Device.scale
s.rootViewController.view.contentScaleFactor = Screen.scale
s.view.sendSubview(toBack: s.rootViewController.view)
completion?(result)
}
......@@ -164,7 +164,7 @@ open class RootController: UIViewController {
open func prepare() {
view.clipsToBounds = true
view.backgroundColor = .white
view.contentScaleFactor = Device.scale
view.contentScaleFactor = Screen.scale
prepareRootViewController()
}
......@@ -191,6 +191,6 @@ open class RootController: UIViewController {
v.didMove(toParentViewController: self)
v.view.clipsToBounds = true
v.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
v.view.contentScaleFactor = Device.scale
v.view.contentScaleFactor = Screen.scale
}
}
/*
* 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
public struct Screen {
/// Retrieves the device bounds.
public static var bounds: CGRect {
return UIScreen.main.bounds
}
/// Retrieves the device width.
public static var width: CGFloat {
return bounds.width
}
/// Retrieves the device height.
public static var height: CGFloat {
return bounds.height
}
/// Retrieves the device scale.
public static var scale: CGFloat {
return UIScreen.main.scale
}
}
......@@ -194,7 +194,7 @@ open class SearchBar: Bar {
/// Prepares the textField.
private func prepareTextField() {
textField.contentScaleFactor = Device.scale
textField.contentScaleFactor = Screen.scale
textField.font = RobotoFont.regular(with: 17)
textField.backgroundColor = Color.clear
textField.clearButtonMode = .whileEditing
......
......@@ -104,7 +104,7 @@ open class Snackbar: Bar {
/// Prepares the textLabel.
private func prepareTextLabel() {
textLabel.contentScaleFactor = Device.scale
textLabel.contentScaleFactor = Screen.scale
textLabel.font = RobotoFont.medium(with: 14)
textLabel.textAlignment = .left
textLabel.textColor = Color.white
......
......@@ -66,7 +66,7 @@ open class StatusBarController: RootController {
open override func layoutSubviews() {
super.layoutSubviews()
statusBar.width = view.width
statusBar.zPosition = Device.isLandscape && .phone == Device.userInterfaceIdiom ? 0 : 3000
statusBar.zPosition = Application.isLandscape && .phone == Device.userInterfaceIdiom ? 0 : 3000
rootViewController.view.frame = view.bounds
}
......
......@@ -419,7 +419,7 @@ open class Switch: UIControl {
when subclassing.
*/
open func prepare() {
contentScaleFactor = Device.scale
contentScaleFactor = Screen.scale
prepareTrack()
prepareButton()
prepareSwitchState()
......
......@@ -172,7 +172,7 @@ open class TableViewCell: UITableViewCell, Pulseable {
open func prepare() {
selectionStyle = .none
separatorInset = .zero
contentScaleFactor = Device.scale
contentScaleFactor = Screen.scale
imageView?.isUserInteractionEnabled = false
textLabel?.isUserInteractionEnabled = false
detailTextLabel?.isUserInteractionEnabled = false
......
......@@ -395,7 +395,7 @@ open class TextField: UITextField {
clipsToBounds = false
borderStyle = .none
backgroundColor = nil
contentScaleFactor = Device.scale
contentScaleFactor = Screen.scale
prepareDivider()
preparePlaceholderLabel()
......
......@@ -223,7 +223,7 @@ open class TextView: UITextView {
when subclassing.
*/
open func prepare() {
contentScaleFactor = Device.scale
contentScaleFactor = Screen.scale
textContainerInset = .zero
backgroundColor = .white
clipsToBounds = false
......
......@@ -147,7 +147,7 @@ open class Toolbar: Bar {
/// Prepares the titleLabel.
private func prepareTitleLabel() {
titleLabel.textAlignment = .center
titleLabel.contentScaleFactor = Device.scale
titleLabel.contentScaleFactor = Screen.scale
titleLabel.font = RobotoFont.medium(with: 17)
titleLabel.textColor = Color.darkText.primary
addObserver(self, forKeyPath: "titleLabel.textAlignment", options: [], context: &ToolbarContext)
......@@ -156,7 +156,7 @@ open class Toolbar: Bar {
/// Prepares the detailLabel.
private func prepareDetailLabel() {
detailLabel.textAlignment = .center
detailLabel.contentScaleFactor = Device.scale
detailLabel.contentScaleFactor = Screen.scale
detailLabel.font = RobotoFont.regular(with: 12)
detailLabel.textColor = Color.darkText.secondary
}
......
......@@ -96,7 +96,7 @@ open class ToolbarController: StatusBarController {
}
set(value) {
if let v = internalFloatingViewController {
v.view.layer.rasterizationScale = Device.scale
v.view.layer.rasterizationScale = Screen.scale
v.view.layer.shouldRasterize = true
delegate?.toolbarControllerWillCloseFloatingViewController?(toolbarController: self)
internalFloatingViewController = nil
......@@ -134,9 +134,9 @@ open class ToolbarController: StatusBarController {
v.view.layer.zPosition = 1500
v.didMove(toParentViewController: self)
v.view.isHidden = false
v.view.layer.rasterizationScale = Device.scale
v.view.layer.rasterizationScale = Screen.scale
v.view.layer.shouldRasterize = true
view.layer.rasterizationScale = Device.scale
view.layer.rasterizationScale = Screen.scale
view.layer.shouldRasterize = true
internalFloatingViewController = v
isUserInteractionEnabled = false
......
......@@ -91,7 +91,7 @@ open class View: UIView {
/**
A floating point value that defines a ratio between the pixel
dimensions of the visualLayer's contents property and the size
of the view. By default, this value is set to the Device.scale.
of the view. By default, this value is set to the Screen.scale.
*/
@IBInspectable
open var contentsScale: CGFloat {
......@@ -175,7 +175,7 @@ open class View: UIView {
when subclassing.
*/
open func prepare() {
contentScaleFactor = Device.scale
contentScaleFactor = Screen.scale
backgroundColor = .white
prepareVisualLayer()
}
......
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