Commit c3ff9361 by Daniel Dahan

initial phase to Swift 4 complete

parent 3130a55c
......@@ -1036,14 +1036,14 @@
attributes = {
LastSwiftMigration = 0710;
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = "CosmicMind, Inc.";
TargetAttributes = {
963832351B88DFD80015F710 = {
CreatedOnToolsVersion = 6.4;
DevelopmentTeam = 9Z76XCNLGL;
DevelopmentTeamName = "CosmicMind Inc.";
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
ProvisioningStyle = Manual;
};
};
......@@ -1215,14 +1215,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
......@@ -1254,6 +1260,7 @@
PRODUCT_NAME = Material;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
......@@ -1269,14 +1276,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
......@@ -1300,6 +1313,7 @@
PRODUCT_NAME = Material;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
......@@ -1329,7 +1343,8 @@
PROVISIONING_PROFILE = "";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
......@@ -1354,7 +1369,8 @@
PROVISIONING_PROFILE = "";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
};
name = Release;
};
......
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
......@@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
......@@ -55,6 +56,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
......
......@@ -770,21 +770,28 @@ extension Motion: UITabBarControllerDelegate {
}
}
public typealias MotionDelayCancelBlock = (Bool) -> Void
public typealias MotionCancelBlock = (Bool) -> Void
extension Motion {
/**
Executes a block of code asynchronously on the main thread.
- Parameter execute: A block that is executed asynchronously on the main thread.
*/
public class func async(_ execute: @escaping () -> Void) {
Motion.delay(0, execute: execute)
}
/**
Executes a block of code after a time delay.
- Parameter duration: An animation duration time.
- Parameter animations: An animation block.
- Parameter execute block: A completion block that is executed once
the animations have completed.
- Parameter _ time: A delay time.
- Parameter execute: A block that is executed once delay has passed.
- Returns: An optional MotionCancelBlock.
*/
@discardableResult
public class func delay(_ time: TimeInterval, execute: @escaping () -> Void) -> MotionDelayCancelBlock? {
var cancelable: MotionDelayCancelBlock?
public class func delay(_ time: TimeInterval, execute: @escaping () -> Void) -> MotionCancelBlock? {
var cancelable: MotionCancelBlock?
let delayed: MotionDelayCancelBlock = {
let delayed: MotionCancelBlock = {
if !$0 {
DispatchQueue.main.async(execute: execute)
}
......@@ -802,10 +809,10 @@ extension Motion {
}
/**
Cancels the delayed MotionDelayCancelBlock.
- Parameter delayed completion: An MotionDelayCancelBlock.
Cancels the delayed MotionCancelBlock.
- Parameter delayed completion: An MotionCancelBlock.
*/
public class func cancel(delayed completion: MotionDelayCancelBlock) {
public class func cancel(delayed completion: MotionCancelBlock) {
completion(true)
}
......
......@@ -227,6 +227,16 @@ public extension MotionAnimation {
}
}
/**
Animates a view's current position to the given x and y values.
- Parameter x: A CGloat.
- Parameter y: A CGloat.
- Returns: A MotionAnimation.
*/
static func position(x: CGFloat, y: CGFloat) -> MotionAnimation {
return .position(CGPoint(x: x, y: y))
}
/// Fades the view in during an animation.
static var fadeIn = MotionAnimation.fade(1)
......@@ -267,6 +277,16 @@ public extension MotionAnimation {
}
/**
Animates the view's current size to the given width and height.
- Parameter width: A CGFloat.
- Parameter height: A CGFloat.
- Returns: A MotionAnimation.
*/
static func size(width: CGFloat, height: CGFloat) -> MotionAnimation {
return .size(CGSize(width: width, height: height))
}
/**
Animates a view's current shadow path to the given one.
- Parameter path: A CGPath.
- Returns: A MotionAnimation.
......
......@@ -310,6 +310,7 @@ internal extension MotionController {
Subclasses should call context.set(fromViews: toViews) after
inserting fromViews & toViews into the container
*/
@objc
func prepareTransition() {
guard isTransitioning else {
return
......@@ -323,6 +324,7 @@ internal extension MotionController {
}
/// Prepares the transition fromView & toView pairs.
@objc
func prepareTransitionPairs() {
guard isTransitioning else {
return
......@@ -358,6 +360,7 @@ internal extension MotionController {
Animates the views. Subclasses should call `prepareTransition` &
`prepareTransitionPairs` before calling `animate`.
*/
@objc
func animate() {
guard isTransitioning else {
return
......@@ -424,6 +427,7 @@ internal extension MotionController {
- Parameter isFinished: A Boolean indicating if the transition
has completed.
*/
@objc
func complete(isFinished: Bool) {
guard isTransitioning else {
return
......
......@@ -234,6 +234,16 @@ public extension MotionTransition {
}
}
/**
Animates a view's current position to the given x and y values.
- Parameter x: A CGloat.
- Parameter y: A CGloat.
- Returns: A MotionTransition.
*/
static func position(x: CGFloat, y: CGFloat) -> MotionTransition {
return .position(CGPoint(x: x, y: y))
}
/// Forces the view to not fade during a transition.
static var forceNonFade = MotionTransition {
$0.nonFade = true
......@@ -279,6 +289,16 @@ public extension MotionTransition {
}
/**
Animates the view's current size to the given width and height.
- Parameter width: A CGFloat.
- Parameter height: A CGFloat.
- Returns: A MotionTransition.
*/
static func size(width: CGFloat, height: CGFloat) -> MotionTransition {
return .size(CGSize(width: width, height: height))
}
/**
Animates the view's current shadow path to the given one.
- Parameter path: A CGPath.
- Returns: A MotionTransition.
......
......@@ -57,47 +57,47 @@ public enum CharacterAttribute: String {
public func CharacterAttributeToValue(attribute: CharacterAttribute) -> String {
switch attribute {
case .font:
return NSFontAttributeName
return NSAttributedStringKey.font.rawValue
case .paragraphStyle:
return NSParagraphStyleAttributeName
return NSAttributedStringKey.paragraphStyle.rawValue
case .forgroundColor:
return NSForegroundColorAttributeName
return NSAttributedStringKey.foregroundColor.rawValue
case .backgroundColor:
return NSBackgroundColorAttributeName
return NSAttributedStringKey.backgroundColor.rawValue
case .ligature:
return NSLigatureAttributeName
return NSAttributedStringKey.ligature.rawValue
case .kern:
return NSKernAttributeName
return NSAttributedStringKey.kern.rawValue
case .strikethroughStyle:
return NSStrikethroughStyleAttributeName
return NSAttributedStringKey.strikethroughStyle.rawValue
case .underlineStyle:
return NSUnderlineStyleAttributeName
return NSAttributedStringKey.underlineStyle.rawValue
case .strokeColor:
return NSStrokeColorAttributeName
return NSAttributedStringKey.strokeColor.rawValue
case .strokeWidth:
return NSStrokeWidthAttributeName
return NSAttributedStringKey.strokeWidth.rawValue
case .shadow:
return NSShadowAttributeName
return NSAttributedStringKey.shadow.rawValue
case .textEffect:
return NSTextEffectAttributeName
return NSAttributedStringKey.textEffect.rawValue
case .attachment:
return NSAttachmentAttributeName
return NSAttributedStringKey.attachment.rawValue
case .link:
return NSLinkAttributeName
return NSAttributedStringKey.link.rawValue
case .baselineOffset:
return NSBaselineOffsetAttributeName
return NSAttributedStringKey.baselineOffset.rawValue
case .underlineColor:
return NSUnderlineColorAttributeName
return NSAttributedStringKey.underlineColor.rawValue
case .strikethroughColor:
return NSStrikethroughColorAttributeName
return NSAttributedStringKey.strikethroughColor.rawValue
case .obliqueness:
return NSObliquenessAttributeName
return NSAttributedStringKey.obliqueness.rawValue
case .expansion:
return NSExpansionAttributeName
return NSAttributedStringKey.expansion.rawValue
case .writingDirection:
return NSWritingDirectionAttributeName
return NSAttributedStringKey.writingDirection.rawValue
case .verticalGlyphForm:
return NSVerticalGlyphFormAttributeName
return NSAttributedStringKey.verticalGlyphForm.rawValue
}
}
......@@ -109,7 +109,7 @@ extension NSMutableAttributedString {
- Parameter range: A NSRange.
*/
open func add(characterAttribute: CharacterAttribute, value: Any, range: NSRange) {
addAttribute(CharacterAttributeToValue(attribute: characterAttribute), value: value, range: range)
addAttribute(NSAttributedStringKey(rawValue: CharacterAttributeToValue(attribute: characterAttribute)), value: value, range: range)
}
/**
......@@ -151,7 +151,7 @@ extension NSMutableAttributedString {
- Parameter range: A NSRange.
*/
open func remove(characterAttribute: CharacterAttribute, range: NSRange) {
removeAttribute(CharacterAttributeToValue(attribute: characterAttribute), range: range)
removeAttribute(NSAttributedStringKey(rawValue: CharacterAttributeToValue(attribute: characterAttribute)), range: range)
}
/**
......
......@@ -94,7 +94,7 @@ private class FontLoader {
let font = CGFont(provider)
var error: Unmanaged<CFError>?
if !CTFontManagerRegisterGraphicsFont(font, &error) {
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()
......
......@@ -41,7 +41,7 @@ extension UIFont {
open func stringSize(string: String, constrainedTo width: CGFloat) -> CGSize {
return string.boundingRect(with: CGSize(width: width, height: CGFloat(Double.greatestFiniteMagnitude)),
options: NSStringDrawingOptions.usesLineFragmentOrigin,
attributes: [NSFontAttributeName: self],
attributes: [NSAttributedStringKey.font: self],
context: nil).size
}
}
......@@ -123,6 +123,7 @@ extension UIView {
width or height property is set, the other will be automatically adjusted
to maintain the shape of the object.
*/
@objc
open var shapePreset: ShapePreset {
get {
return layer.shapePreset
......@@ -223,6 +224,7 @@ extension UIView {
}
/// A property that sets the cornerRadius of the backing layer.
@objc
open var cornerRadiusPreset: CornerRadiusPreset {
get {
return layer.cornerRadiusPreset
......
......@@ -109,7 +109,7 @@ open class SearchBar: Bar {
open var placeholder: String? {
didSet {
if let v = placeholder {
textField.attributedPlaceholder = NSAttributedString(string: v, attributes: [NSForegroundColorAttributeName: placeholderColor])
textField.attributedPlaceholder = NSAttributedString(string: v, attributes: [NSAttributedStringKey.foregroundColor: placeholderColor])
}
}
}
......@@ -119,7 +119,7 @@ open class SearchBar: Bar {
open var placeholderColor = Color.darkText.others {
didSet {
if let v = placeholder {
textField.attributedPlaceholder = NSAttributedString(string: v, attributes: [NSForegroundColorAttributeName: placeholderColor])
textField.attributedPlaceholder = NSAttributedString(string: v, attributes: [NSAttributedStringKey.foregroundColor: placeholderColor])
}
}
}
......
......@@ -115,7 +115,7 @@ open class SnackbarController: TransitionController {
- Parameter status: A SnackbarStatus enum value.
*/
@discardableResult
open func animate(snackbar status: SnackbarStatus, delay: TimeInterval = 0, animations: ((Snackbar) -> Void)? = nil, completion: ((Snackbar) -> Void)? = nil) -> MotionDelayCancelBlock? {
open func animate(snackbar status: SnackbarStatus, delay: TimeInterval = 0, animations: ((Snackbar) -> Void)? = nil, completion: ((Snackbar) -> Void)? = nil) -> MotionCancelBlock? {
return Motion.delay(delay) { [weak self, status = status, animations = animations, completion = completion] in
guard let s = self else {
return
......
......@@ -408,9 +408,9 @@ fileprivate extension TabBar {
selectedTabItem = tabItem
line.animate(.duration(0.25),
.size(CGSize(width: tabItem.width, height: lineHeight)),
.position(CGPoint(x: tabItem.center.x, y: .bottom == lineAlignment ? height - lineHeight / 2 : lineHeight / 2)),
.completion { [weak self, isTriggeredByUserInteraction = isTriggeredByUserInteraction, tabItem = tabItem, completion = completion] _ in
.size(width: tabItem.width, height: lineHeight),
.position(x: tabItem.center.x, y: .bottom == lineAlignment ? height - lineHeight / 2 : lineHeight / 2),
.completion({ [weak self, isTriggeredByUserInteraction = isTriggeredByUserInteraction, tabItem = tabItem, completion = completion] in
guard let s = self else {
return
}
......@@ -420,7 +420,7 @@ fileprivate extension TabBar {
}
completion?(tabItem)
})
}))
updateScrollView()
}
......
......@@ -360,7 +360,7 @@ extension TabsController {
return
}
Motion.delay(0) { [weak self] in
Motion.async { [weak self] in
guard let s = self else {
return
}
......
......@@ -105,7 +105,7 @@ extension TextStorage {
If you don't need this value, pass NULL.
- Returns: The attributes for the character at index.
*/
open override func attributes(at location: Int, effectiveRange range: NSRangePointer?) -> [String: Any] {
open override func attributes(at location: Int, effectiveRange range: NSRangePointer?) -> [NSAttributedStringKey: Any] {
return storage.attributes(at: location, effectiveRange: range)
}
......@@ -126,7 +126,7 @@ extension TextStorage {
- Parameter range: A range of characters that will have their
attributes updated.
*/
open override func setAttributes(_ attrs: [String : Any]?, range: NSRange) {
open override func setAttributes(_ attrs: [NSAttributedStringKey : Any]?, range: NSRange) {
storage.setAttributes(attrs, range: range)
edited(.editedAttributes, range: range, changeInLength: 0)
}
......@@ -138,7 +138,7 @@ extension TextStorage {
- Parameter range: A range of characters that will have their
attributes added.
*/
open override func addAttribute(_ name: String, value: Any, range: NSRange) {
open override func addAttribute(_ name: NSAttributedStringKey, value: Any, range: NSRange) {
storage.addAttribute(name, value: value, range: range)
edited(.editedAttributes, range: range, changeInLength: 0)
}
......@@ -149,7 +149,7 @@ extension TextStorage {
- Parameter range: A range of characters that will have their
attributes removed.
*/
open override func removeAttribute(_ name: String, range: NSRange) {
open override func removeAttribute(_ name: NSAttributedStringKey, range: NSRange) {
storage.removeAttribute(name, range: range)
edited(.editedAttributes, range: range, changeInLength: 0)
}
......
......@@ -162,6 +162,7 @@ internal extension TransitionController {
}
/// A method that prepares the rootViewController.
@objc
func prepareRootViewController() {
prepare(viewController: rootViewController, in: container)
}
......
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