@billdog.io/react-native 1.0.0-beta.2
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/BillDogReactNative.podspec +30 -0
- package/LICENSE +21 -0
- package/README.md +330 -0
- package/android/build.gradle +99 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/kotlin/io/billdog/reactnative/BillDogABTestModule.kt +317 -0
- package/android/src/main/kotlin/io/billdog/reactnative/BillDogAnalyticsModule.kt +389 -0
- package/android/src/main/kotlin/io/billdog/reactnative/BillDogModule.kt +817 -0
- package/android/src/main/kotlin/io/billdog/reactnative/BillDogPaywallViewManager.kt +383 -0
- package/android/src/main/kotlin/io/billdog/reactnative/BillDogSurveyModule.kt +427 -0
- package/android/src/main/kotlin/io/billdog/reactnative/BillDogVirtualCurrencyModule.kt +407 -0
- package/android/src/main/kotlin/io/billdog/virtualcurrency/BillDogVirtualCurrencyPackage.kt +44 -0
- package/dist/AdvancedPaywallCache.d.ts +70 -0
- package/dist/AdvancedPaywallCache.js +344 -0
- package/dist/BillDog.d.ts +255 -0
- package/dist/BillDog.js +918 -0
- package/dist/BillDogConfiguration.d.ts +145 -0
- package/dist/BillDogConfiguration.js +229 -0
- package/dist/ComponentRenderer.d.ts +17 -0
- package/dist/ComponentRenderer.js +886 -0
- package/dist/LayoutEngine.d.ts +101 -0
- package/dist/LayoutEngine.js +394 -0
- package/dist/LocalizationResolver.d.ts +99 -0
- package/dist/LocalizationResolver.js +266 -0
- package/dist/NativePaywallView.d.ts +36 -0
- package/dist/NativePaywallView.js +59 -0
- package/dist/PaywallCache.d.ts +74 -0
- package/dist/PaywallCache.js +293 -0
- package/dist/PaywallStateManager.d.ts +62 -0
- package/dist/PaywallStateManager.js +147 -0
- package/dist/PaywallView.d.ts +42 -0
- package/dist/PaywallView.js +275 -0
- package/dist/ProductVariableProvider.d.ts +60 -0
- package/dist/ProductVariableProvider.js +239 -0
- package/dist/VariableResolver.d.ts +120 -0
- package/dist/VariableResolver.js +379 -0
- package/dist/WebViewPaywall.d.ts +75 -0
- package/dist/WebViewPaywall.js +360 -0
- package/dist/animations/presets.d.ts +49 -0
- package/dist/animations/presets.js +367 -0
- package/dist/components/AccoladeCpsComponent.d.ts +13 -0
- package/dist/components/AccoladeCpsComponent.js +248 -0
- package/dist/components/AccordionComponent.d.ts +10 -0
- package/dist/components/AccordionComponent.js +187 -0
- package/dist/components/AnimatedWrapper.d.ts +35 -0
- package/dist/components/AnimatedWrapper.js +277 -0
- package/dist/components/CarouselComponent.d.ts +23 -0
- package/dist/components/CarouselComponent.js +484 -0
- package/dist/components/ChartCurveComponent.d.ts +13 -0
- package/dist/components/ChartCurveComponent.js +333 -0
- package/dist/components/CheckboxComponent.d.ts +9 -0
- package/dist/components/CheckboxComponent.js +172 -0
- package/dist/components/ConfettiComponent.d.ts +9 -0
- package/dist/components/ConfettiComponent.js +172 -0
- package/dist/components/CountdownComponent.d.ts +16 -0
- package/dist/components/CountdownComponent.js +414 -0
- package/dist/components/DelayedXComponent.d.ts +12 -0
- package/dist/components/DelayedXComponent.js +240 -0
- package/dist/components/DrawerModalComponent.d.ts +20 -0
- package/dist/components/DrawerModalComponent.js +286 -0
- package/dist/components/GradientView.d.ts +38 -0
- package/dist/components/GradientView.js +126 -0
- package/dist/components/HapticFeedbackComponent.d.ts +16 -0
- package/dist/components/HapticFeedbackComponent.js +64 -0
- package/dist/components/HorizontalProductsComponent.d.ts +17 -0
- package/dist/components/HorizontalProductsComponent.js +284 -0
- package/dist/components/MultiChoiceGridComponent.d.ts +13 -0
- package/dist/components/MultiChoiceGridComponent.js +234 -0
- package/dist/components/NPSScaleComponent.d.ts +16 -0
- package/dist/components/NPSScaleComponent.js +260 -0
- package/dist/components/NavigationComponent.d.ts +26 -0
- package/dist/components/NavigationComponent.js +302 -0
- package/dist/components/OAuthButtonComponent.d.ts +20 -0
- package/dist/components/OAuthButtonComponent.js +237 -0
- package/dist/components/ProgressLoaderComponent.d.ts +13 -0
- package/dist/components/ProgressLoaderComponent.js +308 -0
- package/dist/components/ProgressStepperComponent.d.ts +18 -0
- package/dist/components/ProgressStepperComponent.js +228 -0
- package/dist/components/SegmentedPickerComponent.d.ts +10 -0
- package/dist/components/SegmentedPickerComponent.js +221 -0
- package/dist/components/ShareButtonsComponent.d.ts +21 -0
- package/dist/components/ShareButtonsComponent.js +265 -0
- package/dist/components/ShareCodeComponent.d.ts +16 -0
- package/dist/components/ShareCodeComponent.js +274 -0
- package/dist/components/SingleChoiceGridComponent.d.ts +13 -0
- package/dist/components/SingleChoiceGridComponent.js +210 -0
- package/dist/components/SliderComponent.d.ts +9 -0
- package/dist/components/SliderComponent.js +263 -0
- package/dist/components/StarRatingInputComponent.d.ts +20 -0
- package/dist/components/StarRatingInputComponent.js +198 -0
- package/dist/components/StickerCompositeComponent.d.ts +13 -0
- package/dist/components/StickerCompositeComponent.js +136 -0
- package/dist/components/TabsComponent.d.ts +19 -0
- package/dist/components/TabsComponent.js +431 -0
- package/dist/components/TextInputComponent.d.ts +18 -0
- package/dist/components/TextInputComponent.js +227 -0
- package/dist/components/TimelineComponent.d.ts +19 -0
- package/dist/components/TimelineComponent.js +104 -0
- package/dist/components/ToggleComponent.d.ts +14 -0
- package/dist/components/ToggleComponent.js +132 -0
- package/dist/components/VerticalProductsComponent.d.ts +17 -0
- package/dist/components/VerticalProductsComponent.js +311 -0
- package/dist/dynamicValues.d.ts +36 -0
- package/dist/dynamicValues.js +142 -0
- package/dist/filters/dateFilters.d.ts +50 -0
- package/dist/filters/dateFilters.js +390 -0
- package/dist/filters/index.d.ts +18 -0
- package/dist/filters/index.js +253 -0
- package/dist/hooks/useOfferings.d.ts +76 -0
- package/dist/hooks/useOfferings.js +99 -0
- package/dist/hooks/usePaywall.d.ts +27 -0
- package/dist/hooks/usePaywall.js +114 -0
- package/dist/hooks/usePlacement.d.ts +34 -0
- package/dist/hooks/usePlacement.js +89 -0
- package/dist/hooks/useSubscription.d.ts +40 -0
- package/dist/hooks/useSubscription.js +97 -0
- package/dist/index.d.ts +98 -0
- package/dist/index.js +198 -0
- package/dist/models/BillDogError.d.ts +40 -0
- package/dist/models/BillDogError.js +11 -0
- package/dist/models/CacheFetchPolicy.d.ts +8 -0
- package/dist/models/CacheFetchPolicy.js +4 -0
- package/dist/models/CustomProduct.d.ts +32 -0
- package/dist/models/CustomProduct.js +15 -0
- package/dist/models/CustomerInfo.d.ts +17 -0
- package/dist/models/CustomerInfo.js +11 -0
- package/dist/models/Delegate.d.ts +20 -0
- package/dist/models/Delegate.js +11 -0
- package/dist/models/EntitlementInfo.d.ts +19 -0
- package/dist/models/EntitlementInfo.js +2 -0
- package/dist/models/Placement.d.ts +54 -0
- package/dist/models/Placement.js +15 -0
- package/dist/models/PurchaseParams.d.ts +39 -0
- package/dist/models/PurchaseParams.js +60 -0
- package/dist/models/PurchaseResult.d.ts +30 -0
- package/dist/models/PurchaseResult.js +15 -0
- package/dist/models/RestoreResult.d.ts +30 -0
- package/dist/models/RestoreResult.js +22 -0
- package/dist/models/RestoredItem.d.ts +26 -0
- package/dist/models/RestoredItem.js +13 -0
- package/dist/modules/ABTest.d.ts +65 -0
- package/dist/modules/ABTest.js +113 -0
- package/dist/modules/Analytics.d.ts +91 -0
- package/dist/modules/Analytics.js +182 -0
- package/dist/modules/Survey.d.ts +65 -0
- package/dist/modules/Survey.js +82 -0
- package/dist/modules/VirtualCurrency.d.ts +63 -0
- package/dist/modules/VirtualCurrency.js +147 -0
- package/dist/murmur.d.ts +23 -0
- package/dist/murmur.js +104 -0
- package/dist/notifications/LiveActivitiesManager.d.ts +47 -0
- package/dist/notifications/LiveActivitiesManager.js +106 -0
- package/dist/notifications/NotificationScheduler.d.ts +55 -0
- package/dist/notifications/NotificationScheduler.js +199 -0
- package/dist/notifications/PurchaseNotificationHandler.d.ts +24 -0
- package/dist/notifications/PurchaseNotificationHandler.js +55 -0
- package/dist/notifications/useDeviceToken.d.ts +36 -0
- package/dist/notifications/useDeviceToken.js +97 -0
- package/dist/notifications/useLiveActivity.d.ts +39 -0
- package/dist/notifications/useLiveActivity.js +104 -0
- package/dist/review/ReviewAnalytics.d.ts +34 -0
- package/dist/review/ReviewAnalytics.js +73 -0
- package/dist/review/ReviewManager.d.ts +83 -0
- package/dist/review/ReviewManager.js +339 -0
- package/dist/review/ReviewTimingManager.d.ts +82 -0
- package/dist/review/ReviewTimingManager.js +224 -0
- package/dist/survey-core/types.d.ts +215 -0
- package/dist/survey-core/types.js +8 -0
- package/dist/types.d.ts +438 -0
- package/dist/types.js +158 -0
- package/dist/utils/ApiClient.d.ts +65 -0
- package/dist/utils/ApiClient.js +132 -0
- package/dist/utils/CSSConverter.d.ts +49 -0
- package/dist/utils/CSSConverter.js +470 -0
- package/dist/utils/animations.d.ts +41 -0
- package/dist/utils/animations.js +194 -0
- package/dist/utils/calendarIntegration.d.ts +36 -0
- package/dist/utils/calendarIntegration.js +89 -0
- package/dist/utils/configurationResolver.d.ts +23 -0
- package/dist/utils/configurationResolver.js +78 -0
- package/dist/utils/deviceDetection.d.ts +38 -0
- package/dist/utils/deviceDetection.js +59 -0
- package/dist/utils/hapticFeedback.d.ts +17 -0
- package/dist/utils/hapticFeedback.js +53 -0
- package/dist/utils/iconMapper.d.ts +26 -0
- package/dist/utils/iconMapper.js +113 -0
- package/dist/utils/notificationPermissions.d.ts +13 -0
- package/dist/utils/notificationPermissions.js +51 -0
- package/dist/utils/priceFormatting.d.ts +19 -0
- package/dist/utils/priceFormatting.js +99 -0
- package/dist/utils/shareSheet.d.ts +17 -0
- package/dist/utils/shareSheet.js +42 -0
- package/dist/utils/subscriptionUpgrade.d.ts +84 -0
- package/dist/utils/subscriptionUpgrade.js +100 -0
- package/dist/valueUtils.d.ts +48 -0
- package/dist/valueUtils.js +129 -0
- package/dist/xFlowTags.d.ts +18 -0
- package/dist/xFlowTags.js +385 -0
- package/ios/BillDogABTest.m +50 -0
- package/ios/BillDogABTest.swift +188 -0
- package/ios/BillDogAnalytics.m +105 -0
- package/ios/BillDogAnalytics.swift +324 -0
- package/ios/BillDogBridge.m +222 -0
- package/ios/BillDogBridge.swift +715 -0
- package/ios/BillDogLiveActivities.m +41 -0
- package/ios/BillDogLiveActivities.swift +104 -0
- package/ios/BillDogPaywallViewManager.m +39 -0
- package/ios/BillDogPaywallViewManager.swift +361 -0
- package/ios/BillDogSurvey.m +34 -0
- package/ios/BillDogSurvey.swift +257 -0
- package/ios/BillDogVirtualCurrencyBridge.m +63 -0
- package/ios/BillDogVirtualCurrencyBridge.swift +511 -0
- package/junit.xml +25 -0
- package/package.json +61 -0
- package/react-native.config.js +13 -0
- package/src/AdvancedPaywallCache.ts +433 -0
- package/src/BillDog.ts +983 -0
- package/src/BillDogConfiguration.ts +318 -0
- package/src/ComponentRenderer.tsx +1325 -0
- package/src/LayoutEngine.ts +459 -0
- package/src/LocalizationResolver.ts +311 -0
- package/src/NativePaywallView.tsx +132 -0
- package/src/PaywallCache.ts +358 -0
- package/src/PaywallStateManager.ts +154 -0
- package/src/PaywallView.tsx +328 -0
- package/src/ProductVariableProvider.ts +282 -0
- package/src/VariableResolver.ts +516 -0
- package/src/WebViewPaywall.tsx +454 -0
- package/src/animations/presets.ts +421 -0
- package/src/components/AccoladeCpsComponent.tsx +259 -0
- package/src/components/AccordionComponent.tsx +213 -0
- package/src/components/AnimatedWrapper.tsx +316 -0
- package/src/components/CarouselComponent.tsx +615 -0
- package/src/components/ChartCurveComponent.tsx +452 -0
- package/src/components/CheckboxComponent.tsx +185 -0
- package/src/components/ConfettiComponent.tsx +178 -0
- package/src/components/CountdownComponent.tsx +454 -0
- package/src/components/DelayedXComponent.tsx +266 -0
- package/src/components/DrawerModalComponent.tsx +324 -0
- package/src/components/GradientView.tsx +129 -0
- package/src/components/HapticFeedbackComponent.tsx +39 -0
- package/src/components/HorizontalProductsComponent.tsx +329 -0
- package/src/components/MultiChoiceGridComponent.tsx +265 -0
- package/src/components/NPSScaleComponent.tsx +294 -0
- package/src/components/NavigationComponent.tsx +329 -0
- package/src/components/OAuthButtonComponent.tsx +266 -0
- package/src/components/ProgressLoaderComponent.tsx +366 -0
- package/src/components/ProgressStepperComponent.tsx +250 -0
- package/src/components/SegmentedPickerComponent.tsx +245 -0
- package/src/components/ShareButtonsComponent.tsx +299 -0
- package/src/components/ShareCodeComponent.tsx +303 -0
- package/src/components/SingleChoiceGridComponent.tsx +229 -0
- package/src/components/SliderComponent.tsx +280 -0
- package/src/components/StarRatingInputComponent.tsx +223 -0
- package/src/components/StickerCompositeComponent.tsx +168 -0
- package/src/components/TabsComponent.tsx +496 -0
- package/src/components/TextInputComponent.tsx +258 -0
- package/src/components/TimelineComponent.tsx +129 -0
- package/src/components/ToggleComponent.tsx +142 -0
- package/src/components/VerticalProductsComponent.tsx +357 -0
- package/src/dynamicValues.ts +180 -0
- package/src/filters/dateFilters.ts +411 -0
- package/src/filters/index.ts +281 -0
- package/src/hooks/useOfferings.ts +192 -0
- package/src/hooks/usePaywall.ts +154 -0
- package/src/hooks/usePlacement.ts +143 -0
- package/src/hooks/useSubscription.ts +154 -0
- package/src/index.ts +245 -0
- package/src/models/BillDogError.ts +24 -0
- package/src/models/CacheFetchPolicy.ts +13 -0
- package/src/models/CustomProduct.ts +33 -0
- package/src/models/CustomerInfo.ts +26 -0
- package/src/models/Delegate.ts +22 -0
- package/src/models/EntitlementInfo.ts +27 -0
- package/src/models/Placement.ts +50 -0
- package/src/models/PurchaseParams.ts +81 -0
- package/src/models/PurchaseResult.ts +32 -0
- package/src/models/RestoreResult.ts +27 -0
- package/src/models/RestoredItem.ts +25 -0
- package/src/modules/ABTest.ts +131 -0
- package/src/modules/Analytics.ts +227 -0
- package/src/modules/Survey.ts +126 -0
- package/src/modules/VirtualCurrency.ts +223 -0
- package/src/murmur.ts +102 -0
- package/src/notifications/LiveActivitiesManager.ts +140 -0
- package/src/notifications/NotificationScheduler.ts +292 -0
- package/src/notifications/PurchaseNotificationHandler.ts +67 -0
- package/src/notifications/useDeviceToken.ts +116 -0
- package/src/notifications/useLiveActivity.ts +125 -0
- package/src/review/ReviewAnalytics.ts +89 -0
- package/src/review/ReviewManager.ts +355 -0
- package/src/review/ReviewTimingManager.ts +265 -0
- package/src/survey-core/types.ts +244 -0
- package/src/types/ambient.d.ts +9 -0
- package/src/types.ts +680 -0
- package/src/utils/ApiClient.ts +163 -0
- package/src/utils/CSSConverter.ts +552 -0
- package/src/utils/animations.ts +232 -0
- package/src/utils/calendarIntegration.ts +113 -0
- package/src/utils/configurationResolver.ts +106 -0
- package/src/utils/deviceDetection.ts +83 -0
- package/src/utils/hapticFeedback.ts +55 -0
- package/src/utils/iconMapper.ts +102 -0
- package/src/utils/notificationPermissions.ts +48 -0
- package/src/utils/priceFormatting.ts +119 -0
- package/src/utils/shareSheet.ts +55 -0
- package/src/utils/subscriptionUpgrade.ts +183 -0
- package/src/valueUtils.ts +108 -0
- package/src/xFlowTags.ts +463 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StarRatingInputComponent - React Native
|
|
3
|
+
*
|
|
4
|
+
* Interactive star rating with customizable appearance.
|
|
5
|
+
* Features:
|
|
6
|
+
* - Configurable max stars
|
|
7
|
+
* - Half-star support
|
|
8
|
+
* - State manager integration
|
|
9
|
+
* - Animated feedback
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import React, { useState, useEffect, useCallback } from 'react';
|
|
13
|
+
import {
|
|
14
|
+
View,
|
|
15
|
+
Text,
|
|
16
|
+
TouchableOpacity,
|
|
17
|
+
StyleSheet,
|
|
18
|
+
Animated,
|
|
19
|
+
} from 'react-native';
|
|
20
|
+
import { PaywallComponent } from '../types';
|
|
21
|
+
|
|
22
|
+
interface StarRatingInputComponentProps {
|
|
23
|
+
component: PaywallComponent;
|
|
24
|
+
stateManager?: any;
|
|
25
|
+
isPreviewMode?: boolean;
|
|
26
|
+
renderComponent?: (component: PaywallComponent) => React.ReactNode;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const StarRatingInputComponent: React.FC<StarRatingInputComponentProps> = ({
|
|
30
|
+
component,
|
|
31
|
+
stateManager,
|
|
32
|
+
isPreviewMode = false,
|
|
33
|
+
renderComponent,
|
|
34
|
+
}) => {
|
|
35
|
+
const props = component.properties as any;
|
|
36
|
+
const componentId = component.id;
|
|
37
|
+
|
|
38
|
+
// Rating configuration
|
|
39
|
+
const maxStars = props.maxStars ?? 5;
|
|
40
|
+
const defaultRating = Math.min(Math.max(props.defaultRating ?? 0, 0), maxStars);
|
|
41
|
+
const allowHalfStars = props.allowHalfStars ?? false;
|
|
42
|
+
const allowZeroRating = props.allowZeroRating ?? true;
|
|
43
|
+
const disabled = props.disabled ?? false;
|
|
44
|
+
const tapSameToDeselect = props.tapSameToDeselect ?? true;
|
|
45
|
+
|
|
46
|
+
// Label configuration
|
|
47
|
+
const showLabel = props.showLabel ?? true;
|
|
48
|
+
const labelText = props.labelText ?? 'Rate your experience';
|
|
49
|
+
const labelFontSize = props.labelFontSize?.value ?? 16;
|
|
50
|
+
const labelFontWeight = props.labelFontWeight ?? '600';
|
|
51
|
+
const labelTextColor = props.labelTextColor ?? '#1F2937';
|
|
52
|
+
|
|
53
|
+
// Star appearance
|
|
54
|
+
const starSize = props.starSize ?? 32;
|
|
55
|
+
const starSpacing = props.starSpacing ?? 4;
|
|
56
|
+
const activeColor = props.activeColor ?? '#FFD700';
|
|
57
|
+
const inactiveColor = props.inactiveColor ?? '#D1D5DB';
|
|
58
|
+
|
|
59
|
+
// Display options
|
|
60
|
+
const showRatingText = props.showRatingText ?? true;
|
|
61
|
+
const ratingTextFormat = props.ratingTextFormat ?? 'fraction';
|
|
62
|
+
const ratingTextFontSize = props.ratingTextFontSize?.value ?? 14;
|
|
63
|
+
const ratingTextColor = props.ratingTextColor ?? '#6B7280';
|
|
64
|
+
|
|
65
|
+
const [currentRating, setCurrentRating] = useState(defaultRating);
|
|
66
|
+
const [animatedScales] = useState(() =>
|
|
67
|
+
Array.from({ length: maxStars }, () => new Animated.Value(1))
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
// Connect to state manager
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (stateManager) {
|
|
73
|
+
// Subscribe to external changes
|
|
74
|
+
return stateManager.subscribeToState(
|
|
75
|
+
`element:${componentId}.rating`,
|
|
76
|
+
(value: number) => {
|
|
77
|
+
if (value !== currentRating) {
|
|
78
|
+
setCurrentRating(value);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
}, [componentId, stateManager, currentRating]);
|
|
84
|
+
|
|
85
|
+
// Update state manager when rating changes
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
if (stateManager) {
|
|
88
|
+
stateManager.updateState(`element:${componentId}.rating`, currentRating);
|
|
89
|
+
}
|
|
90
|
+
}, [componentId, currentRating, stateManager]);
|
|
91
|
+
|
|
92
|
+
// Handle star press
|
|
93
|
+
const handleStarPress = useCallback((starIndex: number) => {
|
|
94
|
+
if (disabled) return;
|
|
95
|
+
|
|
96
|
+
let newRating = starIndex + 1;
|
|
97
|
+
|
|
98
|
+
// Tap same to deselect
|
|
99
|
+
if (tapSameToDeselect && newRating === currentRating) {
|
|
100
|
+
newRating = allowZeroRating ? 0 : 1;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Clamp rating
|
|
104
|
+
newRating = Math.max(allowZeroRating ? 0 : 1, Math.min(maxStars, newRating));
|
|
105
|
+
|
|
106
|
+
// Animate the star
|
|
107
|
+
Animated.sequence([
|
|
108
|
+
Animated.timing(animatedScales[starIndex], {
|
|
109
|
+
toValue: 1.3,
|
|
110
|
+
duration: 100,
|
|
111
|
+
useNativeDriver: true,
|
|
112
|
+
}),
|
|
113
|
+
Animated.timing(animatedScales[starIndex], {
|
|
114
|
+
toValue: 1,
|
|
115
|
+
duration: 100,
|
|
116
|
+
useNativeDriver: true,
|
|
117
|
+
}),
|
|
118
|
+
]).start();
|
|
119
|
+
|
|
120
|
+
setCurrentRating(newRating);
|
|
121
|
+
}, [disabled, tapSameToDeselect, currentRating, allowZeroRating, maxStars, animatedScales]);
|
|
122
|
+
|
|
123
|
+
// Format rating text
|
|
124
|
+
const formatRatingText = useCallback(() => {
|
|
125
|
+
switch (ratingTextFormat) {
|
|
126
|
+
case 'written':
|
|
127
|
+
return `${currentRating} of ${maxStars}`;
|
|
128
|
+
case 'stars':
|
|
129
|
+
return `${currentRating} ${currentRating === 1 ? 'star' : 'stars'}`;
|
|
130
|
+
case 'percentage':
|
|
131
|
+
return `${Math.round((currentRating / maxStars) * 100)}%`;
|
|
132
|
+
case 'fraction':
|
|
133
|
+
default:
|
|
134
|
+
return `${currentRating}/${maxStars}`;
|
|
135
|
+
}
|
|
136
|
+
}, [currentRating, maxStars, ratingTextFormat]);
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<View style={[styles.container, disabled && styles.disabled]}>
|
|
140
|
+
{/* Label */}
|
|
141
|
+
{showLabel && labelText && (
|
|
142
|
+
<Text
|
|
143
|
+
style={[
|
|
144
|
+
styles.label,
|
|
145
|
+
{
|
|
146
|
+
fontSize: labelFontSize,
|
|
147
|
+
fontWeight: labelFontWeight as any,
|
|
148
|
+
color: labelTextColor,
|
|
149
|
+
},
|
|
150
|
+
]}
|
|
151
|
+
>
|
|
152
|
+
{labelText}
|
|
153
|
+
</Text>
|
|
154
|
+
)}
|
|
155
|
+
|
|
156
|
+
{/* Stars Row */}
|
|
157
|
+
<View style={[styles.starsRow, { gap: starSpacing }]}>
|
|
158
|
+
{Array.from({ length: maxStars }, (_, index) => {
|
|
159
|
+
const isFilled = index < currentRating;
|
|
160
|
+
|
|
161
|
+
return (
|
|
162
|
+
<TouchableOpacity
|
|
163
|
+
key={index}
|
|
164
|
+
onPress={() => handleStarPress(index)}
|
|
165
|
+
disabled={disabled}
|
|
166
|
+
activeOpacity={0.7}
|
|
167
|
+
>
|
|
168
|
+
<Animated.View
|
|
169
|
+
style={{
|
|
170
|
+
transform: [{ scale: animatedScales[index] }],
|
|
171
|
+
}}
|
|
172
|
+
>
|
|
173
|
+
<Text
|
|
174
|
+
style={{
|
|
175
|
+
fontSize: starSize,
|
|
176
|
+
color: isFilled ? activeColor : inactiveColor,
|
|
177
|
+
}}
|
|
178
|
+
>
|
|
179
|
+
★
|
|
180
|
+
</Text>
|
|
181
|
+
</Animated.View>
|
|
182
|
+
</TouchableOpacity>
|
|
183
|
+
);
|
|
184
|
+
})}
|
|
185
|
+
</View>
|
|
186
|
+
|
|
187
|
+
{/* Rating Text */}
|
|
188
|
+
{showRatingText && (
|
|
189
|
+
<Text
|
|
190
|
+
style={[
|
|
191
|
+
styles.ratingText,
|
|
192
|
+
{
|
|
193
|
+
fontSize: ratingTextFontSize,
|
|
194
|
+
color: ratingTextColor,
|
|
195
|
+
},
|
|
196
|
+
]}
|
|
197
|
+
>
|
|
198
|
+
{formatRatingText()}
|
|
199
|
+
</Text>
|
|
200
|
+
)}
|
|
201
|
+
</View>
|
|
202
|
+
);
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const styles = StyleSheet.create({
|
|
206
|
+
container: {
|
|
207
|
+
alignItems: 'center',
|
|
208
|
+
gap: 12,
|
|
209
|
+
},
|
|
210
|
+
disabled: {
|
|
211
|
+
opacity: 0.5,
|
|
212
|
+
},
|
|
213
|
+
label: {
|
|
214
|
+
textAlign: 'center',
|
|
215
|
+
},
|
|
216
|
+
starsRow: {
|
|
217
|
+
flexDirection: 'row',
|
|
218
|
+
alignItems: 'center',
|
|
219
|
+
},
|
|
220
|
+
ratingText: {
|
|
221
|
+
textAlign: 'center',
|
|
222
|
+
},
|
|
223
|
+
});
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StickerCompositeComponent - Native React Native implementation
|
|
3
|
+
* Positioned overlay sticker with rotation, icons, images, and text
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import {
|
|
8
|
+
View,
|
|
9
|
+
Text,
|
|
10
|
+
Image,
|
|
11
|
+
StyleSheet,
|
|
12
|
+
} from 'react-native';
|
|
13
|
+
import { PaywallComponent } from '../types';
|
|
14
|
+
|
|
15
|
+
interface StickerCompositeComponentProps {
|
|
16
|
+
component: PaywallComponent;
|
|
17
|
+
stateManager?: any;
|
|
18
|
+
isPreviewMode?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Icon mapping for common icon names
|
|
22
|
+
const ICON_MAP: Record<string, string> = {
|
|
23
|
+
star: '⭐',
|
|
24
|
+
heart: '❤️',
|
|
25
|
+
fire: '🔥',
|
|
26
|
+
check: '✅',
|
|
27
|
+
crown: '👑',
|
|
28
|
+
lightning: '⚡',
|
|
29
|
+
trophy: '🏆',
|
|
30
|
+
diamond: '💎',
|
|
31
|
+
rocket: '🚀',
|
|
32
|
+
gift: '🎁',
|
|
33
|
+
medal: '🏅',
|
|
34
|
+
sparkle: '✨',
|
|
35
|
+
thumbsup: '👍',
|
|
36
|
+
badge: '🏷️',
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const getColorFromValue = (value: any, fallback: string): string => {
|
|
40
|
+
if (!value) return fallback;
|
|
41
|
+
if (typeof value === 'string') return value;
|
|
42
|
+
if (typeof value === 'object' && value.color) return value.color;
|
|
43
|
+
return fallback;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const StickerCompositeComponent: React.FC<StickerCompositeComponentProps> = ({
|
|
47
|
+
component,
|
|
48
|
+
stateManager,
|
|
49
|
+
isPreviewMode = false,
|
|
50
|
+
}) => {
|
|
51
|
+
const props = component.properties as any;
|
|
52
|
+
|
|
53
|
+
// Properties
|
|
54
|
+
const imageUrl = props.imageUrl as string | undefined;
|
|
55
|
+
const iconName = props.iconName as string | undefined;
|
|
56
|
+
const text = props.text as string | undefined;
|
|
57
|
+
const rotation = (props.rotation as number) || 0;
|
|
58
|
+
const backgroundColor = getColorFromValue(props.backgroundColor, '#FFEB3B');
|
|
59
|
+
const borderRadius = (props.borderRadius as number) ?? 8;
|
|
60
|
+
const borderColor = props.borderColor ? getColorFromValue(props.borderColor, 'transparent') : undefined;
|
|
61
|
+
const borderWidth = (props.borderWidth as number) ?? 0;
|
|
62
|
+
const shadowColor = props.shadowColor ? getColorFromValue(props.shadowColor, 'rgba(0,0,0,0.2)') : undefined;
|
|
63
|
+
const shadowBlur = (props.shadowBlur as number) ?? 8;
|
|
64
|
+
const paddingHorizontal = (props.paddingHorizontal as number) ?? 16;
|
|
65
|
+
const paddingVertical = (props.paddingVertical as number) ?? 8;
|
|
66
|
+
const fontSize = (props.fontSize as number) ?? 14;
|
|
67
|
+
const textColor = getColorFromValue(props.textColor, '#000000');
|
|
68
|
+
const fontWeight = (props.fontWeight as string) ?? '600';
|
|
69
|
+
const iconSize = (props.iconSize as number) ?? 24;
|
|
70
|
+
const iconColor = props.iconColor ? getColorFromValue(props.iconColor, textColor) : textColor;
|
|
71
|
+
|
|
72
|
+
// Get icon emoji
|
|
73
|
+
const iconEmoji = iconName ? ICON_MAP[iconName.toLowerCase()] || '🏷️' : null;
|
|
74
|
+
|
|
75
|
+
// Build content
|
|
76
|
+
const hasIcon = !!iconEmoji;
|
|
77
|
+
const hasImage = !!imageUrl;
|
|
78
|
+
const hasText = !!text;
|
|
79
|
+
|
|
80
|
+
if (!hasIcon && !hasImage && !hasText) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<View
|
|
86
|
+
style={[
|
|
87
|
+
styles.container,
|
|
88
|
+
{
|
|
89
|
+
transform: [{ rotate: `${rotation}deg` }],
|
|
90
|
+
backgroundColor,
|
|
91
|
+
borderRadius,
|
|
92
|
+
paddingHorizontal,
|
|
93
|
+
paddingVertical,
|
|
94
|
+
...(borderColor && borderWidth > 0 && {
|
|
95
|
+
borderColor,
|
|
96
|
+
borderWidth,
|
|
97
|
+
}),
|
|
98
|
+
...(shadowColor && {
|
|
99
|
+
shadowColor,
|
|
100
|
+
shadowOffset: { width: 2, height: 2 },
|
|
101
|
+
shadowOpacity: 0.3,
|
|
102
|
+
shadowRadius: shadowBlur / 2,
|
|
103
|
+
elevation: 4,
|
|
104
|
+
}),
|
|
105
|
+
},
|
|
106
|
+
]}
|
|
107
|
+
>
|
|
108
|
+
{/* Icon */}
|
|
109
|
+
{hasIcon && (
|
|
110
|
+
<Text style={[styles.icon, { fontSize: iconSize }]}>
|
|
111
|
+
{iconEmoji}
|
|
112
|
+
</Text>
|
|
113
|
+
)}
|
|
114
|
+
|
|
115
|
+
{/* Image */}
|
|
116
|
+
{hasImage && (
|
|
117
|
+
<Image
|
|
118
|
+
source={{ uri: imageUrl }}
|
|
119
|
+
style={[
|
|
120
|
+
styles.image,
|
|
121
|
+
{
|
|
122
|
+
width: iconSize,
|
|
123
|
+
height: iconSize,
|
|
124
|
+
borderRadius: borderRadius / 2,
|
|
125
|
+
},
|
|
126
|
+
]}
|
|
127
|
+
resizeMode="cover"
|
|
128
|
+
/>
|
|
129
|
+
)}
|
|
130
|
+
|
|
131
|
+
{/* Text */}
|
|
132
|
+
{hasText && (
|
|
133
|
+
<Text
|
|
134
|
+
style={[
|
|
135
|
+
styles.text,
|
|
136
|
+
{
|
|
137
|
+
fontSize,
|
|
138
|
+
color: textColor,
|
|
139
|
+
fontWeight: fontWeight as any,
|
|
140
|
+
marginLeft: (hasIcon || hasImage) ? 8 : 0,
|
|
141
|
+
},
|
|
142
|
+
]}
|
|
143
|
+
>
|
|
144
|
+
{text}
|
|
145
|
+
</Text>
|
|
146
|
+
)}
|
|
147
|
+
</View>
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const styles = StyleSheet.create({
|
|
152
|
+
container: {
|
|
153
|
+
flexDirection: 'row',
|
|
154
|
+
alignItems: 'center',
|
|
155
|
+
alignSelf: 'flex-start',
|
|
156
|
+
},
|
|
157
|
+
icon: {
|
|
158
|
+
textAlign: 'center',
|
|
159
|
+
},
|
|
160
|
+
image: {
|
|
161
|
+
overflow: 'hidden',
|
|
162
|
+
},
|
|
163
|
+
text: {
|
|
164
|
+
textAlign: 'center',
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
export default StickerCompositeComponent;
|