Repository: airbnb/lottie-ios
File: Sources/Public/Animation/LottieView.swift (Swift)

Code before:
    copy.sizing = .proposed
    return copy
  }

  @available(*, deprecated, renamed: "playing(_:)", message: "Will be removed in a future major release.")
  public func play() -> Self {
    playbackMode(.play(.progress(to: 1, loopMode: .playOnce)))
  }

  /// Returns a copy of this view that loops its animation from the start to end whenever visible
  public func looping() -> Self {
    playbackMode(.play(.progress(from: 0, to: 1, loopMode: .loop)))
  }

  @available(*, deprecated, renamed: "playbackMode(_:)", message: "Will be removed in a future major release.")
  public func play(loopMode: LottieLoopMode = .playOnce) -> Self {
    playbackMode(.play(.progress(to: 1, loopMode: loopMode)))
  }

  @available(*, deprecated, renamed: "playbackMode(_:)", message: "Will be removed in a future major release.")
  public func play(_ playbackMode: LottiePlaybackMode) -> Self {
    self.playbackMode(playbackMode)
  }

  /// Returns a copy of this view playing with the given playback mode
  public func playing(_ playbackMode: LottiePlaybackMode.PlaybackMode = .progress(to: 1, loopMode: .playOnce)) -> Self {
    self.playbackMode(.play(playbackMode))
  }

  /// Returns a copy of this view paused with the given state
  public func paused(at state: LottiePlaybackMode.PausedState = .currentFrame) -> Self {
    playbackMode(.paused(at: state))
  }

  /// Returns a copy of this view using the given `LottiePlaybackMode`
  public func playbackMode(_ playbackMode: LottiePlaybackMode) -> Self {
    var copy = self
    copy.playbackMode = playbackMode
    return copy
  }

  /// Returns a copy of this view with the given closure that is called whenever the
  /// `LottieAnimationSource` provided via `init` is loaded and applied to the underlying `LottieAnimationView`.
  public func animationDidLoad(_ animationDidLoad: @escaping (LottieAnimationSource) -> Void) -> Self {
    var copy = self
    copy.animationDidLoad = animationDidLoad
    return copy
  }

  /// Returns a copy of this view with the given `LottieCompletionBlock` that is called
  /// when an animation finishes playing.

Review comment (suggestion):
Before we had `play()`, `play(loopMode:)` and `play(_:)` (which took a `LottiePlaybackMode`)

Can we keep all three of those methods, without using a default parameter? That lets us tailor the doc comment to exactly describe what each method does (e.g. that `playing()` causing the animation to play once from the start to the end)

Code after:
    copy.sizing = .proposed
    return copy
  }

  @available(*, deprecated, renamed: "playing()", message: "Will be removed in a future major release.")
  public func play() -> Self {
    playbackMode(.playing(.fromProgress(nil, toProgress: 1, loopMode: .playOnce)))
  }

  /// Returns a copy of this view that loops its animation from the start to end whenever visible
  public func looping() -> Self {
    playbackMode(.playing(.fromProgress(0, toProgress: 1, loopMode: .loop)))
  }

  @available(*, deprecated, renamed: "playing(_:)", message: "Will be removed in a future major release.")
  public func play(loopMode: LottieLoopMode = .playOnce) -> Self {
    playbackMode(.playing(.fromProgress(nil, toProgress: 1, loopMode: loopMode)))
  }

  @available(*, deprecated, renamed: "playbackMode(_:)", message: "Will be removed in a future major release.")
  public func play(_ playbackMode: LottiePlaybackMode) -> Self {
    self.playbackMode(playbackMode)
  }

  /// Returns a copy of this view playing with the given playback mode
  public func playing(_ mode: LottiePlaybackMode.PlaybackMode) -> Self {
    playbackMode(.playing(mode))
  }

  /// Returns a copy of this view playing from the current frame to the end frame,
  /// with the given `LottiePlaybackMode`.
  public func playing(loopMode: LottieLoopMode) -> Self {
    playbackMode(.playing(.fromProgress(nil, toProgress: 1, loopMode: loopMode)))
  }

  // Returns a copy of this view playing once from the current frame to the end frame
  public func playing() -> Self {
    playbackMode(.playing(.fromProgress(nil, toProgress: 1, loopMode: .playOnce)))
  }

  /// Returns a copy of this view paused with the given state
  public func paused(at state: LottiePlaybackMode.PausedState = .currentFrame) -> Self {
    playbackMode(.paused(at: state))
  }

  /// Returns a copy of this view using the given `LottiePlaybackMode`
  public func playbackMode(_ playbackMode: LottiePlaybackMode) -> Self {
    var copy = self
    copy.playbackMode = playbackMode
    return copy
  }