react-native-flyy 1.4.23 → 1.4.25

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 (36) hide show
  1. package/android/.project +2 -2
  2. package/android/.settings/org.eclipse.buildship.core.prefs +4 -1
  3. package/android/build.gradle +1 -1
  4. package/android/src/main/java/com/reactnativeflyy/FlyyModule.kt +72 -73
  5. package/android/src/main/java/com/reactnativeflyy/FlyyRouteActivity.java +4 -0
  6. package/ios/Montserrat-Bold.ttf +0 -0
  7. package/ios/ReactNativeFlyy.m +220 -117
  8. package/lib/commonjs/assets/images/check.png +0 -0
  9. package/lib/commonjs/assets/images/medal.png +0 -0
  10. package/lib/commonjs/assets/images/radio.png +0 -0
  11. package/lib/commonjs/assets/images/reward_flyy.png +0 -0
  12. package/lib/commonjs/assets/images/xmark.png +0 -0
  13. package/lib/commonjs/flyy_checkin_view.js +382 -0
  14. package/lib/commonjs/flyy_checkin_view.js.map +1 -0
  15. package/lib/commonjs/index.js +248 -3
  16. package/lib/commonjs/index.js.map +1 -1
  17. package/lib/module/assets/images/check.png +0 -0
  18. package/lib/module/assets/images/medal.png +0 -0
  19. package/lib/module/assets/images/radio.png +0 -0
  20. package/lib/module/assets/images/reward_flyy.png +0 -0
  21. package/lib/module/assets/images/xmark.png +0 -0
  22. package/lib/module/flyy_checkin_view.js +365 -0
  23. package/lib/module/flyy_checkin_view.js.map +1 -0
  24. package/lib/module/index.js +233 -3
  25. package/lib/module/index.js.map +1 -1
  26. package/lib/typescript/flyy_checkin_view.d.ts +19 -0
  27. package/lib/typescript/index.d.ts +22 -0
  28. package/package.json +4 -1
  29. package/react-native-flyy.podspec +1 -1
  30. package/src/assets/images/check.png +0 -0
  31. package/src/assets/images/medal.png +0 -0
  32. package/src/assets/images/radio.png +0 -0
  33. package/src/assets/images/reward_flyy.png +0 -0
  34. package/src/assets/images/xmark.png +0 -0
  35. package/src/flyy_checkin_view.tsx +214 -0
  36. package/src/index.tsx +219 -1
