Skip to content

Commit 5bbc2ba

Browse files
authored
Merge pull request #1 from xxsnakerxx/confetti_reanimated
Reanimated + confetti
2 parents 1748c36 + 6ebdbd9 commit 5bbc2ba

30 files changed

+611
-117
lines changed

README.md

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,61 @@ A fully customizable alert system for React Native with promise-based API and qu
2020
- 🖼️ SVG icon support
2121
- ⚙️ Global styling and behavior configuration
2222
- ✅ Built-in helpers for success, error, and confirm dialogs
23+
- 🎉 Confetti support
2324
- 🌐 React Native Web support
2425

25-
## Demo
26+
## 📺 Demo
2627

27-
https://github.com/user-attachments/assets/aeb9a635-9ac5-451f-9005-96cdd6ad2361
28+
See how `react-native-alert-queue` works in action! 🚀
29+
30+
---
31+
32+
### 🛠 Basics
33+
34+
Basic usage:
35+
36+
![Basics Demo](./demo/basics.gif)
37+
38+
---
39+
40+
### 🎨 Customizations
41+
42+
Custom titles, messages, icons, buttons, and slots:
43+
44+
![Customizations Demo](./demo/customizations.gif)
45+
46+
---
47+
48+
### 🔄 Real-Time Updating
49+
50+
Dynamically update the alert while it's displayed:
51+
52+
![Updating Demo](./demo/updating.gif)
53+
54+
---
55+
56+
### 🎹 Keyboard Avoidance
57+
58+
Alerts automatically adjust position when the keyboard appears:
59+
60+
![Keyboard Avoidance Demo](./demo/keyboard-avoiding.gif)
61+
62+
---
63+
64+
### 🎉 Confetti Animation
65+
66+
Celebrate success with built-in confetti effects:
67+
68+
![Confetti Demo](./demo/confetti.gif)
69+
70+
---
71+
72+
## Requirements
73+
74+
- `2.x` versions require [`react-native-reanimated 3.x`](https://docs.swmansion.com/react-native-reanimated/).
75+
- If your project does not use Reanimated, you can use `react-native-alert-queue@1.x`.
76+
77+
Install `RN Reanimated` following [their official guide](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started#installation).
2878

2979
## Installation
3080

@@ -36,6 +86,9 @@ yarn add react-native-alert-queue
3686

3787
## Usage
3888

89+
> **Full working examples available!**
90+
> Explore the [example app here](https://github.com/xxsnakerxx/react-native-alert-queue/tree/main/example/src/containers) to see all features in action.
91+
3992
### Basic Setup
4093

4194
First, add the `AlertContainer` to your app:
@@ -119,6 +172,32 @@ const result = await alert.confirm({
119172
});
120173
```
121174

175+
### Confetti
176+
177+
```tsx
178+
alert.show({
179+
message: 'Welcome to the app!',
180+
confetti: true,
181+
});
182+
```
183+
184+
```tsx
185+
alert.show({
186+
title: 'Congratulations!',
187+
message: 'You are a winner!',
188+
confetti: {
189+
colors: ['#4CAF50', '#8BC34A', '#CDDC39', '#81C784', '#A5D6A7', '#C8E6C9'],
190+
numberOfPieces: 200,
191+
pieceDimensions: {
192+
height: 10,
193+
width: 30,
194+
},
195+
},
196+
});
197+
```
198+
199+
Confetti can be used with any alert type. Also, you can customize the confetti appearance globally in the config.
200+
122201
### Advanced Features
123202

124203
#### Custom Helper Functions
@@ -372,6 +451,7 @@ You can customize the default appearance and behavior of alerts using the `confi
372451
- `iconColor?: ColorValue` - Icon color
373452
- `iconSize?: number` - Icon size
374453
- `buttons?: AlertButton[]` - Array of buttons
454+
- `confetti?: boolean | ConfettiProps` - Confetti configuration
375455
- `renderMessage?: ({ style, text }) => ReactElement` - Custom message renderer
376456
- `renderTitle?: ({ style, text }) => ReactElement` - Custom title renderer
377457
- `renderButton?: (props) => ReactElement` - Custom button renderer
@@ -450,6 +530,9 @@ type AlertConfig = {
450530
color?: ColorValue;
451531
};
452532

533+
// Confetti configuration
534+
confetti?: ConfettiProps;
535+
453536
// Custom renderers for alert components
454537
renderTitle?: AlertProps['renderTitle'];
455538
renderMessage?: AlertProps['renderMessage'];

demo/basics.gif

2.23 MB
Loading

demo/confetti.gif

1.14 MB
Loading

demo/customizations.gif

2.19 MB
Loading

demo/keyboard-avoiding.gif

1.46 MB
Loading

demo/updating.gif

1.18 MB
Loading

example/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"react": "18.3.1",
1616
"react-dom": "18.3.1",
1717
"react-native": "0.76.9",
18+
"react-native-reanimated": "~3.16.1",
1819
"react-native-safe-area-context": "4.12.0",
1920
"react-native-web": "0.19.13"
2021
},

example/src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Basics } from './containers/Basics';
77
import { Customizations } from './containers/Customizations';
88
import { Updating } from './containers/Updating';
99
import { KeyboardAvoiding } from './containers/Keyboard';
10+
import { Confetti } from './containers/Confetti';
1011

1112
export default function App() {
1213
return (
@@ -19,6 +20,7 @@ export default function App() {
1920
<Customizations />
2021
<Updating />
2122
<KeyboardAvoiding />
23+
<Confetti />
2224
</ScrollView>
2325
</SafeAreaView>
2426
<AlertContainer />

example/src/containers/Basics.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const Basics = () => {
1212
message: 'I am an alert',
1313
})
1414
}
15-
text="Show Alert"
15+
text="Simple Alert"
1616
/>
1717
<Button
1818
onPress={() =>
@@ -24,7 +24,7 @@ export const Basics = () => {
2424
),
2525
})
2626
}
27-
text="Show Alert with long message"
27+
text="Long Message"
2828
/>
2929
<Button
3030
onPress={() => {
@@ -53,21 +53,21 @@ export const Basics = () => {
5353
],
5454
});
5555
}}
56-
text="Show 2 Alerts"
56+
text="Alerts queue"
5757
/>
5858
<Button
5959
onPress={() => {
6060
alert.success({
6161
message: 'I am a success alert',
6262
});
6363
}}
64-
text="Show Success Alert"
64+
text="Success"
6565
/>
6666
<Button
6767
onPress={() => {
6868
alert.error(new Error('I am an error alert'));
6969
}}
70-
text="Show Error Alert"
70+
text="Error"
7171
/>
7272
<Button
7373
onPress={async () => {
@@ -83,7 +83,7 @@ export const Basics = () => {
8383
alert.error(new Error('You pressed no'));
8484
}
8585
}}
86-
text="Show Confirm"
86+
text="Confirm"
8787
/>
8888
<Button
8989
onPress={async () => {
@@ -108,7 +108,7 @@ export const Basics = () => {
108108
],
109109
});
110110
}}
111-
text="Show Dismissible Alert"
111+
text="Dismissible alert"
112112
/>
113113
</Section>
114114
);
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/* eslint-disable react/no-unstable-nested-components */
2+
/* eslint-disable react-native/no-inline-styles */
3+
4+
import { alert } from 'react-native-alert-queue';
5+
import { Button } from '../components/Button';
6+
import { Section } from '../components/Section';
7+
import { Text, View } from 'react-native';
8+
9+
export const Confetti = () => {
10+
return (
11+
<Section title="Confetti">
12+
<Button
13+
onPress={() =>
14+
alert.show({
15+
title: 'Congrats!',
16+
confetti: true,
17+
})
18+
}
19+
text="Confetti Alert"
20+
/>
21+
<Button
22+
onPress={() =>
23+
alert.success({
24+
title: 'Congratulations!',
25+
message: 'You are a winner!',
26+
confetti: {
27+
colors: [
28+
'#4CAF50',
29+
'#8BC34A',
30+
'#CDDC39',
31+
'#81C784',
32+
'#A5D6A7',
33+
'#C8E6C9',
34+
],
35+
numberOfPieces: 200,
36+
pieceDimensions: {
37+
height: 10,
38+
width: 30,
39+
},
40+
},
41+
})
42+
}
43+
text="Custom Confetti"
44+
/>
45+
<Button
46+
onPress={() =>
47+
alert.show({
48+
beforeTitleSlot: () => (
49+
<Text style={{ fontSize: 70, textAlign: 'center' }}>🎂</Text>
50+
),
51+
title: 'Happy Birthday!',
52+
message: 'Best wishes on your special day!',
53+
confetti: {
54+
numberOfPieces: 300,
55+
pieceDimensions: {
56+
height: 20,
57+
width: 20,
58+
},
59+
renderPiece: ({ style }) => (
60+
<View
61+
style={[style, { width: 20, height: 20, borderRadius: 10 }]}
62+
/>
63+
),
64+
},
65+
})
66+
}
67+
text="Custom Confetti Piece"
68+
/>
69+
</Section>
70+
);
71+
};

0 commit comments

Comments
 (0)