-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Camera animations lifecycle listener (#2114)
- Allows listening to start/stop events of camera animator based on its animation owner, or by observing directly from the animator itself when created from low-level camera API. Co-authored-by: Patrick Leonard <[email protected]>
- Loading branch information
Showing
30 changed files
with
530 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
Sources/MapboxMaps/Camera/CameraAnimatorStatusObservable.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Foundation | ||
|
||
enum CameraAnimatorStatus: Equatable { | ||
case started | ||
case stopped(reason: StopReason) | ||
case paused | ||
|
||
enum StopReason: Equatable { | ||
case finished, cancelled | ||
} | ||
} | ||
|
||
final class CameraAnimatorStatusObserver { | ||
let owners: [AnimationOwner] | ||
let onStarted: OnCameraAnimatorStarted? | ||
let onStopped: OnCameraAnimatorStopped? | ||
|
||
init( | ||
owners: [AnimationOwner], | ||
onStarted: OnCameraAnimatorStarted? = nil, | ||
onStopped: OnCameraAnimatorStopped? = nil | ||
) { | ||
self.owners = owners | ||
self.onStarted = onStarted | ||
self.onStopped = onStopped | ||
} | ||
} | ||
|
||
/// A closure to handle event when a camera animator has started. | ||
public typealias OnCameraAnimatorStarted = (CameraAnimator) -> Void | ||
/// A closure to handle event when a camera animator has stopped. | ||
public typealias OnCameraAnimatorStopped = (CameraAnimator, _ isCancelled: Bool) -> Void |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.