@@ -0,0 +1,365 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
3
+ // @ts-nocheck
4
+ import React, { Component } from "react";
5
+ import { View, Text, TouchableOpacity, StyleSheet, Image, VirtualizedList, Platform, ToastAndroid, Linking } from "react-native";
6
+ import Flyy from 'react-native-flyy';
7
+ import Toast from 'react-native-simple-toast';
8
+
9
+ class FlyyCheckinComponent extends Component {
10
+ constructor(...args) {
11
+ super(...args);
12
+
13
+ _defineProperty(this, "state", {
14
+ mileStoneData: [],
15
+ checkinOffer: [],
16
+ listItems: [],
17
+ persons: [1, 2, 3, 4, 5],
18
+ partnerId: "",
19
+ userId: "",
20
+ appData: "",
21
+ environment: 0
22
+ });
23
+ }
24
+
25
+ async componentDidMount() {
26
+ try {
27
+ const data = await Flyy.getUserData();
28
+ const appData = await Flyy.getAppData();
29
+ this.setState({
30
+ partnerId: data["partner_id"],
31
+ userId: data["user_id"],
32
+ environment: data["environment"],
33
+ appData: appData
34
+ });
35
+ } catch (e) {
36
+ console.error(e);
37
+ }
38
+
39
+ await this.fetchData();
40
+ }
41
+
42
+ async fetchData() {
43
+ this.setState({
44
+ listItems: []
45
+ });
46
+ const resp = await fetch(`https://${this.state.environment == 0 ? "ghc-stage" : "ghc"}.theflyy.com/api/v7/flyy_app_info`, {
47
+ headers: {
48
+ "X-Key": this.state.partnerId,
49
+ "Content-Type": "application/json",
50
+ "X-App-Data": this.state.appData
51
+ }
52
+ });
53
+ const data = await resp.json();
54
+
55
+ for (var key in data.info.offers) {
56
+ if (data.info.offers[key].offer_type_code === "checkin") {
57
+ this.setState({
58
+ checkinOffer: data.info.offers[key]
59
+ });
60
+ this.setState({
61
+ mileStoneData: data.info.offers[key].milestones
62
+ });
63
+ break;
64
+ }
65
+ }
66
+
67
+ var tempData = [];
68
+ var isRewardDay = false;
69
+ var isCheckedIn = false;
70
+
71
+ for (let i = 0; i < this.state.checkinOffer.total_streak; i++) {
72
+ for (let j = 0; j < this.state.mileStoneData.length; j++) {
73
+ if (i + 1 === parseInt(this.state.mileStoneData[j].value)) {
74
+ isRewardDay = true;
75
+ }
76
+ }
77
+
78
+ if (i + 1 <= this.state.checkinOffer.streak) {
79
+ isCheckedIn = true;
80
+ }
81
+
82
+ tempData.push({
83
+ "isRewardDay": isRewardDay,
84
+ "isCheckedIn": isCheckedIn
85
+ });
86
+ isRewardDay = false;
87
+ isCheckedIn = false;
88
+ }
89
+
90
+ this.setState({
91
+ listItems: tempData
92
+ });
93
+ }
94
+
95
+ async checkInApi() {
96
+ var url = `https://${this.state.environment == 0 ? "ghc-stage" : "ghc"}.theflyy.com/api/v1/checkin?offer_id=` + this.state.checkinOffer.id.toString();
97
+ const resp = await fetch(url, {
98
+ headers: {
99
+ "X-Key": this.state.partnerId,
100
+ "Content-Type": "application/json",
101
+ "X-App-Data": this.state.appData
102
+ }
103
+ });
104
+ const data = await resp.json();
105
+
106
+ if (data.success) {
107
+ this.fetchData();
108
+ } else {
109
+ this.notifyMessage(data.message);
110
+ }
111
+ }
112
+
113
+ notifyMessage(msg) {
114
+ if (Platform.OS === 'android') {
115
+ ToastAndroid.show(msg, ToastAndroid.SHORT);
116
+ } else {
117
+ Toast.showWithGravity(msg, Toast.SHORT, Toast.BOTTOM);
118
+ }
119
+ }
120
+
121
+ render() {
122
+ var _this$props$style$che3, _this$props$style3, _this$props$style$fon, _this$props$style4, _this$state$checkinOf, _this$props$style$che4, _this$props$style5, _this$props$style$fon2, _this$props$style6, _this$props$style$che5, _this$props$style7;
123
+
124
+ const Divider = ({
125
+ color = "black",
126
+ index
127
+ }) => {
128
+ return /*#__PURE__*/React.createElement(View, {
129
+ style: {
130
+ flexDirection: 'row'
131
+ }
132
+ }, React.Children.toArray(this.state.persons.map(() => {
133
+ return /*#__PURE__*/React.createElement(View, {
134
+ style: {
135
+ flexDirection: 'row'
136
+ }
137
+ }, /*#__PURE__*/React.createElement(View, {
138
+ style: {
139
+ height: 1,
140
+ width: 2,
141
+ backgroundColor: color,
142
+ borderRadius: 2
143
+ }
144
+ }), /*#__PURE__*/React.createElement(View, {
145
+ style: {
146
+ width: 1,
147
+ backgroundColor: "white",
148
+ borderRadius: 2
149
+ }
150
+ }));
151
+ })));
152
+ };
153
+
154
+ const getItemCount = () => this.state.listItems.length;
155
+
156
+ const getItem = (data, index) => ({
157
+ id: Math.random().toString(12).substring(0),
158
+ isRewardDay: data[index].isRewardDay,
159
+ isCheckedIn: data[index].isCheckedIn,
160
+ index: index
161
+ });
162
+
163
+ const Item = ({
164
+ title,
165
+ index
166
+ }) => {
167
+ var _this$props$style$che, _this$props$style, _this$props$style$che2, _this$props$style2;
168
+
169
+ const day = index + 1;
170
+ return /*#__PURE__*/React.createElement(View, {
171
+ style: {
172
+ justifyContent: "center",
173
+ alignItems: 'center',
174
+ alignContent: 'center'
175
+ }
176
+ }, /*#__PURE__*/React.createElement(View, {
177
+ style: {
178
+ flexDirection: 'row',
179
+ height: 35,
180
+ justifyContent: 'center',
181
+ alignItems: 'center'
182
+ }
183
+ }, title.isCheckedIn ? /*#__PURE__*/React.createElement(View, {
184
+ style: {
185
+ height: 1,
186
+ width: 15,
187
+ alignSelf: "center",
188
+ backgroundColor: index == 0 ? "white" : "black"
189
+ }
190
+ }) : /*#__PURE__*/React.createElement(Divider, {
191
+ color: index == 0 ? "white" : "black",
192
+ index: index
193
+ }), title.isRewardDay ? title.isCheckedIn ? /*#__PURE__*/React.createElement(Image, {
194
+ source: require('./assets/images/reward_flyy.png'),
195
+ style: {
196
+ height: 20,
197
+ width: 15
198
+ }
199
+ }) : /*#__PURE__*/React.createElement(Image, {
200
+ source: {
201
+ uri: this.state.checkinOffer["currency_icon_url"]
202
+ },
203
+ style: {
204
+ height: 20,
205
+ width: 20
206
+ }
207
+ }) : title.isCheckedIn ? /*#__PURE__*/React.createElement(View, {
208
+ style: {
209
+ height: 17,
210
+ width: 17,
211
+ backgroundColor: "black",
212
+ borderRadius: 15,
213
+ justifyContent: 'center',
214
+ alignItems: 'center'
215
+ }
216
+ }, /*#__PURE__*/React.createElement(Text, {
217
+ style: {
218
+ color: "white",
219
+ fontSize: 10
220
+ }
221
+ }, "\u2713")) : /*#__PURE__*/React.createElement(Image, {
222
+ source: require('./assets/images/radio.png'),
223
+ style: {
224
+ height: 20,
225
+ width: 20
226
+ }
227
+ }), index != this.state.listItems.length - 1 ? this.state.listItems[index + 1].isCheckedIn ? /*#__PURE__*/React.createElement(View, {
228
+ style: {
229
+ height: 1,
230
+ width: 15,
231
+ alignSelf: "center",
232
+ backgroundColor: index == this.state.listItems.length - 1 ? "white" : "black"
233
+ }
234
+ }) : /*#__PURE__*/React.createElement(Divider, {
235
+ color: index == this.state.listItems.length - 1 ? "white" : "black",
236
+ index: index
237
+ }) : /*#__PURE__*/React.createElement(View, {
238
+ style: {
239
+ width: 15
240
+ }
241
+ })), /*#__PURE__*/React.createElement(Text, {
242
+ style: {
243
+ textAlign: 'center',
244
+ color: title.isRewardDay ? (_this$props$style$che = (_this$props$style = this.props.style) === null || _this$props$style === void 0 ? void 0 : _this$props$style.checkInEarnColor) !== null && _this$props$style$che !== void 0 ? _this$props$style$che : "black" : (_this$props$style$che2 = (_this$props$style2 = this.props.style) === null || _this$props$style2 === void 0 ? void 0 : _this$props$style2.checkInDaysColor) !== null && _this$props$style$che2 !== void 0 ? _this$props$style$che2 : "black"
245
+ }
246
+ }, title.isRewardDay ? title.isCheckedIn ? "Won" : "Earn" : title.isCheckedIn ? "Day " + day : "Day " + day));
247
+ };
248
+
249
+ return /*#__PURE__*/React.createElement(TouchableOpacity, {
250
+ style: styles.main,
251
+ onPress: () => {
252
+ Flyy.openFlyyCheckinPage();
253
+ }
254
+ }, /*#__PURE__*/React.createElement(View, {
255
+ style: {
256
+ height: 10
257
+ }
258
+ }), /*#__PURE__*/React.createElement(Text, {
259
+ style: {
260
+ fontSize: 20,
261
+ color: (_this$props$style$che3 = (_this$props$style3 = this.props.style) === null || _this$props$style3 === void 0 ? void 0 : _this$props$style3.checkInTitleColor) !== null && _this$props$style$che3 !== void 0 ? _this$props$style$che3 : "black",
262
+ fontFamily: (_this$props$style$fon = (_this$props$style4 = this.props.style) === null || _this$props$style4 === void 0 ? void 0 : _this$props$style4.fontFamily) !== null && _this$props$style$fon !== void 0 ? _this$props$style$fon : "Montserrat-Regular"
263
+ }
264
+ }, (_this$state$checkinOf = this.state.checkinOffer["offer_type_title"]) !== null && _this$state$checkinOf !== void 0 ? _this$state$checkinOf : "N/A"), /*#__PURE__*/React.createElement(View, {
265
+ style: {
266
+ height: 10
267
+ }
268
+ }), /*#__PURE__*/React.createElement(View, {
269
+ style: {
270
+ flexDirection: 'row',
271
+ width: 250,
272
+ justifyContent: 'center'
273
+ }
274
+ }, /*#__PURE__*/React.createElement(Text, {
275
+ numberOfLines: 1,
276
+ style: {
277
+ fontSize: 18,
278
+ color: (_this$props$style$che4 = (_this$props$style5 = this.props.style) === null || _this$props$style5 === void 0 ? void 0 : _this$props$style5.checkInDescriptionColor) !== null && _this$props$style$che4 !== void 0 ? _this$props$style$che4 : "grey",
279
+ fontFamily: (_this$props$style$fon2 = (_this$props$style6 = this.props.style) === null || _this$props$style6 === void 0 ? void 0 : _this$props$style6.fontFamily) !== null && _this$props$style$fon2 !== void 0 ? _this$props$style$fon2 : "Montserrat-Regular",
280
+ textAlign: "center"
281
+ }
282
+ }, this.state.checkinOffer["description"] != null ? this.state.checkinOffer["description"].replace(/(<([^>]+)>)/ig, '') : "N/A")), /*#__PURE__*/React.createElement(View, {
283
+ style: {
284
+ height: 10
285
+ }
286
+ }), /*#__PURE__*/React.createElement(View, {
287
+ style: styles.listContainer
288
+ }, /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(VirtualizedList, {
289
+ data: this.state.listItems,
290
+ style: {
291
+ alignSelf: "center"
292
+ },
293
+ initialNumToRender: 4,
294
+ horizontal: true,
295
+ renderItem: ({
296
+ item,
297
+ index
298
+ }) => /*#__PURE__*/React.createElement(Item, {
299
+ title: item,
300
+ index: index
301
+ }),
302
+ getItemCount: getItemCount,
303
+ getItem: getItem
304
+ }))), /*#__PURE__*/React.createElement(View, {
305
+ style: {
306
+ height: 10
307
+ }
308
+ }), /*#__PURE__*/React.createElement(TouchableOpacity, {
309
+ style: styles.button,
310
+ onPress: async () => {
311
+ const eventId = this.state.checkinOffer["event_id"];
312
+ const url = this.state.checkinOffer["deeplink"];
313
+
314
+ if (eventId != null) {
315
+ if (url != "") {
316
+ const supported = await Linking.canOpenURL(url);
317
+
318
+ if (supported) {
319
+ await Linking.openURL(url);
320
+ }
321
+ }
322
+ } else {
323
+ this.checkInApi();
324
+ }
325
+ }
326
+ }, /*#__PURE__*/React.createElement(Text, {
327
+ style: {
328
+ fontSize: 20,
329
+ color: (_this$props$style$che5 = (_this$props$style7 = this.props.style) === null || _this$props$style7 === void 0 ? void 0 : _this$props$style7.checkInBtnTextColor) !== null && _this$props$style$che5 !== void 0 ? _this$props$style$che5 : "white",
330
+ paddingLeft: 10,
331
+ paddingRight: 10,
332
+ fontFamily: "Montserrat-Regular"
333
+ }
334
+ }, this.state.checkinOffer["checked_in"] ? "Checked In" : this.state.checkinOffer["button_text"] != "" ? this.state.checkinOffer["button_text"] : "Check In")));
335
+ }
336
+
337
+ }
338
+
339
+ const styles = StyleSheet.create({
340
+ main: {
341
+ backgroundColor: "white",
342
+ elevation: 5,
343
+ height: 210,
344
+ width: "90%",
345
+ alignItems: "center",
346
+ borderRadius: 10
347
+ },
348
+ listContainer: {
349
+ height: 60,
350
+ flexDirection: "row",
351
+ justifyContent: "center",
352
+ width: "100%",
353
+ alignItems: 'center',
354
+ alignContent: 'center',
355
+ backgroundColor: "white"
356
+ },
357
+ button: {
358
+ backgroundColor: "#f57242",
359
+ height: 35,
360
+ borderRadius: 5,
361
+ justifyContent: "center"
362
+ }
363
+ });
364
+ export default FlyyCheckinComponent;
365
+ //# sourceMappingURL=flyy_checkin_view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["flyy_checkin_view.tsx"],"names":["React","Component","View","Text","TouchableOpacity","StyleSheet","Image","VirtualizedList","Platform","ToastAndroid","Linking","Flyy","Toast","FlyyCheckinComponent","mileStoneData","checkinOffer","listItems","persons","partnerId","userId","appData","environment","componentDidMount","data","getUserData","getAppData","setState","e","console","error","fetchData","resp","fetch","state","headers","json","key","info","offers","offer_type_code","milestones","tempData","isRewardDay","isCheckedIn","i","total_streak","j","length","parseInt","value","streak","push","checkInApi","url","id","toString","success","notifyMessage","message","msg","OS","show","SHORT","showWithGravity","BOTTOM","render","Divider","color","index","flexDirection","Children","toArray","map","height","width","backgroundColor","borderRadius","getItemCount","getItem","Math","random","substring","Item","title","day","justifyContent","alignItems","alignContent","alignSelf","require","uri","fontSize","textAlign","props","style","checkInEarnColor","checkInDaysColor","styles","main","openFlyyCheckinPage","checkInTitleColor","fontFamily","checkInDescriptionColor","replace","listContainer","item","button","eventId","supported","canOpenURL","openURL","checkInBtnTextColor","paddingLeft","paddingRight","create","elevation"],"mappings":";;AAAA;AACA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,SAASC,IAAT,EAAeC,IAAf,EAAqBC,gBAArB,EAAsCC,UAAtC,EAAiDC,KAAjD,EAAwDC,eAAxD,EAAyEC,QAAzE,EAAmFC,YAAnF,EAAwGC,OAAxG,QAAuH,cAAvH;AACA,OAAOC,IAAP,MAAiB,mBAAjB;AACA,OAAOC,KAAP,MAAkB,2BAAlB;;AAEA,MAAMC,oBAAN,SAAmCZ,SAAnC,CAA6C;AAAA;AAAA;;AAAA,mCAEjC;AACJa,MAAAA,aAAa,EAAE,EADX;AAEJC,MAAAA,YAAY,EAAE,EAFV;AAGJC,MAAAA,SAAS,EAAE,EAHP;AAIJC,MAAAA,OAAO,EAAE,CAAC,CAAD,EAAG,CAAH,EAAK,CAAL,EAAO,CAAP,EAAS,CAAT,CAJL;AAKJC,MAAAA,SAAS,EAAE,EALP;A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,EAAE;AANZ,GADuB;AAS7B4B,EAAAA,aAAa,EAAE;AAAE/B,IAAAA,MAAM,EAAE,EAAV;AAAaJ,IAAAA,aAAa,EAAE,KAA5B;AAAkCgB,IAAAA,cAAc,EAAE,QAAlD;AAA2DX,IAAAA,KAAK,EAAC,MAAjE;AAAwEY,IAAAA,UAAU,EAAC,QAAnF;AAA4FC,IAAAA,YAAY,EAAC,QAAzG;AAAkHZ,IAAAA,eAAe,EAAE;AAAnI,GATc;AAU7B+B,EAAAA,MAAM,EAAE;AAAE/B,IAAAA,eAAe,EAAE,SAAnB;AAA8BF,IAAAA,MAAM,EAAE,EAAtC;AAA0CG,IAAAA,YAAY,EAAE,CAAxD;AAA2DS,IAAAA,cAAc,EAAE;AAA3E;AAVqB,CAAlB,CAAf;AAaA,eAAexE,oBAAf","sourcesContent":["// @ts-nocheck\nimport React, { Component } from \"react\";\nimport { View, Text, TouchableOpacity,StyleSheet,Image, VirtualizedList, Platform, ToastAndroid, Alert, Linking } from \"react-native\";\nimport Flyy from 'react-native-flyy';\nimport Toast from 'react-native-simple-toast';\n\nclass FlyyCheckinComponent extends Component {\n\n state = {\n mileStoneData: [],\n checkinOffer: [],\n listItems: [],\n persons: [1,2,3,4,5],\n partnerId: \"\",\n userId: \"\",\n appData: \"\",\n environment: 0\n };\n\n async componentDidMount(){\n try {\n const data = await Flyy.getUserData();\n const appData = await Flyy.getAppData();\n this.setState({ \n partnerId : data[\"partner_id\"],\n userId : data[\"user_id\"],\n environment : data[\"environment\"],\n appData: appData\n })\n } catch (e) {\n console.error(e);\n }\n\n await this.fetchData();\n }\n\n\n async fetchData(){\n this.setState({ listItems : []})\n const resp = await fetch(`https://${this.state.environment == 0 ? \"ghc-stage\" : \"ghc\"}.theflyy.com/api/v7/flyy_app_info`, {\n headers: {\n \"X-Key\": this.state.partnerId,\n \"Content-Type\": \"application/json\",\n \"X-App-Data\": this.state.appData\n }\n });\n const data = await resp.json();\n for (var key in data.info.offers) {\n if (data.info.offers[key].offer_type_code === \"checkin\") {\n this.setState({ checkinOffer : data.info.offers[key] })\n this.setState({ mileStoneData : data.info.offers[key].milestones })\n break;\n }\n }\n var tempData = [];\n var isRewardDay = false;\n var isCheckedIn = false;\n for (let i = 0; i < this.state.checkinOffer.total_streak; i++) {\n for (let j = 0; j < this.state.mileStoneData.length; j++) {\n if (i + 1 === parseInt(this.state.mileStoneData[j].value)) {\n isRewardDay = true;\n }\n }\n if (i+1 <= this.state.checkinOffer.streak) {\n isCheckedIn = true;\n }\n tempData.push({ \"isRewardDay\": isRewardDay, \"isCheckedIn\": isCheckedIn })\n isRewardDay = false;\n isCheckedIn = false;\n }\n this.setState({ listItems : tempData })\n }\n\n\n async checkInApi() {\n var url = `https://${this.state.environment == 0 ? \"ghc-stage\" : \"ghc\"}.theflyy.com/api/v1/checkin?offer_id=` + this.state.checkinOffer.id.toString();\n const resp = await fetch(url, {\n headers: {\n \"X-Key\": this.state.partnerId,\n \"Content-Type\": \"application/json\",\n \"X-App-Data\": this.state.appData\n }\n });\n const data = await resp.json();\n if (data.success) {\n this.fetchData()\n } else {\n this.notifyMessage(data.message)\n }\n }\n\n notifyMessage(msg:string) {\n if (Platform.OS === 'android') {\n ToastAndroid.show(msg, ToastAndroid.SHORT)\n } else {\n Toast.showWithGravity(msg, Toast.SHORT, Toast.BOTTOM);\n }\n }\n\n render() {\n const Divider = ({color = \"black\",index}:{color:any,index:any}) => {\n return (\n <View style={{ flexDirection: 'row'}}>\n {React.Children.toArray(\n this.state.persons.map(() => {\n return (\n <View style={{ flexDirection: 'row' }}>\n <View style={{ height: 1, width: 2, backgroundColor: color, borderRadius: 2 }} />\n <View style={{ width: 1, backgroundColor: \"white\", borderRadius: 2 }} />\n </View>\n );\n })\n )}\n </View>\n )\n }\n const getItemCount = () => this.state.listItems.length;\n const getItem = (data:any, index:any) => ({\n id: Math.random().toString(12).substring(0),\n isRewardDay: data[index].isRewardDay,\n isCheckedIn: data[index].isCheckedIn,\n index: index\n });\n const Item = ({ title, index }: {title:any,index:any}) => {\n const day = index + 1;\n return (\n <View style = {{justifyContent: \"center\",alignItems:'center',alignContent:'center'}}>\n <View style = {{flexDirection : 'row',height: 35,justifyContent:'center',alignItems:'center'}}>\n {title.isCheckedIn? <View style={{ height: 1, width: 15, alignSelf: \"center\" , backgroundColor: index == 0 ? \"white\" : \"black\"}} />:<Divider color={index == 0 ? \"white\" : \"black\"} index={index}/>}\n {title.isRewardDay ?\n title.isCheckedIn ? <Image source={require('./assets/images/reward_flyy.png')} style={{ height: 20, width: 15 }} /> : <Image source={{ uri: this.state.checkinOffer[\"currency_icon_url\"] }} style={{ height: 20, width: 20 }} />\n : title.isCheckedIn ?\n <View style = {{height:17,width:17,backgroundColor:\"black\",borderRadius:15,justifyContent:'center',alignItems:'center'}}><Text style={{color:\"white\",fontSize:10}}>✓</Text></View>\n : <Image source={require('./assets/images/radio.png')} style={{ height: 20, width: 20 }} />}\n {index != this.state.listItems.length-1 ? this.state.listItems[index+1].isCheckedIn ? <View style={{ height: 1, width: 15, alignSelf: \"center\" , backgroundColor: index == this.state.listItems.length-1 ? \"white\" : \"black\"}} />:<Divider color={index == this.state.listItems.length - 1 ? \"white\" : \"black\"} index={index}/>: <View style = {{width:15}}/>}\n </View>\n <Text style = {{textAlign: 'center',color: title.isRewardDay ? this.props.style?.checkInEarnColor ?? \"black\" : this.props.style?.checkInDaysColor ?? \"black\"}}>{title.isRewardDay ?\n title.isCheckedIn ? \"Won\" : \"Earn\"\n : title.isCheckedIn ? \"Day \"+day : \"Day \"+day}</Text>\n </View>\n )\n }\n return (\n <TouchableOpacity style={styles.main} onPress = {()=>{\n Flyy.openFlyyCheckinPage();\n }}>\n <View style={{ height: 10 }} />\n <Text style={{ fontSize: 20, color: this.props.style?.checkInTitleColor ?? \"black\", fontFamily: this.props.style?.fontFamily ?? \"Montserrat-Regular\" }}>\n {this.state.checkinOffer[\"offer_type_title\"] ?? \"N/A\"}\n </Text>\n <View style={{ height: 10 }} />\n <View style = {{flexDirection: 'row',width:250,justifyContent: 'center'}}>\n <Text numberOfLines={1} style={{ fontSize: 18, color: this.props.style?.checkInDescriptionColor ?? \"grey\", fontFamily: this.props.style?.fontFamily ?? \"Montserrat-Regular\",textAlign: \"center\"}}>\n {this.state.checkinOffer[\"description\"] != null ? this.state.checkinOffer[\"description\"].replace(/(<([^>]+)>)/ig, '') : \"N/A\"}\n </Text>\n </View>\n <View style={{ height: 10 }} />\n <View style={styles.listContainer}>\n <View>\n <VirtualizedList\n data={this.state.listItems}\n style = {{alignSelf: \"center\"}}\n initialNumToRender={4}\n horizontal={true}\n renderItem={({ item, index }) => <Item title={item} index={index} />}\n getItemCount={getItemCount}\n getItem={getItem}\n />\n </View>\n </View>\n <View style={{ height: 10 }} />\n <TouchableOpacity\n style={styles.button}\n onPress={async () => {\n const eventId = this.state.checkinOffer[\"event_id\"];\n const url = this.state.checkinOffer[\"deeplink\"];\n if(eventId != null){\n if (url != \"\") {\n const supported = await Linking.canOpenURL(url);\n if (supported) {\n await Linking.openURL(url);\n }\n }\n }else{\n this.checkInApi();\n }\n }}>\n <Text style={{\n fontSize: 20,\n color: this.props.style?.checkInBtnTextColor ?? \"white\",\n paddingLeft: 10, \n paddingRight: 10,\n fontFamily: \"Montserrat-Regular\"\n }}>{this.state.checkinOffer[\"checked_in\"] ? \"Checked In\" : this.state.checkinOffer[\"button_text\"] != \"\" ? this.state.checkinOffer[\"button_text\"] : \"Check In\"}</Text>\n </TouchableOpacity>\n </TouchableOpacity>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n main: {\n backgroundColor: \"white\",\n elevation: 5,\n height: 210,\n width: \"90%\",\n alignItems: \"center\",\n borderRadius: 10\n },\n listContainer: { height: 60,flexDirection: \"row\",justifyContent: \"center\",width:\"100%\",alignItems:'center',alignContent:'center',backgroundColor: \"white\"},\n button: { backgroundColor: \"#f57242\", height: 35, borderRadius: 5, justifyContent: \"center\" },\n});\n\nexport default FlyyCheckinComponent;"]}
@@ -1,9 +1,239 @@
1
- import React from 'react';
2
- import { Image, NativeModules, Text, TouchableOpacity, View } from 'react-native';
1
+ // @ts-nocheck
2
+ import React, { useEffect, useState } from 'react';
3
+ import { Image, NativeModules, Text, TouchableOpacity, View, Dimensions, Linking } from 'react-native';
4
+ import Draggable from 'react-native-draggable';
5
+ import FlyyCheckinComponent from './flyy_checkin_view';
6
+ import AsyncStorage from '@react-native-async-storage/async-storage';
3
7
  const {
4
8
  Flyy
5
9
  } = NativeModules;
