Skip to content

Commit

Permalink
feat(targets): update lottie-ios to 3.1.1 (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
n8chur committed Jul 16, 2019
1 parent c57c919 commit 119b85e
Show file tree
Hide file tree
Showing 19 changed files with 176 additions and 284 deletions.
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ matrix:
language: objective-c
osx_image: xcode10.2
cache: yarn
before_script:
- pod repo update
script:
- yarn health
after_success:
Expand All @@ -27,8 +29,10 @@ matrix:
- yarn build-examples --target android
- name: iOS Examples
language: objective-c
cache: cocoapods
osx_image: xcode10.2
cache: cocoapods
before_script:
- pod repo update
script:
- yarn build-examples --target ios
addons:
Expand All @@ -43,6 +47,7 @@ before_install:
- nvm alias default 10.15.3
- nvm use 10.15.3
- export PATH="$HOME/.yarn/bin:$PATH"
- gem install cocoapods -v '1.7.4'
install: yarn
branches:
only:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,11 @@
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-LoremIpsum/Pods-LoremIpsum-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/DiezLoremIpsum/DiezLoremIpsum.framework",
"${BUILT_PRODUCTS_DIR}/lottie-ios/Lottie.framework",
"${PODS_ROOT}/Target Support Files/Pods-LoremIpsum/Pods-LoremIpsum-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
);
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DiezLoremIpsum.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Lottie.framework",
"${PODS_ROOT}/Target Support Files/Pods-LoremIpsum/Pods-LoremIpsum-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down
2 changes: 1 addition & 1 deletion examples/lorem-ipsum/examples/ios/LoremIpsum/View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class View: UIView {
let titleLabel = UILabel()
let captionLabel = UILabel()
let animationStackView = UIStackView()
let animationView = LOTAnimationView()
let animationView = AnimationView()
let animationLabel = UILabel()

override init(frame: CGRect) {
Expand Down
2 changes: 1 addition & 1 deletion examples/lorem-ipsum/examples/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ target 'LoremIpsum' do

pod 'DiezLoremIpsum', :path => '../../build/diez-lorem-ipsum-ios'

pod 'lottie-ios', '2.5.2'
pod 'lottie-ios', '3.1.1'
end
14 changes: 7 additions & 7 deletions examples/lorem-ipsum/examples/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
PODS:
- DiezLoremIpsum (0.1.0):
- lottie-ios (~> 2.5.2)
- lottie-ios (2.5.2)
- lottie-ios (~> 3.1.1)
- lottie-ios (3.1.1)

DEPENDENCIES:
- DiezLoremIpsum (from `../../build/diez-lorem-ipsum-ios`)
- lottie-ios (= 2.5.2)
- lottie-ios (= 3.1.1)

SPEC REPOS:
https://github.com/cocoapods/specs.git:
Expand All @@ -16,9 +16,9 @@ EXTERNAL SOURCES:
:path: "../../build/diez-lorem-ipsum-ios"

SPEC CHECKSUMS:
DiezLoremIpsum: 4dccf7d4536f9e1d8ca23aef41237380eeb21a91
lottie-ios: 3fef45d3fabe63e3c7c2eb603dd64ddfffc73062
DiezLoremIpsum: 3b02836469ae9dd33886900e766abcbaab33cc2c
lottie-ios: 43a472d22b2dd2bed292cc4010c0b4d2e66d3ba8

PODFILE CHECKSUM: a79aa59f925d2c472d63b1d2344ba6da58241ee9
PODFILE CHECKSUM: 0252dab712b9ae8559f499051289c6c08eadc0f9

COCOAPODS: 1.6.1
COCOAPODS: 1.7.4
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ - (void)viewDidLoad {
imageView.contentMode = UIViewContentModeScaleAspectFit;
[self.stackView appendView:imageView];

LOTAnimationView *animationView = [[LOTAnimationView alloc] init];
AnimationView *animationView = [[AnimationView alloc] init];
[self.stackView appendView:animationView];
[animationView.heightAnchor constraintEqualToAnchor:animationView.widthAnchor].active = YES;

Expand Down Expand Up @@ -81,7 +81,7 @@ - (void)viewDidLoad {

[gradientView.gradientLayer dez_applyLinearGradient:component.designs.report.waterTemperature.shared.gradient];

[animationView dez_loadLottie:component.designs.loading.animation withSession:NSURLSession.sharedSession completion:nil];
[animationView dez_loadLottie:component.designs.loading.animation completion:nil];
}];
}

Expand Down
2 changes: 1 addition & 1 deletion examples/poodle-surf/examples/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ target 'PoodleSurf' do

pod 'DiezPoodleSurf', :path => '../../build/diez-poodle-surf-ios'

pod 'lottie-ios', '2.5.2'
pod 'lottie-ios', '3.1.1'
end
14 changes: 7 additions & 7 deletions examples/poodle-surf/examples/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
PODS:
- DiezPoodleSurf (0.1.0):
- lottie-ios (~> 2.5.2)
- lottie-ios (2.5.2)
- lottie-ios (~> 3.1.1)
- lottie-ios (3.1.1)

DEPENDENCIES:
- DiezPoodleSurf (from `../../build/diez-poodle-surf-ios`)
- lottie-ios (= 2.5.2)
- lottie-ios (= 3.1.1)

SPEC REPOS:
https://github.com/cocoapods/specs.git:
Expand All @@ -16,9 +16,9 @@ EXTERNAL SOURCES:
:path: "../../build/diez-poodle-surf-ios"

SPEC CHECKSUMS:
DiezPoodleSurf: 86c1d7aa84dc357c559dd3564633a55d0d3c8403
lottie-ios: 3fef45d3fabe63e3c7c2eb603dd64ddfffc73062
DiezPoodleSurf: 408fc61002083b2dbe28b3f976f3cad66716ce3e
lottie-ios: 43a472d22b2dd2bed292cc4010c0b4d2e66d3ba8

PODFILE CHECKSUM: d1516643ba0c111d1e67198e6bf75ecfa9ac807b
PODFILE CHECKSUM: 677d35819389b4af10b2328fe426d72e2250ac2d

COCOAPODS: 1.6.1
COCOAPODS: 1.7.4
Original file line number Diff line number Diff line change
Expand Up @@ -339,18 +339,11 @@
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-PoodleSurf/Pods-PoodleSurf-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/DiezPoodleSurf/DiezPoodleSurf.framework",
"${BUILT_PRODUCTS_DIR}/lottie-ios/Lottie.framework",
"${PODS_ROOT}/Target Support Files/Pods-PoodleSurf/Pods-PoodleSurf-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
);
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DiezPoodleSurf.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Lottie.framework",
"${PODS_ROOT}/Target Support Files/Pods-PoodleSurf/Pods-PoodleSurf-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import UIKit
import Lottie

