Commit 6d0fde91 by whitepixelstudios Committed by GitHub

Merge pull request #1 from CosmicMind/master

Update to match CosmicMind version
parents 461dcd69 6bfd58cf
Pod::Spec.new do |s|
s.name = 'Material'
s.version = '2.5.2'
s.version = '2.6.3'
s.license = 'BSD-3-Clause'
s.summary = 'An animation and graphics framework for Material Design in Swift.'
s.homepage = 'http://materialswift.com'
......
......@@ -18,8 +18,6 @@
9617B0811DFCA8CF00410F8F /* Capture.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96717B0D1DBE6AF600DA84DB /* Capture.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0821DFCA8CF00410F8F /* CapturePreview.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96717B0F1DBE6AF600DA84DB /* CapturePreview.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0831DFCA8CF00410F8F /* CaptureController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96717B0E1DBE6AF600DA84DB /* CaptureController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0841DFCA8CF00410F8F /* Editor.swift in Headers */ = {isa = PBXBuildFile; fileRef = 961DED451DCC40C500F425B6 /* Editor.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0851DFCA8CF00410F8F /* EditorController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 961DED4A1DCC546100F425B6 /* EditorController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0861DFCA8CF00410F8F /* HeightPreset.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9626CB9A1DAD3D1D003E2611 /* HeightPreset.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0871DFCA8CF00410F8F /* PageTabBarController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 963FBF071D669D14008F8512 /* PageTabBarController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0881DFCA8CF00410F8F /* PhotoLibrary.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96717B161DBE6B1800DA84DB /* PhotoLibrary.swift */; settings = {ATTRIBUTES = (Public, ); }; };
......@@ -117,8 +115,6 @@
965E81211DD4D5C800D61E4B /* TextStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB79D1CB40DC500C806FE /* TextStorage.swift */; };
965E81221DD4D5C800D61E4B /* TextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB79E1CB40DC500C806FE /* TextView.swift */; };
965E81231DD4D7C800D61E4B /* BottomTabBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7591CB40DC500C806FE /* BottomTabBar.swift */; };
965E81241DD4D7C800D61E4B /* Editor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961DED451DCC40C500F425B6 /* Editor.swift */; };
965E81251DD4D7C800D61E4B /* EditorController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961DED4A1DCC546100F425B6 /* EditorController.swift */; };
965E81261DD4D7C800D61E4B /* CharacterAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961276621DCD8B1800A7D920 /* CharacterAttribute.swift */; };
9697F7BF1D8F2572004741EC /* Divider.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96230AB71D6A520C00AF47DC /* Divider.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9697F7C01D8F2572004741EC /* Material+CALayer.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96F1DC871D654FDF0025F925 /* Material+CALayer.swift */; settings = {ATTRIBUTES = (Public, ); }; };
......@@ -195,8 +191,6 @@
/* Begin PBXFileReference section */
961276621DCD8B1800A7D920 /* CharacterAttribute.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CharacterAttribute.swift; sourceTree = "<group>"; };
961730591E145DE900A9A297 /* CollectionViewCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionViewCard.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>"; };
......@@ -311,15 +305,6 @@
name = TextField;
sourceTree = "<group>";
};
961DED441DCC40AC00F425B6 /* Editor */ = {
isa = PBXGroup;
children = (
961DED451DCC40C500F425B6 /* Editor.swift */,
961DED4A1DCC546100F425B6 /* EditorController.swift */,
);
name = Editor;
sourceTree = "<group>";
};
961E6BDD1DDA2A7E004E6C93 /* Application */ = {
isa = PBXGroup;
children = (
......@@ -377,12 +362,12 @@
name = Height;
sourceTree = "<group>";
};
962DDD071D6FBBB7001C307C /* Page */ = {
962DDD071D6FBBB7001C307C /* PageTabBar */ = {
isa = PBXGroup;
children = (
963FBF071D669D14008F8512 /* PageTabBarController.swift */,
);
name = Page;
name = PageTabBar;
sourceTree = "<group>";
};
962DDD081D6FBBD0001C307C /* BottomTabBar */ = {
......@@ -519,6 +504,7 @@
96BCB7571CB40DC500C806FE /* iOS */ = {
isa = PBXGroup;
children = (
96EF418E1E835E850012CA1C /* Animation */,
961E6BDD1DDA2A7E004E6C93 /* Application */,
96264BE41D833C8400576F37 /* Bar */,
962DDD081D6FBBD0001C307C /* BottomTabBar */,
......@@ -530,7 +516,6 @@
96328B9A1E05C135009A4C90 /* Data */,
96BCB80B1CB410CC00C806FE /* Device */,
96230AB61D6A51FD00AF47DC /* Divider */,
961DED441DCC40AC00F425B6 /* Editor */,
96BCB80A1CB410A100C806FE /* Extension */,
96BCB8071CB4101C00C806FE /* Font */,
9602F00C1DA1163000F3FB79 /* Grid */,
......@@ -542,7 +527,7 @@
96BCB8091CB4107700C806FE /* Motion */,
96BCB8011CB40F1700C806FE /* Navigation */,
961E6BEF1DDA4B04004E6C93 /* NavigationDrawer */,
962DDD071D6FBBB7001C307C /* Page */,
962DDD071D6FBBB7001C307C /* PageTabBar */,
96717B151DBE6B1800DA84DB /* Photos */,
96328B8F1E05B69A009A4C90 /* Reminders */,
9626CA951DAB5370003E2611 /* Root */,
......@@ -681,8 +666,6 @@
children = (
96BFC1671E61D9FD0075DE1F /* Material+Motion.swift */,
96BFC1691E61DAA10075DE1F /* Material+MotionAnimation.swift */,
96BCB7821CB40DC500C806FE /* PulseAnimation.swift */,
965532281E47E388005C2792 /* SpringAnimation.swift */,
);
name = Motion;
sourceTree = "<group>";
......@@ -750,6 +733,15 @@
path = Sources;
sourceTree = "<group>";
};
96EF418E1E835E850012CA1C /* Animation */ = {
isa = PBXGroup;
children = (
96BCB7821CB40DC500C806FE /* PulseAnimation.swift */,
965532281E47E388005C2792 /* SpringAnimation.swift */,
);
name = Animation;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
......@@ -821,8 +813,6 @@
9617B0811DFCA8CF00410F8F /* Capture.swift in Headers */,
9617B0821DFCA8CF00410F8F /* CapturePreview.swift in Headers */,
9617B0831DFCA8CF00410F8F /* CaptureController.swift in Headers */,
9617B0841DFCA8CF00410F8F /* Editor.swift in Headers */,
9617B0851DFCA8CF00410F8F /* EditorController.swift in Headers */,
9617B0861DFCA8CF00410F8F /* HeightPreset.swift in Headers */,
9617B0871DFCA8CF00410F8F /* PageTabBarController.swift in Headers */,
9617B0881DFCA8CF00410F8F /* PhotoLibrary.swift in Headers */,
......@@ -928,8 +918,6 @@
buildActionMask = 2147483647;
files = (
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 */,
......
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
......
......@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.5.2</string>
<string>2.6.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
......
......@@ -137,7 +137,6 @@ open class Button: UIButton, Pulseable, PulseableLayer {
*/
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
tintColor = Color.blue.base
prepare()
}
......
......@@ -198,7 +198,7 @@ open class Card: PulseView {
}
container.height = h
height = h
bounds.size.height = h
}
/**
......
......@@ -117,7 +117,7 @@ extension NSMutableAttributedString {
- Parameter characterAttributes: A Dictionary of CharacterAttribute type keys and Any type values.
- Parameter range: A NSRange.
*/
open func addAttributes(characterAttributes: [CharacterAttribute : Any] = [:], range: NSRange) {
open func addAttributes(characterAttributes: [CharacterAttribute: Any], range: NSRange) {
for (k, v) in characterAttributes {
addAttribute(characterAttribute: k, value: v, range: range)
}
......@@ -139,7 +139,7 @@ extension NSMutableAttributedString {
- Parameter characterAttributes: A Dictionary of CharacterAttribute type keys and Any type values.
- Parameter range: A NSRange.
*/
open func updateAttributes(characterAttributes: [CharacterAttribute : Any] = [:], range: NSRange) {
open func updateAttributes(characterAttributes: [CharacterAttribute: Any], range: NSRange) {
for (k, v) in characterAttributes {
updateAttribute(characterAttribute: k, value: v, range: range)
}
......@@ -159,7 +159,7 @@ extension NSMutableAttributedString {
- Parameter characterAttributes: An Array of CharacterAttributes.
- Parameter range: A NSRange.
*/
open func removeAttributes(characterAttributes: [CharacterAttribute] = [], range: NSRange) {
open func removeAttributes(characterAttributes: [CharacterAttribute], range: NSRange) {
for k in characterAttributes {
removeAttribute(characterAttribute: k, range: range)
}
......
/*
* Copyright (C) 2015 - 2017, 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
import AVFoundation
extension UIViewController {
/**
A convenience property that provides access to the EditorController.
This is the recommended method of accessing the EditorController
through child UIViewControllers.
*/
public var editorController: EditorController? {
var viewController: UIViewController? = self
while nil != viewController {
if viewController is EditorController {
return viewController as? EditorController
}
viewController = viewController?.parent
}
return nil
}
}
open class EditorController: ToolbarController {
/// A reference to the Editor instance.
@IBInspectable
open let editor = Editor()
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
open override func prepare() {
super.prepare()
view.backgroundColor = .white
prepareToolbar()
prepareEditor()
}
/// Prepares the toolbar.
private func prepareToolbar() {
toolbar.depthPreset = .none
}
/// Prepares editor.
private func prepareEditor() {
editor.delegate = self
}
}
extension EditorController: EditorDelegate {}
......@@ -97,7 +97,7 @@ private class FontLoader {
if !CTFontManagerRegisterGraphicsFont(font, &error) {
let errorDescription = CFErrorCopyDescription(error!.takeUnretainedValue())
let nsError = error!.takeUnretainedValue() as Any as! Error
NSException(name: .internalInconsistencyException, reason: errorDescription as? String, userInfo: [NSUnderlyingErrorKey: nsError as Any]).raise()
NSException(name: .internalInconsistencyException, reason: errorDescription as String?, userInfo: [NSUnderlyingErrorKey: nsError as Any]).raise()
}
}
}
......
......@@ -105,6 +105,6 @@ open class ImageCard: Card {
}
container.height = h
height = h
bounds.size.height = h
}
}
......@@ -44,7 +44,7 @@ extension Array where Element: Equatable {
}
guard -1 < start else {
fatalError("Range out of bounds for \(start) - \(end), should be 0 - \(count).")
fatalError("Range out of bounds for \(start) - \(end ?? 0), should be 0 - \(count).")
}
var diff = abs(e - start)
......
......@@ -374,10 +374,10 @@ extension UIView {
/// Computes the rotation of the view.
open var motionRotationAngle: CGFloat {
get {
return CGFloat(atan2f(Float(transform.b), Float(transform.a))) * 180 / CGFloat(M_PI)
return CGFloat(atan2f(Float(transform.b), Float(transform.a))) * 180 / CGFloat(Double.pi)
}
set(value) {
transform = CGAffineTransform(rotationAngle: CGFloat(M_PI) * value / 180)
transform = CGAffineTransform(rotationAngle: CGFloat(Double.pi) * value / 180)
}
}
......@@ -506,7 +506,7 @@ extension Motion {
*/
public static func rotation(angle: CGFloat) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .rotation)
animation.toValue = NSNumber(value: Double(CGFloat(M_PI) * angle / 180))
animation.toValue = NSNumber(value: Double(CGFloat(Double.pi) * angle / 180))
return animation
}
......@@ -517,7 +517,7 @@ extension Motion {
*/
public static func rotationX(angle: CGFloat) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .rotationX)
animation.toValue = NSNumber(value: Double(CGFloat(M_PI) * angle / 180))
animation.toValue = NSNumber(value: Double(CGFloat(Double.pi) * angle / 180))
return animation
}
......@@ -528,7 +528,7 @@ extension Motion {
*/
public static func rotationY(angle: CGFloat) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .rotationY)
animation.toValue = NSNumber(value: Double(CGFloat(M_PI) * angle / 180))
animation.toValue = NSNumber(value: Double(CGFloat(Double.pi) * angle / 180))
return animation
}
......@@ -539,7 +539,7 @@ extension Motion {
*/
public static func rotationZ(angle: CGFloat) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .rotationZ)
animation.toValue = NSNumber(value: Double(CGFloat(M_PI) * angle / 180))
animation.toValue = NSNumber(value: Double(CGFloat(Double.pi) * angle / 180))
return animation
}
......@@ -550,7 +550,7 @@ extension Motion {
*/
public static func spin(rotations: CGFloat) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .rotation)
animation.toValue = NSNumber(value: Double(CGFloat(M_PI) * 2 * rotations))
animation.toValue = NSNumber(value: Double(CGFloat(Double.pi) * 2 * rotations))
return animation
}
......@@ -561,7 +561,7 @@ extension Motion {
*/
public static func spinX(rotations: CGFloat) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .rotationX)
animation.toValue = NSNumber(value: Double(CGFloat(M_PI) * 2 * rotations))
animation.toValue = NSNumber(value: Double(CGFloat(Double.pi) * 2 * rotations))
return animation
}
......@@ -572,7 +572,7 @@ extension Motion {
*/
public static func spinY(rotations: CGFloat) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .rotationY)
animation.toValue = NSNumber(value: Double(CGFloat(M_PI) * 2 * rotations))
animation.toValue = NSNumber(value: Double(CGFloat(Double.pi) * 2 * rotations))
return animation
}
......@@ -583,7 +583,7 @@ extension Motion {
*/
public static func spinZ(rotations: CGFloat) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .rotationZ)
animation.toValue = NSNumber(value: Double(CGFloat(M_PI) * 2 * rotations))
animation.toValue = NSNumber(value: Double(CGFloat(Double.pi) * 2 * rotations))
return animation
}
......
......@@ -39,7 +39,7 @@ extension UIFont {
- Returns a CGSize.
*/
open func stringSize(string: String, constrainedTo width: CGFloat) -> CGSize {
return string.boundingRect(with: CGSize(width: width, height: CGFloat(DBL_MAX)),
return string.boundingRect(with: CGSize(width: width, height: CGFloat(Double.greatestFiniteMagnitude)),
options: NSStringDrawingOptions.usesLineFragmentOrigin,
attributes: [NSFontAttributeName: self],
context: nil).size
......
......@@ -227,13 +227,13 @@ extension UIImage {
switch imageOrientation {
case .down, .downMirrored:
transform = transform.translatedBy(x: size.width, y: size.height)
transform = transform.rotated(by: CGFloat(M_PI))
transform = transform.rotated(by: CGFloat(Double.pi))
case .left, .leftMirrored:
transform = transform.translatedBy(x: size.width, y: 0)
transform = transform.rotated(by: CGFloat(M_PI_2))
transform = transform.rotated(by: CGFloat(Double.pi / 2))
case .right, .rightMirrored:
transform = transform.translatedBy(x: 0, y: size.height)
transform = transform.rotated(by: -CGFloat(M_PI_2))
transform = transform.rotated(by: -CGFloat(Double.pi / 2))
default:break
}
......@@ -296,8 +296,8 @@ extension UIImage {
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)
let hasBlur = radius > CGFloat(Float.ulpOfOne)
let hasSaturationChange = fabs(saturationDeltaFactor - 1.0) > CGFloat(Float.ulpOfOne)
if hasBlur || hasSaturationChange {
UIGraphicsBeginImageContextWithOptions(size, false, screenScale)
......@@ -315,7 +315,7 @@ extension UIImage {
var outBuffer = createEffectBuffer(context: outContext)
if hasBlur {
let a = sqrt(2 * M_PI)
let a = sqrt(2 * .pi)
let b = CGFloat(a) / 4
let c = radius * screenScale
let d = c * 3.0 * b
......
......@@ -113,8 +113,18 @@ open class PageTabBarController: RootController {
/// Indicates that the tab has been pressed and animating.
open internal(set) var isTabSelectedAnimation = false
/// An internal reference to the selectedIndex.
fileprivate var internalSelectedIndex = 0
/// The currently selected UIViewController.
open internal(set) var selectedIndex = 0
open var selectedIndex: Int {
get {
return internalSelectedIndex
}
set(value) {
setInternalSelectedIndex(index: value, animated: true)
}
}
/// PageTabBar alignment setting.
open var pageTabBarAlignment = PageTabBarAlignment.bottom
......@@ -155,16 +165,15 @@ open class PageTabBarController: RootController {
isBounceEnabled = true
super.init(rootViewController: UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil))
viewControllers.append(rootViewController)
setViewControllers(viewControllers, direction: .forward, animated: true)
setInternalSelectedIndex(index: 0, animated: true)
prepare()
}
public init(viewControllers: [UIViewController], selectedIndex: Int = 0) {
public init(viewControllers: [UIViewController], selectedIndex index: Int = 0) {
isBounceEnabled = true
super.init(rootViewController: UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil))
self.selectedIndex = selectedIndex
self.viewControllers.append(contentsOf: viewControllers)
setViewControllers([self.viewControllers[selectedIndex]], direction: .forward, animated: true)
setInternalSelectedIndex(index: index, animated: true)
prepare()
}
......@@ -198,7 +207,6 @@ open class PageTabBarController: RootController {
*/
open func setViewControllers(_ viewControllers: [UIViewController], direction: UIPageViewControllerNavigationDirection, animated: Bool, completion: ((Bool) -> Void)? = nil) {
pageViewController?.setViewControllers(viewControllers, direction: direction, animated: animated, completion: completion)
prepare()
}
/**
......@@ -240,44 +248,65 @@ open class PageTabBarController: RootController {
button.addTarget(self, action: #selector(handlePageTabBarButton(button:)), for: .touchUpInside)
}
}
}
extension PageTabBarController {
/// Prepares the pageTabBar.
fileprivate func preparePageTabBar() {
pageTabBar.zPosition = 1000
pageTabBar.dividerColor = Color.grey.lighten3
view.addSubview(pageTabBar)
pageTabBar.select(at: internalSelectedIndex)
}
}
extension PageTabBarController {
/**
Handles the pageTabBarButton.
- Parameter button: A UIButton.
*/
@objc
internal func handlePageTabBarButton(button: UIButton) {
fileprivate func handlePageTabBarButton(button: UIButton) {
guard let index = pageTabBar.buttons.index(of: button) else {
return
}
guard index != selectedIndex else {
guard index != internalSelectedIndex else {
return
}
let direction: UIPageViewControllerNavigationDirection = index < selectedIndex ? .reverse : .forward
setInternalSelectedIndex(index: index, animated: true)
}
}
extension PageTabBarController {
/**
Internally sets the internalSelectedIndex value.
- Parameter index: Int.
- Parameter animated: Bool.
*/
fileprivate func setInternalSelectedIndex(index: Int, animated: Bool = false) {
guard animated else {
internalSelectedIndex = index
return
}
let direction: UIPageViewControllerNavigationDirection = index < internalSelectedIndex ? .reverse : .forward
isTabSelectedAnimation = true
selectedIndex = index
pageTabBar.select(at: selectedIndex)
internalSelectedIndex = index
setViewControllers([viewControllers[index]], direction: direction, animated: true) { [weak self] _ in
pageTabBar.select(at: internalSelectedIndex)
setViewControllers([viewControllers[internalSelectedIndex]], direction: direction, animated: true) { [weak self] _ in
guard let s = self else {
return
}
s.isTabSelectedAnimation = false
s.delegate?.pageTabBarController?(pageTabBarController: s, didTransitionTo: s.viewControllers[s.selectedIndex])
s.delegate?.pageTabBarController?(pageTabBarController: s, didTransitionTo: s.viewControllers[s.internalSelectedIndex])
}
}
/// Prepares the pageTabBar.
private func preparePageTabBar() {
pageTabBar.zPosition = 1000
pageTabBar.dividerColor = Color.grey.lighten3
view.addSubview(pageTabBar)
pageTabBar.select(at: selectedIndex)
}
}
extension PageTabBarController: UIPageViewControllerDelegate {
......@@ -290,8 +319,9 @@ extension PageTabBarController: UIPageViewControllerDelegate {
return
}
selectedIndex = index
pageTabBar.select(at: selectedIndex)
setInternalSelectedIndex(index: index)
pageTabBar.select(at: index)
if finished && completed {
delegate?.pageTabBarController?(pageTabBarController: self, didTransitionTo: v)
......
......@@ -79,6 +79,6 @@ open class PresenterCard: Card {
}
container.height = h
height = h
bounds.size.height = h
}
}
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.com>.
* Copyright (C) 2015 - 2017, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.com>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
......
......@@ -382,7 +382,8 @@ open class TextField: UITextField {
}
open override func becomeFirstResponder() -> Bool {
layoutSubviews()
setNeedsLayout()
layoutIfNeeded()
return super.becomeFirstResponder()
}
......@@ -398,6 +399,8 @@ open class TextField: UITextField {
borderStyle = .none
backgroundColor = nil
contentScaleFactor = Screen.scale
font = RobotoFont.regular(with: 16)
textColor = Color.darkText.primary
prepareDivider()
preparePlaceholderLabel()
......@@ -425,8 +428,8 @@ extension TextField {
/// Prepares the placeholderLabel.
fileprivate func preparePlaceholderLabel() {
font = RobotoFont.regular(with: 16)
placeholderNormalColor = Color.darkText.others
placeholderLabel.backgroundColor = .clear
addSubview(placeholderLabel)
}
......@@ -506,7 +509,7 @@ extension TextField {
/// Layout the detailLabel.
fileprivate func layoutDetailLabel() {
let c = dividerContentEdgeInsets
detailLabel.height = detailLabel.sizeThatFits(CGSize(width: width, height: CGFloat.greatestFiniteMagnitude)).height
detailLabel.height = detailLabel.sizeThatFits(CGSize(width: width, height: .greatestFiniteMagnitude)).height
detailLabel.x = c.left
detailLabel.y = height + detailVerticalOffset
detailLabel.width = width - c.left - c.right
......
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