@thealteroffice/react-native-adgeist 0.0.1

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 (46) hide show
  1. package/Adgeist.podspec +28 -0
  2. package/LICENSE +20 -0
  3. package/README.md +65 -0
  4. package/android/build.gradle +101 -0
  5. package/android/generated/java/com/adgeist/NativeAdgeistSpec.java +42 -0
  6. package/android/generated/jni/CMakeLists.txt +36 -0
  7. package/android/generated/jni/RNAdgeistSpec-generated.cpp +38 -0
  8. package/android/generated/jni/RNAdgeistSpec.h +31 -0
  9. package/android/generated/jni/react/renderer/components/RNAdgeistSpec/RNAdgeistSpecJSI-generated.cpp +38 -0
  10. package/android/generated/jni/react/renderer/components/RNAdgeistSpec/RNAdgeistSpecJSI.h +80 -0
  11. package/android/gradle.properties +5 -0
  12. package/android/src/main/AndroidManifest.xml +3 -0
  13. package/android/src/main/AndroidManifestNew.xml +2 -0
  14. package/android/src/main/java/com/adgeist/AdgeistModule.kt +89 -0
  15. package/android/src/main/java/com/adgeist/AdgeistPackage.kt +33 -0
  16. package/ios/Adgeist.h +18 -0
  17. package/ios/Adgeist.mm +52 -0
  18. package/ios/AdgeistImpl.swift +57 -0
  19. package/ios/adgeist-Bridging-Header.h +2 -0
  20. package/ios/generated/RNAdgeistSpec/RNAdgeistSpec-generated.mm +46 -0
  21. package/ios/generated/RNAdgeistSpec/RNAdgeistSpec.h +71 -0
  22. package/ios/generated/RNAdgeistSpecJSI-generated.cpp +38 -0
  23. package/ios/generated/RNAdgeistSpecJSI.h +80 -0
  24. package/lib/module/NativeAdgeist.ts +14 -0
  25. package/lib/module/components/BannerAd.js +176 -0
  26. package/lib/module/components/BannerAd.js.map +1 -0
  27. package/lib/module/components/BottomBannerAd.js +150 -0
  28. package/lib/module/components/BottomBannerAd.js.map +1 -0
  29. package/lib/module/index.js +5 -0
  30. package/lib/module/index.js.map +1 -0
  31. package/lib/module/package.json +1 -0
  32. package/lib/typescript/package.json +1 -0
  33. package/lib/typescript/src/NativeAdgeist.d.ts +8 -0
  34. package/lib/typescript/src/NativeAdgeist.d.ts.map +1 -0
  35. package/lib/typescript/src/components/BannerAd.d.ts +10 -0
  36. package/lib/typescript/src/components/BannerAd.d.ts.map +1 -0
  37. package/lib/typescript/src/components/BottomBannerAd.d.ts +8 -0
  38. package/lib/typescript/src/components/BottomBannerAd.d.ts.map +1 -0
  39. package/lib/typescript/src/index.d.ts +3 -0
  40. package/lib/typescript/src/index.d.ts.map +1 -0
  41. package/package.json +170 -0
  42. package/react-native.config.js +12 -0
  43. package/src/NativeAdgeist.ts +14 -0
  44. package/src/components/BannerAd.tsx +202 -0
  45. package/src/components/BottomBannerAd.tsx +185 -0
  46. package/src/index.tsx +2 -0
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+
3
+ import React, { useEffect, useState } from 'react';
4
+ import { Dimensions, Image, Linking, StyleSheet, Text, View, TouchableOpacity, TouchableWithoutFeedback } from 'react-native';
5
+ import Adgeist from '../NativeAdgeist';
6
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
+ export const BottomBannerAd = ({
8
+ dataPublisherId,
9
+ dataAdSlot
10
+ }) => {
11
+ const [adData, setAdData] = useState(null);
12
+ useEffect(() => {
13
+ (async () => {
14
+ try {
15
+ const response = await Adgeist.fetchCreative(dataAdSlot, dataPublisherId);
16
+ const creative = response;
17
+ setAdData(creative.data);
18
+ await Adgeist.sendCreativeAnalytic(creative.data._id, dataAdSlot, dataPublisherId, 'impression');
19
+ } catch (error) {
20
+ console.error('Ad load failed:', error);
21
+ }
22
+ })();
23
+ }, [dataPublisherId, dataAdSlot]);
24
+ const handleClick = async () => {
25
+ if (adData?.creative?.ctaUrl) {
26
+ await Adgeist.sendCreativeAnalytic(adData._id, dataAdSlot, dataPublisherId, 'click');
27
+ Linking.openURL(adData.creative.ctaUrl).catch(err => console.error('Failed to open URL:', err));
28
+ }
29
+ };
30
+ if (!adData?.creative?.fileUrl) return null;
31
+ return /*#__PURE__*/_jsx(TouchableWithoutFeedback, {
32
+ style: styles.container,
33
+ onPress: handleClick,
34
+ accessible: true,
35
+ accessibilityLabel: "Ad Banner",
36
+ children: /*#__PURE__*/_jsxs(View, {
37
+ style: styles.adContent,
38
+ children: [/*#__PURE__*/_jsx(Image, {
39
+ style: styles.logo,
40
+ source: {
41
+ uri: adData.creative.fileUrl
42
+ }
43
+ }), /*#__PURE__*/_jsxs(View, {
44
+ style: styles.textContainer,
45
+ children: [/*#__PURE__*/_jsxs(View, {
46
+ style: styles.titleRow,
47
+ children: [/*#__PURE__*/_jsx(Text, {
48
+ style: styles.adBadge,
49
+ children: "AD"
50
+ }), /*#__PURE__*/_jsx(Text, {
51
+ style: styles.title,
52
+ numberOfLines: 1,
53
+ ellipsizeMode: "tail",
54
+ children: adData.creative.title
55
+ })]
56
+ }), /*#__PURE__*/_jsx(Text, {
57
+ style: styles.description,
58
+ numberOfLines: 1,
59
+ ellipsizeMode: "tail",
60
+ children: adData.creative.description
61
+ })]
62
+ }), /*#__PURE__*/_jsx(TouchableOpacity, {
63
+ style: styles.button,
64
+ onPress: handleClick,
65
+ accessible: true,
66
+ accessibilityLabel: "Visit Site Button",
67
+ children: /*#__PURE__*/_jsx(Text, {
68
+ style: styles.buttonText,
69
+ children: "Visit Site"
70
+ })
71
+ })]
72
+ })
73
+ });
74
+ };
75
+ const styles = StyleSheet.create({
76
+ container: {
77
+ backgroundColor: 'white',
78
+ borderRadius: 10
79
+ },
80
+ creative: {
81
+ resizeMode: 'contain',
82
+ borderTopLeftRadius: 10,
83
+ borderTopRightRadius: 10
84
+ },
85
+ options: {
86
+ flexDirection: 'row',
87
+ gap: 2,
88
+ position: 'absolute',
89
+ top: 5,
90
+ left: 5
91
+ },
92
+ option: {
93
+ color: 'green',
94
+ backgroundColor: '#00000022',
95
+ width: 20,
96
+ height: 20,
97
+ textAlign: 'center'
98
+ },
99
+ adContent: {
100
+ width: '100%',
101
+ backgroundColor: 'white',
102
+ flexDirection: 'row',
103
+ justifyContent: 'space-between',
104
+ paddingHorizontal: 10,
105
+ paddingVertical: 10,
106
+ alignItems: 'center'
107
+ },
108
+ logo: {
109
+ width: 35,
110
+ height: 35,
111
+ resizeMode: 'contain',
112
+ borderRadius: 2
113
+ },
114
+ textContainer: {
115
+ width: Dimensions.get('window').width - 150
116
+ },
117
+ titleRow: {
118
+ flexDirection: 'row',
119
+ alignItems: 'center',
120
+ gap: 5,
121
+ width: Dimensions.get('window').width - 200
122
+ },
123
+ adBadge: {
124
+ color: 'white',
125
+ backgroundColor: 'green',
126
+ width: 40,
127
+ borderRadius: 4,
128
+ textAlign: 'center'
129
+ },
130
+ title: {
131
+ color: 'black'
132
+ },
133
+ description: {
134
+ color: 'black'
135
+ },
136
+ button: {
137
+ paddingHorizontal: 10,
138
+ paddingVertical: 5,
139
+ borderWidth: 1,
140
+ borderColor: 'green',
141
+ borderRadius: 5,
142
+ alignItems: 'center',
143
+ justifyContent: 'center',
144
+ height: 40
145
+ },
146
+ buttonText: {
147
+ color: 'green'
148
+ }
149
+ });
150
+ //# sourceMappingURL=BottomBannerAd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useEffect","useState","Dimensions","Image","Linking","StyleSheet","Text","View","TouchableOpacity","TouchableWithoutFeedback","Adgeist","jsx","_jsx","jsxs","_jsxs","BottomBannerAd","dataPublisherId","dataAdSlot","adData","setAdData","response","fetchCreative","creative","data","sendCreativeAnalytic","_id","error","console","handleClick","ctaUrl","openURL","catch","err","fileUrl","style","styles","container","onPress","accessible","accessibilityLabel","children","adContent","logo","source","uri","textContainer","titleRow","adBadge","title","numberOfLines","ellipsizeMode","description","button","buttonText","create","backgroundColor","borderRadius","resizeMode","borderTopLeftRadius","borderTopRightRadius","options","flexDirection","gap","position","top","left","option","color","width","height","textAlign","justifyContent","paddingHorizontal","paddingVertical","alignItems","get","borderWidth","borderColor"],"sourceRoot":"../../../src","sources":["components/BottomBannerAd.tsx"],"mappings":";;AAAA,OAA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AG;EAC1C,CAAC;EACDtB,QAAQ,EAAE;IACRe,aAAa,EAAE,KAAK;IACpBa,UAAU,EAAE,QAAQ;IACpBZ,GAAG,EAAE,CAAC;IACNM,KAAK,EAAElE,UAAU,CAACyE,GAAG,CAAC,QAAQ,CAAC,CAACP,KAAK,GAAG;EAC1C,CAAC;EACDrB,OAAO,EAAE;IACPoB,KAAK,EAAE,OAAO;IACdZ,eAAe,EAAE,OAAO;IACxBa,KAAK,EAAE,EAAE;IACTZ,YAAY,EAAE,CAAC;IACfc,SAAS,EAAE;EACb,CAAC;EACDtB,KAAK,EAAE;IACLmB,KAAK,EAAE;EACT,CAAC;EACDhB,WAAW,EAAE;IACXgB,KAAK,EAAE;EACT,CAAC;EACDf,MAAM,EAAE;IACNoB,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE,CAAC;IAClBG,WAAW,EAAE,CAAC;IACdC,WAAW,EAAE,OAAO;IACpBrB,YAAY,EAAE,CAAC;IACfkB,UAAU,EAAE,QAAQ;IACpBH,cAAc,EAAE,QAAQ;IACxBF,MAAM,EAAE;EACV,CAAC;EACDhB,UAAU,EAAE;IACVc,KAAK,EAAE;EACT;AACF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ export * from "./components/BannerAd.js";
4
+ export * from "./components/BottomBannerAd.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,cAAc,0BAAuB;AACrC,cAAc,gCAA6B","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,8 @@
1
+ import type { TurboModule } from 'react-native';
2
+ export interface Spec extends TurboModule {
3
+ fetchCreative(adSpaceId: string, publisherId: string): Promise<Object>;
4
+ sendCreativeAnalytic(campaignId: string, adSpaceId: string, publisherId: string, eventType: string): Promise<Object>;
5
+ }
6
+ declare const _default: Spec;
7
+ export default _default;
8
+ //# sourceMappingURL=NativeAdgeist.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeAdgeist.d.ts","sourceRoot":"","sources":["../../../src/NativeAdgeist.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACvE,oBAAoB,CAClB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CAAC;CACpB;;AAED,wBAAiE"}
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ interface AdBannerTypes {
3
+ dataPublisherId: string;
4
+ dataAdSlot: string;
5
+ width: number;
6
+ height: number;
7
+ }
8
+ export declare const BannerAd: React.FC<AdBannerTypes>;
9
+ export {};
10
+ //# sourceMappingURL=BannerAd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BannerAd.d.ts","sourceRoot":"","sources":["../../../../src/components/BannerAd.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAwBnD,UAAU,aAAa;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA0F5C,CAAC"}
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ interface AdBannerTypes {
3
+ dataPublisherId: string;
4
+ dataAdSlot: string;
5
+ }
6
+ export declare const BottomBannerAd: React.FC<AdBannerTypes>;
7
+ export {};
8
+ //# sourceMappingURL=BottomBannerAd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BottomBannerAd.d.ts","sourceRoot":"","sources":["../../../../src/components/BottomBannerAd.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAyBnD,UAAU,aAAa;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA8ElD,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './components/BannerAd';
2
+ export * from './components/BottomBannerAd';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC"}
package/package.json ADDED
@@ -0,0 +1,170 @@
1
+ {
2
+ "name": "@thealteroffice/react-native-adgeist",
3
+ "version": "0.0.1",
4
+ "description": "Publishers can integrate our SDK to connect their ad spaces to the AdGeist marketplace.",
5
+ "source": "./src/index.tsx",
6
+ "main": "./lib/module/index.js",
7
+ "types": "./lib/typescript/src/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./lib/typescript/src/index.d.ts",
11
+ "default": "./lib/module/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "src",
17
+ "lib",
18
+ "android",
19
+ "ios",
20
+ "cpp",
21
+ "*.podspec",
22
+ "react-native.config.js",
23
+ "!ios/build",
24
+ "!android/build",
25
+ "!android/gradle",
26
+ "!android/gradlew",
27
+ "!android/gradlew.bat",
28
+ "!android/local.properties",
29
+ "!**/__tests__",
30
+ "!**/__fixtures__",
31
+ "!**/__mocks__",
32
+ "!**/.*"
33
+ ],
34
+ "scripts": {
35
+ "example": "yarn workspace react-native-adgeist-example",
36
+ "test": "jest",
37
+ "typecheck": "tsc",
38
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
39
+ "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
40
+ "prepare": "bob build",
41
+ "release": "release-it"
42
+ },
43
+ "keywords": [
44
+ "react-native",
45
+ "ios",
46
+ "android"
47
+ ],
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "git+https://github.com/the-alter-office/react-native-adgeist.git"
51
+ },
52
+ "author": "kishore <kishore@thealteroffice.com> (https://github.com/the-alter-office/react-native-adgeist)",
53
+ "license": "MIT",
54
+ "bugs": {
55
+ "url": "https://github.com/the-alter-office/react-native-adgeist/issues"
56
+ },
57
+ "homepage": "https://github.com/the-alter-office/react-native-adgeist#readme",
58
+ "publishConfig": {
59
+ "access": "public",
60
+ "registry": "https://registry.npmjs.org/"
61
+ },
62
+ "devDependencies": {
63
+ "@commitlint/config-conventional": "^19.6.0",
64
+ "@eslint/compat": "^1.2.7",
65
+ "@eslint/eslintrc": "^3.3.0",
66
+ "@eslint/js": "^9.22.0",
67
+ "@evilmartians/lefthook": "^1.5.0",
68
+ "@react-native-community/cli": "15.0.1",
69
+ "@react-native/eslint-config": "^0.78.0",
70
+ "@release-it/conventional-changelog": "^9.0.2",
71
+ "@types/jest": "^29.5.5",
72
+ "@types/react": "^19.0.0",
73
+ "commitlint": "^19.6.1",
74
+ "del-cli": "^5.1.0",
75
+ "eslint": "^9.22.0",
76
+ "eslint-config-prettier": "^10.1.1",
77
+ "eslint-plugin-prettier": "^5.2.3",
78
+ "jest": "^29.7.0",
79
+ "prettier": "^3.0.3",
80
+ "react": "19.0.0",
81
+ "react-native": "0.78.2",
82
+ "react-native-builder-bob": "^0.40.7",
83
+ "release-it": "^17.10.0",
84
+ "turbo": "^1.10.7",
85
+ "typescript": "^5.2.2"
86
+ },
87
+ "peerDependencies": {
88
+ "react": "*",
89
+ "react-native": "*"
90
+ },
91
+ "workspaces": [
92
+ "example"
93
+ ],
94
+ "packageManager": "yarn@3.6.1",
95
+ "jest": {
96
+ "preset": "react-native",
97
+ "modulePathIgnorePatterns": [
98
+ "<rootDir>/example/node_modules",
99
+ "<rootDir>/lib/"
100
+ ]
101
+ },
102
+ "commitlint": {
103
+ "extends": [
104
+ "@commitlint/config-conventional"
105
+ ]
106
+ },
107
+ "release-it": {
108
+ "git": {
109
+ "commitMessage": "chore: release ${version}",
110
+ "tagName": "v${version}"
111
+ },
112
+ "npm": {
113
+ "publish": true
114
+ },
115
+ "github": {
116
+ "release": true
117
+ },
118
+ "plugins": {
119
+ "@release-it/conventional-changelog": {
120
+ "preset": {
121
+ "name": "angular"
122
+ }
123
+ }
124
+ }
125
+ },
126
+ "prettier": {
127
+ "quoteProps": "consistent",
128
+ "singleQuote": true,
129
+ "tabWidth": 2,
130
+ "trailingComma": "es5",
131
+ "useTabs": false
132
+ },
133
+ "react-native-builder-bob": {
134
+ "source": "src",
135
+ "output": "lib",
136
+ "targets": [
137
+ "codegen",
138
+ [
139
+ "module",
140
+ {
141
+ "esm": true
142
+ }
143
+ ],
144
+ [
145
+ "typescript",
146
+ {
147
+ "project": "tsconfig.build.json"
148
+ }
149
+ ]
150
+ ]
151
+ },
152
+ "codegenConfig": {
153
+ "name": "RNAdgeistSpec",
154
+ "type": "modules",
155
+ "jsSrcsDir": "src",
156
+ "outputDir": {
157
+ "ios": "ios/generated",
158
+ "android": "android/generated"
159
+ },
160
+ "android": {
161
+ "javaPackageName": "com.adgeist"
162
+ },
163
+ "includesGeneratedCode": true
164
+ },
165
+ "create-react-native-library": {
166
+ "type": "turbo-module",
167
+ "languages": "kotlin-objc",
168
+ "version": "0.49.8"
169
+ }
170
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @type {import('@react-native-community/cli-types').UserDependencyConfig}
3
+ */
4
+ module.exports = {
5
+ dependency: {
6
+ platforms: {
7
+ android: {
8
+ cmakeListsPath: 'generated/jni/CMakeLists.txt',
9
+ },
10
+ },
11
+ },
12
+ };
@@ -0,0 +1,14 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+
4
+ export interface Spec extends TurboModule {
5
+ fetchCreative(adSpaceId: string, publisherId: string): Promise<Object>;
6
+ sendCreativeAnalytic(
7
+ campaignId: string,
8
+ adSpaceId: string,
9
+ publisherId: string,
10
+ eventType: string
11
+ ): Promise<Object>;
12
+ }
13
+
14
+ export default TurboModuleRegistry.getEnforcing<Spec>('Adgeist');
@@ -0,0 +1,202 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import {
3
+ Dimensions,
4
+ Image,
5
+ Linking,
6
+ StyleSheet,
7
+ Text,
8
+ View,
9
+ TouchableWithoutFeedback,
10
+ } from 'react-native';
11
+ import Adgeist from '../NativeAdgeist';
12
+
13
+ interface Creative {
14
+ fileUrl: string;
15
+ title: string;
16
+ description: string;
17
+ ctaUrl?: string;
18
+ }
19
+
20
+ interface AdData {
21
+ _id: string;
22
+ creative: Creative;
23
+ }
24
+
25
+ interface AdBannerTypes {
26
+ dataPublisherId: string;
27
+ dataAdSlot: string;
28
+ width: number;
29
+ height: number;
30
+ }
31
+
32
+ export const BannerAd: React.FC<AdBannerTypes> = ({
33
+ dataPublisherId,
34
+ dataAdSlot,
35
+ width,
36
+ height,
37
+ }) => {
38
+ const [adData, setAdData] = useState<AdData | null>(null);
39
+
40
+ useEffect(() => {
41
+ (async () => {
42
+ try {
43
+ const response: Object = await Adgeist.fetchCreative(
44
+ dataAdSlot,
45
+ dataPublisherId
46
+ );
47
+ const creative: { data: AdData } = response as { data: AdData };
48
+ setAdData(creative.data);
49
+
50
+ await Adgeist.sendCreativeAnalytic(
51
+ creative.data._id,
52
+ dataAdSlot,
53
+ dataPublisherId,
54
+ 'impression'
55
+ );
56
+ } catch (error) {
57
+ console.error('Ad load failed:', error);
58
+ }
59
+ })();
60
+ }, [dataPublisherId, dataAdSlot]);
61
+
62
+ const handleClick = async () => {
63
+ if (adData?.creative?.ctaUrl) {
64
+ await Adgeist.sendCreativeAnalytic(
65
+ adData._id,
66
+ dataAdSlot,
67
+ dataPublisherId,
68
+ 'click'
69
+ );
70
+ Linking.openURL(adData.creative.ctaUrl).catch((err) =>
71
+ console.error('Failed to open URL:', err)
72
+ );
73
+ }
74
+ };
75
+
76
+ if (!adData?.creative?.fileUrl) return null;
77
+
78
+ return (
79
+ <TouchableWithoutFeedback accessible accessibilityLabel="Ad Banner">
80
+ <View style={styles.container}>
81
+ <Image
82
+ style={[styles.creative, { width, height }]}
83
+ source={{ uri: adData.creative.fileUrl }}
84
+ />
85
+ <View style={styles.options}>
86
+ <Text style={styles.option}>x</Text>
87
+ <Text style={styles.option}>i</Text>
88
+ </View>
89
+ <View style={styles.adContent}>
90
+ <Image
91
+ style={styles.logo}
92
+ source={{ uri: adData.creative.fileUrl }}
93
+ />
94
+ <View style={styles.textContainer}>
95
+ <View style={styles.titleRow}>
96
+ <Text style={styles.adBadge}>AD</Text>
97
+ <Text style={styles.title} numberOfLines={1} ellipsizeMode="tail">
98
+ {adData.creative.title}
99
+ </Text>
100
+ </View>
101
+ <Text
102
+ style={styles.description}
103
+ numberOfLines={1}
104
+ ellipsizeMode="tail"
105
+ >
106
+ {adData.creative.description}
107
+ </Text>
108
+ </View>
109
+ <TouchableWithoutFeedback
110
+ onPress={handleClick}
111
+ accessible
112
+ accessibilityLabel="Visit Site Button"
113
+ >
114
+ <View style={styles.button}>
115
+ <Text style={styles.buttonText}>Visit Site</Text>
116
+ </View>
117
+ </TouchableWithoutFeedback>
118
+ </View>
119
+ </View>
120
+ </TouchableWithoutFeedback>
121
+ );
122
+ };
123
+
124
+ const styles = StyleSheet.create({
125
+ container: {
126
+ backgroundColor: 'white',
127
+ borderRadius: 10,
128
+ },
129
+ creative: {
130
+ resizeMode: 'contain',
131
+ borderTopLeftRadius: 10,
132
+ borderTopRightRadius: 10,
133
+ },
134
+ options: {
135
+ flexDirection: 'row',
136
+ gap: 2,
137
+ position: 'absolute',
138
+ top: 5,
139
+ left: 5,
140
+ },
141
+ option: {
142
+ color: 'green',
143
+ backgroundColor: '#00000022',
144
+ width: 20,
145
+ height: 20,
146
+ textAlign: 'center',
147
+ },
148
+ adContent: {
149
+ width: '100%',
150
+ backgroundColor: 'white',
151
+ flexDirection: 'row',
152
+ justifyContent: 'space-between',
153
+ paddingHorizontal: 10,
154
+ paddingVertical: 10,
155
+ alignItems: 'center',
156
+ borderBottomLeftRadius: 10,
157
+ borderBottomRightRadius: 10,
158
+ borderTopColor: '#00000022',
159
+ borderTopWidth: 1,
160
+ },
161
+ logo: {
162
+ width: 35,
163
+ height: 35,
164
+ resizeMode: 'contain',
165
+ borderRadius: 2,
166
+ },
167
+ textContainer: {
168
+ width: Dimensions.get('window').width - 150,
169
+ },
170
+ titleRow: {
171
+ flexDirection: 'row',
172
+ alignItems: 'center',
173
+ gap: 5,
174
+ width: Dimensions.get('window').width - 200,
175
+ },
176
+ adBadge: {
177
+ color: 'white',
178
+ backgroundColor: 'green',
179
+ width: 40,
180
+ borderRadius: 4,
181
+ textAlign: 'center',
182
+ },
183
+ title: {
184
+ color: 'black',
185
+ },
186
+ description: {
187
+ color: 'black',
188
+ },
189
+ button: {
190
+ paddingHorizontal: 10,
191
+ paddingVertical: 5,
192
+ borderWidth: 1,
193
+ borderColor: 'green',
194
+ borderRadius: 5,
195
+ alignItems: 'center',
196
+ justifyContent: 'center',
197
+ height: 40,
198
+ },
199
+ buttonText: {
200
+ color: 'green',
201
+ },
202
+ });