@tyrads.com/tyrads-sdk 1.1.15 → 2.0.0-beta.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 (158) hide show
  1. package/android/build.gradle +18 -2
  2. package/android/src/main/java/com/tyradssdk/TyradsSdkComposeViewManager.kt +112 -0
  3. package/android/src/main/java/com/tyradssdk/TyradsSdkModule.kt +21 -9
  4. package/android/src/main/java/com/tyradssdk/TyradsSdkPackage.kt +2 -1
  5. package/ios/Tyrads/Tyrads.swift +43 -18
  6. package/ios/TyradsSdk.mm +3 -1
  7. package/ios/TyradsSdk.swift +5 -4
  8. package/lib/commonjs/acmo/core/marquee.js +60 -0
  9. package/lib/commonjs/acmo/core/marquee.js.map +1 -0
  10. package/lib/commonjs/acmo/core/storage/storage.js +36 -0
  11. package/lib/commonjs/acmo/core/storage/storage.js.map +1 -0
  12. package/lib/commonjs/acmo/core/types/types.d.js +2 -0
  13. package/lib/commonjs/acmo/core/types/types.d.js.map +1 -0
  14. package/lib/commonjs/acmo/modules/dashboard/components/auto_scroller.js +87 -0
  15. package/lib/commonjs/acmo/modules/dashboard/components/auto_scroller.js.map +1 -0
  16. package/lib/commonjs/acmo/modules/dashboard/components/custom_card.js +41 -0
  17. package/lib/commonjs/acmo/modules/dashboard/components/custom_card.js.map +1 -0
  18. package/lib/commonjs/acmo/modules/dashboard/components/my_games_button.js +50 -0
  19. package/lib/commonjs/acmo/modules/dashboard/components/my_games_button.js.map +1 -0
  20. package/lib/commonjs/acmo/modules/dashboard/components/offer_info_section.js +163 -0
  21. package/lib/commonjs/acmo/modules/dashboard/components/offer_info_section.js.map +1 -0
  22. package/lib/commonjs/acmo/modules/dashboard/components/premium_header.js +103 -0
  23. package/lib/commonjs/acmo/modules/dashboard/components/premium_header.js.map +1 -0
  24. package/lib/commonjs/acmo/modules/dashboard/components/premium_option_1.js +186 -0
  25. package/lib/commonjs/acmo/modules/dashboard/components/premium_option_1.js.map +1 -0
  26. package/lib/commonjs/acmo/modules/dashboard/components/premium_option_2.js +104 -0
  27. package/lib/commonjs/acmo/modules/dashboard/components/premium_option_2.js.map +1 -0
  28. package/lib/commonjs/acmo/modules/dashboard/components/premium_option_3.js +43 -0
  29. package/lib/commonjs/acmo/modules/dashboard/components/premium_option_3.js.map +1 -0
  30. package/lib/commonjs/acmo/modules/dashboard/components/premium_option_4.js +215 -0
  31. package/lib/commonjs/acmo/modules/dashboard/components/premium_option_4.js.map +1 -0
  32. package/lib/commonjs/acmo/modules/dashboard/repository.js +71 -0
  33. package/lib/commonjs/acmo/modules/dashboard/repository.js.map +1 -0
  34. package/lib/commonjs/acmo/modules/dashboard/top_offers.js +137 -0
  35. package/lib/commonjs/acmo/modules/dashboard/top_offers.js.map +1 -0
  36. package/lib/commonjs/assets/images/premium_star.png +0 -0
  37. package/lib/commonjs/assets/images/right_arrow.png +0 -0
  38. package/lib/commonjs/assets/images/star_pointed.png +0 -0
  39. package/lib/commonjs/i18n.js +112 -0
  40. package/lib/commonjs/i18n.js.map +1 -0
  41. package/lib/commonjs/index.js +58 -1
  42. package/lib/commonjs/index.js.map +1 -1
  43. package/lib/module/acmo/core/marquee.js +54 -0
  44. package/lib/module/acmo/core/marquee.js.map +1 -0
  45. package/lib/module/acmo/core/storage/storage.js +29 -0
  46. package/lib/module/acmo/core/storage/storage.js.map +1 -0
  47. package/lib/module/acmo/core/types/types.d.js +2 -0
  48. package/lib/module/acmo/core/types/types.d.js.map +1 -0
  49. package/lib/module/acmo/modules/dashboard/components/auto_scroller.js +81 -0
  50. package/lib/module/acmo/modules/dashboard/components/auto_scroller.js.map +1 -0
  51. package/lib/module/acmo/modules/dashboard/components/custom_card.js +36 -0
  52. package/lib/module/acmo/modules/dashboard/components/custom_card.js.map +1 -0
  53. package/lib/module/acmo/modules/dashboard/components/my_games_button.js +45 -0
  54. package/lib/module/acmo/modules/dashboard/components/my_games_button.js.map +1 -0
  55. package/lib/module/acmo/modules/dashboard/components/offer_info_section.js +158 -0
  56. package/lib/module/acmo/modules/dashboard/components/offer_info_section.js.map +1 -0
  57. package/lib/module/acmo/modules/dashboard/components/premium_header.js +98 -0
  58. package/lib/module/acmo/modules/dashboard/components/premium_header.js.map +1 -0
  59. package/lib/module/acmo/modules/dashboard/components/premium_option_1.js +181 -0
  60. package/lib/module/acmo/modules/dashboard/components/premium_option_1.js.map +1 -0
  61. package/lib/module/acmo/modules/dashboard/components/premium_option_2.js +99 -0
  62. package/lib/module/acmo/modules/dashboard/components/premium_option_2.js.map +1 -0
  63. package/lib/module/acmo/modules/dashboard/components/premium_option_3.js +38 -0
  64. package/lib/module/acmo/modules/dashboard/components/premium_option_3.js.map +1 -0
  65. package/lib/module/acmo/modules/dashboard/components/premium_option_4.js +210 -0
  66. package/lib/module/acmo/modules/dashboard/components/premium_option_4.js.map +1 -0
  67. package/lib/module/acmo/modules/dashboard/repository.js +65 -0
  68. package/lib/module/acmo/modules/dashboard/repository.js.map +1 -0
  69. package/lib/module/acmo/modules/dashboard/top_offers.js +130 -0
  70. package/lib/module/acmo/modules/dashboard/top_offers.js.map +1 -0
  71. package/lib/module/assets/images/premium_star.png +0 -0
  72. package/lib/module/assets/images/right_arrow.png +0 -0
  73. package/lib/module/assets/images/star_pointed.png +0 -0
  74. package/lib/module/i18n.js +107 -0
  75. package/lib/module/i18n.js.map +1 -0
  76. package/lib/module/index.js +59 -2
  77. package/lib/module/index.js.map +1 -1
  78. package/lib/typescript/commonjs/src/acmo/core/marquee.d.ts +11 -0
  79. package/lib/typescript/commonjs/src/acmo/core/marquee.d.ts.map +1 -0
  80. package/lib/typescript/commonjs/src/acmo/core/storage/storage.d.ts +3 -0
  81. package/lib/typescript/commonjs/src/acmo/core/storage/storage.d.ts.map +1 -0
  82. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/auto_scroller.d.ts +10 -0
  83. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/auto_scroller.d.ts.map +1 -0
  84. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/custom_card.d.ts +9 -0
  85. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/custom_card.d.ts.map +1 -0
  86. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/my_games_button.d.ts +7 -0
  87. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/my_games_button.d.ts.map +1 -0
  88. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/offer_info_section.d.ts +10 -0
  89. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/offer_info_section.d.ts.map +1 -0
  90. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_header.d.ts +8 -0
  91. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_header.d.ts.map +1 -0
  92. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_option_1.d.ts +8 -0
  93. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_option_1.d.ts.map +1 -0
  94. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_option_2.d.ts +8 -0
  95. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_option_2.d.ts.map +1 -0
  96. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_option_3.d.ts +8 -0
  97. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_option_3.d.ts.map +1 -0
  98. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_option_4.d.ts +8 -0
  99. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_option_4.d.ts.map +1 -0
  100. package/lib/typescript/commonjs/src/acmo/modules/dashboard/repository.d.ts +2 -0
  101. package/lib/typescript/commonjs/src/acmo/modules/dashboard/repository.d.ts.map +1 -0
  102. package/lib/typescript/commonjs/src/acmo/modules/dashboard/top_offers.d.ts +10 -0
  103. package/lib/typescript/commonjs/src/acmo/modules/dashboard/top_offers.d.ts.map +1 -0
  104. package/lib/typescript/commonjs/src/i18n.d.ts +3 -0
  105. package/lib/typescript/commonjs/src/i18n.d.ts.map +1 -0
  106. package/lib/typescript/commonjs/src/index.d.ts +15 -1
  107. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  108. package/lib/typescript/module/src/acmo/core/marquee.d.ts +11 -0
  109. package/lib/typescript/module/src/acmo/core/marquee.d.ts.map +1 -0
  110. package/lib/typescript/module/src/acmo/core/storage/storage.d.ts +3 -0
  111. package/lib/typescript/module/src/acmo/core/storage/storage.d.ts.map +1 -0
  112. package/lib/typescript/module/src/acmo/modules/dashboard/components/auto_scroller.d.ts +10 -0
  113. package/lib/typescript/module/src/acmo/modules/dashboard/components/auto_scroller.d.ts.map +1 -0
  114. package/lib/typescript/module/src/acmo/modules/dashboard/components/custom_card.d.ts +9 -0
  115. package/lib/typescript/module/src/acmo/modules/dashboard/components/custom_card.d.ts.map +1 -0
  116. package/lib/typescript/module/src/acmo/modules/dashboard/components/my_games_button.d.ts +7 -0
  117. package/lib/typescript/module/src/acmo/modules/dashboard/components/my_games_button.d.ts.map +1 -0
  118. package/lib/typescript/module/src/acmo/modules/dashboard/components/offer_info_section.d.ts +10 -0
  119. package/lib/typescript/module/src/acmo/modules/dashboard/components/offer_info_section.d.ts.map +1 -0
  120. package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_header.d.ts +8 -0
  121. package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_header.d.ts.map +1 -0
  122. package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_option_1.d.ts +8 -0
  123. package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_option_1.d.ts.map +1 -0
  124. package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_option_2.d.ts +8 -0
  125. package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_option_2.d.ts.map +1 -0
  126. package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_option_3.d.ts +8 -0
  127. package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_option_3.d.ts.map +1 -0
  128. package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_option_4.d.ts +8 -0
  129. package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_option_4.d.ts.map +1 -0
  130. package/lib/typescript/module/src/acmo/modules/dashboard/repository.d.ts +2 -0
  131. package/lib/typescript/module/src/acmo/modules/dashboard/repository.d.ts.map +1 -0
  132. package/lib/typescript/module/src/acmo/modules/dashboard/top_offers.d.ts +10 -0
  133. package/lib/typescript/module/src/acmo/modules/dashboard/top_offers.d.ts.map +1 -0
  134. package/lib/typescript/module/src/i18n.d.ts +3 -0
  135. package/lib/typescript/module/src/i18n.d.ts.map +1 -0
  136. package/lib/typescript/module/src/index.d.ts +15 -1
  137. package/lib/typescript/module/src/index.d.ts.map +1 -1
  138. package/package.json +12 -1
  139. package/readme.md +71 -0
  140. package/src/acmo/core/marquee.tsx +62 -0
  141. package/src/acmo/core/storage/storage.ts +28 -0
  142. package/src/acmo/core/types/types.d.ts +94 -0
  143. package/src/acmo/modules/dashboard/components/auto_scroller.tsx +85 -0
  144. package/src/acmo/modules/dashboard/components/custom_card.tsx +31 -0
  145. package/src/acmo/modules/dashboard/components/my_games_button.tsx +40 -0
  146. package/src/acmo/modules/dashboard/components/offer_info_section.tsx +144 -0
  147. package/src/acmo/modules/dashboard/components/premium_header.tsx +81 -0
  148. package/src/acmo/modules/dashboard/components/premium_option_1.tsx +161 -0
  149. package/src/acmo/modules/dashboard/components/premium_option_2.tsx +104 -0
  150. package/src/acmo/modules/dashboard/components/premium_option_3.tsx +46 -0
  151. package/src/acmo/modules/dashboard/components/premium_option_4.tsx +184 -0
  152. package/src/acmo/modules/dashboard/repository.ts +95 -0
  153. package/src/acmo/modules/dashboard/top_offers.tsx +131 -0
  154. package/src/assets/images/premium_star.png +0 -0
  155. package/src/assets/images/right_arrow.png +0 -0
  156. package/src/assets/images/star_pointed.png +0 -0
  157. package/src/i18n.ts +115 -0
  158. package/src/index.tsx +64 -2
