added merge paths, oncomplete callback, specific frame setting#12
added merge paths, oncomplete callback, specific frame setting#12marcprux merged 10 commits intoskiptools:mainfrom
Conversation
Added MotionLoopMode enum: playOnce - play once and stop loop - loop forever (default) autoReverse - back-forth loop forever repeat(Int) - loop N times repeatBackwards(Int) - back-forth N times Added isPlaying parameter to MotionView (default: true)
Sources/SkipMotion/SkipMotion.swift
Outdated
| @@ -99,33 +111,45 @@ public struct MotionView : View { | |||
| if isPlaying { | |||
There was a problem hiding this comment.
There is a lot of branching here. Could we simplify this with some private extensions on LottieView that handle these optional values? E.g., something like:
#if !SKIP
private extension LottieView {
@ViewBuilder func currentFrameOptional(_ currentFrameOptional: Double?) -> some View {
if let currentFrameOptional {
return self.currentFrame(currentFrameOptional)
} else {
return self
}
}
}
#endifAnd then the body could be kept simple by just passing the optional values along like:
LottieView(animation: lottieContainer.lottieAnimation)
.currentProgressOptional(progressOptional)
.animationSpeedOptional(animationSpeedOptional)
.currentFrameOptional(currentFrameOptional)
.resizable()
.scaledToFillOptional(when: contentMode == .fit)There was a problem hiding this comment.
great idea. had some problems with my initial viewbuilder attempt but I'm all for shorter more readable code. just tried to get it working first ;) do you want me to try updating it with that approach or are you already doing it? I'll gladly do it!
There was a problem hiding this comment.
Yes, please give it a shot and if you run into issues, I'll be happy to help out.
Sources/SkipMotion/SkipMotion.swift
Outdated
There was a problem hiding this comment.
You shouldn't need SKIP @nobridge for private vars. They won't be bridged by default.
|
oh no, again these merge conflicts... still dont get why. however this should be much less code, let me know if theres anything else. |
|
Great, thanks for the contribution and for the fixes! |
|
no problem, its fun :-) |
Thank you for contributing to the Skip project! Please use this space to describe your change and add any labels (bug, enhancement, documentation, etc.) to help categorize your contribution.
Skip Pull Request Checklist:
swift test