@thealteroffice/react-native-adgeist 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/java/com/adgeist/AdgeistPackage.kt +15 -7
  3. package/android/src/main/java/com/adgeist/implementation/AdgeistModuleImpl.kt +37 -28
  4. package/android/src/newarch/java/com/AdgeistModule.kt +4 -4
  5. package/android/src/oldarch/java/com/AdgeistModule.kt +4 -4
  6. package/lib/module/NativeAdgeist.js +5 -0
  7. package/lib/module/NativeAdgeist.js.map +1 -0
  8. package/lib/module/components/AdgeistProvider.js +29 -0
  9. package/lib/module/components/AdgeistProvider.js.map +1 -0
  10. package/lib/module/components/BannerAd.js +69 -109
  11. package/lib/module/components/BannerAd.js.map +1 -1
  12. package/lib/module/index.js +1 -1
  13. package/lib/module/index.js.map +1 -1
  14. package/lib/typescript/src/NativeAdgeist.d.ts +2 -2
  15. package/lib/typescript/src/NativeAdgeist.d.ts.map +1 -1
  16. package/lib/typescript/src/components/AdgeistProvider.d.ts +18 -0
  17. package/lib/typescript/src/components/AdgeistProvider.d.ts.map +1 -0
  18. package/lib/typescript/src/components/BannerAd.d.ts +0 -1
  19. package/lib/typescript/src/components/BannerAd.d.ts.map +1 -1
  20. package/lib/typescript/src/index.d.ts +1 -1
  21. package/lib/typescript/src/index.d.ts.map +1 -1
  22. package/package.json +4 -4
  23. package/plugin/build/index.js +1 -1
  24. package/src/NativeAdgeist.ts +12 -2
  25. package/src/components/AdgeistProvider.tsx +41 -0
  26. package/src/components/BannerAd.tsx +105 -108
  27. package/src/index.tsx +1 -1
  28. package/lib/module/NativeAdgeist.ts +0 -14
  29. package/lib/module/components/BottomBannerAd.js +0 -150
  30. package/lib/module/components/BottomBannerAd.js.map +0 -1
  31. package/lib/typescript/src/components/BottomBannerAd.d.ts +0 -8
  32. package/lib/typescript/src/components/BottomBannerAd.d.ts.map +0 -1
  33. package/src/components/BottomBannerAd.tsx +0 -185
@@ -1,185 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import {
3
- Dimensions,
4
- Image,
5
- Linking,
6
- StyleSheet,
7
- Text,
8
- View,
9
- TouchableOpacity,
10
- TouchableWithoutFeedback,
11
- } from 'react-native';
12
- import Adgeist from '../NativeAdgeist';
13
-
14
- interface Creative {
15
- fileUrl: string;
16
- title: string;
17
- description: string;
18
- ctaUrl?: string;
19
- }
20
-
21
- interface AdData {
22
- _id: string;
23
- creative: Creative;
24
- }
25
-
26
- interface AdBannerTypes {
27
- dataPublisherId: string;
28
- dataAdSlot: string;
29
- }
30
-
31
- export const BottomBannerAd: React.FC<AdBannerTypes> = ({
32
- dataPublisherId,
33
- dataAdSlot,
34
- }) => {
35
- const [adData, setAdData] = useState<AdData | null>(null);
36
-
37
- useEffect(() => {
38
- (async () => {
39
- try {
40
- const response: Object = await Adgeist.fetchCreative(
41
- dataAdSlot,
42
- dataPublisherId
43
- );
44
- const creative: { data: AdData } = response as { data: AdData };
45
- setAdData(creative.data);
46
- await Adgeist.sendCreativeAnalytic(
47
- creative.data._id,
48
- dataAdSlot,
49
- dataPublisherId,
50
- 'impression'
51
- );
52
- } catch (error) {
53
- console.error('Ad load failed:', error);
54
- }
55
- })();
56
- }, [dataPublisherId, dataAdSlot]);
57
-
58
- const handleClick = async () => {
59
- if (adData?.creative?.ctaUrl) {
60
- await Adgeist.sendCreativeAnalytic(
61
- adData._id,
62
- dataAdSlot,
63
- dataPublisherId,
64
- 'click'
65
- );
66
- Linking.openURL(adData.creative.ctaUrl).catch((err) =>
67
- console.error('Failed to open URL:', err)
68
- );
69
- }
70
- };
71
-
72
- if (!adData?.creative?.fileUrl) return null;
73
-
74
- return (
75
- <TouchableWithoutFeedback
76
- style={styles.container}
77
- onPress={handleClick}
78
- accessible
79
- accessibilityLabel="Ad Banner"
80
- >
81
- <View style={styles.adContent}>
82
- <Image style={styles.logo} source={{ uri: adData.creative.fileUrl }} />
83
- <View style={styles.textContainer}>
84
- <View style={styles.titleRow}>
85
- <Text style={styles.adBadge}>AD</Text>
86
- <Text style={styles.title} numberOfLines={1} ellipsizeMode="tail">
87
- {adData.creative.title}
88
- </Text>
89
- </View>
90
- <Text
91
- style={styles.description}
92
- numberOfLines={1}
93
- ellipsizeMode="tail"
94
- >
95
- {adData.creative.description}
96
- </Text>
97
- </View>
98
- <TouchableOpacity
99
- style={styles.button}
100
- onPress={handleClick}
101
- accessible
102
- accessibilityLabel="Visit Site Button"
103
- >
104
- <Text style={styles.buttonText}>Visit Site</Text>
105
- </TouchableOpacity>
106
- </View>
107
- </TouchableWithoutFeedback>
108
- );
109
- };
110
-
111
- const styles = StyleSheet.create({
112
- container: {
113
- backgroundColor: 'white',
114
- borderRadius: 10,
115
- },
116
- creative: {
117
- resizeMode: 'contain',
118
- borderTopLeftRadius: 10,
119
- borderTopRightRadius: 10,
120
- },
121
- options: {
122
- flexDirection: 'row',
123
- gap: 2,
124
- position: 'absolute',
125
- top: 5,
126
- left: 5,
127
- },
128
- option: {
129
- color: 'green',
130
- backgroundColor: '#00000022',
131
- width: 20,
132
- height: 20,
133
- textAlign: 'center',
134
- },
135
- adContent: {
136
- width: '100%',
137
- backgroundColor: 'white',
138
- flexDirection: 'row',
139
- justifyContent: 'space-between',
140
- paddingHorizontal: 10,
141
- paddingVertical: 10,
142
- alignItems: 'center',
143
- },
144
- logo: {
145
- width: 35,
146
- height: 35,
147
- resizeMode: 'contain',
148
- borderRadius: 2,
149
- },
150
- textContainer: {
151
- width: Dimensions.get('window').width - 150,
152
- },
153
- titleRow: {
154
- flexDirection: 'row',
155
- alignItems: 'center',
156
- gap: 5,
157
- width: Dimensions.get('window').width - 200,
158
- },
159
- adBadge: {
160
- color: 'white',
161
- backgroundColor: 'green',
162
- width: 40,
163
- borderRadius: 4,
164
- textAlign: 'center',
165
- },
166
- title: {
167
- color: 'black',
168
- },
169
- description: {
170
- color: 'black',
171
- },
172
- button: {
173
- paddingHorizontal: 10,
174
- paddingVertical: 5,
175
- borderWidth: 1,
176
- borderColor: 'green',
177
- borderRadius: 5,
178
- alignItems: 'center',
179
- justifyContent: 'center',
180
- height: 40,
181
- },
182
- buttonText: {
183
- color: 'green',
184
- },
185
- });