@@ -0,0 +1,184 @@
1
+ import React from 'react';
2
+ import {
3
+ View,
4
+ Text,
5
+ Image,
6
+ StyleSheet,
7
+ Dimensions,
8
+ TouchableOpacity,
9
+ } from 'react-native';
10
+ import AutoScrollPagerWithIndicators from './auto_scroller';
11
+ import numeral from 'numeral';
12
+ import Tyrads from '../../../../index';
13
+ import { useTranslation } from 'react-i18next';
14
+
15
+ const { width } = Dimensions.get('window');
16
+
17
+ interface PremiumOption4Props {
18
+ data: TransformedCampaign[];
19
+ premiumColor?: string;
20
+ }
21
+
22
+ const PremiumOption4: React.FC<PremiumOption4Props> = ({ data, premiumColor }) => {
23
+ return (
24
+ <AutoScrollPagerWithIndicators
25
+ totalPages={data.length}
26
+ premiumColor={premiumColor}
27
+ content={(page) => (
28
+ <View key={page}>
29
+ {
30
+ data[page] && (
31
+ <OfferBanner details={data[page]} index={page} premiumColor={premiumColor} />
32
+ )
33
+ }
34
+ </View>
35
+ )}
36
+ />
37
+ );
38
+ };
39
+
40
+ interface OfferBannerProps {
41
+ details: TransformedCampaign;
42
+ index: number;
43
+ premiumColor?: string;
44
+ }
45
+
46
+ const OfferBanner: React.FC<OfferBannerProps> = ({ details, index, premiumColor }) => {
47
+ const { t } = useTranslation();
48
+ return (
49
+ <View style={styles.outerContainer}>
50
+ <View style={styles.bannerContainer}>
51
+ <Image style={styles.bannerImage} source={{ uri: details.fileUrl }} resizeMode="cover" />
52
+
53
+ <View style={styles.starContainer}>
54
+ <Image
55
+ source={require('../../../../assets/images/premium_star.png')}
56
+ style={[styles.starIcon, { tintColor: premiumColor || '#1C90DF' }]}
57
+ />
58
+ <Text style={styles.index} numberOfLines={1} ellipsizeMode="tail">
59
+ {index + 1}
60
+ </Text>
61
+ </View>
62
+ </View>
63
+ <View style={styles.titleContainer}>
64
+ <View style={{ flexDirection: 'row', flex: 8, width: '70%' }}>
65
+ <Image style={styles.gameIcon} source={{ uri: details.thumbnail }} resizeMode="cover" />
66
+ <View style={{ marginLeft: 10 }}>
67
+ <Text style={styles.titleText}>{details.title}</Text>
68
+ <View style={styles.rewardDetails}>
69
+ <Image
70
+ source={{ uri: details.currency.adUnitCurrencyIcon }}
71
+ resizeMode="contain"
72
+ style={styles.coinIcon}
73
+ />
74
+ <Text style={styles.points}>{numeral(details.points).format("0.00a").toUpperCase()}</Text>
75
+ <Text style={styles.points}>{''}{details.currency.adUnitCurrencyName}</Text>
76
+ <Text style={styles.rewards}>
77
+ {' '}
78
+ {details.rewards} {t('dashboard.rewards', { count: details.rewards })}
79
+ </Text>
80
+ </View>
81
+ </View>
82
+ </View>
83
+ <TouchableOpacity
84
+ onPress={() => Tyrads.showOffers({ route: "campaign-details", campaignID: details.campaignId })}
85
+ style={[styles.playButton, { backgroundColor: premiumColor || '#1C90DF' }]}
86
+ >
87
+ <Text style={styles.playButtonText}>{t('dashboard.play_button')}</Text>
88
+ </TouchableOpacity>
89
+ </View>
90
+ </View>
91
+ );
92
+ };
93
+
94
+ const styles = StyleSheet.create({
95
+ outerContainer: {},
96
+ bannerContainer: {
97
+ width: width,
98
+ height: 190,
99
+ },
100
+ bannerImage: {
101
+ flex: 1,
102
+ borderRadius: 8,
103
+ },
104
+ starContainer: {
105
+ position: 'absolute',
106
+ top: 10,
107
+ left: 10,
108
+ backgroundColor: 'rgba(0,0,0,0)',
109
+ },
110
+ starIcon: {
111
+ width: 30,
112
+ height: 30,
113
+ },
114
+ index: {
115
+ position: 'absolute',
116
+ top: 0,
117
+ left: 0,
118
+ right: 0,
119
+ bottom: 0,
120
+ textAlign: 'center',
121
+ textAlignVertical: 'center',
122
+ color: 'white',
123
+ fontSize: 14,
124
+ fontWeight: 'bold',
125
+ },
126
+ titleContainer: {
127
+ flex: 1,
128
+ width: '91.5%',
129
+ flexDirection: 'row',
130
+ justifyContent: 'space-between',
131
+ alignItems: 'center',
132
+ padding: 8,
133
+ backgroundColor: 'rgba(0,0,0,0.5)',
134
+ position: 'absolute',
135
+ bottom: 0,
136
+ left: 0,
137
+ right: 0,
138
+ },
139
+ titleText: {
140
+ color: 'white',
141
+ fontSize: 14,
142
+ fontWeight: 'bold',
143
+ marginBottom: 4,
144
+ },
145
+ gameIcon: {
146
+ width: 35,
147
+ height: 35,
148
+ borderRadius: 8,
149
+ },
150
+ coinIcon: {
151
+ width: 16,
152
+ height: 16,
153
+ },
154
+ points: {
155
+ fontSize: 12,
156
+ marginLeft: 4,
157
+ fontWeight: 'bold',
158
+ color: 'white',
159
+ },
160
+ rewardDetails: {
161
+ flexDirection: 'row',
162
+ alignItems: 'center',
163
+ },
164
+ rewards: {
165
+ fontSize: 10,
166
+ fontStyle: 'italic',
167
+ color: 'lightgray',
168
+ },
169
+ playButton: {
170
+ paddingHorizontal: 12,
171
+ paddingVertical: 2,
172
+ height: 31,
173
+ borderRadius: 8,
174
+ alignItems: 'center',
175
+ justifyContent: 'center',
176
+ },
177
+ playButtonText: {
178
+ fontSize: 16,
179
+ fontWeight: 'bold',
180
+ color: 'white',
181
+ },
182
+ });
183
+
184
+ export default PremiumOption4;
@@ -0,0 +1,95 @@
1
+ import axios, { type AxiosResponse } from 'axios';
2
+ import { getData } from '../../core/storage/storage';
3
+
4
+ interface ApiHeaders {
5
+ languageCode: string;
6
+ premiumColor: string;
7
+ xUserId: string;
8
+ xApiKey: string;
9
+ xApiSecret: string;
10
+ xSdkPlatform: string;
11
+ xSdkVersion: string;
12
+ userAgent: string;
13
+ }
14
+
15
+ const transformCampaigns = (campaigns: Campaign[]): TransformedCampaign[] => {
16
+ return campaigns.map((campaign) => ({
17
+ campaignId: campaign.campaignId || 0,
18
+ appId: campaign.app?.id || 0,
19
+ title: campaign.app?.title || 'Unknown Title',
20
+ creativePackName:
21
+ campaign.creative?.creativePacks?.[0]?.creativePackName || '',
22
+ fileUrl:
23
+ campaign.creative?.creativePacks?.[0]?.creatives?.[0]?.fileUrl || '',
24
+ points: campaign.campaignPayout?.totalPayoutConverted || 0,
25
+ rewards: campaign.campaignPayout?.totalEvents || 0,
26
+ currency: campaign.currency || {},
27
+ thumbnail: campaign.app?.thumbnail || '',
28
+ premium: campaign.premium || false,
29
+ sortingScore: campaign.sortingScore || 0,
30
+ }));
31
+ };
32
+
33
+ export const fetchCampaignsData = async (
34
+ // setLanguage: (language: string) => void,
35
+ setPremiumColor: (color: string) => void,
36
+ setCampaigns: (campaigns: TransformedCampaign[]) => void,
37
+ setError: (error: string) => void,
38
+ setIsLoading: (loading: boolean) => void
39
+ ): Promise<void> => {
40
+ setIsLoading(true);
41
+
42
+ try {
43
+ const data: any = await getData('apiHeaders');
44
+ if (!data) {
45
+ throw new Error('apiHeaders data not found.');
46
+ }
47
+ const parsedHeaderData: ApiHeaders = JSON.parse(data);
48
+ // setLanguage(parsedHeaderData.languageCode);
49
+ setPremiumColor(parsedHeaderData.premiumColor);
50
+
51
+ const headers = {
52
+ 'Content-Type': 'application/json',
53
+ Accept: 'application/json',
54
+ 'X-User-ID': parsedHeaderData.xUserId,
55
+ 'X-API-Key': parsedHeaderData.xApiKey,
56
+ 'X-API-Secret': parsedHeaderData.xApiSecret,
57
+ 'X-SDK-Platform': parsedHeaderData.xSdkPlatform,
58
+ 'X-SDK-Version': parsedHeaderData.xSdkVersion,
59
+ 'User-Agent': parsedHeaderData.userAgent,
60
+ };
61
+
62
+ const response: AxiosResponse<{ data: Campaign[] }> = await axios.get(
63
+ `https://api.tyrads.com/v2.0/campaigns?lang=${parsedHeaderData.languageCode}`,
64
+ {
65
+ headers: headers,
66
+ }
67
+ );
68
+
69
+ const transformedCampaigns = transformCampaigns(response.data.data);
70
+
71
+ const hotOffers = transformedCampaigns
72
+ .sort((a, b) => {
73
+ if (a.premium && !b.premium) return -1;
74
+ if (!a.premium && b.premium) return 1;
75
+ return b.sortingScore - a.sortingScore;
76
+ })
77
+ .filter((item) => item.points > 0)
78
+ .slice(0, 5);
79
+
80
+ setCampaigns(hotOffers);
81
+ } catch (error: any) {
82
+ if (axios.isAxiosError(error) && error.response) {
83
+ console.log('Response Error:', error.response.data);
84
+ console.log('Status Code:', error.response.status);
85
+ console.log('Response Headers:', error.response.headers);
86
+ } else if (axios.isAxiosError(error) && error.request) {
87
+ console.log('No Response from API:', error.request);
88
+ } else {
89
+ console.log('Error setting up request:', error.message);
90
+ }
91
+ setError('Something went wrong, please try again');
92
+ } finally {
93
+ setIsLoading(false);
94
+ }
95
+ };
@@ -0,0 +1,131 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import {
3
+ View,
4
+ Text,
5
+ ActivityIndicator,
6
+ StyleSheet,
7
+ } from 'react-native';
8
+ import { fetchCampaignsData } from './repository';
9
+ import PremiumHeaderSection from './components/premium_header';
10
+ import CustomCard from './components/custom_card';
11
+ import MyGamesButton from './components/my_games_button';
12
+ import PremiumOption1 from './components/premium_option_1';
13
+ import PremiumOption2 from './components/premium_option_2';
14
+ import PremiumOption3 from './components/premium_option_3';
15
+ import PremiumOption4 from './components/premium_option_4';
16
+
17
+ interface TopOffersProps {
18
+ showMore?: boolean;
19
+ showMyOffers?: boolean;
20
+ showMyOffersEmptyView?: boolean;
21
+ style?: number;
22
+ }
23
+
24
+ const TopOffers: React.FC<TopOffersProps> = ({
25
+ showMore,
26
+ showMyOffers = false,
27
+ showMyOffersEmptyView = false,
28
+ style = 1,
29
+ }) => {
30
+ const [campaigns, setCampaigns] = useState<TransformedCampaign[]>([]);
31
+ const [isLoading, setIsLoading] = useState<boolean>(true);
32
+ const [error, setError] = useState<string | null>(null);
33
+ const [premiumColor, setPremiumColor] = useState<string>('#1C90DF');
34
+ // const [language, setLanguage] = useState<string>('en');
35
+
36
+ useEffect(() => {
37
+ fetchCampaignsData(
38
+ // setLanguage,
39
+ setPremiumColor,
40
+ setCampaigns,
41
+ setError,
42
+ setIsLoading
43
+ );
44
+ }, []);
45
+
46
+ if (isLoading) {
47
+ return (
48
+ <View style={styles.loadingContainer}>
49
+ <ActivityIndicator size="large" color="#007AFF" />
50
+ </View>
51
+ );
52
+ }
53
+
54
+ if (error) {
55
+ return (
56
+ <View style={styles.errorContainer}>
57
+ <Text style={styles.errorText}>Error: {error}</Text>
58
+ </View>
59
+ );
60
+ }
61
+
62
+ if (campaigns.length === 0) {
63
+ if (showMyOffersEmptyView) {
64
+ return (
65
+ <View style={styles.noCampaignContainer}>
66
+ <Text>No campaigns available</Text>
67
+ </View>
68
+ );
69
+ } else {
70
+ return <View />;
71
+ }
72
+ }
73
+
74
+ return (
75
+ <CustomCard style={{}}>
76
+ <View style={{ flex: 1 }}>
77
+ <PremiumHeaderSection showMore={showMore} premiumColor={premiumColor} />
78
+ <View style={styles.headerSpacer} />
79
+ {(() => {
80
+ switch (style) {
81
+ case 1:
82
+ return (
83
+ <PremiumOption1 data={campaigns} premiumColor={premiumColor} />
84
+ );
85
+ case 2:
86
+ return (
87
+ <PremiumOption2 data={campaigns} premiumColor={premiumColor} />
88
+ );
89
+ case 3:
90
+ return (
91
+ <PremiumOption3 data={campaigns} premiumColor={premiumColor} />
92
+ );
93
+ case 4:
94
+ return (
95
+ <PremiumOption4 data={campaigns} premiumColor={premiumColor} />
96
+ );
97
+ default:
98
+ return <Text>Please specify a correct style</Text>;
99
+ }
100
+ })()}
101
+ <View style={styles.gameListSpacer} />
102
+ {showMyOffers && <MyGamesButton premiumColor={premiumColor} />}
103
+ </View>
104
+ </CustomCard>
105
+ );
106
+ };
107
+
108
+ const styles = StyleSheet.create({
109
+ loadingContainer: {
110
+ flex: 1,
111
+ justifyContent: 'center',
112
+ alignItems: 'center',
113
+ },
114
+ errorContainer: {
115
+ padding: 16,
116
+ },
117
+ errorText: {
118
+ color: 'red',
119
+ },
120
+ noCampaignContainer: {
121
+ padding: 16,
122
+ },
123
+ headerSpacer: {
124
+ height: 10,
125
+ },
126
+ gameListSpacer: {
127
+ height: 10,
128
+ },
129
+ });
130
+
131
+ export default TopOffers;
package/src/i18n.ts ADDED
@@ -0,0 +1,115 @@
1
+ import i18n from 'i18next';
2
+ import { initReactI18next } from 'react-i18next';
3
+ import AsyncStorage from '@react-native-async-storage/async-storage';
4
+
5
+
6
+ const resources = {
7
+ en: {
8
+ translation: {
9
+ "dashboard": {
10
+ "suggested_offers": "Suggested Offers",
11
+ "more_offers": "More Offers",
12
+ "my_games": "My Games",
13
+ "play_button": "Play Now",
14
+ "top_ranking": "Top {{number}}",
15
+ "rewards_one": "Reward",
16
+ "rewards_other": "Rewards"
17
+ },
18
+
19
+
20
+ }
21
+ },
22
+ es: {
23
+ translation: {
24
+ "dashboard": {
25
+ "suggested_offers": "Ofertas sugeridas",
26
+ "more_offers": "Más ofertas",
27
+ "my_games": "Mis juegos",
28
+ "play_button": "Jugar Ahora",
29
+ "top_ranking": "Los mejores {{number}}",
30
+ "rewards_one": "Recompensa",
31
+ "rewards_other": "Recompensas"
32
+ },
33
+
34
+ }
35
+ },
36
+ id: {
37
+ translation: {
38
+ "dashboard": {
39
+ "suggested_offers": "Penawaran yang Disarankan",
40
+ "more_offers": "Penawaran Lainnya",
41
+ "my_games": "Permainan Saya",
42
+ "play_button": "Mainkan Sekarang",
43
+ "top_ranking": "Top {{number}}",
44
+ "rewards_one": "Hadiah",
45
+ "rewards_other": "Hadiah"
46
+ },
47
+ }
48
+ },
49
+ in: {
50
+ translation: {
51
+ "dashboard": {
52
+ "suggested_offers": "Penawaran yang Disarankan",
53
+ "more_offers": "Penawaran Lainnya",
54
+ "my_games": "Permainan Saya",
55
+ "play_button": "Mainkan Sekarang",
56
+ "top_ranking": "Top {{number}}",
57
+ "rewards_one": "Hadiah",
58
+ "rewards_other": "Hadiah"
59
+ },
60
+ }
61
+ },
62
+ ja: {
63
+ translation: {
64
+ "dashboard": {
65
+ "suggested_offers": "おすすめのオファー",
66
+ "more_offers": "その他のオファー",
67
+ "my_games": "マイゲーム",
68
+ "play_button": "プレイ する",
69
+ "top_ranking": "トップ {{number}}",
70
+ "rewards_one": "報酬",
71
+ "rewards_other": "報酬"
72
+ },
73
+ }
74
+ },
75
+ ko: {
76
+ translation: {
77
+ "dashboard": {
78
+ "suggested_offers": "추천 제안",
79
+ "more_offers": "더 많은 제안",
80
+ "my_games": "내 게임",
81
+ "play_button": "플레이 하고",
82
+ "top_ranking": "상위 {{number}}",
83
+ "rewards_one": "보상",
84
+ "rewards_other": "보상들"
85
+ },
86
+ }
87
+ }
88
+ };
89
+
90
+ const initializeI18n = async () => {
91
+ try {
92
+ const language:any = await AsyncStorage.getItem('language');
93
+ const storedLanguage: string = JSON.parse(language);
94
+ console.log('storedLanguage', storedLanguage);
95
+
96
+ const initialLanguage = storedLanguage;
97
+ await i18n
98
+ .use(initReactI18next)
99
+ .init({
100
+ resources,
101
+ fallbackLng: 'en',
102
+ lng: initialLanguage,
103
+ debug: __DEV__,
104
+ interpolation: {
105
+ escapeValue: false,
106
+ },
107
+ });
108
+ } catch (error) {
109
+ console.error('Error initializing i18n:', error);
110
+ }
111
+ };
112
+
113
+ initializeI18n();
114
+
115
+ export default i18n;
package/src/index.tsx CHANGED
@@ -1,4 +1,12 @@
1
- import { NativeModules, Platform } from 'react-native';
1
+ import { NativeModules, Platform, View,} from 'react-native';
2
+
3
+ import TopOffers from './acmo/modules/dashboard/top_offers';
4
+ import { saveData } from './acmo/core/storage/storage';
5
+ import { I18nextProvider } from 'react-i18next';
6
+ import i18n from './i18n';
7
+
8
+ // const TyradsSdkComposeView = requireNativeComponent('TyradsSdkComposeView');
9
+
2
10
 
