Skip to content

Commit

Permalink
lint cpp code
Browse files Browse the repository at this point in the history
  • Loading branch information
hannojg committed Jan 28, 2024
1 parent a864791 commit a41c5d0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 256 deletions.
231 changes: 0 additions & 231 deletions package/README.md

This file was deleted.

49 changes: 24 additions & 25 deletions package/cpp/RNSkSkottieView.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ class RNSkSkottieRenderer : public RNSkRenderer, public std::enable_shared_from_
_animation->getObject()->seekFrame(0);
}

void setOnFinishAnimation(std::function<void()> onFinishAnimation) {
_onFinishAnimation = onFinishAnimation;
}
void setOnFinishAnimation(std::function<void()> onFinishAnimation) {
_onFinishAnimation = onFinishAnimation;
}

private:
bool performDraw(std::shared_ptr<RNSkCanvasProvider> canvasProvider) {
Expand Down Expand Up @@ -159,7 +159,7 @@ class RNSkSkottieRenderer : public RNSkRenderer, public std::enable_shared_from_
_totalPausedDuration = 0.0;

if (_onFinishAnimation != nullptr) {
_onFinishAnimation();
_onFinishAnimation();
}
}

Expand All @@ -171,7 +171,7 @@ class RNSkSkottieRenderer : public RNSkRenderer, public std::enable_shared_from_

std::shared_ptr<RNSkPlatformContext> _platformContext;
std::shared_ptr<JsiSkSkottie> _animation;
std::function<void()> _onFinishAnimation;
std::function<void()> _onFinishAnimation;
SkRect _srcR;
std::string _resizeMode = "contain";
double _startTime = -1.0;
Expand All @@ -181,9 +181,9 @@ class RNSkSkottieRenderer : public RNSkRenderer, public std::enable_shared_from_

class RNSkSkottieView : public RNSkView {
private:
std::shared_ptr<jsi::Function> onAnimationFinishPtr = nullptr;
bool isLooping = true;
std::shared_ptr<jsi::Function> onAnimationFinishPtr = nullptr;
bool isLooping = true;

public:
/**
* Constructor
Expand All @@ -192,22 +192,22 @@ class RNSkSkottieView : public RNSkView {
: RNSkView(context, canvasProvider,
std::make_shared<RNSkSkottieRenderer>(std::bind(&RNSkSkottieView::requestRedraw, this), context)) {

// Set the onFinish callback
std::static_pointer_cast<RNSkSkottieRenderer>(getRenderer())->setOnFinishAnimation([this](){
if (onAnimationFinishPtr != nullptr) {
auto runtime = getPlatformContext()->getJsRuntime();
onAnimationFinishPtr->call(*runtime, jsi::Value(false));
}

if (!isLooping) {
resetAnimation();
}
});
// Set the onFinish callback
std::static_pointer_cast<RNSkSkottieRenderer>(getRenderer())->setOnFinishAnimation([this]() {
if (onAnimationFinishPtr != nullptr) {
auto runtime = getPlatformContext()->getJsRuntime();
onAnimationFinishPtr->call(*runtime, jsi::Value(false));
}


if (!isLooping) {
resetAnimation();
}
});
}

void resetAnimation() {
std::static_pointer_cast<RNSkSkottieRenderer>(getRenderer())->resetPlayback();
setDrawingMode(RNSkDrawingMode::Default);
std::static_pointer_cast<RNSkSkottieRenderer>(getRenderer())->resetPlayback();
setDrawingMode(RNSkDrawingMode::Default);
}

~RNSkSkottieView() {
Expand All @@ -234,7 +234,6 @@ class RNSkSkottieView : public RNSkView {
std::sort(sortedProps.begin(), sortedProps.end(),
[](const auto& a, const auto& b) { return !(a.first == "start") && (b.first == "start" || a.first < b.first); });
}


for (auto& prop : sortedProps) {
if (prop.first == "src" && prop.second.getType() == RNJsi::JsiWrapperValueType::HostObject) {
Expand All @@ -257,7 +256,7 @@ class RNSkSkottieView : public RNSkView {
// Use a shared pointer to manage the lifecycle of the JSI function
onAnimationFinishPtr = std::make_shared<jsi::Function>(std::move(onAnimationFinish));
} else {
onAnimationFinishPtr = nullptr;
onAnimationFinishPtr = nullptr;
}

std::static_pointer_cast<RNSkSkottieRenderer>(getRenderer())->setStartTime(RNSkTime::GetSecs());
Expand All @@ -273,7 +272,7 @@ class RNSkSkottieView : public RNSkView {
std::static_pointer_cast<RNSkSkottieRenderer>(getRenderer())->resetPlayback();
setDrawingMode(RNSkDrawingMode::Default); // This will also trigger a requestRedraw
} else if (prop.first == "loop") {
isLooping = prop.second.getAsBool();
isLooping = prop.second.getAsBool();
}
}
}
Expand Down

0 comments on commit a41c5d0

Please sign in to comment.