react-native-flyy 1.4.32 → 1.4.33

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 +1 -1
  2. package/android/.settings/org.eclipse.buildship.core.prefs +5 -2
  3. package/android/build.gradle +1 -1
  4. package/android/src/main/java/com/reactnativeflyy/FlyyModule.kt +155 -49
  5. package/android/src/main/java/com/reactnativeflyy/FlyyRouteActivity.java +16 -0
  6. package/ios/Montserrat-Bold.ttf +0 -0
  7. package/ios/ReactNativeFlyy.m +276 -122
  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 +379 -0
  14. package/lib/commonjs/flyy_checkin_view.js.map +1 -0
  15. package/lib/commonjs/index.js +634 -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 +616 -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 +32 -0
  28. package/package.json +3 -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 +213 -0
  36. package/src/index.tsx +548 -1
package/src/index.tsx CHANGED
@@ -1,19 +1,371 @@
1
- import React from 'react';
1
+ // @ts-nocheck
2
+ import React, { useEffect, useState } from 'react';
2
3
  import {
3
4
  Image,
4
5
  NativeModules,
5
6
  Text,
6
7
  TouchableOpacity,
7
8
  View,
9
+ Dimensions,
10
+ AppState,
11
+ ToastAndroid,
12
+ Linking,
13
+ FlatList,
14
+ Alert
8
15
  } from 'react-native';
16
+ import FlyyCheckinComponent from './flyy_checkin_view';
17
+ import { FlyyStoriesWidget } from './flyy_stories';
18
+ import AsyncStorage from '@react-native-async-storage/async-storage';
19
+ import Draggable from 'react-native-draggable';
9
20
 
10
21
  type FlyyType = {
22
+ getUserId(arg0: (data: any) => void): unknown;
11
23
  multiply(a: number, b: number): Promise<number>;
12
24
  };
13
25
 
14
26
  const { Flyy } = NativeModules;
15
27
 
16
28
  export default Flyy as FlyyType;