3
11
  const LINKING_ERROR =
4
12
  `The package 'tyrads-sdk' doesn't seem to be linked. Make sure: \n\n` +
@@ -6,7 +14,7 @@ const LINKING_ERROR =
6
14
  '- You rebuilt the app after installing the package\n' +
7
15
  '- You are not using Expo Go\n';
8
16
 
9
- const Tyrads = NativeModules.TyradsSdk
17
+ const TyradsSdk = NativeModules.TyradsSdk
10
18
  ? NativeModules.TyradsSdk
11
19
  : new Proxy(
12
20
  {},
@@ -16,4 +24,58 @@ const Tyrads = NativeModules.TyradsSdk
16
24
  },
17
25
  }
18
26
  );
27
+
28
+ const Tyrads = {
29
+ init: (apiKey: string, apiSecret: string) => {
30
+ return TyradsSdk.init(apiKey, apiSecret);
31
+ },
32
+ loginUser: async (userId: string) =>{
33
+ try{
34
+ var data = await TyradsSdk.loginUser(userId);
35
+ console.log("data from login: ",data);
36
+
37
+ await saveData('apiHeaders', data);
38
+ await saveData('language', JSON.parse(data).languageCode);
39
+ }catch (err){
40
+ console.log(err);
41
+ }
42
+ return TyradsSdk.loginUser(userId);
43
+ },
44
+ showOffers: ({
45
+ launchMode = 3,
46
+ route,
47
+ campaignID = 0,
48
+ }: { launchMode?: number; route?: string; campaignID?: number } = {}) => {
49
+ if (Platform.OS === 'ios') {
50
+ return TyradsSdk.showOffers(launchMode, route, campaignID);
51
+ } else {
52
+ return TyradsSdk.showOffers(route, campaignID);
53
+ }
54
+ },
55
+ topPremiumOffers: ({
56
+ showMore = true,
57
+ showMyOffers = true,
58
+ showMyOffersEmptyView = false,
59
+ viewStyle = 1,
60
+ }: {
61
+ showMore?: boolean;
62
+ showMyOffers?: boolean;
63
+ showMyOffersEmptyView?: boolean;
64
+ viewStyle?: number;
65
+ } = {}) => {
66
+ return (
67
+ <I18nextProvider i18n={i18n}>
68
+ <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
69
+ <TopOffers
70
+ showMore={showMore}
71
+ showMyOffers={showMyOffers}
72
+ showMyOffersEmptyView={showMyOffersEmptyView}
73
+ style={viewStyle}
74
+ />
75
+ </View>
76
+ </I18nextProvider>
77
+ );
78
+ },
79
+ };
80
+
19
81
  export default Tyrads;