Skip to content

Commit

Permalink
Update Lottie and the related code
Browse files Browse the repository at this point in the history
  • Loading branch information
leandroalonso committed Jan 24, 2024
1 parent 4cda81b commit e2c6474
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion podcasts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11358,7 +11358,7 @@
repositoryURL = "https://github.com/airbnb/lottie-ios.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 3.2.3;
minimumVersion = 4.4.0;
};
};
BDD239BB267C869B0047750C /* XCRemoteSwiftPackageReference "SwipeCellKit" */ = {
Expand Down
4 changes: 2 additions & 2 deletions podcasts.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@
"repositoryURL": "https://github.com/airbnb/lottie-ios.git",
"state": {
"branch": null,
"revision": "4a6058cbbdfe4f74aeae92c8bd51ad3b0de2a1ee",
"version": "3.3.0"
"revision": "f522990668c2f9132323a2e68d924c7dcb9130b4",
"version": "4.4.0"
}
},
{
Expand Down
8 changes: 4 additions & 4 deletions podcasts/BasePlayPauseButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class BasePlayPauseButton: UIButton {
private enum PlayState { case playing, paused, notSet }

private var currentState = PlayState.notSet
var animationView: AnimationView!
var animationView: LottieAnimationView!

var isPlaying = false {
didSet {
Expand All @@ -33,7 +33,7 @@ class BasePlayPauseButton: UIButton {
var playButtonColor: UIColor = .white {
didSet {
let colorValues = playButtonColor.getRGBA()
let colorProvider = ColorValueProvider(Color(r: colorValues[0], g: colorValues[1], b: colorValues[2], a: colorValues[3]))
let colorProvider = ColorValueProvider(LottieColor(r: colorValues[0], g: colorValues[1], b: colorValues[2], a: colorValues[3]))
animationView.setValueProvider(colorProvider, keypath: AnimationKeypath(keypath: "**.Fill 1.Color"))
animationView.setValueProvider(colorProvider, keypath: AnimationKeypath(keypath: "**.Stroke 1.Color"))
}
Expand All @@ -42,7 +42,7 @@ class BasePlayPauseButton: UIButton {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)

animationView = AnimationView(name: animationName())
animationView = LottieAnimationView(name: animationName())
animationView.isUserInteractionEnabled = false
animationView.animationSpeed = BasePlayPauseButton.animationSpeed
}
Expand All @@ -65,7 +65,7 @@ class BasePlayPauseButton: UIButton {
animate(from: 0, to: 0.5, changingToState: .paused)
}

func place(animation: AnimationView) {}
func place(animation: LottieAnimationView) {}
func animationName() -> String {
"player_play_button"
}
Expand Down
4 changes: 2 additions & 2 deletions podcasts/NowPlayingAnimationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class NowPlayingAnimationView: UIView {
}
}

private var animationView: AnimationView
private var animationView: LottieAnimationView

required init?(coder aDecoder: NSCoder) {
animationView = AnimationView(name: "nowplaying")
animationView = LottieAnimationView(name: "nowplaying")

super.init(coder: aDecoder)
}
Expand Down
2 changes: 1 addition & 1 deletion podcasts/PlayPauseButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PlayPauseButton: BasePlayPauseButton {
circleView.layer.cornerRadius = 0.5 * circleView.bounds.width
}

override func place(animation: AnimationView) {
override func place(animation: LottieAnimationView) {
circleView.translatesAutoresizingMaskIntoConstraints = false
addSubview(circleView)
NSLayoutConstraint.activate([
Expand Down
2 changes: 1 addition & 1 deletion podcasts/PlayPauseLabeledButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class PlayPauseLabeledButton: BasePlayPauseButton {
layer.cornerRadius = frame.size.height / 2
}

override func place(animation: AnimationView) {
override func place(animation: LottieAnimationView) {
animation.translatesAutoresizingMaskIntoConstraints = false
animation.isUserInteractionEnabled = false
label.translatesAutoresizingMaskIntoConstraints = false
Expand Down
6 changes: 3 additions & 3 deletions podcasts/SkipButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ class SkipButton: UIButton {
skipLabel.textColor = tintColor

let colorValues = tintColor.getRGBA()
let colorProvider = ColorValueProvider(Color(r: colorValues[0], g: colorValues[1], b: colorValues[2], a: colorValues[3]))
let colorProvider = ColorValueProvider(LottieColor(r: colorValues[0], g: colorValues[1], b: colorValues[2], a: colorValues[3]))
animationView.setValueProvider(colorProvider, keypath: AnimationKeypath(keypath: "**.Fill 1.Color"))
animationView.setValueProvider(colorProvider, keypath: AnimationKeypath(keypath: "**.Stroke 1.Color"))
}
}

private var animationView: AnimationView
private var animationView: LottieAnimationView
private let skipLabel: UILabel

required init?(coder aDecoder: NSCoder) {
animationView = AnimationView(name: "skip_button")
animationView = LottieAnimationView(name: "skip_button")
skipLabel = UILabel()

super.init(coder: aDecoder)
Expand Down
8 changes: 4 additions & 4 deletions podcasts/SleepTimerButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ class SleepTimerButton: UIButton {
}
}

private var animationView: AnimationView
private var animationView: LottieAnimationView

override var tintColor: UIColor! {
didSet {
let colorValues = tintColor.getRGBA()
let colorProvider = ColorValueProvider(Color(r: colorValues[0], g: colorValues[1], b: colorValues[2], a: colorValues[3] * 2))
let colorProvider = ColorValueProvider(LottieColor(r: colorValues[0], g: colorValues[1], b: colorValues[2], a: colorValues[3] * 2))
animationView.setValueProvider(colorProvider, keypath: AnimationKeypath(keypath: "**.Fill 1.Color"))
animationView.setValueProvider(colorProvider, keypath: AnimationKeypath(keypath: "**.Fill 2.Color"))
animationView.setValueProvider(colorProvider, keypath: AnimationKeypath(keypath: "**.Fill 3.Color"))
}
}

override init(frame: CGRect) {
animationView = AnimationView(name: "sleep_button")
animationView = LottieAnimationView(name: "sleep_button")
animationView.isUserInteractionEnabled = false
animationView.animationSpeed = 1.0
animationView.currentProgress = 0.5
Expand All @@ -45,7 +45,7 @@ class SleepTimerButton: UIButton {
}

required init?(coder aDecoder: NSCoder) {
animationView = AnimationView(name: "sleep_button")
animationView = LottieAnimationView(name: "sleep_button")
animationView.isUserInteractionEnabled = false
animationView.animationSpeed = 1.0
animationView.currentProgress = 0.5
Expand Down

0 comments on commit e2c6474

Please sign in to comment.