class LoadingView: UIView {
let animationView = LOTAnimationView()
let animationView = AnimationView()

override init(frame: CGRect) {
super.init(frame: CGRect.zero)

setupLayout()
configureViews()
}

override class var requiresConstraintBasedLayout: Bool {
Expand All @@ -30,6 +31,10 @@ class LoadingView: UIView {
animationView.centerYAnchor.constraint(equalTo: centerYAnchor),
])
}

private func configureViews() {
animationView.backgroundBehavior = .pauseAndRestore
}

@available(*, unavailable)
required init?(coder aDecoder: NSCoder) { fatalError("\(#function) not implemented.") }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ extension Lottie {
}
```

#### LOTAnimationView Loader
#### AnimationView Loader

```swift
extension LOTAnimationView {
typealias LoadCompletion = (Result<Void, LottieError>) -> Void
extension AnimationView {
typealias LoadCompletion = (Bool) -> Void

func load(_ lottie: Lottie, session: URLSession = .shared, completion: LoadCompletion? = nil) -> URLSessionDataTask?
func load(_ lottie: Lottie, completion: LoadCompletion? = nil)
}
```

Expand Down
64 changes: 64 additions & 0 deletions packages/targets/sources/ios/bindings/Lottie+AnimationView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import Foundation
import Lottie

/**
An error that occurred when attempting to load a `Lottie` object in a `LOTAnimationView`.
*/
public enum LottieError: Error, CustomDebugStringConvertible {
case invalidURL
case requestFailed(Error?)
case deserializationError(Data, Error)
case invalidType(json: Any)

public var debugDescription: String {
switch self {
case .invalidURL:
return "Lottie URL is invalid."
case .requestFailed(let error):
return "Request failed: \(String(describing: error))"
case .deserializationError(let data, let error):
let dataAsString = String(data: data, encoding: String.Encoding.utf8)
return "Lottie file failed to be deserialized: \(error)\n\(String(describing: dataAsString))"
case .invalidType(let json):
return "JSON was not in the correct format ([AnyHashable: Any]): \(json)"
}
}
}

extension AnimationView {
/**
A closure to be called when loading a `Lottie` animation has completed with a value that represents whether the animation was loaded successfully.
*/
public typealias LoadCompletion = (Bool) -> Void

/**
Loads the provided `Lottie` animation.
*/
@objc(dez_loadLottie:completion:)
public func load(_ lottie: Lottie, completion: LoadCompletion? = nil) {
// TODO: Add a parameter that allows a fade in animated and add a description of the parameter to doc comment.
// TODO: Should this be synchronous when resource is local?
guard let url = lottie.url else {
completion?(false)
return
}

Animation.loadedFrom(url: url, closure: { [weak self] animation in
guard let self = self else { return }

guard let animation = animation else {
completion?(false)
return
}

self.animation = animation
self.loopMode = lottie.loop ? .loop : .playOnce

if lottie.autoplay {
self.play()
}

completion?(true)
}, animationCache: nil)
}
}
116 changes: 0 additions & 116 deletions packages/targets/sources/ios/bindings/Lottie+LOTAnimationView.swift

This file was deleted.

0 comments on commit 119b85e

Please sign in to comment.