@hayanmind/monetai-react-native 0.3.0 → 0.4.0
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/lib/commonjs/MonetaiProvider.js +45 -23
- package/lib/commonjs/MonetaiProvider.js.map +1 -1
- package/lib/commonjs/PaywallManager.js +63 -0
- package/lib/commonjs/PaywallManager.js.map +1 -0
- package/lib/commonjs/components/Banner.js +141 -0
- package/lib/commonjs/components/Banner.js.map +1 -0
- package/lib/commonjs/components/Paywall.js +236 -0
- package/lib/commonjs/components/Paywall.js.map +1 -0
- package/lib/commonjs/components/paywall-wrappers/CompactPaywallWrapper.js +61 -0
- package/lib/commonjs/components/paywall-wrappers/CompactPaywallWrapper.js.map +1 -0
- package/lib/commonjs/components/paywall-wrappers/HighlightBenefitsPaywallWrapper.js +33 -0
- package/lib/commonjs/components/paywall-wrappers/HighlightBenefitsPaywallWrapper.js.map +1 -0
- package/lib/commonjs/components/paywall-wrappers/KeyFeatureSummaryPaywallWrapper.js +33 -0
- package/lib/commonjs/components/paywall-wrappers/KeyFeatureSummaryPaywallWrapper.js.map +1 -0
- package/lib/commonjs/components/paywall-wrappers/TextFocusedPaywallWrapper.js +33 -0
- package/lib/commonjs/components/paywall-wrappers/TextFocusedPaywallWrapper.js.map +1 -0
- package/lib/commonjs/components/paywall-wrappers/index.js +41 -0
- package/lib/commonjs/components/paywall-wrappers/index.js.map +1 -0
- package/lib/commonjs/constants/paywall.js +11 -0
- package/lib/commonjs/constants/paywall.js.map +1 -0
- package/lib/commonjs/hooks/useBanner.js +84 -0
- package/lib/commonjs/hooks/useBanner.js.map +1 -0
- package/lib/commonjs/hooks/useInterval.js +34 -0
- package/lib/commonjs/hooks/useInterval.js.map +1 -0
- package/lib/commonjs/hooks/usePaywall.js +60 -0
- package/lib/commonjs/hooks/usePaywall.js.map +1 -0
- package/lib/commonjs/index.js +54 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/lib.js +2 -2
- package/lib/module/MonetaiProvider.js +48 -25
- package/lib/module/MonetaiProvider.js.map +1 -1
- package/lib/module/PaywallManager.js +58 -0
- package/lib/module/PaywallManager.js.map +1 -0
- package/lib/module/components/Banner.js +136 -0
- package/lib/module/components/Banner.js.map +1 -0
- package/lib/module/components/Paywall.js +230 -0
- package/lib/module/components/Paywall.js.map +1 -0
- package/lib/module/components/paywall-wrappers/CompactPaywallWrapper.js +55 -0
- package/lib/module/components/paywall-wrappers/CompactPaywallWrapper.js.map +1 -0
- package/lib/module/components/paywall-wrappers/HighlightBenefitsPaywallWrapper.js +27 -0
- package/lib/module/components/paywall-wrappers/HighlightBenefitsPaywallWrapper.js.map +1 -0
- package/lib/module/components/paywall-wrappers/KeyFeatureSummaryPaywallWrapper.js +27 -0
- package/lib/module/components/paywall-wrappers/KeyFeatureSummaryPaywallWrapper.js.map +1 -0
- package/lib/module/components/paywall-wrappers/TextFocusedPaywallWrapper.js +27 -0
- package/lib/module/components/paywall-wrappers/TextFocusedPaywallWrapper.js.map +1 -0
- package/lib/module/components/paywall-wrappers/index.js +11 -0
- package/lib/module/components/paywall-wrappers/index.js.map +1 -0
- package/lib/module/constants/paywall.js +7 -0
- package/lib/module/constants/paywall.js.map +1 -0
- package/lib/module/hooks/useBanner.js +79 -0
- package/lib/module/hooks/useBanner.js.map +1 -0
- package/lib/module/hooks/useInterval.js +30 -0
- package/lib/module/hooks/useInterval.js.map +1 -0
- package/lib/module/hooks/usePaywall.js +55 -0
- package/lib/module/hooks/usePaywall.js.map +1 -0
- package/lib/module/index.js +8 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/lib.js +2 -2
- package/lib/typescript/commonjs/src/MonetaiProvider.d.ts +3 -7
- package/lib/typescript/commonjs/src/MonetaiProvider.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/PaywallManager.d.ts +7 -0
- package/lib/typescript/commonjs/src/PaywallManager.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/Banner.d.ts +10 -0
- package/lib/typescript/commonjs/src/components/Banner.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/Paywall.d.ts +14 -0
- package/lib/typescript/commonjs/src/components/Paywall.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/paywall-wrappers/CompactPaywallWrapper.d.ts +8 -0
- package/lib/typescript/commonjs/src/components/paywall-wrappers/CompactPaywallWrapper.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/paywall-wrappers/HighlightBenefitsPaywallWrapper.d.ts +8 -0
- package/lib/typescript/commonjs/src/components/paywall-wrappers/HighlightBenefitsPaywallWrapper.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/paywall-wrappers/KeyFeatureSummaryPaywallWrapper.d.ts +8 -0
- package/lib/typescript/commonjs/src/components/paywall-wrappers/KeyFeatureSummaryPaywallWrapper.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/paywall-wrappers/TextFocusedPaywallWrapper.d.ts +8 -0
- package/lib/typescript/commonjs/src/components/paywall-wrappers/TextFocusedPaywallWrapper.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/paywall-wrappers/index.d.ts +6 -0
- package/lib/typescript/commonjs/src/components/paywall-wrappers/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/constants/paywall.d.ts +3 -0
- package/lib/typescript/commonjs/src/constants/paywall.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/useBanner.d.ts +14 -0
- package/lib/typescript/commonjs/src/hooks/useBanner.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/useInterval.d.ts +7 -0
- package/lib/typescript/commonjs/src/hooks/useInterval.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/usePaywall.d.ts +15 -0
- package/lib/typescript/commonjs/src/hooks/usePaywall.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +7 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types.d.ts +48 -2
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
- package/lib/typescript/module/src/MonetaiProvider.d.ts +3 -7
- package/lib/typescript/module/src/MonetaiProvider.d.ts.map +1 -1
- package/lib/typescript/module/src/PaywallManager.d.ts +7 -0
- package/lib/typescript/module/src/PaywallManager.d.ts.map +1 -0
- package/lib/typescript/module/src/components/Banner.d.ts +10 -0
- package/lib/typescript/module/src/components/Banner.d.ts.map +1 -0
- package/lib/typescript/module/src/components/Paywall.d.ts +14 -0
- package/lib/typescript/module/src/components/Paywall.d.ts.map +1 -0
- package/lib/typescript/module/src/components/paywall-wrappers/CompactPaywallWrapper.d.ts +8 -0
- package/lib/typescript/module/src/components/paywall-wrappers/CompactPaywallWrapper.d.ts.map +1 -0
- package/lib/typescript/module/src/components/paywall-wrappers/HighlightBenefitsPaywallWrapper.d.ts +8 -0
- package/lib/typescript/module/src/components/paywall-wrappers/HighlightBenefitsPaywallWrapper.d.ts.map +1 -0
- package/lib/typescript/module/src/components/paywall-wrappers/KeyFeatureSummaryPaywallWrapper.d.ts +8 -0
- package/lib/typescript/module/src/components/paywall-wrappers/KeyFeatureSummaryPaywallWrapper.d.ts.map +1 -0
- package/lib/typescript/module/src/components/paywall-wrappers/TextFocusedPaywallWrapper.d.ts +8 -0
- package/lib/typescript/module/src/components/paywall-wrappers/TextFocusedPaywallWrapper.d.ts.map +1 -0
- package/lib/typescript/module/src/components/paywall-wrappers/index.d.ts +6 -0
- package/lib/typescript/module/src/components/paywall-wrappers/index.d.ts.map +1 -0
- package/lib/typescript/module/src/constants/paywall.d.ts +3 -0
- package/lib/typescript/module/src/constants/paywall.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/useBanner.d.ts +14 -0
- package/lib/typescript/module/src/hooks/useBanner.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/useInterval.d.ts +7 -0
- package/lib/typescript/module/src/hooks/useInterval.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/usePaywall.d.ts +15 -0
- package/lib/typescript/module/src/hooks/usePaywall.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +7 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/types.d.ts +48 -2
- package/lib/typescript/module/src/types.d.ts.map +1 -1
- package/package.json +4 -2
- package/src/MonetaiProvider.tsx +72 -29
- package/src/PaywallManager.tsx +61 -0
- package/src/components/Banner.tsx +152 -0
- package/src/components/Paywall.tsx +254 -0
- package/src/components/paywall-wrappers/CompactPaywallWrapper.tsx +58 -0
- package/src/components/paywall-wrappers/HighlightBenefitsPaywallWrapper.tsx +30 -0
- package/src/components/paywall-wrappers/KeyFeatureSummaryPaywallWrapper.tsx +30 -0
- package/src/components/paywall-wrappers/TextFocusedPaywallWrapper.tsx +30 -0
- package/src/components/paywall-wrappers/index.ts +8 -0
- package/src/constants/paywall.ts +4 -0
- package/src/hooks/useBanner.ts +112 -0
- package/src/hooks/useInterval.ts +29 -0
- package/src/hooks/usePaywall.ts +73 -0
- package/src/index.tsx +36 -1
- package/src/types.ts +65 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompactPaywallWrapper.d.ts","sourceRoot":"","sources":["../../../../../../src/components/paywall-wrappers/CompactPaywallWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,UAAU,0BAA0B;IAClC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAGD,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAiBtE,CAAC;AA+BF,eAAe,qBAAqB,CAAC"}
|
package/lib/typescript/module/src/components/paywall-wrappers/HighlightBenefitsPaywallWrapper.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface HighlightBenefitsPaywallWrapperProps {
|
|
3
|
+
onClose: () => void;
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export declare const HighlightBenefitsPaywallWrapper: React.FC<HighlightBenefitsPaywallWrapperProps>;
|
|
7
|
+
export default HighlightBenefitsPaywallWrapper;
|
|
8
|
+
//# sourceMappingURL=HighlightBenefitsPaywallWrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HighlightBenefitsPaywallWrapper.d.ts","sourceRoot":"","sources":["../../../../../../src/components/paywall-wrappers/HighlightBenefitsPaywallWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,UAAU,oCAAoC;IAC5C,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAGD,eAAO,MAAM,+BAA+B,EAAE,KAAK,CAAC,EAAE,CACpD,oCAAoC,CAKrC,CAAC;AAcF,eAAe,+BAA+B,CAAC"}
|
package/lib/typescript/module/src/components/paywall-wrappers/KeyFeatureSummaryPaywallWrapper.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface KeyFeatureSummaryPaywallWrapperProps {
|
|
3
|
+
onClose: () => void;
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export declare const KeyFeatureSummaryPaywallWrapper: React.FC<KeyFeatureSummaryPaywallWrapperProps>;
|
|
7
|
+
export default KeyFeatureSummaryPaywallWrapper;
|
|
8
|
+
//# sourceMappingURL=KeyFeatureSummaryPaywallWrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeyFeatureSummaryPaywallWrapper.d.ts","sourceRoot":"","sources":["../../../../../../src/components/paywall-wrappers/KeyFeatureSummaryPaywallWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,UAAU,oCAAoC;IAC5C,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAGD,eAAO,MAAM,+BAA+B,EAAE,KAAK,CAAC,EAAE,CACpD,oCAAoC,CAKrC,CAAC;AAcF,eAAe,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface TextFocusedPaywallWrapperProps {
|
|
3
|
+
onClose: () => void;
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export declare const TextFocusedPaywallWrapper: React.FC<TextFocusedPaywallWrapperProps>;
|
|
7
|
+
export default TextFocusedPaywallWrapper;
|
|
8
|
+
//# sourceMappingURL=TextFocusedPaywallWrapper.d.ts.map
|
package/lib/typescript/module/src/components/paywall-wrappers/TextFocusedPaywallWrapper.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextFocusedPaywallWrapper.d.ts","sourceRoot":"","sources":["../../../../../../src/components/paywall-wrappers/TextFocusedPaywallWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,UAAU,8BAA8B;IACtC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAGD,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,EAAE,CAC9C,8BAA8B,CAK/B,CAAC;AAcF,eAAe,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as CompactPaywallWrapper } from './CompactPaywallWrapper';
|
|
2
|
+
export { default as HighlightBenefitsPaywallWrapper } from './HighlightBenefitsPaywallWrapper';
|
|
3
|
+
export { default as KeyFeatureSummaryPaywallWrapper } from './KeyFeatureSummaryPaywallWrapper';
|
|
4
|
+
export { default as TextFocusedPaywallWrapper } from './TextFocusedPaywallWrapper';
|
|
5
|
+
export { default } from './CompactPaywallWrapper';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/paywall-wrappers/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AAC/F,OAAO,EAAE,OAAO,IAAI,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AAC/F,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAGnF,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paywall.d.ts","sourceRoot":"","sources":["../../../../../src/constants/paywall.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,gBAAgB,yCAAyC,CAAC;AAEvE,eAAO,MAAM,kBAAkB,eAAe,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BannerParams, DiscountInfo, PaywallConfig } from '../types';
|
|
2
|
+
interface UseBannerProps {
|
|
3
|
+
paywallConfig?: PaywallConfig;
|
|
4
|
+
discountInfo: DiscountInfo | null;
|
|
5
|
+
}
|
|
6
|
+
interface UseBannerReturn {
|
|
7
|
+
bannerVisible: boolean;
|
|
8
|
+
openBanner: () => void;
|
|
9
|
+
closeBanner: () => void;
|
|
10
|
+
bannerParams: BannerParams | null;
|
|
11
|
+
}
|
|
12
|
+
export declare const useBanner: ({ paywallConfig, discountInfo, }: UseBannerProps) => UseBannerReturn;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=useBanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBanner.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/useBanner.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAM1E,UAAU,cAAc;IACtB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;CACnC;AAED,UAAU,eAAe;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;CACnC;AAED,eAAO,MAAM,SAAS,GAAI,kCAGvB,cAAc,KAAG,eAuFnB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom hook for setting up an interval that can be paused/resumed
|
|
3
|
+
* @param callback Function to call on each interval
|
|
4
|
+
* @param delay Delay in milliseconds, null to pause
|
|
5
|
+
*/
|
|
6
|
+
export declare const useInterval: (callback: () => void, delay: number | null) => void;
|
|
7
|
+
//# sourceMappingURL=useInterval.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInterval.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/useInterval.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,UAAU,MAAM,IAAI,EAAE,OAAO,MAAM,GAAG,IAAI,SAqBrE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PaywallParams, PaywallConfig, DiscountInfo } from '../types';
|
|
2
|
+
interface UsePaywallProps {
|
|
3
|
+
paywallConfig?: PaywallConfig;
|
|
4
|
+
discountInfo: DiscountInfo | null;
|
|
5
|
+
onClose?: () => void;
|
|
6
|
+
}
|
|
7
|
+
interface UsePaywallReturn {
|
|
8
|
+
paywallVisible: boolean;
|
|
9
|
+
paywallParams: PaywallParams | null;
|
|
10
|
+
openPaywall: () => void;
|
|
11
|
+
closePaywall: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const usePaywall: ({ paywallConfig, discountInfo, onClose, }: UsePaywallProps) => UsePaywallReturn;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=usePaywall.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePaywall.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/usePaywall.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE3E,UAAU,eAAe;IACvB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAClC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,UAAU,gBAAgB;IACxB,cAAc,EAAE,OAAO,CAAC;IACxB,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IACpC,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED,eAAO,MAAM,UAAU,GAAI,2CAIxB,eAAe,KAAG,gBAoDpB,CAAC"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import MonetaiSDK from './MonetaiSDK';
|
|
2
2
|
import MonetaiProvider from './MonetaiProvider';
|
|
3
|
+
import Banner from './components/Banner';
|
|
4
|
+
import Paywall from './components/Paywall';
|
|
5
|
+
import { CompactPaywallWrapper, HighlightBenefitsPaywallWrapper, KeyFeatureSummaryPaywallWrapper, TextFocusedPaywallWrapper } from './components/paywall-wrappers';
|
|
6
|
+
import { useBanner } from './hooks/useBanner';
|
|
7
|
+
import { usePaywall } from './hooks/usePaywall';
|
|
3
8
|
export default MonetaiSDK;
|
|
4
|
-
export { MonetaiProvider };
|
|
9
|
+
export { MonetaiProvider, Banner, Paywall, useBanner, usePaywall, CompactPaywallWrapper, HighlightBenefitsPaywallWrapper, KeyFeatureSummaryPaywallWrapper, TextFocusedPaywallWrapper, };
|
|
10
|
+
export type { ABTestGroup, PredictResult, EventParams, LogEventOptions, DiscountInfo, AppUserDiscountResponse, PaywallConfig, Feature, BannerParams, PaywallParams, PaywallStyle, } from './types';
|
|
5
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,eAAe,UAAU,CAAC;AAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,OAAO,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EACL,qBAAqB,EACrB,+BAA+B,EAC/B,+BAA+B,EAC/B,yBAAyB,EAC1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,eAAe,UAAU,CAAC;AAC1B,OAAO,EACL,eAAe,EACf,MAAM,EACN,OAAO,EACP,SAAS,EACT,UAAU,EACV,qBAAqB,EACrB,+BAA+B,EAC/B,+BAA+B,EAC/B,yBAAyB,GAC1B,CAAC;AAGF,YAAY,EACV,WAAW,EACX,aAAa,EACb,WAAW,EACX,eAAe,EACf,YAAY,EACZ,uBAAuB,EACvB,aAAa,EACb,OAAO,EACP,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,SAAS,CAAC"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
export type ABTestGroup = 'baseline' | 'monetai' | 'unknown';
|
|
2
2
|
export type PredictResult = 'non-purchaser' | 'purchaser' | null;
|
|
3
|
+
export type PaywallStyle = 'compact' | 'highlight-benefits' | 'key-feature-summary' | 'text-focused';
|
|
4
|
+
export interface Feature {
|
|
5
|
+
title: string;
|
|
6
|
+
description: string;
|
|
7
|
+
isPremiumOnly?: boolean;
|
|
8
|
+
}
|
|
3
9
|
export interface EventParams {
|
|
4
10
|
[key: string]: any;
|
|
5
11
|
}
|
|
@@ -15,10 +21,50 @@ export interface DiscountInfo {
|
|
|
15
21
|
}
|
|
16
22
|
export interface AppUserDiscountResponse {
|
|
17
23
|
id: number;
|
|
18
|
-
started_at:
|
|
19
|
-
ended_at:
|
|
24
|
+
started_at: string;
|
|
25
|
+
ended_at: string;
|
|
20
26
|
app_user_id: string;
|
|
21
27
|
sdk_key: string;
|
|
22
28
|
created_at: Date;
|
|
23
29
|
}
|
|
30
|
+
export interface PaywallConfig {
|
|
31
|
+
enabled: boolean;
|
|
32
|
+
isSubscriber: boolean;
|
|
33
|
+
locale: string;
|
|
34
|
+
discountPercent: number;
|
|
35
|
+
style: PaywallStyle;
|
|
36
|
+
bannerBottom?: number;
|
|
37
|
+
bannerZIndex?: number;
|
|
38
|
+
bannerElevation?: number;
|
|
39
|
+
paywallZIndex?: number;
|
|
40
|
+
paywallElevation?: number;
|
|
41
|
+
regularPrice: string;
|
|
42
|
+
discountedPrice: string;
|
|
43
|
+
features?: Feature[];
|
|
44
|
+
onPurchase?: (closePaywall: () => void) => void;
|
|
45
|
+
onTermsOfService?: () => void;
|
|
46
|
+
onPrivacyPolicy?: () => void;
|
|
47
|
+
}
|
|
48
|
+
export interface PaywallParams {
|
|
49
|
+
discountPercent: string;
|
|
50
|
+
endedAt: string;
|
|
51
|
+
regularPrice: string;
|
|
52
|
+
discountedPrice: string;
|
|
53
|
+
locale: string;
|
|
54
|
+
style: PaywallStyle;
|
|
55
|
+
features?: Feature[];
|
|
56
|
+
zIndex?: number;
|
|
57
|
+
elevation?: number;
|
|
58
|
+
}
|
|
59
|
+
export interface BannerParams {
|
|
60
|
+
enabled: boolean;
|
|
61
|
+
isSubscriber: boolean;
|
|
62
|
+
locale: string;
|
|
63
|
+
discountPercent: number;
|
|
64
|
+
endedAt: Date;
|
|
65
|
+
style: PaywallStyle;
|
|
66
|
+
bottom?: number;
|
|
67
|
+
zIndex?: number;
|
|
68
|
+
elevation?: number;
|
|
69
|
+
}
|
|
24
70
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAC7D,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG,WAAW,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAC7D,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG,WAAW,GAAG,IAAI,CAAC;AAGjE,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,oBAAoB,GACpB,qBAAqB,GACrB,cAAc,CAAC;AAGnB,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,IAAI,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,IAAI,CAAC;CAClB;AAGD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,YAAY,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IAGrB,UAAU,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;IAChD,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,aAAa;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,YAAY,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IAErB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,IAAI,CAAC;IACd,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hayanmind/monetai-react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Unlock hidden app revenue with AI from non-converting users",
|
|
5
5
|
"source": "./src/index.tsx",
|
|
6
6
|
"main": "./lib/commonjs/index.js",
|
|
@@ -80,13 +80,15 @@
|
|
|
80
80
|
"react": "19.0.0",
|
|
81
81
|
"react-native": "0.78.2",
|
|
82
82
|
"react-native-builder-bob": "^0.40.10",
|
|
83
|
+
"react-native-webview": "^13.15.0",
|
|
83
84
|
"release-it": "^17.10.0",
|
|
84
85
|
"turbo": "^1.10.7",
|
|
85
86
|
"typescript": "^5.2.2"
|
|
86
87
|
},
|
|
87
88
|
"peerDependencies": {
|
|
88
89
|
"react": "*",
|
|
89
|
-
"react-native": "*"
|
|
90
|
+
"react-native": "*",
|
|
91
|
+
"react-native-webview": "*"
|
|
90
92
|
},
|
|
91
93
|
"workspaces": [
|
|
92
94
|
"example"
|
package/src/MonetaiProvider.tsx
CHANGED
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
// MonetaiProvider.tsx
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
useCallback,
|
|
4
|
+
useEffect,
|
|
5
|
+
useMemo,
|
|
6
|
+
useState,
|
|
7
|
+
type ReactNode,
|
|
8
|
+
} from 'react';
|
|
3
9
|
import { StyleSheet, View } from 'react-native';
|
|
4
10
|
import monetaiSDK from './MonetaiSDK';
|
|
5
|
-
import type { DiscountInfo } from './types';
|
|
11
|
+
import type { DiscountInfo, PaywallConfig } from './types';
|
|
6
12
|
import { getAppUserDiscount } from './ApiRequest';
|
|
13
|
+
import PaywallManager from './PaywallManager';
|
|
14
|
+
import dayjs from 'dayjs';
|
|
15
|
+
import isBetween from 'dayjs/plugin/isBetween';
|
|
16
|
+
|
|
17
|
+
// dayjs 플러그인 확장
|
|
18
|
+
dayjs.extend(isBetween);
|
|
7
19
|
|
|
8
20
|
const styles = StyleSheet.create({
|
|
9
21
|
container: { flex: 1 },
|
|
10
22
|
});
|
|
11
23
|
|
|
12
24
|
type MonetaiProviderProps = {
|
|
13
|
-
banner?: {
|
|
14
|
-
title: string;
|
|
15
|
-
discountTitle: string;
|
|
16
|
-
onPress: () => void;
|
|
17
|
-
};
|
|
18
25
|
children: ReactNode;
|
|
19
26
|
onDiscountInfoChange?: (discountInfo: DiscountInfo | null) => void;
|
|
27
|
+
paywallConfig?: PaywallConfig; // 통합된 설정 (optional)
|
|
20
28
|
};
|
|
21
29
|
|
|
22
30
|
/**
|
|
@@ -26,43 +34,57 @@ type MonetaiProviderProps = {
|
|
|
26
34
|
export default function MonetaiProvider({
|
|
27
35
|
children,
|
|
28
36
|
onDiscountInfoChange,
|
|
37
|
+
paywallConfig, // 통합된 설정
|
|
29
38
|
}: MonetaiProviderProps) {
|
|
30
39
|
const [discountInfo, setDiscountInfo] = useState<DiscountInfo | null>(null);
|
|
31
40
|
|
|
41
|
+
const onLoadDiscountInfo = useCallback(async () => {
|
|
42
|
+
const userId = await monetaiSDK.getUserId();
|
|
43
|
+
const sdkKey = await monetaiSDK.getSdkKey();
|
|
44
|
+
|
|
45
|
+
if (userId == null || sdkKey == null) {
|
|
46
|
+
console.warn('onLoadDiscountInfo: User ID or SDK Key is not set.');
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const discount = await getAppUserDiscount({ userId, sdkKey });
|
|
51
|
+
if (discount != null && discount.app_user_id !== userId) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const newDiscountInfo =
|
|
56
|
+
discount == null
|
|
57
|
+
? null
|
|
58
|
+
: {
|
|
59
|
+
startedAt: new Date(discount.started_at),
|
|
60
|
+
endedAt: new Date(discount.ended_at),
|
|
61
|
+
userId: discount.app_user_id,
|
|
62
|
+
sdkKey: discount.sdk_key,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
setDiscountInfo(newDiscountInfo);
|
|
66
|
+
}, []);
|
|
67
|
+
|
|
32
68
|
useEffect(() => {
|
|
33
|
-
|
|
34
|
-
const onLoadDiscountInfo = async () => {
|
|
69
|
+
(async () => {
|
|
35
70
|
const userId = await monetaiSDK.getUserId();
|
|
36
71
|
const sdkKey = await monetaiSDK.getSdkKey();
|
|
37
72
|
|
|
38
|
-
if (userId
|
|
39
|
-
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const discount = await getAppUserDiscount({ userId, sdkKey });
|
|
44
|
-
if (discount != null && discount.app_user_id !== userId) {
|
|
45
|
-
return;
|
|
73
|
+
if (userId != null && sdkKey != null) {
|
|
74
|
+
onLoadDiscountInfo();
|
|
46
75
|
}
|
|
76
|
+
})();
|
|
77
|
+
}, [onLoadDiscountInfo]);
|
|
47
78
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
? null
|
|
51
|
-
: {
|
|
52
|
-
startedAt: discount.started_at,
|
|
53
|
-
endedAt: discount.ended_at,
|
|
54
|
-
userId: discount.app_user_id,
|
|
55
|
-
sdkKey: discount.sdk_key,
|
|
56
|
-
}
|
|
57
|
-
);
|
|
58
|
-
};
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
const emitter = monetaiSDK.getEmitter();
|
|
59
81
|
|
|
60
82
|
emitter.on('LOAD_DISCOUNT_INFO', onLoadDiscountInfo);
|
|
61
83
|
|
|
62
84
|
return () => {
|
|
63
85
|
emitter.off('LOAD_DISCOUNT_INFO', onLoadDiscountInfo);
|
|
64
86
|
};
|
|
65
|
-
}, []);
|
|
87
|
+
}, [onLoadDiscountInfo]);
|
|
66
88
|
|
|
67
89
|
useEffect(() => {
|
|
68
90
|
if (onDiscountInfoChange) {
|
|
@@ -70,10 +92,31 @@ export default function MonetaiProvider({
|
|
|
70
92
|
}
|
|
71
93
|
}, [onDiscountInfoChange, discountInfo]);
|
|
72
94
|
|
|
95
|
+
const isPromotionActive = useMemo(() => {
|
|
96
|
+
return (
|
|
97
|
+
paywallConfig?.enabled &&
|
|
98
|
+
!paywallConfig.isSubscriber &&
|
|
99
|
+
discountInfo != null &&
|
|
100
|
+
dayjs().isBetween(
|
|
101
|
+
dayjs(discountInfo.startedAt),
|
|
102
|
+
dayjs(discountInfo.endedAt),
|
|
103
|
+
null,
|
|
104
|
+
'[]'
|
|
105
|
+
)
|
|
106
|
+
);
|
|
107
|
+
}, [discountInfo, paywallConfig]);
|
|
108
|
+
|
|
73
109
|
return (
|
|
74
110
|
<View style={styles.container}>
|
|
75
111
|
{/** 자식(실제 앱 화면) 렌더 */}
|
|
76
112
|
{children}
|
|
113
|
+
|
|
114
|
+
{isPromotionActive && paywallConfig != null && (
|
|
115
|
+
<PaywallManager
|
|
116
|
+
paywallConfig={paywallConfig}
|
|
117
|
+
discountInfo={discountInfo}
|
|
118
|
+
/>
|
|
119
|
+
)}
|
|
77
120
|
</View>
|
|
78
121
|
);
|
|
79
122
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import Banner from './components/Banner';
|
|
2
|
+
import Paywall from './components/Paywall';
|
|
3
|
+
import { useBanner } from './hooks/useBanner';
|
|
4
|
+
import { usePaywall } from './hooks/usePaywall';
|
|
5
|
+
import type { DiscountInfo, PaywallConfig } from './types';
|
|
6
|
+
|
|
7
|
+
const PaywallManager = ({
|
|
8
|
+
paywallConfig,
|
|
9
|
+
discountInfo,
|
|
10
|
+
}: {
|
|
11
|
+
paywallConfig: PaywallConfig;
|
|
12
|
+
discountInfo: DiscountInfo | null;
|
|
13
|
+
}) => {
|
|
14
|
+
// 배너 상태 관리 및 자동 표시 훅 사용
|
|
15
|
+
const { bannerVisible, bannerParams } = useBanner({
|
|
16
|
+
paywallConfig,
|
|
17
|
+
discountInfo,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// 페이월 상태 관리 훅 사용
|
|
21
|
+
const { paywallVisible, paywallParams, openPaywall, closePaywall } =
|
|
22
|
+
usePaywall({
|
|
23
|
+
discountInfo,
|
|
24
|
+
paywallConfig,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// 페이월 열기 (배너 닫기 + 페이월 열기)
|
|
28
|
+
const handlePaywall = () => {
|
|
29
|
+
openPaywall(); // 페이월 열기
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// 구매 처리
|
|
33
|
+
const handlePurchase = () => {
|
|
34
|
+
paywallConfig?.onPurchase?.(closePaywall);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<>
|
|
39
|
+
{bannerParams != null && (
|
|
40
|
+
<Banner
|
|
41
|
+
visible={bannerVisible}
|
|
42
|
+
onPaywall={handlePaywall}
|
|
43
|
+
bannerParams={bannerParams}
|
|
44
|
+
/>
|
|
45
|
+
)}
|
|
46
|
+
{paywallParams && (
|
|
47
|
+
<Paywall
|
|
48
|
+
visible={paywallVisible}
|
|
49
|
+
params={paywallParams}
|
|
50
|
+
onClose={closePaywall}
|
|
51
|
+
onPurchase={handlePurchase}
|
|
52
|
+
onTermsOfService={paywallConfig?.onTermsOfService}
|
|
53
|
+
onPrivacyPolicy={paywallConfig?.onPrivacyPolicy}
|
|
54
|
+
preload
|
|
55
|
+
/>
|
|
56
|
+
)}
|
|
57
|
+
</>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default PaywallManager;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { View, StyleSheet } from 'react-native';
|
|
3
|
+
import { WebView } from 'react-native-webview';
|
|
4
|
+
import type { BannerParams } from '../types';
|
|
5
|
+
import { PAYWELL_BASE_URL, WEBVIEW_USER_AGENT } from '../constants/paywall';
|
|
6
|
+
|
|
7
|
+
const MESSAGE_KEY_CLICK_BANNER = 'CLICK_BANNER';
|
|
8
|
+
|
|
9
|
+
export interface BannerProps {
|
|
10
|
+
visible: boolean;
|
|
11
|
+
onPaywall: () => void;
|
|
12
|
+
bannerParams: BannerParams;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const Banner: React.FC<BannerProps> = ({
|
|
16
|
+
visible,
|
|
17
|
+
onPaywall,
|
|
18
|
+
bannerParams,
|
|
19
|
+
}) => {
|
|
20
|
+
const [isLoaded, setIsLoaded] = useState(false);
|
|
21
|
+
const [hasWebViewError, setHasWebViewError] = useState(false);
|
|
22
|
+
|
|
23
|
+
const handleWebViewMessage = (event: any) => {
|
|
24
|
+
const message = event.nativeEvent.data;
|
|
25
|
+
|
|
26
|
+
if (message === MESSAGE_KEY_CLICK_BANNER) {
|
|
27
|
+
onPaywall();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const getBannerWebViewUrl = () => {
|
|
32
|
+
// Banner 컴포넌트에서 직접 URL 생성
|
|
33
|
+
const baseUrl = `${PAYWELL_BASE_URL}/banner`;
|
|
34
|
+
const bannerStyle = bannerParams.style;
|
|
35
|
+
|
|
36
|
+
// 기본 파라미터들
|
|
37
|
+
const params = new URLSearchParams();
|
|
38
|
+
params.append('discount', bannerParams.discountPercent.toString());
|
|
39
|
+
params.append('locale', bannerParams.locale);
|
|
40
|
+
params.append('endedAt', bannerParams.endedAt.toISOString());
|
|
41
|
+
|
|
42
|
+
const url = `${baseUrl}/${bannerStyle}?${params.toString()}`;
|
|
43
|
+
|
|
44
|
+
return url;
|
|
45
|
+
};
|
|
46
|
+
const isCompactStyle = bannerParams.style === 'compact';
|
|
47
|
+
const isKeyFeatureSummaryStyle = bannerParams.style === 'key-feature-summary';
|
|
48
|
+
const isHighlightBenefitsStyle = bannerParams.style === 'highlight-benefits';
|
|
49
|
+
const isTextFocusedStyle = bannerParams.style === 'text-focused';
|
|
50
|
+
|
|
51
|
+
if (!visible || hasWebViewError) return null;
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<View
|
|
55
|
+
style={[
|
|
56
|
+
styles.bannerContainer,
|
|
57
|
+
{ bottom: bannerParams.bottom ?? 20 },
|
|
58
|
+
bannerParams.zIndex != null && { zIndex: bannerParams.zIndex },
|
|
59
|
+
bannerParams.elevation != null && { elevation: bannerParams.elevation },
|
|
60
|
+
isCompactStyle && styles.compactBannerContainer,
|
|
61
|
+
isKeyFeatureSummaryStyle && styles.keyFeatureSummaryBannerContainer,
|
|
62
|
+
isHighlightBenefitsStyle && styles.highlightBenefitsBannerContainer,
|
|
63
|
+
isCompactStyle && styles.noShadow,
|
|
64
|
+
isTextFocusedStyle && styles.redShadow,
|
|
65
|
+
isKeyFeatureSummaryStyle && styles.blackShadow,
|
|
66
|
+
isHighlightBenefitsStyle && styles.blackShadow,
|
|
67
|
+
isLoaded ? styles.visible : styles.hidden,
|
|
68
|
+
]}
|
|
69
|
+
pointerEvents={isLoaded ? 'auto' : 'none'}
|
|
70
|
+
>
|
|
71
|
+
<View style={styles.innerRoundedContainer}>
|
|
72
|
+
<WebView
|
|
73
|
+
source={{ uri: getBannerWebViewUrl() }}
|
|
74
|
+
onMessage={handleWebViewMessage}
|
|
75
|
+
onLoadStart={() => setIsLoaded(false)}
|
|
76
|
+
onLoadEnd={() => setIsLoaded(true)}
|
|
77
|
+
onError={() => {
|
|
78
|
+
console.error('[MonetaiSDK] Banner WebView onError');
|
|
79
|
+
setHasWebViewError(true);
|
|
80
|
+
}}
|
|
81
|
+
onHttpError={() => {
|
|
82
|
+
console.error('[MonetaiSDK] Banner WebView onHttpError');
|
|
83
|
+
setHasWebViewError(true);
|
|
84
|
+
}}
|
|
85
|
+
javaScriptEnabled={true}
|
|
86
|
+
userAgent={WEBVIEW_USER_AGENT}
|
|
87
|
+
style={styles.webView}
|
|
88
|
+
/>
|
|
89
|
+
</View>
|
|
90
|
+
</View>
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const styles = StyleSheet.create({
|
|
95
|
+
bannerContainer: {
|
|
96
|
+
position: 'absolute',
|
|
97
|
+
left: 12,
|
|
98
|
+
right: 12,
|
|
99
|
+
height: 45, // 기본 높이
|
|
100
|
+
backgroundColor: 'white',
|
|
101
|
+
borderRadius: 12, // 둥근 모서리
|
|
102
|
+
shadowColor: 'rgba(0, 0, 0, 0.25)',
|
|
103
|
+
shadowOffset: {
|
|
104
|
+
width: 0,
|
|
105
|
+
height: 4,
|
|
106
|
+
},
|
|
107
|
+
shadowOpacity: 1,
|
|
108
|
+
shadowRadius: 10,
|
|
109
|
+
elevation: 8,
|
|
110
|
+
flexDirection: 'row',
|
|
111
|
+
alignItems: 'center',
|
|
112
|
+
justifyContent: 'center',
|
|
113
|
+
zIndex: 1000,
|
|
114
|
+
},
|
|
115
|
+
compactBannerContainer: {
|
|
116
|
+
height: 68, // compact 스타일일 때 높이
|
|
117
|
+
},
|
|
118
|
+
noShadow: {
|
|
119
|
+
shadowColor: 'transparent',
|
|
120
|
+
shadowOffset: { width: 0, height: 0 },
|
|
121
|
+
shadowOpacity: 0,
|
|
122
|
+
shadowRadius: 0,
|
|
123
|
+
},
|
|
124
|
+
webView: {
|
|
125
|
+
flex: 1,
|
|
126
|
+
},
|
|
127
|
+
visible: {
|
|
128
|
+
opacity: 1,
|
|
129
|
+
},
|
|
130
|
+
hidden: {
|
|
131
|
+
opacity: 0,
|
|
132
|
+
},
|
|
133
|
+
innerRoundedContainer: {
|
|
134
|
+
flex: 1,
|
|
135
|
+
borderRadius: 12,
|
|
136
|
+
overflow: 'hidden',
|
|
137
|
+
},
|
|
138
|
+
keyFeatureSummaryBannerContainer: {
|
|
139
|
+
height: 56, // key-feature-summary 스타일일 때 높이
|
|
140
|
+
},
|
|
141
|
+
highlightBenefitsBannerContainer: {
|
|
142
|
+
height: 56, // highlight-benefits 스타일일 때 높이
|
|
143
|
+
},
|
|
144
|
+
blackShadow: {
|
|
145
|
+
shadowColor: 'rgba(0, 0, 0, 0.25)',
|
|
146
|
+
},
|
|
147
|
+
redShadow: {
|
|
148
|
+
shadowColor: 'rgba(228, 78, 72, 0.25)',
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
export default Banner;
|