-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAlertComponent.js
148 lines (143 loc) · 4.17 KB
/
AlertComponent.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import React, { memo } from 'react';
import { Modal, View, StyleSheet, TouchableOpacity, Dimensions, TouchableWithoutFeedback, Text } from 'react-native';
import LinearGradient from 'react-native-linear-gradient';
import { BlurView } from '@react-native-community/blur';
const { width, height } = Dimensions.get('window');
const AlertComponent = ({
visible,
title,
message,
onConfirm,
confirmText,
cancelText = 'Cancel',
onCancel,
modalStyle = {},
confirmButtonStyle = {},
cancelButtonStyle = {},
confirmTextStyle = {fontSize:18},
cancelTextStyle = {fontSize:18},
confirmGradientColors = ['#56ab2f', '#a8e063'],
cancelGradientColors = ['#D31027', '#EA384D'],
}) => {
return (
<Modal
animationType="fade"
transparent={true}
visible={visible}
onRequestClose={onCancel} // Android back button için
>
<TouchableWithoutFeedback onPress={onCancel}>
<View style={styles.centeredView}>
{/* Blur the background outside the modal */}
<BlurView
style={styles.absoluteBlur}
blurType="light" // You can change this to "dark" or "extra light"
blurAmount={1} // Adjust the blur amount to make it more intense
/>
<TouchableWithoutFeedback onPress={() => {}}>
<View style={[styles.modalView, modalStyle]}>
<Text style={[styles.modalTitle]}>{title}</Text>
<Text style={[styles.modalMessage]}>{message}</Text>
<View style={styles.buttonContainer}>
{onCancel && (
<LinearGradient
colors={cancelGradientColors}
start={{x: 0, y: 0}}
end={{x: 1, y: 1}}
style={[styles.linearGradient, cancelButtonStyle, styles.buttonGap]}
>
<TouchableOpacity
onPress={onCancel}
style={styles.buttonContent}
accessibilityLabel="Cancel"
accessibilityRole="button"
>
<Text style={[styles.buttonText, cancelTextStyle]}>{cancelText}</Text>
</TouchableOpacity>
</LinearGradient>
)}
<LinearGradient
colors={confirmGradientColors}
start={{x: 0, y: 0}}
end={{x: 1, y: 1}}
style={[styles.linearGradient, confirmButtonStyle]}
>
<TouchableOpacity
onPress={onConfirm}
style={styles.buttonContent}
accessibilityLabel="Confirm"
accessibilityRole="button"
>
<Text style={[styles.buttonText, confirmTextStyle]}>{confirmText}</Text>
</TouchableOpacity>
</LinearGradient>
</View>
</View>
</TouchableWithoutFeedback>
</View>
</TouchableWithoutFeedback>
</Modal>
);
};
const styles = StyleSheet.create({
centeredView: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
modalView: {
margin: 50,
borderRadius: 20,
padding: 25,
alignItems: 'center',
shadowColor: '#000',
shadowOffset: {
width: 0,
height: height * 0.005,
},
shadowOpacity: 0.25,
shadowRadius: 4,
elevation: 5,
backgroundColor: 'white',
},
modalTitle: {
fontSize: 32,
color: 'black',
fontFamily: 'Poppins-Bold',
},
modalMessage: {
marginVertical: 30,
textAlign: 'center',
fontSize: 22,
color: '#555',
fontFamily: 'Poppins-Bold',
},
buttonContainer: {
flexDirection: 'row',
justifyContent: 'space-between',
width: '30%',
},
linearGradient: {
borderRadius: 10,
padding: 10,
flex: 1,
},
buttonContent: {
alignItems: 'center',
fontSize: 18,
fontWeight: 'bold',
},
buttonGap: {
marginRight: 15,
},
buttonText: {
color: 'white',
fontFamily: 'Poppins-Bold',
},
absoluteBlur: {
position: 'absolute',
width: width,
height: height,
},
});
export default memo(AlertComponent);