Skip to content

Add in AnimationOption Objects#102

Open
Jackson Taylor (jacksontaylor13) wants to merge 1 commit intowillowtreeapps:masterfrom
jacksontaylor13:feature/add-in-animation-options
Open

Add in AnimationOption Objects#102
Jackson Taylor (jacksontaylor13) wants to merge 1 commit intowillowtreeapps:masterfrom
jacksontaylor13:feature/add-in-animation-options

Conversation

@jacksontaylor13
Copy link
Copy Markdown
Contributor

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

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 }) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: [])

Copy link
Copy Markdown

@jackson13info Jackson Taylor (jackson13info) left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha. Whoops!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants