Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions frontend/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "react-native-gesture-handler";
import Theme from "./components/Shared/Theme";
import AuthModal from "./components/Pages/Auth/AuthModal";
import MainNavigator from "./components/Navigation";
import Confetti from "./components/Shared/Confetti/Confetti";
import { CommunityProvider } from "./components/Contexts/CommunityContext";

export default function App() {
Expand All @@ -17,6 +18,7 @@ export default function App() {
<CommunityProvider>
<NavigationContainer>
<AuthModal />
<Confetti />
<MainNavigator />
</NavigationContainer>
</CommunityProvider>
Expand Down
8 changes: 7 additions & 1 deletion frontend/components/Pages/ActionsPage/ActionDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { CommunityContext, useDetails } from "../../Contexts/CommunityContext";
import { TestimonialCard } from "../TestimonialsPage/TestimonialsCard";
import Ionicons from "react-native-vector-icons/Ionicons";
import { getActionMetric } from "../../Shared/Utils";
import ConfettiController from "../../Shared/Confetti/ConfettiController";

export default function ActionDetails({ route, navigation }) {
const { action_id } = route.params;
Expand Down Expand Up @@ -142,6 +143,11 @@ export default function ActionDetails({ route, navigation }) {
}
};

const completeThisAction = () => {
setIsDoneOpen(true);
ConfettiController.startConfetti();
}

return (
<Page>
{isActionLoading ? (
Expand Down Expand Up @@ -197,7 +203,7 @@ export default function ActionDetails({ route, navigation }) {
color: "white",
fontWeight: "bold",
}}
onPress={() => setIsDoneOpen(true)}
onPress={completeThisAction}
>
Done
</Button>
Expand Down
38 changes: 38 additions & 0 deletions frontend/components/Shared/Confetti/Confetti.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React, { forwardRef, useLayoutEffect, useState } from "react";

import { View } from "native-base";
import ConfettiCannon from "react-native-confetti-cannon";

import ConfettiController from "./ConfettiController";

const Confetti = () => {
let ref;
const [isConfettiVisible, setIsConfettiVisible] = useState(false);

useLayoutEffect(() => {
ConfettiController.setConfettiRef(ref);
}, []);

return (
<View
position="absolute"
height="100%"
width="100%"
zIndex={999}
display={isConfettiVisible ? "block" : "none"}
>
<ConfettiCannon
count={50}
origin={{ x: -10, y: 0 }}
fallSpeed={1500}
fadeOut={true}
autoStart={false}
onAnimationStart={() => setIsConfettiVisible(true)}
onAnimationEnd={() => setIsConfettiVisible(false)}
ref={(_ref) => (ref = _ref)}
/>
</View>
);
};

export default forwardRef(Confetti);
15 changes: 15 additions & 0 deletions frontend/components/Shared/Confetti/ConfettiController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export default class ConfettiController {
static confettiRef;

static setConfettiRef = (ref) => {
this.confettiRef = ref;
};

static startConfetti() {
this.confettiRef?.start();
}

static stopConfetti() {
this.confettiRef?.stop();
}
}
6 changes: 6 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"pinar": "^0.12.2",
"react": "18.2.0",
"react-native": "0.72.3",
"react-native-confetti-cannon": "^1.5.2",
"react-native-gesture-handler": "~2.12.0",
"react-native-reanimated": "~3.3.0",
"react-native-render-html": "^6.3.4",
Expand Down