Add in AnimationOption Objects#102
Open
Jackson Taylor (jacksontaylor13) wants to merge 1 commit intowillowtreeapps:masterfrom
Open
Add in AnimationOption Objects#102Jackson Taylor (jacksontaylor13) wants to merge 1 commit intowillowtreeapps:masterfrom
Jackson Taylor (jacksontaylor13) wants to merge 1 commit intowillowtreeapps:masterfrom
Conversation
Looks like the parameters were getting too large for Spruce. Decided to try and have it with AnimationOptions instead so that the method length is customized based off of how much you need. This way it will be easier to read and add more options in the future like PR willowtreeapps#95. Also added in the documentation for the new features
Zack Sheppard (zackdotcomputer)
approved these changes
Jul 15, 2019
Contributor
Zack Sheppard (zackdotcomputer)
left a comment
There was a problem hiding this comment.
I would love to see this and an updated #95 merged in!
| } | ||
| for (index, timedView) in timedViews.enumerated() { | ||
| if let exclude = exclude, exclude.reduce(false, { $0 || $1 == timedView.spruceView.view }) { | ||
| if optionsObject.excludedViews.reduce(false, { $0 || $1 == timedView.spruceView.view }) { |
Contributor
There was a problem hiding this comment.
Might it be cleaner to just say:
Suggested change
| if optionsObject.excludedViews.reduce(false, { $0 || $1 == timedView.spruceView.view }) { | |
| if optionsObject.excludedViews.contains(timedView.spruceView.view) { |
| /// - prepare: a `bool` as to whether we should run `prepare` on your view for you. If set to `true`, then we will run `prepare` right before the animation using the stock animations that you provided. If `false`, then `prepare` will not run. (default is `true`) | ||
| /// - completion: a closure that is called upon the final animation completing. A `Bool` is passed into the closure letting you know if the animation has completed. **Note:** If you stop animations on the whole animating view, then `false` will be passed into the completion closure. However, if the final animation is allowed to proceed then `true` will be the value passed into the completion closure. | ||
| public func animate(_ animations: [StockAnimation], duration: TimeInterval = 0.3, animationType: Animation, sortFunction: SortFunction, prepare: Bool = true, completion: CompletionHandler? = nil) { | ||
| public func animate(_ animations: [StockAnimation], duration: TimeInterval = 0.3, animationType: Animation, sortFunction: SortFunction, options: [AnimationOption] = [], completion: CompletionHandler? = nil) { |
Contributor
There was a problem hiding this comment.
You've reversed the default behavior here. Is that intentional? If not, this should be:
Suggested change
| public func animate(_ animations: [StockAnimation], duration: TimeInterval = 0.3, animationType: Animation, sortFunction: SortFunction, options: [AnimationOption] = [], completion: CompletionHandler? = nil) { | |
| public func animate(_ animations: [StockAnimation], duration: TimeInterval = 0.3, animationType: Animation, sortFunction: SortFunction, options: [AnimationOption] = [.prepare], completion: CompletionHandler? = nil) { |
| /// - completion: a closure that is called upon the final animation completing. A `Bool` is passed into the closure letting you know if the animation has completed. **Note:** If you stop animations on the whole animating view, then `false` will be passed into the completion closure. However, if the final animation is allowed to proceed then `true` will be the value passed into the completion closure. | ||
| public func animate(withSortFunction sortFunction: SortFunction, prepare: PrepareHandler? = nil, animation: Animation, exclude: [UIView]? = nil, recursiveDepth: Int = 0, completion: CompletionHandler? = nil) { | ||
| var timedViews = sortFunction.timeOffsets(view: self.view, recursiveDepth: recursiveDepth) | ||
| public func animate(withSortFunction sortFunction: SortFunction, prepare: PrepareHandler? = nil, animation: Animation, options: [AnimationOption] = [], completion: CompletionHandler? = nil) { |
Contributor
There was a problem hiding this comment.
Similarly, to keep the "prepare by default" behavior:
Suggested change
| public func animate(withSortFunction sortFunction: SortFunction, prepare: PrepareHandler? = nil, animation: Animation, options: [AnimationOption] = [], completion: CompletionHandler? = nil) { | |
| public func animate(withSortFunction sortFunction: SortFunction, prepare: PrepareHandler? = nil, animation: Animation, options: [AnimationOption] = [.prepare], completion: CompletionHandler? = nil) { |
| super.viewDidAppear(animated) | ||
|
|
||
| animationView?.spruce.animate(animations, duration: duration, animationType: animationType, sortFunction: sortFunction, prepare: false) | ||
| animationView?.spruce.animate(animations, duration: duration, animationType: animationType, sortFunction: sortFunction) |
Contributor
There was a problem hiding this comment.
If you accept the above suggestions restoring the "prepare by default" behavior, then this should be:
Suggested change
| animationView?.spruce.animate(animations, duration: duration, animationType: animationType, sortFunction: sortFunction) | |
| animationView?.spruce.animate(animations, duration: duration, animationType: animationType, sortFunction: sortFunction, options: []) |
Jackson Taylor (jackson13info)
approved these changes
Aug 13, 2020
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Looks like the parameters were getting too large for Spruce. Decided to try and have it with AnimationOptions instead so that the method length is customized based off of how much you need. This way it will be easier to read and add more options in the future like PR #95.
Also added in the documentation for the new features