29
+
30
+ // ****** Flyy CheckinView Widget ******
31
+ export const FlyyCheckinView = (props: any) => {
32
+ return (<FlyyCheckinComponent style={{
33
+ checkInBtnTextColor: props.checkInBtnTextColor,
34
+ checkInTitleColor: props.checkInTitleColor,
35
+ checkInDescriptionColor: props.checkInDescriptionColor,
36
+ checkInDaysColor: props.checkInDaysColor,
37
+ checkInEarnColor: props.checkInEarnColor,
38
+ fontFamily: props.fontFamily
39
+ }} />)
40
+ }
41
+ const windowHeight = Dimensions.get('window').height;
42
+ const windowWidth = Dimensions.get('window').width;
43
+
44
+ // ****** Flyy Floating Widget ******
45
+ export const FlyyFloatingWidget = ({
46
+ props = {
47
+ backgroundColor: "#654EA3",
48
+ buttonHeight: 55,
49
+ buttonWidth: 55,
50
+ buttonCornerRadius: 40,
51
+ buttonIcon: require('./assets/images/rewardwidget.png'),
52
+ onPress: () => { },
53
+ x: windowWidth - 75,
54
+ y: windowHeight - 100,
55
+ minX: 5,
56
+ minY: 5,
57
+ maxX: windowWidth - 5,
58
+ maxY: windowHeight - 5,
59
+ show: true,
60
+ stick: false,
61
+ startDate: 0,
62
+ endDate: 0
63
+ } }) => {
64
+
65
+ const [showWidget,setShowWidget] = useState(false);
66
+ const [userData,setUserData] = useState({});
67
+ const [iconUrl,setIconUrl] = useState(require('./assets/images/rewardwidget.png'));
68
+ const [backgroundColor,setBackgroundColor] = useState("#654EA3");
69
+ const [buttonSize,setButtonSize] = useState(55);
70
+ const [buttonXPosition,setButtonXPosition] = useState(windowWidth - 75);
71
+ const [buttonYPosition,setButtonYPosition] = useState(windowHeight - 200);
72
+ const [deeplink,setDeeplink] = useState(null);
73
+ const flyyConfigDate = "flyy_config_date";
74
+ const flyyConfigUserId = "user_id";
75
+ var oldState = null;
76
+ var currentState = null;
77
+ var data = null;
78
+
79
+ useEffect(()=>{
80
+ fetchData();
81
+ },[]);
82
+
83
+ const fetchData = async() => {
84
+ const sdkInfo = await Flyy.getUserData();
85
+ const appData = await Flyy.getAppData();
86
+ const resp = await fetch(`https://${sdkInfo["environment"] == 0 ? "ghc-stage" : "ghc"}.theflyy.com/api/v8/flyy_app_info`, {
87
+ headers: {
88
+ "X-Key": sdkInfo["partner_id"],
89
+ "Content-Type": "application/json",
90
+ "X-App-Data": appData
91
+ }
92
+ });
93
+ data = await resp.json();
94
+ if(!data.success){
95
+ if (Platform.OS === 'android') {
96
+ ToastAndroid.show(data.message, ToastAndroid.SHORT);
97
+ } else {
98
+ // Toast.showWithGravity(data.message, Toast.SHORT, Toast.BOTTOM);
99
+ Alert.alert(data.message);
100
+ }
101
+ return;
102
+ }
103
+ const widgetConfig = data.info.floating_widget_configuration;
104
+
105
+ if (widgetConfig.icon_url != null && widgetConfig.icon_url != '') {
106
+ setIconUrl({ uri: widgetConfig.icon_url })
107
+ } else {
108
+ setIconUrl(props.buttonIcon)
109
+ }
110
+
111
+ if (widgetConfig.color != null && widgetConfig.color != '') {
112
+ setBackgroundColor(widgetConfig.color)
113
+ } else {
114
+ setBackgroundColor(props.backgroundColor)
115
+ }
116
+
117
+ if (widgetConfig.size != null && widgetConfig.color != 0) {
118
+ setButtonSize(parseInt(data.info.floating_widget_configuration.size))
119
+ } else {
120
+ setButtonSize(props.buttonHeight)
121
+ }
122
+
123
+ //FloatingButton Position
124
+ if (widgetConfig.position == "bottom_left") {
125
+ setButtonXPosition(10)
126
+ } else if (widgetConfig.position == "bottom_right") {
127
+ setButtonXPosition(windowWidth - 75)
128
+ } else if (widgetConfig.position == "upper_left") {
129
+ setButtonXPosition(10)
130
+ if (Platform.OS === 'android'){
131
+ setButtonYPosition(10)
132
+ }else{
133
+ setButtonYPosition(50)
134
+ }
135
+ } else if (widgetConfig.position == "upper_right") {
136
+ setButtonXPosition(windowWidth - 75)
137
+ if (Platform.OS === 'android'){
138
+ setButtonYPosition(10)
139
+ }else{
140
+ setButtonYPosition(50)
141
+ }
142
+ }
143
+
144
+ //Set DeepLink
145
+ if (widgetConfig.deeplink != null && widgetConfig.deeplink != "") {
146
+ setDeeplink(widgetConfig.deeplink)
147
+ }
148
+ //Set Visibility of FloatingButton
149
+ var currentDate = new Date();
150
+ const getDate = await AsyncStorage.getItem(flyyConfigDate);
151
+ const userId = await AsyncStorage.getItem(flyyConfigUserId);
152
+ var date = new Date(parseInt(getDate));
153
+ const diffTime = Math.abs(getDate - currentDate);
154
+ const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24))-1;
155
+ if(diffDays != 0 || userId == null || userId != sdkInfo[flyyConfigUserId]){
156
+ var data = await Flyy.getAppOccurence(1);
157
+ await AsyncStorage.setItem(
158
+ flyyConfigUserId,
159
+ sdkInfo[flyyConfigUserId]
160
+ );
161
+ }
162
+ const occurrenceCount = await Flyy.getAppOccurence(0);
163
+ if (widgetConfig.show_to_user && occurrenceCount <= parseInt(widgetConfig.num_times)) {
164
+ // var numberOfDaysToAdd = widgetConfig.num_days+1;
165
+ // var result = currentDate.setDate(currentDate.getDate() + numberOfDaysToAdd);
166
+ if(getDate === null || userId == null || userId != sdkInfo[flyyConfigUserId]){
167
+ await AsyncStorage.setItem(
168
+ flyyConfigDate,
169
+ JSON.stringify(currentDate.getTime())
170
+ );
171
+ }
172
+ const getDate2 = await AsyncStorage.getItem(flyyConfigDate);
173
+ var date = new Date(parseInt(getDate2));
174
+ const diffTime = Math.abs(getDate2 - currentDate);
175
+ const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24))-1;
176
+ //Show widget on same day
177
+ if(diffDays === 0 || diffDays === -1){
178
+ setShowWidget(true)
179
+ }else{
180
+ //reset occurrence on next day
181
+ await Flyy.getAppOccurence(1);
182
+ if(diffDays >= parseInt(widgetConfig.num_days)+1){
183
+ await AsyncStorage.setItem(
184
+ flyyConfigDate,
185
+ JSON.stringify(currentDate.getTime())
186
+ );
187
+ setShowWidget(true)
188
+ }
189
+ }
190
+ }else{
191
+ setShowWidget(false);
192
+ const getDate2 = await AsyncStorage.getItem(flyyConfigDate);
193
+ var date = new Date(parseInt(getDate2));
194
+ const diffTime = Math.abs(getDate2 - currentDate);
195
+ const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
196
+ if(diffDays != 1){
197
+ var data = await Flyy.getAppOccurence(1);
198
+ }
199
+ }
200
+ }
201
+
202
+ // if(props.show){
203
+ // if(props.startDate != null && props.startDate != 0){
204
+ // var now = new Date().getTime();
205
+ // if(now >= props.startDate && now <= props.endDate){
206
+ // props.show = true
207
+ // }else{
208
+ // props.show = false
209
+ // }
210
+ // }
211
+ // }
212
+
213
+ // AppState.addEventListener('change', state =>{
214
+ // console.log('AppState updated to', AppState.currentState)
215
+ // oldState = currentState;
216
+ // currentState = state;
217
+ // if(oldState == null){
218
+ // console.log('App is newly start :::')
219
+ // }})
220
+
221
+ return (
222
+ // @ts-ignore
223
+ props.show && showWidget? <Draggable x={buttonXPosition}
224
+ y={buttonYPosition}
225
+ minX={props.minX ?? 5}
226
+ minY={props.minY ?? 5}
227
+ maxX={props.maxX ?? windowWidth - 5}
228
+ maxY={props.maxY ?? windowHeight - 5}
229
+ renderSize={56}
230
+ // shouldReverse = {true}
231
+ onDragRelease={props.stick ? () => {
232
+
233
+ } : null} isCircle>
234
+ <TouchableOpacity
235
+ onPress={deeplink != null ? async()=>{
236
+ if (Platform.OS === 'android' || !deeplink.startsWith("flyy://")) {
237
+ const supported = await Linking.canOpenURL(deeplink);
238
+ await Linking.openURL(deeplink);
239
+ } else {
240
+ navigateTo(deeplink);
241
+ }
242
+ }:props.onPress}
243
+ style={{
244
+ height: buttonSize,
245
+ width: buttonSize,
246
+ backgroundColor: backgroundColor,
247
+ borderRadius: buttonSize/2,
248
+ justifyContent: 'center',
249
+ alignItems: 'center',
250
+ }}>
251
+ <Image source={iconUrl} style={{ height: buttonSize*55/100, width: buttonSize*55/100 }} />
252
+ <TouchableOpacity
253
+ onPress={()=>{
254
+ props.show = false;
255
+ setShowWidget(false);
256
+ }}
257
+ style = {{height: 20, width: 20, backgroundColor: "transparent",position:'absolute',left:buttonSize-11, bottom: buttonSize*72/100}}>
258
+ <Image source={require('./assets/images/xmark.png')} style={{ height: 18, width: 18, tintColor: "black"}} />
259
+ </TouchableOpacity>
260
+ </TouchableOpacity>
261
+ </Draggable> : <View/>
262
+ );
263
+ }
264
+
265
+ const navigateTo = (deeplink) => {
266
+ let components = deeplink.split("/");
267
+ let screenCode = components[components.length - 1];
268
+ switch (screenCode) {
269
+ case "flyy_offers":
270
+ {
271
+ Flyy.openOffersScreen();
272
+ }
273
+ break;
274
+ case "challenge_details":
275
+ {
276
+ Flyy.openFlyyChallengeDetailPage(0);
277
+ }
278
+ break;
279
+
280
+ case "flyy_quiz_list":
281
+ {
282
+ Flyy.openFlyyQuizListPage();
283
+ }
284
+ break;
285
+
286
+ case "stamp_campaign_new":
287
+ {
288
+ Flyy.openFlyyStampsPage();
289
+ }
290
+ break;
291
+
292
+ case "campaign_home":
293
+ {
294
+ Flyy.openFlyyStampsPage();
295
+ }
296
+ break;
297
+
298
+ case "bonanza_details":
299
+ {
300
+ Flyy.openFlyyBonanzaPage();
301
+ }
302
+ break;
303
+ case "invite_earn":
304
+ {
305
+ Flyy.openFlyyInviteAndEarnPage(0);
306
+ }
307
+ break;
308
+ case "invite_details":
309
+ {
310
+ Flyy.openFlyyInviteDetailsPage(0);
311
+ }
312
+ break;
313
+ case "custom_invite_details":
314
+ {
315
+ Flyy.openFlyyCustomInviteAndEarnPage(0, FlyyFlutterPlugin.themeColor);
316
+ }
317
+ break;
318
+ case "raffle_details":
319
+ {
320
+ Flyy.openFlyyRafflePage(0);
321
+ }
322
+ break;
323
+ case "quiz_history":
324
+ {
325
+ Flyy.openFlyyQuizHistoryPage();
326
+ }
327
+ break;
328
+ case "flyy_rewards":
329
+ {
330
+ Flyy.openRewardsScreen();
331
+ }
332
+ break;
333
+ case "flyy_referrals":
334
+ {
335
+ Flyy.openReferralHistory();
336
+ }
337
+ break;
338
+ case "flyy_gift_cards":
339
+ {
340
+ Flyy.openGiftCardScreen();
341
+ }
342
+ break;
343
+ case "flyy_wallet":
344
+ {
345
+ Flyy.openWalletScreen();
346
+ }
347
+ break;
348
+ case "game_list":
349
+ {
350
+ Flyy.openFlyyGamesPage();
351
+ }
352
+ break;
353
+ case "flyy_bonanza":
354
+ {
355
+ Flyy.openFlyyBonanzaPage();
356
+ }
357
+ break;
358
+ case "flyy_quiz_detail":
359
+ {
360
+ Flyy.openFlyyQuizPage(0);
361
+ }
362
+ break;
363
+ default:
364
+ // Toast.showWithGravity("ACTION NOT FOUND", Toast.SHORT, Toast.BOTTOM);
365
+ Alert.alert("ACTION NOT FOUND");
366
+
367
+ }
368
+ }
17
369
  export const FlyyWidget = ({
18
370
  widgetStyle = {
19
371
  rewardsButtonIcon: require('./assets/images/rewardwidget.png'),
@@ -150,3 +502,198 @@ const FlyyCardView = ({ cardStyle, buttonTitle, buttonIcon }) => {
150
502
  </View>
151
503
  );
152
504
  };
505
+
506
+
507
+ // ****** Flyy Stories Widget ******
508
+
509
+ export const FlyyStories = ({
510
+ widgetStyle = {
511
+ titleColor: 'black',
512
+ iconButtonBgColor: '#654EA3',
513
+ fontSize: 16.0,
514
+ iconCornerRadius: 55,
515
+ iconSize: 60,
516
+ iconBgSize: 100
517
+ },
518
+ }) => {
519
+ const [data,setData] = useState(null);
520
+
521
+ useEffect(()=>{
522
+ fetchStoriesData();
523
+ },[]);
524
+
525
+ const fetchStoriesData = async() => {
526
+ const sdkInfo = await Flyy.getUserData();
527
+ const appData = await Flyy.getAppData();
528
+ const resp = await fetch(`https://${sdkInfo["environment"] == 0 ? "ghc-stage" : "ghc"}.theflyy.com/api/storyboard`, {
529
+ headers: {
530
+ "X-Key": sdkInfo["partner_id"],
531
+ "Content-Type": "application/json",
532
+ "X-App-Data": appData
533
+ }
534
+ });
535
+ const responseData = await resp.json();
536
+ setData(responseData.storyboard_items);
537
+ }
538
+
539
+ const navigateTo = (screenCode) => {
540
+ switch (screenCode) {
541
+ case "offers":
542
+ {
543
+ Flyy.openOffersScreen();
544
+ }
545
+ break;
546
+ case "spin_wheel":
547
+ {
548
+ Flyy.openFlyySpinTheWheelPage(0);
549
+ }
550
+ break;
551
+
552
+ case "challenge":
553
+ {
554
+ Flyy.openFlyyChallengeDetailPage(0);
555
+ }
556
+ break;
557
+
558
+ case "quiz_list":
559
+ {
560
+ Flyy.openFlyyQuizListPage();
561
+ }
562
+ break;
563
+
564
+ case "stamp_campaign":
565
+ {
566
+ Flyy.openFlyyStampsPage();
567
+ }
568
+ break;
569
+
570
+ case "campaign_home":
571
+ {
572
+ Flyy.openFlyyStampsPage();
573
+ }
574
+ break;
575
+
576
+ case "bonanza_details":
577
+ {
578
+ Flyy.openFlyyBonanzaPage();
579
+ }
580
+ break;
581
+ case "invite_earn":
582
+ {
583
+ Flyy.openFlyyInviteAndEarnPage(0);
584
+ }
585
+ break;
586
+ case "invite_details":
587
+ {
588
+ Flyy.openFlyyInviteDetailsPage(0);
589
+ }
590
+ break;
591
+ case "custom_invite_details":
592
+ {
593
+ Flyy.openFlyyCustomInviteAndEarnPage(0, FlyyFlutterPlugin.themeColor);
594
+ }
595
+ break;
596
+ case "raffle":
597
+ {
598
+ Flyy.openFlyyRafflePage(0);
599
+ }
600
+ break;
601
+ case "quiz_history":
602
+ {
603
+ Flyy.openFlyyQuizHistoryPage();
604
+ }
605
+ break;
606
+ case "flyy_rewards":
607
+ {
608
+ Flyy.openRewardsScreen();
609
+ }
610
+ break;
611
+ case "referrals":
612
+ {
613
+ Flyy.openReferralHistory();
614
+ }
615
+ break;
616
+ case "flyy_gift_cards":
617
+ {
618
+ Flyy.openGiftCardScreen();
619
+ }
620
+ break;
621
+ case "wallet":
622
+ {
623
+ Flyy.openWalletScreen();
624
+ }
625
+ break;
626
+ case "game_list":
627
+ {
628
+ Flyy.openFlyyGamesPage();
629
+ }
630
+ break;
631
+ case "bonanza":
632
+ {
633
+ Flyy.openFlyyBonanzaPage();
634
+ }
635
+ break;
636
+ case "quiz_detail":
637
+ {
638
+ Flyy.openFlyyQuizPage(0);
639
+ }
640
+ break;
641
+ default:
642
+ // Toast.showWithGravity("ACTION NOT FOUND", Toast.SHORT, Toast.BOTTOM);
643
+ Alert.alert("ACTION NOT FOUND");
644
+ }
645
+ }
646
+
647
+ const StoriesItem = ({data}) => {
648
+ return (
649
+ <View style = {{alignItems: 'center'}}>
650
+ <View style={{ height: 10 }} />
651
+ <TouchableOpacity
652
+ onPress={()=>{
653
+ navigateTo(data.screen_code);
654
+ }}
655
+ style={{
656
+ backgroundColor: widgetStyle.iconButtonBgColor ?? '#654EA3',
657
+ height: widgetStyle.iconBgSize ?? 60,
658
+ width: widgetStyle.iconBgSize ?? 60,
659
+ borderRadius: widgetStyle.iconCornerRadius ?? 55,
660
+ alignSelf: 'center',
661
+ justifyContent: 'center',
662
+ alignItems: 'center',
663
+ marginHorizontal: 10
664
+ }}
665
+ >
666
+ <Image source={{uri: data.icon_url}} style={{ height: 60, width: 60 }} />
667
+ </TouchableOpacity>
668
+ <View style={{ height: 10 }} />
669
+ <View style = {{width:120}}>
670
+ <Text
671
+ style={{
672
+ alignSelf: 'center',
673
+ flexShrink: 1,
674
+ color: widgetStyle.titleColor ?? 'black',
675
+ fontSize: widgetStyle.fontSize ?? 14,
676
+ fontFamily: 'Montserrat-Bold',
677
+ textAlign: 'center',
678
+ paddingLeft: 5,
679
+ paddingRight: 5,
680
+ }}
681
+ numberOfLines={2}
682
+ >
683
+ {data.title}
684
+ </Text>
685
+ </View>
686
+ <View style={{ height: 10 }} />
687
+ </View>
688
+ );
689
+ };
690
+
691
+ return (<View style = {{flexDirection: "row",justifyContent: "center",width:"100%",alignItems:'center',alignContent:'center',backgroundColor: "white"}}>
692
+ <FlatList
693
+ horizontal={true}
694
+ data={data}
695
+ renderItem={({ item }) => <StoriesItem data={item} />}
696
+ keyExtractor={item => item.id}
697
+ />
698
+ </View>);
699
+ }