Skip to content

Commit

Permalink
重大更新
Browse files Browse the repository at this point in the history
  • Loading branch information
时点软件 冯成林 authored and 时点软件 冯成林 committed Jan 28, 2016
1 parent c02e5da commit 921daa6
Show file tree
Hide file tree
Showing 61 changed files with 1,280 additions and 1,236 deletions.
700 changes: 312 additions & 388 deletions PhotoBrowser.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file not shown.
2 changes: 1 addition & 1 deletion PhotoBrowser/DisplayVC+Host.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ extension DisplayVC{
//模型数据数组
for (var i=0; i<9; i++){

let model = PhotoBrowser.PhotoModel(hostHDImgURL: hostHDImageUrls[i], hostThumbnailImg: (displayView.subviews[i] as! UIImageView).image, titleStr: titles[i], descStr: descs[i], sourceView: displayView.subviews[i] as! UIView)
let model = PhotoBrowser.PhotoModel(hostHDImgURL: hostHDImageUrls[i], hostThumbnailImg: (displayView.subviews[i] as! UIImageView).image, titleStr: titles[i], descStr: descs[i], sourceView: displayView.subviews[i])

models.append(model)
}
Expand Down
4 changes: 3 additions & 1 deletion PhotoBrowser/Frameworks/CFSnapKit/CFSnapKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import Foundation
import UIKit


/**
* You must add -DSNAPKIT_DEPLOYMENT_LEGACY to your OTHER_SWIFT_FLAGS in your targets Build Settings.
*/

extension UIView {

Expand Down
587 changes: 0 additions & 587 deletions PhotoBrowser/Frameworks/CFSnapKit/Lib/ConstraintDescription.swift

This file was deleted.

26 changes: 0 additions & 26 deletions PhotoBrowser/Frameworks/CFSnapKit/Lib/Info.plist

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit
#else
import AppKit
Expand Down Expand Up @@ -58,9 +58,9 @@ public class Constraint {
public func updatePriorityMedium() -> Void { fatalError("Must be implemented by Concrete subclass.") }
public func updatePriorityLow() -> Void { fatalError("Must be implemented by Concrete subclass.") }

internal var makerFile: String = "Unknown"
internal var makerLine: UInt = 0
internal var makerLocation: SourceLocation = SourceLocation(file: "Unknown", line: 0)

internal(set) public var location: SourceLocation?
}

/**
Expand Down Expand Up @@ -119,7 +119,7 @@ internal class ConcreteConstraint: Constraint {
self.updatePriority(Float(750.0))
}
internal override func updatePriorityMedium() -> Void {
#if os(iOS)
#if os(iOS) || os(tvOS)
self.updatePriority(Float(500.0))
#else
self.updatePriority(Float(501.0))
Expand All @@ -128,31 +128,41 @@ internal class ConcreteConstraint: Constraint {
internal override func updatePriorityLow() -> Void {
self.updatePriority(Float(250.0))
}

internal override func install() -> [LayoutConstraint] {
return self.installOnView(updateExisting: false, file: self.makerFile, line: self.makerLine)
return self.installOnView(updateExisting: false, location: self.makerLocation)
}

internal override func uninstall() -> Void {
self.uninstallFromView()
}

internal override func activate() -> Void {
guard #available(iOS 8.0, OSX 10.10, *), self.installInfo != nil else {
guard self.installInfo != nil else {
self.install()
return
}
#if SNAPKIT_DEPLOYMENT_LEGACY
guard #available(iOS 8.0, OSX 10.10, *) else {
self.install()
return
}
#endif
let layoutConstraints = self.installInfo!.layoutConstraints.allObjects as! [LayoutConstraint]
if layoutConstraints.count > 0 {
NSLayoutConstraint.activateConstraints(layoutConstraints)
}
}

internal override func deactivate() -> Void {
guard #available(iOS 8.0, OSX 10.10, *), self.installInfo != nil else {
self.install()
guard self.installInfo != nil else {
return
}
#if SNAPKIT_DEPLOYMENT_LEGACY
guard #available(iOS 8.0, OSX 10.10, *) else {
return
}
#endif
let layoutConstraints = self.installInfo!.layoutConstraints.allObjects as! [LayoutConstraint]
if layoutConstraints.count > 0 {
NSLayoutConstraint.deactivateConstraints(layoutConstraints)
Expand Down Expand Up @@ -185,21 +195,23 @@ internal class ConcreteConstraint: Constraint {

private var installInfo: ConcreteConstraintInstallInfo? = nil

internal init(fromItem: ConstraintItem, toItem: ConstraintItem, relation: ConstraintRelation, constant: Any, multiplier: Float, priority: Float) {
internal init(fromItem: ConstraintItem, toItem: ConstraintItem, relation: ConstraintRelation, constant: Any, multiplier: Float, priority: Float, location: SourceLocation?) {
self.fromItem = fromItem
self.toItem = toItem
self.relation = relation
self.constant = constant
self.multiplier = multiplier
self.priority = priority
super.init()
self.location = location
}

internal func installOnView(updateExisting updateExisting: Bool = false, file: String? = nil, line: UInt? = nil) -> [LayoutConstraint] {
internal func installOnView(updateExisting updateExisting: Bool = false, location: SourceLocation? = nil) -> [LayoutConstraint] {
var installOnView: View? = nil
if self.toItem.view != nil {
installOnView = closestCommonSuperviewFromView(self.fromItem.view, toView: self.toItem.view)
if installOnView == nil {
NSException(name: "Cannot Install Constraint", reason: "No common superview between views (@\(self.makerFile)#\(self.makerLine))", userInfo: nil).raise()
NSException(name: "Cannot Install Constraint", reason: "No common superview between views (@\(self.makerLocation.file)#\(self.makerLocation.line))", userInfo: nil).raise()
return []
}
} else {
Expand All @@ -209,15 +221,15 @@ internal class ConcreteConstraint: Constraint {
} else {
installOnView = self.fromItem.view?.superview
if installOnView == nil {
NSException(name: "Cannot Install Constraint", reason: "Missing superview (@\(self.makerFile)#\(self.makerLine))", userInfo: nil).raise()
NSException(name: "Cannot Install Constraint", reason: "Missing superview (@\(self.makerLocation.file)#\(self.self.makerLocation.line))", userInfo: nil).raise()
return []
}
}
}

if let installedOnView = self.installInfo?.view {
if installedOnView != installOnView {
NSException(name: "Cannot Install Constraint", reason: "Already installed on different view. (@\(self.makerFile)#\(self.makerLine))", userInfo: nil).raise()
NSException(name: "Cannot Install Constraint", reason: "Already installed on different view. (@\(self.makerLocation.file)#\(self.makerLocation.line))", userInfo: nil).raise()
return []
}
return self.installInfo?.layoutConstraints.allObjects as? [LayoutConstraint] ?? []
Expand All @@ -241,7 +253,11 @@ internal class ConcreteConstraint: Constraint {
let layoutConstant: CGFloat = layoutToAttribute.snp_constantForValue(self.constant)

// get layout to
var layoutTo: View? = self.toItem.view
#if os(iOS) || os(tvOS)
var layoutTo: AnyObject? = self.toItem.view ?? self.toItem.layoutSupport
#else
var layoutTo: AnyObject? = self.toItem.view
#endif
if layoutTo == nil && layoutToAttribute != .Width && layoutToAttribute != .Height {
layoutTo = installOnView
}
Expand Down Expand Up @@ -301,7 +317,15 @@ internal class ConcreteConstraint: Constraint {
}

// add constraints
installOnView!.addConstraints(newLayoutConstraints)
#if SNAPKIT_DEPLOYMENT_LEGACY && !os(OSX)
if #available(iOS 8.0, *) {
NSLayoutConstraint.activateConstraints(newLayoutConstraints)
} else {
installOnView!.addConstraints(newLayoutConstraints)
}
#else
NSLayoutConstraint.activateConstraints(newLayoutConstraints)
#endif

// set install info
self.installInfo = ConcreteConstraintInstallInfo(view: installOnView, layoutConstraints: NSHashTable.weakObjectsHashTable())
Expand All @@ -323,11 +347,16 @@ internal class ConcreteConstraint: Constraint {
let installedLayoutConstraints = installInfo.layoutConstraints.allObjects as? [LayoutConstraint] {

if installedLayoutConstraints.count > 0 {

if let installedOnView = installInfo.view {
// remove the constraints from the UIView's storage
// remove the constraints from the UIView's storage
#if SNAPKIT_DEPLOYMENT_LEGACY && !os(OSX)
if #available(iOS 8.0, *) {
NSLayoutConstraint.deactivateConstraints(installedLayoutConstraints)
} else if let installedOnView = installInfo.view {
installedOnView.removeConstraints(installedLayoutConstraints)
}
#else
NSLayoutConstraint.deactivateConstraints(installedLayoutConstraints)
#endif

// remove the constraints from the from item view
if let fromView = self.fromItem.view {
Expand Down Expand Up @@ -383,7 +412,7 @@ private extension NSLayoutAttribute {
}
// CGPoint
else if let point = value as? CGPoint {
#if os(iOS)
#if os(iOS) || os(tvOS)
switch self {
case .Left, .CenterX, .LeftMargin, .CenterXWithinMargins: return point.x
case .Top, .CenterY, .TopMargin, .CenterYWithinMargins, .Baseline, .FirstBaseline: return point.y
Expand All @@ -408,15 +437,17 @@ private extension NSLayoutAttribute {
}
// EdgeInsets
else if let insets = value as? EdgeInsets {
#if os(iOS)
#if os(iOS) || os(tvOS)
switch self {
case .Left, .CenterX, .LeftMargin, .CenterXWithinMargins: return insets.left
case .Top, .CenterY, .TopMargin, .CenterYWithinMargins, .Baseline, .FirstBaseline: return insets.top
case .Right, .RightMargin: return insets.right
case .Bottom, .BottomMargin: return insets.bottom
case .Leading, .LeadingMargin: return (Config.interfaceLayoutDirection == .LeftToRight) ? insets.left : -insets.right
case .Trailing, .TrailingMargin: return (Config.interfaceLayoutDirection == .LeftToRight) ? insets.right : -insets.left
case .Width, .Height, .NotAnAttribute: return CGFloat(0)
case .Width: return -insets.left + insets.right
case .Height: return -insets.top + insets.bottom
case .NotAnAttribute: return CGFloat(0)
}
#else
switch self {
Expand All @@ -426,7 +457,9 @@ private extension NSLayoutAttribute {
case .Bottom: return insets.bottom
case .Leading: return (Config.interfaceLayoutDirection == .LeftToRight) ? insets.left : -insets.right
case .Trailing: return (Config.interfaceLayoutDirection == .LeftToRight) ? insets.right : -insets.left
case .Width, .Height, .NotAnAttribute: return CGFloat(0)
case .Width: return -insets.left + insets.right
case .Height: return -insets.top + insets.bottom
case .NotAnAttribute: return CGFloat(0)
case .FirstBaseline: return insets.bottom
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#if os(iOS)
#if os(iOS) || os(tvOS)
import UIKit
#else
import AppKit
Expand Down Expand Up @@ -66,7 +66,6 @@ internal struct ConstraintAttributes: OptionSetType, BooleanType {
internal static var CenterY: ConstraintAttributes { return self.init(512) }
internal static var Baseline: ConstraintAttributes { return self.init(1024) }

#if os(iOS)
@available(iOS 8.0, *)
internal static var FirstBaseline: ConstraintAttributes { return self.init(2048) }
@available(iOS 8.0, *)
Expand All @@ -85,20 +84,18 @@ internal struct ConstraintAttributes: OptionSetType, BooleanType {
internal static var CenterXWithinMargins: ConstraintAttributes { return self.init(262144) }
@available(iOS 8.0, *)
internal static var CenterYWithinMargins: ConstraintAttributes { return self.init(524288) }
#endif

// aggregates

internal static var Edges: ConstraintAttributes { return self.init(15) }
internal static var Size: ConstraintAttributes { return self.init(192) }
internal static var Center: ConstraintAttributes { return self.init(768) }

#if os(iOS)
@available(iOS 8.0, *)
internal static var Margins: ConstraintAttributes { return self.init(61440) }

@available(iOS 8.0, *)
internal static var CenterWithinMargins: ConstraintAttributes { return self.init(786432) }
#endif

internal var layoutAttributes:[NSLayoutAttribute] {
var attrs = [NSLayoutAttribute]()
Expand Down Expand Up @@ -135,10 +132,13 @@ internal struct ConstraintAttributes: OptionSetType, BooleanType {
if (self.contains(ConstraintAttributes.Baseline)) {
attrs.append(.Baseline)
}
#if os(iOS)

#if os(iOS) || os(tvOS)
#if SNAPKIT_DEPLOYMENT_LEGACY
guard #available(iOS 8.0, *) else {
fatalError("Constrant attribute unavaialble for running platform and deployment target.")
return attrs
}
#endif
if (self.contains(ConstraintAttributes.FirstBaseline)) {
attrs.append(.FirstBaseline)
}
Expand Down Expand Up @@ -167,6 +167,7 @@ internal struct ConstraintAttributes: OptionSetType, BooleanType {
attrs.append(.CenterYWithinMargins)
}
#endif

return attrs
}
}
Expand Down
Loading

0 comments on commit 921daa6

Please sign in to comment.