6
- export default Flyy;
10
+ export default Flyy; // ****** Flyy CheckinView Widget ******
11
+
12
+ export const FlyyCheckinView = props => {
13
+ return /*#__PURE__*/React.createElement(FlyyCheckinComponent, {
14
+ style: {
15
+ checkInBtnTextColor: props.checkInBtnTextColor,
16
+ checkInTitleColor: props.checkInTitleColor,
17
+ checkInDescriptionColor: props.checkInDescriptionColor,
18
+ checkInDaysColor: props.checkInDaysColor,
19
+ checkInEarnColor: props.checkInEarnColor,
20
+ fontFamily: props.fontFamily
21
+ }
22
+ });
23
+ };
24
+ const windowHeight = Dimensions.get('window').height;
25
+ const windowWidth = Dimensions.get('window').width; // ****** Flyy Floating Widget ******
26
+
27
+ export const FlyyFloatingWidget = ({
28
+ props = {
29
+ backgroundColor: "#654EA3",
30
+ buttonHeight: 55,
31
+ buttonWidth: 55,
32
+ buttonCornerRadius: 40,
33
+ buttonIcon: require('./assets/images/rewardwidget.png'),
34
+ onPress: () => {},
35
+ x: windowWidth - 75,
36
+ y: windowHeight - 100,
37
+ minX: 5,
38
+ minY: 5,
39
+ maxX: windowWidth - 5,
40
+ maxY: windowHeight - 5,
41
+ show: true,
42
+ stick: false,
43
+ startDate: 0,
44
+ endDate: 0
45
+ }
46
+ }) => {
47
+ var _props$minX, _props$minY, _props$maxX, _props$maxY;
48
+
49
+ const [showWidget, setShowWidget] = useState(false);
50
+ const [userData, setUserData] = useState({});
51
+ const [iconUrl, setIconUrl] = useState(require('./assets/images/rewardwidget.png'));
52
+ const [backgroundColor, setBackgroundColor] = useState("#654EA3");
53
+ const [buttonSize, setButtonSize] = useState(55);
54
+ const [buttonXPosition, setButtonXPosition] = useState(windowWidth - 75);
55
+ const [buttonYPosition, setButtonYPosition] = useState(windowHeight - 100);
56
+ const [deeplink, setDeeplink] = useState(null);
57
+ const flyyConfigDate = "flyy_config_date";
58
+ var oldState = null;
59
+ var currentState = null;
60
+ var data = null;
61
+ useEffect(() => {
62
+ fetchData();
63
+ }, []);
64
+
65
+ const fetchData = async () => {
66
+ const sdkInfo = await Flyy.getUserData();
67
+ const appData = await Flyy.getAppData();
68
+ const resp = await fetch(`https://${sdkInfo["environment"] == 0 ? "ghc-stage" : "ghc"}.theflyy.com/api/v8/flyy_app_info`, {
69
+ headers: {
70
+ "X-Key": sdkInfo["partner_id"],
71
+ "Content-Type": "application/json",
72
+ "X-App-Data": appData
73
+ }
74
+ });
75
+ data = await resp.json();
76
+ const widgetConfig = data.info.floating_widget_configuration;
77
+
78
+ if (widgetConfig.icon_url != null && widgetConfig.icon_url != '') {
79
+ setIconUrl({
80
+ uri: widgetConfig.icon_url
81
+ });
82
+ } else {
83
+ setIconUrl(props.buttonIcon);
84
+ }
85
+
86
+ if (widgetConfig.color != null && widgetConfig.color != '') {
87
+ setBackgroundColor(widgetConfig.color);
88
+ } else {
89
+ setBackgroundColor(props.backgroundColor);
90
+ }
91
+
92
+ if (widgetConfig.size != null && widgetConfig.color != 0) {
93
+ setButtonSize(parseInt(data.info.floating_widget_configuration.size));
94
+ } else {
95
+ setButtonSize(props.buttonHeight);
96
+ } //FloatingButton Position
97
+
98
+
99
+ if (widgetConfig.position == "bottom_left") {
100
+ setButtonXPosition(10);
101
+ } else if (widgetConfig.position == "bottom_right") {
102
+ setButtonXPosition(windowWidth - 75);
103
+ } else if (widgetConfig.position == "upper_left") {
104
+ setButtonXPosition(10);
105
+ setButtonYPosition(10);
106
+ } else if (widgetConfig.position == "upper_right") {
107
+ setButtonXPosition(windowWidth - 75);
108
+ setButtonYPosition(10);
109
+ } //Set DeepLink
110
+
111
+
112
+ if (widgetConfig.deeplink != null && widgetConfig.deeplink != "") {
113
+ setDeeplink(widgetConfig.deeplink);
114
+ } //Set Visibility of FloatingButton
115
+
116
+
117
+ var currentDate = new Date();
118
+ const getDate = await AsyncStorage.getItem(flyyConfigDate);
119
+ var date = new Date(parseInt(getDate));
120
+ const diffTime = Math.abs(getDate - currentDate);
121
+ const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)) - 1;
122
+
123
+ if (diffDays != 0) {
124
+ var data = await Flyy.getAppOccurence(1);
125
+ }
126
+
127
+ const occurrenceCount = await Flyy.getAppOccurence(0);
128
+
129
+ if (widgetConfig.show_to_user && occurrenceCount <= widgetConfig.num_times) {
130
+ // var numberOfDaysToAdd = widgetConfig.num_days+1;
131
+ // var result = currentDate.setDate(currentDate.getDate() + numberOfDaysToAdd);
132
+ if (getDate === null) {
133
+ await AsyncStorage.setItem(flyyConfigDate, JSON.stringify(currentDate.getTime()));
134
+ }
135
+
136
+ const getDate2 = await AsyncStorage.getItem(flyyConfigDate);
137
+ var date = new Date(parseInt(getDate2));
138
+ const diffTime = Math.abs(getDate2 - currentDate);
139
+ const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)) - 1; //Show widget on same day
140
+
141
+ if (diffDays === 0) {
142
+ setShowWidget(true);
143
+ } else {
144
+ //reset occurrence on next day
145
+ await Flyy.getAppOccurence(1);
146
+
147
+ if (diffDays >= widgetConfig.num_days + 1) {
148
+ await AsyncStorage.setItem(flyyConfigDate, JSON.stringify(currentDate.getTime()));
149
+ setShowWidget(true);
150
+ }
151
+ }
152
+ } else {
153
+ const getDate2 = await AsyncStorage.getItem(flyyConfigDate);
154
+ var date = new Date(parseInt(getDate2));
155
+ const diffTime = Math.abs(getDate2 - currentDate);
156
+ const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
157
+
158
+ if (diffDays != 1) {
159
+ var data = await Flyy.getAppOccurence(1);
160
+ }
161
+ }
162
+ }; // if(props.show){
163
+ // if(props.startDate != null && props.startDate != 0){
164
+ // var now = new Date().getTime();
165
+ // if(now >= props.startDate && now <= props.endDate){
166
+ // props.show = true
167
+ // }else{
168
+ // props.show = false
169
+ // }
170
+ // }
171
+ // }
172
+ // AppState.addEventListener('change', state =>{
173
+ // console.log('AppState updated to', AppState.currentState)
174
+ // oldState = currentState;
175
+ // currentState = state;
176
+ // if(oldState == null){
177
+ // console.log('App is newly start :::')
178
+ // }})
179
+
180
+
181
+ return (// @ts-ignore
182
+ props.show && showWidget ? /*#__PURE__*/React.createElement(Draggable, {
183
+ x: buttonXPosition,
184
+ y: buttonYPosition,
185
+ minX: (_props$minX = props.minX) !== null && _props$minX !== void 0 ? _props$minX : 5,
186
+ minY: (_props$minY = props.minY) !== null && _props$minY !== void 0 ? _props$minY : 5,
187
+ maxX: (_props$maxX = props.maxX) !== null && _props$maxX !== void 0 ? _props$maxX : windowWidth - 5,
188
+ maxY: (_props$maxY = props.maxY) !== null && _props$maxY !== void 0 ? _props$maxY : windowHeight - 5,
189
+ renderSize: 56 // shouldReverse = {true}
190
+ ,
191
+ onDragRelease: props.stick ? () => {} : null,
192
+ isCircle: true
193
+ }, /*#__PURE__*/React.createElement(TouchableOpacity, {
194
+ onPress: deeplink != null ? async () => {
195
+ const supported = await Linking.canOpenURL(deeplink);
196
+ await Linking.openURL(deeplink);
197
+ } : props.onPress,
198
+ style: {
199
+ height: buttonSize,
200
+ width: buttonSize,
201
+ backgroundColor: backgroundColor,
202
+ borderRadius: buttonSize / 2,
203
+ justifyContent: 'center',
204
+ alignItems: 'center'
205
+ }
206
+ }, /*#__PURE__*/React.createElement(Image, {
207
+ source: iconUrl,
208
+ style: {
209
+ height: buttonSize * 55 / 100,
210
+ width: buttonSize * 55 / 100
211
+ }
212
+ }), /*#__PURE__*/React.createElement(TouchableOpacity, {
213
+ onPress: () => {
214
+ props.show = false;
215
+ setShowWidget(false);
216
+ console.log("SHOW PROPS :::");
217
+ console.log(props.show);
218
+ },
219
+ style: {
220
+ height: 20,
221
+ width: 20,
222
+ backgroundColor: "transparent",
223
+ position: 'absolute',
224
+ left: buttonSize - 11,
225
+ bottom: buttonSize * 72 / 100
226
+ }
227
+ }, /*#__PURE__*/React.createElement(Image, {
228
+ source: require('./assets/images/xmark.png'),
229
+ style: {
230
+ height: 18,
231
+ width: 18,
232
+ tintColor: "black"
233
+ }
234
+ })))) : /*#__PURE__*/React.createElement(View, null)
235
+ );
236
+ };
7
237
  export const FlyyWidget = ({
8
238
  widgetStyle = {
9
239
  rewardsButtonIcon: require('./assets/images/rewardwidget.png'),