react-native-flyy 1.4.34 → 1.4.35

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.
@@ -1,9 +1,7 @@
1
1
  // @ts-nocheck
2
2
  import React, { useEffect, useState } from 'react';
3
- import { Image, NativeModules, Text, TouchableOpacity, View, Dimensions, ToastAndroid, Linking, FlatList, Alert } from 'react-native';
3
+ import { Image, NativeModules, Text, TouchableOpacity, View, Dimensions, FlatList, Alert } from 'react-native';
4
4
  import FlyyCheckinComponent from './flyy_checkin_view';
5
- import AsyncStorage from '@react-native-async-storage/async-storage';
6
- import Draggable from 'react-native-draggable';
7
5
  const {
8
6
  Flyy
9
7
  } = NativeModules;
@@ -23,245 +21,213 @@ export const FlyyCheckinView = props => {
23
21
  };
24
22
  const windowHeight = Dimensions.get('window').height;
25
23
  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 - 200);
56
- const [deeplink, setDeeplink] = useState(null);
57
- const flyyConfigDate = "flyy_config_date";
58
- const flyyConfigUserId = "user_id";
59
- var oldState = null;
60
- var currentState = null;
61
- var data = null;
62
- useEffect(() => {
63
- fetchData();
64
- }, []);
65
-
66
- const fetchData = async () => {
67
- const sdkInfo = await Flyy.getUserData();
68
- const appData = await Flyy.getAppData();
69
- const resp = await fetch(`https://${sdkInfo["environment"] == 0 ? "ghc-stage" : "ghc"}.theflyy.com/api/v8/flyy_app_info`, {
70
- headers: {
71
- "X-Key": sdkInfo["partner_id"],
72
- "Content-Type": "application/json",
73
- "X-App-Data": appData
74
- }
75
- });
76
- data = await resp.json();
77
-
78
- if (!data.success) {
79
- if (Platform.OS === 'android') {
80
- ToastAndroid.show(data.message, ToastAndroid.SHORT);
81
- } else {
82
- // Toast.showWithGravity(data.message, Toast.SHORT, Toast.BOTTOM);
83
- Alert.alert(data.message);
84
- }
85
-
86
- return;
87
- }
88
-
89
- const widgetConfig = data.info.floating_widget_configuration;
90
-
91
- if (widgetConfig.icon_url != null && widgetConfig.icon_url != '') {
92
- setIconUrl({
93
- uri: widgetConfig.icon_url
94
- });
95
- } else {
96
- setIconUrl(props.buttonIcon);
97
- }
98
-
99
- if (widgetConfig.color != null && widgetConfig.color != '') {
100
- setBackgroundColor(widgetConfig.color);
101
- } else {
102
- setBackgroundColor(props.backgroundColor);
103
- }
104
-
105
- if (widgetConfig.size != null && widgetConfig.color != 0) {
106
- setButtonSize(parseInt(data.info.floating_widget_configuration.size));
107
- } else {
108
- setButtonSize(props.buttonHeight);
109
- } //FloatingButton Position
110
-
111
-
112
- if (widgetConfig.position == "bottom_left") {
113
- setButtonXPosition(10);
114
- } else if (widgetConfig.position == "bottom_right") {
115
- setButtonXPosition(windowWidth - 75);
116
- } else if (widgetConfig.position == "upper_left") {
117
- setButtonXPosition(10);
118
-
119
- if (Platform.OS === 'android') {
120
- setButtonYPosition(10);
121
- } else {
122
- setButtonYPosition(50);
123
- }
124
- } else if (widgetConfig.position == "upper_right") {
125
- setButtonXPosition(windowWidth - 75);
126
-
127
- if (Platform.OS === 'android') {
128
- setButtonYPosition(10);
129
- } else {
130
- setButtonYPosition(50);
131
- }
132
- } //Set DeepLink
133
-
134
-
135
- if (widgetConfig.deeplink != null && widgetConfig.deeplink != "") {
136
- setDeeplink(widgetConfig.deeplink);
137
- } //Set Visibility of FloatingButton
138
-
139
-
140
- var currentDate = new Date();
141
- const getDate = await AsyncStorage.getItem(flyyConfigDate);
142
- const userId = await AsyncStorage.getItem(flyyConfigUserId);
143
- var date = new Date(parseInt(getDate));
144
- const diffTime = Math.abs(getDate - currentDate);
145
- const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)) - 1;
146
-
147
- if (diffDays != 0 || userId == null || userId != sdkInfo[flyyConfigUserId]) {
148
- var data = await Flyy.getAppOccurence(1);
149
- await AsyncStorage.setItem(flyyConfigUserId, sdkInfo[flyyConfigUserId]);
150
- }
151
-
152
- const occurrenceCount = await Flyy.getAppOccurence(0);
153
-
154
- if (widgetConfig.show_to_user && occurrenceCount <= parseInt(widgetConfig.num_times)) {
155
- // var numberOfDaysToAdd = widgetConfig.num_days+1;
156
- // var result = currentDate.setDate(currentDate.getDate() + numberOfDaysToAdd);
157
- if (getDate === null || userId == null || userId != sdkInfo[flyyConfigUserId]) {
158
- await AsyncStorage.setItem(flyyConfigDate, JSON.stringify(currentDate.getTime()));
159
- }
160
-
161
- const getDate2 = await AsyncStorage.getItem(flyyConfigDate);
162
- var date = new Date(parseInt(getDate2));
163
- const diffTime = Math.abs(getDate2 - currentDate);
164
- const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)) - 1; //Show widget on same day
165
-
166
- if (diffDays === 0 || diffDays === -1) {
167
- setShowWidget(true);
168
- } else {
169
- //reset occurrence on next day
170
- await Flyy.getAppOccurence(1);
171
-
172
- if (diffDays >= parseInt(widgetConfig.num_days) + 1) {
173
- await AsyncStorage.setItem(flyyConfigDate, JSON.stringify(currentDate.getTime()));
174
- setShowWidget(true);
175
- }
176
- }
177
- } else {
178
- setShowWidget(false);
179
- const getDate2 = await AsyncStorage.getItem(flyyConfigDate);
180
- var date = new Date(parseInt(getDate2));
181
- const diffTime = Math.abs(getDate2 - currentDate);
182
- const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
183
-
184
- if (diffDays != 1) {
185
- var data = await Flyy.getAppOccurence(1);
186
- }
187
- }
188
- }; // if(props.show){
189
- // if(props.startDate != null && props.startDate != 0){
190
- // var now = new Date().getTime();
191
- // if(now >= props.startDate && now <= props.endDate){
192
- // props.show = true
193
- // }else{
194
- // props.show = false
195
- // }
196
- // }
197
- // }
198
- // AppState.addEventListener('change', state =>{
199
- // console.log('AppState updated to', AppState.currentState)
200
- // oldState = currentState;
201
- // currentState = state;
202
- // if(oldState == null){
203
- // console.log('App is newly start :::')
204
- // }})
205
-
206
-
207
- return (// @ts-ignore
208
- props.show && showWidget ? /*#__PURE__*/React.createElement(Draggable, {
209
- x: buttonXPosition,
210
- y: buttonYPosition,
211
- minX: (_props$minX = props.minX) !== null && _props$minX !== void 0 ? _props$minX : 5,
212
- minY: (_props$minY = props.minY) !== null && _props$minY !== void 0 ? _props$minY : 5,
213
- maxX: (_props$maxX = props.maxX) !== null && _props$maxX !== void 0 ? _props$maxX : windowWidth - 5,
214
- maxY: (_props$maxY = props.maxY) !== null && _props$maxY !== void 0 ? _props$maxY : windowHeight - 5,
215
- renderSize: 56 // shouldReverse = {true}
216
- ,
217
- onDragRelease: props.stick ? () => {} : null,
218
- isCircle: true
219
- }, /*#__PURE__*/React.createElement(TouchableOpacity, {
220
- onPress: deeplink != null ? async () => {
221
- if (Platform.OS === 'android' || !deeplink.startsWith("flyy://")) {
222
- const supported = await Linking.canOpenURL(deeplink);
223
- await Linking.openURL(deeplink);
224
- } else {
225
- navigateTo(deeplink);
226
- }
227
- } : props.onPress,
228
- style: {
229
- height: buttonSize,
230
- width: buttonSize,
231
- backgroundColor: backgroundColor,
232
- borderRadius: buttonSize / 2,
233
- justifyContent: 'center',
234
- alignItems: 'center'
235
- }
236
- }, /*#__PURE__*/React.createElement(Image, {
237
- source: iconUrl,
238
- style: {
239
- height: buttonSize * 55 / 100,
240
- width: buttonSize * 55 / 100
241
- }
242
- }), /*#__PURE__*/React.createElement(TouchableOpacity, {
243
- onPress: () => {
244
- props.show = false;
245
- setShowWidget(false);
246
- },
247
- style: {
248
- height: 20,
249
- width: 20,
250
- backgroundColor: "transparent",
251
- position: 'absolute',
252
- left: buttonSize - 11,
253
- bottom: buttonSize * 72 / 100
254
- }
255
- }, /*#__PURE__*/React.createElement(Image, {
256
- source: require('./assets/images/xmark.png'),
257
- style: {
258
- height: 18,
259
- width: 18,
260
- tintColor: "black"
261
- }
262
- })))) : /*#__PURE__*/React.createElement(View, null)
263
- );
264
- };
24
+ // export const FlyyFloatingWidget = ({
25
+ // props = {
26
+ // backgroundColor: "#654EA3",
27
+ // buttonHeight: 55,
28
+ // buttonWidth: 55,
29
+ // buttonCornerRadius: 40,
30
+ // buttonIcon: require('./assets/images/rewardwidget.png'),
31
+ // onPress: () => { },
32
+ // x: windowWidth - 75,
33
+ // y: windowHeight - 100,
34
+ // minX: 5,
35
+ // minY: 5,
36
+ // maxX: windowWidth - 5,
37
+ // maxY: windowHeight - 5,
38
+ // show: true,
39
+ // stick: false,
40
+ // startDate: 0,
41
+ // endDate: 0
42
+ // } }) => {
43
+ // const [showWidget,setShowWidget] = useState(false);
44
+ // const [userData,setUserData] = useState({});
45
+ // const [iconUrl,setIconUrl] = useState(require('./assets/images/rewardwidget.png'));
46
+ // const [backgroundColor,setBackgroundColor] = useState("#654EA3");
47
+ // const [buttonSize,setButtonSize] = useState(55);
48
+ // const [buttonXPosition,setButtonXPosition] = useState(windowWidth - 75);
49
+ // const [buttonYPosition,setButtonYPosition] = useState(windowHeight - 200);
50
+ // const [deeplink,setDeeplink] = useState(null);
51
+ // const flyyConfigDate = "flyy_config_date";
52
+ // const flyyConfigUserId = "user_id";
53
+ // var oldState = null;
54
+ // var currentState = null;
55
+ // var data = null;
56
+ // useEffect(()=>{
57
+ // fetchData();
58
+ // },[]);
59
+ // const fetchData = async() => {
60
+ // const sdkInfo = await Flyy.getUserData();
61
+ // const appData = await Flyy.getAppData();
62
+ // const resp = await fetch(`https://${sdkInfo["environment"] == 0 ? "ghc-stage" : "ghc"}.theflyy.com/api/v8/flyy_app_info`, {
63
+ // headers: {
64
+ // "X-Key": sdkInfo["partner_id"],
65
+ // "Content-Type": "application/json",
66
+ // "X-App-Data": appData
67
+ // }
68
+ // });
69
+ // data = await resp.json();
70
+ // if(!data.success){
71
+ // if (Platform.OS === 'android') {
72
+ // ToastAndroid.show(data.message, ToastAndroid.SHORT);
73
+ // } else {
74
+ // // Toast.showWithGravity(data.message, Toast.SHORT, Toast.BOTTOM);
75
+ // Alert.alert(data.message);
76
+ // }
77
+ // return;
78
+ // }
79
+ // const widgetConfig = data.info.floating_widget_configuration;
80
+ // if (widgetConfig.icon_url != null && widgetConfig.icon_url != '') {
81
+ // setIconUrl({ uri: widgetConfig.icon_url })
82
+ // } else {
83
+ // setIconUrl(props.buttonIcon)
84
+ // }
85
+ // if (widgetConfig.color != null && widgetConfig.color != '') {
86
+ // setBackgroundColor(widgetConfig.color)
87
+ // } else {
88
+ // setBackgroundColor(props.backgroundColor)
89
+ // }
90
+ // if (widgetConfig.size != null && widgetConfig.color != 0) {
91
+ // setButtonSize(parseInt(data.info.floating_widget_configuration.size))
92
+ // } else {
93
+ // setButtonSize(props.buttonHeight)
94
+ // }
95
+ // //FloatingButton Position
96
+ // if (widgetConfig.position == "bottom_left") {
97
+ // setButtonXPosition(10)
98
+ // } else if (widgetConfig.position == "bottom_right") {
99
+ // setButtonXPosition(windowWidth - 75)
100
+ // } else if (widgetConfig.position == "upper_left") {
101
+ // setButtonXPosition(10)
102
+ // if (Platform.OS === 'android'){
103
+ // setButtonYPosition(10)
104
+ // }else{
105
+ // setButtonYPosition(50)
106
+ // }
107
+ // } else if (widgetConfig.position == "upper_right") {
108
+ // setButtonXPosition(windowWidth - 75)
109
+ // if (Platform.OS === 'android'){
110
+ // setButtonYPosition(10)
111
+ // }else{
112
+ // setButtonYPosition(50)
113
+ // }
114
+ // }
115
+ // //Set DeepLink
116
+ // if (widgetConfig.deeplink != null && widgetConfig.deeplink != "") {
117
+ // setDeeplink(widgetConfig.deeplink)
118
+ // }
119
+ // //Set Visibility of FloatingButton
120
+ // var currentDate = new Date();
121
+ // const getDate = await AsyncStorage.getItem(flyyConfigDate);
122
+ // const userId = await AsyncStorage.getItem(flyyConfigUserId);
123
+ // var date = new Date(parseInt(getDate));
124
+ // const diffTime = Math.abs(getDate - currentDate);
125
+ // const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24))-1;
126
+ // if(diffDays != 0 || userId == null || userId != sdkInfo[flyyConfigUserId]){
127
+ // var data = await Flyy.getAppOccurence(1);
128
+ // await AsyncStorage.setItem(
129
+ // flyyConfigUserId,
130
+ // sdkInfo[flyyConfigUserId]
131
+ // );
132
+ // }
133
+ // const occurrenceCount = await Flyy.getAppOccurence(0);
134
+ // if (widgetConfig.show_to_user && occurrenceCount <= parseInt(widgetConfig.num_times)) {
135
+ // // var numberOfDaysToAdd = widgetConfig.num_days+1;
136
+ // // var result = currentDate.setDate(currentDate.getDate() + numberOfDaysToAdd);
137
+ // if(getDate === null || userId == null || userId != sdkInfo[flyyConfigUserId]){
138
+ // await AsyncStorage.setItem(
139
+ // flyyConfigDate,
140
+ // JSON.stringify(currentDate.getTime())
141
+ // );
142
+ // }
143
+ // const getDate2 = await AsyncStorage.getItem(flyyConfigDate);
144
+ // var date = new Date(parseInt(getDate2));
145
+ // const diffTime = Math.abs(getDate2 - currentDate);
146
+ // const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24))-1;
147
+ // //Show widget on same day
148
+ // if(diffDays === 0 || diffDays === -1){
149
+ // setShowWidget(true)
150
+ // }else{
151
+ // //reset occurrence on next day
152
+ // await Flyy.getAppOccurence(1);
153
+ // if(diffDays >= parseInt(widgetConfig.num_days)+1){
154
+ // await AsyncStorage.setItem(
155
+ // flyyConfigDate,
156
+ // JSON.stringify(currentDate.getTime())
157
+ // );
158
+ // setShowWidget(true)
159
+ // }
160
+ // }
161
+ // }else{
162
+ // setShowWidget(false);
163
+ // const getDate2 = await AsyncStorage.getItem(flyyConfigDate);
164
+ // var date = new Date(parseInt(getDate2));
165
+ // const diffTime = Math.abs(getDate2 - currentDate);
166
+ // const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
167
+ // if(diffDays != 1){
168
+ // var data = await Flyy.getAppOccurence(1);
169
+ // }
170
+ // }
171
+ // }
172
+ // // if(props.show){
173
+ // // if(props.startDate != null && props.startDate != 0){
174
+ // // var now = new Date().getTime();
175
+ // // if(now >= props.startDate && now <= props.endDate){
176
+ // // props.show = true
177
+ // // }else{
178
+ // // props.show = false
179
+ // // }
180
+ // // }
181
+ // // }
182
+ // // AppState.addEventListener('change', state =>{
183
+ // // console.log('AppState updated to', AppState.currentState)
184
+ // // oldState = currentState;
185
+ // // currentState = state;
186
+ // // if(oldState == null){
187
+ // // console.log('App is newly start :::')
188
+ // // }})
189
+ // return (
190
+ // // @ts-ignore
191
+ // props.show && showWidget? <Draggable x={buttonXPosition}
192
+ // y={buttonYPosition}
193
+ // minX={props.minX ?? 5}
194
+ // minY={props.minY ?? 5}
195
+ // maxX={props.maxX ?? windowWidth - 5}
196
+ // maxY={props.maxY ?? windowHeight - 5}
197
+ // renderSize={56}
198
+ // // shouldReverse = {true}
199
+ // onDragRelease={props.stick ? () => {
200
+ // } : null} isCircle>
201
+ // <TouchableOpacity
202
+ // onPress={deeplink != null ? async()=>{
203
+ // if (Platform.OS === 'android' || !deeplink.startsWith("flyy://")) {
204
+ // const supported = await Linking.canOpenURL(deeplink);
205
+ // await Linking.openURL(deeplink);
206
+ // } else {
207
+ // navigateTo(deeplink);
208
+ // }
209
+ // }:props.onPress}
210
+ // style={{
211
+ // height: buttonSize,
212
+ // width: buttonSize,
213
+ // backgroundColor: backgroundColor,
214
+ // borderRadius: buttonSize/2,
215
+ // justifyContent: 'center',
216
+ // alignItems: 'center',
217
+ // }}>
218
+ // <Image source={iconUrl} style={{ height: buttonSize*55/100, width: buttonSize*55/100 }} />
219
+ // <TouchableOpacity
220
+ // onPress={()=>{
221
+ // props.show = false;
222
+ // setShowWidget(false);
223
+ // }}
224
+ // style = {{height: 20, width: 20, backgroundColor: "transparent",position:'absolute',left:buttonSize-11, bottom: buttonSize*72/100}}>
225
+ // <Image source={require('./assets/images/xmark.png')} style={{ height: 18, width: 18, tintColor: "black"}} />
226
+ // </TouchableOpacity>
227
+ // </TouchableOpacity>
228
+ // </Draggable> : <View/>
229
+ // );
230
+ // }
265
231
 
266
232
  const navigateTo = deeplink => {
267
233
  let components = deeplink.split("/");