Skip to content

Commit

Permalink
added CHANGELOG and fixed snapshot issue in iOS 11
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Dahan committed Oct 11, 2017
1 parent ce1eaae commit 8530c66
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 13 deletions.
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## 1.2.2

* Updated Motion for iOS 11, where snapshot would no longer include a container view.

## 1.2.1

* Submodule access rights update for [Material](https://github.com/CosmicMind/Material).

## 1.2.0

* Updated to `Swift 4`.
* Fixed a couple memory leaks.

## 1.1.2

* Minor internal updates.

## 1.1.1

* Added Motion logo to README.

## 1.1.0

* [issue-5](https://github.com/CosmicMind/Motion/issues/5): Added the ability to add custom timing functions.
* [issue-4](https://github.com/CosmicMind/Motion/issues/4): Fixed an issue where a white flash occurred when pushing/popping a view controller.
* [issue-8](https://github.com/CosmicMind/Motion/issues/8): Added the ability to add animation immediately.
* [issue-6](https://github.com/CosmicMind/Motion/issues/6): Added the ability to animate views that are not paired.
2 changes: 1 addition & 1 deletion Motion.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Motion'
s.version = '1.2.1'
s.version = '1.2.2'
s.license = 'MIT'
s.summary = 'A library used to create beautiful animations and transitions for Apple devices.'
s.homepage = 'http://cosmicmind.com'
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ In the above code example, a box view is created with a width of 100, height of
> **Embedded frameworks require a minimum deployment target of iOS 8.**
> - [Download Motion](https://github.com/CosmicMind/Motion/archive/master.zip)
Visit the [Installation](https://cosmicmind.gitbooks.io/motion/content/installation.html) page to learn how to install Motion using [CocoaPods](http://cocoapods.org) and [Carthage](https://github.com/Carthage/Carthage).
Read [Material - It's time to download](https://www.cosmicmind.com/danieldahan/lesson/6) to learn how to install Material using [GitHub](http://github.com), [CocoaPods](http://cocoapods.org), and [Carthage](https://github.com/Carthage/Carthage).

## Change Log

Motion is a growing project and will encounter changes throughout its development. It is recommended that the [Change Log](https://cosmicmind.gitbooks.io/motion/content/change_log.html) be reviewed prior to updating versions.
Motion is a growing project and will encounter changes throughout its development. It is recommended that the [Change Log](https://github.com/CosmicMind/Motion/blob/master/CHANGELOG.md) be reviewed prior to updating versions.

## License

Expand Down
10 changes: 8 additions & 2 deletions Sources/Extensions/Motion+UIView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,13 @@ internal extension UIView {
}

internal class SnapshotWrapperView: UIView {
/// A reference to the contentView.
let contentView: UIView

/**
An initializer that takes in a contentView.
- Parameter contentView: A UIView.
*/
init(contentView: UIView) {
self.contentView = contentView
super.init(frame: contentView.frame)
Expand Down Expand Up @@ -269,7 +275,7 @@ internal extension UIView {

let movePoints = realFromPos.distance(realToPos) + realFromSize.bottomRight.distance(realToSize.bottomRight)

// duration is 0.2 @ 0 to 0.375 @ 500
// Duration is 0.2 @ 0 to 0.375 @ 500
return 0.208 + Double(movePoints.clamp(0, 500)) / 3000
}

Expand Down Expand Up @@ -298,7 +304,7 @@ internal extension UIView {
let snapshot = snapshotView(afterScreenUpdates: true)

if #available(iOS 11.0, *), let oldSnapshot = snapshot {
/// iOS 11 no longer contains a container view.
// iOS 11 no longer contains a container view.
return SnapshotWrapperView(contentView: oldSnapshot)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.2.1</string>
<string>1.2.2</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
20 changes: 13 additions & 7 deletions Sources/MotionContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,14 @@ public extension MotionContext {

unhide(view: view)

/// Capture a snapshot without alpha & cornerRadius.
// Capture a snapshot without alpha & cornerRadius.
let oldCornerRadius = view.layer.cornerRadius
let oldAlpha = view.alpha
view.layer.cornerRadius = 0
view.alpha = 1

let snapshot: UIView
let snapshotType: MotionSnapshotType = self[view]?.snapshotType ?? .optimized
let snapshotType = self[view]?.snapshotType ?? MotionSnapshotType.optimized

switch snapshotType {
case .normal:
Expand All @@ -209,7 +209,7 @@ public extension MotionContext {

case .noSnapshot:
if view.superview != container {
if superviewToNoSnapshotSubviewMap[view.superview!] == nil {
if nil == superviewToNoSnapshotSubviewMap[view.superview!] {
superviewToNoSnapshotSubviewMap[view.superview!] = []
}

Expand All @@ -222,35 +222,41 @@ public extension MotionContext {
#if os(tvOS)
snapshot = view.snapshotView(afterScreenUpdates: true)!
#else

if #available(iOS 9.0, *), let stackView = view as? UIStackView {
snapshot = stackView.slowSnapshotView()

} else if let imageView = view as? UIImageView, view.subviews.isEmpty {
let contentView = UIImageView(image: imageView.image)
contentView.frame = imageView.bounds
contentView.contentMode = imageView.contentMode
contentView.tintColor = imageView.tintColor
contentView.backgroundColor = imageView.backgroundColor

let snapShotView = UIView()
snapShotView.addSubview(contentView)
snapshot = snapShotView

} else if let barView = view as? UINavigationBar, barView.isTranslucent {
let newBarView = UINavigationBar(frame: barView.frame)

newBarView.barStyle = barView.barStyle
newBarView.tintColor = barView.tintColor
newBarView.barTintColor = barView.barTintColor
newBarView.clipsToBounds = false

// take a snapshot without the background
barView.layer.sublayers![0].opacity = 0

let realSnapshot = barView.snapshotView(afterScreenUpdates: true)!
barView.layer.sublayers![0].opacity = 1

newBarView.addSubview(realSnapshot)
snapshot = newBarView

} else if let effectView = view as? UIVisualEffectView {
snapshot = UIVisualEffectView(effect: effectView.effect)
snapshot.frame = effectView.bounds

} else {
snapshot = view.snapshotView() ?? UIView()
}
Expand All @@ -272,10 +278,10 @@ public extension MotionContext {
snapshot.layer.bounds = view.layer.bounds
snapshot.motionIdentifier = view.motionIdentifier

if snapshotType != .noSnapshot {
if .noSnapshot != snapshotType {
if !(view is UINavigationBar), let contentView = snapshot.subviews.get(0) {
// the Snapshot's contentView must have hold the cornerRadius value,
// since the snapshot might not have maskToBounds set
// The Snapshot's contentView must have hold the cornerRadius value,
// since the snapshot might not have maskToBounds set.
contentView.layer.cornerRadius = view.layer.cornerRadius
contentView.layer.masksToBounds = true
}
Expand Down

0 comments on commit 8530c66

Please sign in to comment.