apps-sdk 1.0.28 → 1.0.29
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.
- package/package.json +1 -1
- package/src/libraries/PayWall.js +47 -5
- package/types/index.d.ts +3 -2
package/package.json
CHANGED
package/src/libraries/PayWall.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { WebView } from 'react-native-webview';
|
|
3
|
-
import
|
|
3
|
+
import { BottomSheet } from 'react-native-btr';
|
|
4
|
+
import Utils from "./Utils";
|
|
5
|
+
import { StyleSheet, View, Dimensions } from 'react-native';
|
|
6
|
+
|
|
7
|
+
class PayWall extends React.Component {
|
|
8
|
+
constructor(props) {
|
|
9
|
+
super(props);
|
|
10
|
+
this.state = { isVisible: false, url: null };
|
|
11
|
+
}
|
|
4
12
|
|
|
5
|
-
class PayWall {
|
|
6
13
|
webviewRef = React.createRef();
|
|
14
|
+
bottomSheetRef = React.createRef();
|
|
7
15
|
|
|
8
16
|
handleMessage = (message) => {
|
|
9
17
|
const data = JSON.parse(message.nativeEvent.data);
|
|
@@ -19,15 +27,49 @@ class PayWall {
|
|
|
19
27
|
return "window.subInfoInterval = setInterval(() => window.Appquiles && Appquiles.setSubscriptionPlans(" + JSON.stringify(information.subsPlansInfo) + "), 300);";
|
|
20
28
|
}
|
|
21
29
|
|
|
22
|
-
|
|
30
|
+
show = (url) => {
|
|
31
|
+
this.setState({ isVisible: true, url: url });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
hide = () => {
|
|
35
|
+
this.setState({ isVisible: false, url: null });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
render() {
|
|
23
39
|
return (
|
|
24
|
-
|
|
25
|
-
|
|
40
|
+
this.state.isVisible &&
|
|
41
|
+
<View style={styles.container}>
|
|
42
|
+
<BottomSheet
|
|
43
|
+
ref={this.bottomSheetRef}
|
|
44
|
+
height={0.9 * Dimensions.get('window').height} // 90% de la altura de la pantalla
|
|
45
|
+
open={true}
|
|
46
|
+
customStyles={{
|
|
47
|
+
container: {
|
|
48
|
+
flex: 1,
|
|
49
|
+
borderTopLeftRadius: 10,
|
|
50
|
+
borderTopRightRadius: 10,
|
|
51
|
+
}
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
<WebView
|
|
55
|
+
style={styles.webview}
|
|
56
|
+
source={{ uri: this.state.url }}
|
|
57
|
+
javaScriptEnabled
|
|
58
|
+
ref={this.webviewRef}
|
|
59
|
+
onMessage={this.handleMessage}
|
|
60
|
+
onError={(err) => {console.log('Error al cargar webview:',err)}}
|
|
61
|
+
injectedJavaScript={this.getPayWallJS()}
|
|
62
|
+
/>
|
|
63
|
+
</BottomSheet>
|
|
64
|
+
</View>
|
|
26
65
|
);
|
|
27
66
|
}
|
|
28
67
|
}
|
|
29
68
|
|
|
30
69
|
const styles = StyleSheet.create({
|
|
70
|
+
container: {
|
|
71
|
+
flex: 1,
|
|
72
|
+
},
|
|
31
73
|
webview: {
|
|
32
74
|
flex: 1,
|
|
33
75
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -84,7 +84,8 @@ declare module 'apps-sdk' {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
export class PayWall {
|
|
87
|
-
|
|
87
|
+
show(url: string): void;
|
|
88
|
+
hide(): void;
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
export class AppsSDK {
|
|
@@ -97,7 +98,7 @@ declare module 'apps-sdk' {
|
|
|
97
98
|
storage: Storage;
|
|
98
99
|
session: Session;
|
|
99
100
|
utils: Utils;
|
|
100
|
-
|
|
101
|
+
paywall: PayWall;
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
const Core: AppsSDK;
|