@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,470 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* CSS to React Native Style Converter
|
|
4
|
+
* Converts CSS strings to React Native StyleSheet-compatible objects
|
|
5
|
+
* Enhanced with gradient detection and unified style generation
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.convertCSSToReactNative = convertCSSToReactNative;
|
|
9
|
+
exports.validateCSSForNative = validateCSSForNative;
|
|
10
|
+
exports.angleToGradientPoints = angleToGradientPoints;
|
|
11
|
+
/**
|
|
12
|
+
* Properties that only work in WebView, not native React Native
|
|
13
|
+
*/
|
|
14
|
+
const WEBVIEW_ONLY_PROPERTIES = [
|
|
15
|
+
'backdrop-filter',
|
|
16
|
+
'box-shadow', // Partially supported via shadow* props
|
|
17
|
+
'text-shadow',
|
|
18
|
+
'background-image',
|
|
19
|
+
'clip-path',
|
|
20
|
+
'mask',
|
|
21
|
+
'filter',
|
|
22
|
+
'mix-blend-mode',
|
|
23
|
+
'background-blend-mode',
|
|
24
|
+
];
|
|
25
|
+
/**
|
|
26
|
+
* Parse gradient from CSS background property
|
|
27
|
+
*/
|
|
28
|
+
function parseGradientFromCSS(value) {
|
|
29
|
+
// Match linear-gradient(angle, color1 pos1, color2 pos2, ...)
|
|
30
|
+
const linearMatch = value.match(/linear-gradient\(([^)]+)\)/);
|
|
31
|
+
if (linearMatch) {
|
|
32
|
+
const parts = linearMatch[1].split(',').map(p => p.trim());
|
|
33
|
+
let angle = 180;
|
|
34
|
+
let colorStops = [];
|
|
35
|
+
// First part might be angle
|
|
36
|
+
if (parts[0].includes('deg')) {
|
|
37
|
+
angle = parseFloat(parts[0].replace('deg', ''));
|
|
38
|
+
colorStops = parts.slice(1);
|
|
39
|
+
}
|
|
40
|
+
else if (parts[0].startsWith('to ')) {
|
|
41
|
+
// Handle direction keywords
|
|
42
|
+
const dir = parts[0].replace('to ', '');
|
|
43
|
+
if (dir === 'right')
|
|
44
|
+
angle = 90;
|
|
45
|
+
else if (dir === 'left')
|
|
46
|
+
angle = 270;
|
|
47
|
+
else if (dir === 'bottom')
|
|
48
|
+
angle = 180;
|
|
49
|
+
else if (dir === 'top')
|
|
50
|
+
angle = 0;
|
|
51
|
+
colorStops = parts.slice(1);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
colorStops = parts;
|
|
55
|
+
}
|
|
56
|
+
const stops = colorStops.map((stop, index) => {
|
|
57
|
+
const match = stop.match(/(.+?)\s+(\d+)%?$/);
|
|
58
|
+
if (match) {
|
|
59
|
+
return { color: match[1].trim(), position: parseFloat(match[2]) };
|
|
60
|
+
}
|
|
61
|
+
// Default position based on index
|
|
62
|
+
return {
|
|
63
|
+
color: stop.trim(),
|
|
64
|
+
position: (index / Math.max(colorStops.length - 1, 1)) * 100
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
return { type: 'linear', angle, stops };
|
|
68
|
+
}
|
|
69
|
+
// Match radial-gradient
|
|
70
|
+
const radialMatch = value.match(/radial-gradient\(([^)]+)\)/);
|
|
71
|
+
if (radialMatch) {
|
|
72
|
+
const parts = radialMatch[1].split(',').map(p => p.trim());
|
|
73
|
+
// Skip shape/size specification, get color stops
|
|
74
|
+
const colorStops = parts.filter(p => !p.includes('circle') && !p.includes('ellipse'));
|
|
75
|
+
const stops = colorStops.map((stop, index) => {
|
|
76
|
+
const match = stop.match(/(.+?)\s+(\d+)%?$/);
|
|
77
|
+
if (match) {
|
|
78
|
+
return { color: match[1].trim(), position: parseFloat(match[2]) };
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
color: stop.trim(),
|
|
82
|
+
position: (index / Math.max(colorStops.length - 1, 1)) * 100
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
return { type: 'radial', stops };
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Convert CSS string to React Native styles
|
|
91
|
+
* Now with gradient detection and extraction
|
|
92
|
+
*/
|
|
93
|
+
function convertCSSToReactNative(css) {
|
|
94
|
+
var _a;
|
|
95
|
+
const style = {};
|
|
96
|
+
const warnings = [];
|
|
97
|
+
let requiresGradient = false;
|
|
98
|
+
let gradient;
|
|
99
|
+
let fallbackColor;
|
|
100
|
+
if (!css || css.trim() === '') {
|
|
101
|
+
return { style, warnings };
|
|
102
|
+
}
|
|
103
|
+
const properties = parseCSSProperties(css);
|
|
104
|
+
for (const [property, value] of Object.entries(properties)) {
|
|
105
|
+
// Check for gradient in background property
|
|
106
|
+
if (property === 'background' || property === 'background-image') {
|
|
107
|
+
const gradientConfig = parseGradientFromCSS(value);
|
|
108
|
+
if (gradientConfig) {
|
|
109
|
+
requiresGradient = true;
|
|
110
|
+
gradient = gradientConfig;
|
|
111
|
+
fallbackColor = ((_a = gradientConfig.stops[0]) === null || _a === void 0 ? void 0 : _a.color) || 'transparent';
|
|
112
|
+
style.backgroundColor = fallbackColor; // Fallback
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// Check for unsupported properties
|
|
117
|
+
if (WEBVIEW_ONLY_PROPERTIES.some(p => property.includes(p))) {
|
|
118
|
+
warnings.push(`'${property}' is not supported in native rendering`);
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
processProperty(property, value, style, warnings);
|
|
122
|
+
}
|
|
123
|
+
return { style, warnings, requiresGradient, gradient, fallbackColor };
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Parse CSS string into property map
|
|
127
|
+
*/
|
|
128
|
+
function parseCSSProperties(css) {
|
|
129
|
+
const properties = {};
|
|
130
|
+
const declarations = css.split(';').filter(d => d.trim());
|
|
131
|
+
for (const decl of declarations) {
|
|
132
|
+
const colonIndex = decl.indexOf(':');
|
|
133
|
+
if (colonIndex > 0) {
|
|
134
|
+
const prop = decl.substring(0, colonIndex).trim();
|
|
135
|
+
const value = decl.substring(colonIndex + 1).trim();
|
|
136
|
+
properties[prop] = value;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return properties;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Process a single CSS property
|
|
143
|
+
*/
|
|
144
|
+
function processProperty(property, value, style, warnings) {
|
|
145
|
+
const numericValue = parseNumericValue(value);
|
|
146
|
+
switch (property) {
|
|
147
|
+
// Background
|
|
148
|
+
case 'background-color':
|
|
149
|
+
style.backgroundColor = value;
|
|
150
|
+
break;
|
|
151
|
+
// Opacity
|
|
152
|
+
case 'opacity':
|
|
153
|
+
style.opacity = parseFloat(value);
|
|
154
|
+
break;
|
|
155
|
+
// Border radius
|
|
156
|
+
case 'border-radius':
|
|
157
|
+
style.borderRadius = numericValue;
|
|
158
|
+
break;
|
|
159
|
+
case 'border-top-left-radius':
|
|
160
|
+
style.borderTopLeftRadius = numericValue;
|
|
161
|
+
break;
|
|
162
|
+
case 'border-top-right-radius':
|
|
163
|
+
style.borderTopRightRadius = numericValue;
|
|
164
|
+
break;
|
|
165
|
+
case 'border-bottom-left-radius':
|
|
166
|
+
style.borderBottomLeftRadius = numericValue;
|
|
167
|
+
break;
|
|
168
|
+
case 'border-bottom-right-radius':
|
|
169
|
+
style.borderBottomRightRadius = numericValue;
|
|
170
|
+
break;
|
|
171
|
+
// Border
|
|
172
|
+
case 'border-width':
|
|
173
|
+
style.borderWidth = numericValue;
|
|
174
|
+
break;
|
|
175
|
+
case 'border-color':
|
|
176
|
+
style.borderColor = value;
|
|
177
|
+
break;
|
|
178
|
+
case 'border-style':
|
|
179
|
+
style.borderStyle = value;
|
|
180
|
+
break;
|
|
181
|
+
case 'border-top-width':
|
|
182
|
+
style.borderTopWidth = numericValue;
|
|
183
|
+
break;
|
|
184
|
+
case 'border-right-width':
|
|
185
|
+
style.borderRightWidth = numericValue;
|
|
186
|
+
break;
|
|
187
|
+
case 'border-bottom-width':
|
|
188
|
+
style.borderBottomWidth = numericValue;
|
|
189
|
+
break;
|
|
190
|
+
case 'border-left-width':
|
|
191
|
+
style.borderLeftWidth = numericValue;
|
|
192
|
+
break;
|
|
193
|
+
// Padding
|
|
194
|
+
case 'padding':
|
|
195
|
+
applySpacingShorthand(value, style, 'padding');
|
|
196
|
+
break;
|
|
197
|
+
case 'padding-top':
|
|
198
|
+
style.paddingTop = numericValue;
|
|
199
|
+
break;
|
|
200
|
+
case 'padding-right':
|
|
201
|
+
style.paddingRight = numericValue;
|
|
202
|
+
break;
|
|
203
|
+
case 'padding-bottom':
|
|
204
|
+
style.paddingBottom = numericValue;
|
|
205
|
+
break;
|
|
206
|
+
case 'padding-left':
|
|
207
|
+
style.paddingLeft = numericValue;
|
|
208
|
+
break;
|
|
209
|
+
// Margin
|
|
210
|
+
case 'margin':
|
|
211
|
+
applySpacingShorthand(value, style, 'margin');
|
|
212
|
+
break;
|
|
213
|
+
case 'margin-top':
|
|
214
|
+
style.marginTop = numericValue;
|
|
215
|
+
break;
|
|
216
|
+
case 'margin-right':
|
|
217
|
+
style.marginRight = numericValue;
|
|
218
|
+
break;
|
|
219
|
+
case 'margin-bottom':
|
|
220
|
+
style.marginBottom = numericValue;
|
|
221
|
+
break;
|
|
222
|
+
case 'margin-left':
|
|
223
|
+
style.marginLeft = numericValue;
|
|
224
|
+
break;
|
|
225
|
+
// Dimensions
|
|
226
|
+
case 'width':
|
|
227
|
+
style.width = parseNumericOrPercent(value);
|
|
228
|
+
break;
|
|
229
|
+
case 'height':
|
|
230
|
+
style.height = parseNumericOrPercent(value);
|
|
231
|
+
break;
|
|
232
|
+
case 'min-width':
|
|
233
|
+
style.minWidth = parseNumericOrPercent(value);
|
|
234
|
+
break;
|
|
235
|
+
case 'min-height':
|
|
236
|
+
style.minHeight = parseNumericOrPercent(value);
|
|
237
|
+
break;
|
|
238
|
+
case 'max-width':
|
|
239
|
+
style.maxWidth = parseNumericOrPercent(value);
|
|
240
|
+
break;
|
|
241
|
+
case 'max-height':
|
|
242
|
+
style.maxHeight = parseNumericOrPercent(value);
|
|
243
|
+
break;
|
|
244
|
+
// Transform
|
|
245
|
+
case 'transform':
|
|
246
|
+
// parseTransform returns a dynamically-built array of single-key transform
|
|
247
|
+
// objects from parsed CSS. RN's transform union (RotateTransform | ... |
|
|
248
|
+
// MatrixTransform) is impractical to satisfy from dynamic parsing, so cast.
|
|
249
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
250
|
+
style.transform = parseTransform(value);
|
|
251
|
+
break;
|
|
252
|
+
// Flexbox
|
|
253
|
+
case 'flex':
|
|
254
|
+
style.flex = parseFloat(value);
|
|
255
|
+
break;
|
|
256
|
+
case 'flex-direction':
|
|
257
|
+
style.flexDirection = value;
|
|
258
|
+
break;
|
|
259
|
+
case 'justify-content':
|
|
260
|
+
style.justifyContent = mapJustifyContent(value);
|
|
261
|
+
break;
|
|
262
|
+
case 'align-items':
|
|
263
|
+
style.alignItems = mapAlignItems(value);
|
|
264
|
+
break;
|
|
265
|
+
case 'align-self':
|
|
266
|
+
style.alignSelf = mapAlignItems(value);
|
|
267
|
+
break;
|
|
268
|
+
case 'flex-wrap':
|
|
269
|
+
style.flexWrap = value;
|
|
270
|
+
break;
|
|
271
|
+
// Shadow (partial support)
|
|
272
|
+
case 'box-shadow':
|
|
273
|
+
applyBoxShadow(value, style);
|
|
274
|
+
break;
|
|
275
|
+
// Position
|
|
276
|
+
case 'position':
|
|
277
|
+
style.position = value;
|
|
278
|
+
break;
|
|
279
|
+
case 'top':
|
|
280
|
+
style.top = numericValue;
|
|
281
|
+
break;
|
|
282
|
+
case 'right':
|
|
283
|
+
style.right = numericValue;
|
|
284
|
+
break;
|
|
285
|
+
case 'bottom':
|
|
286
|
+
style.bottom = numericValue;
|
|
287
|
+
break;
|
|
288
|
+
case 'left':
|
|
289
|
+
style.left = numericValue;
|
|
290
|
+
break;
|
|
291
|
+
case 'z-index':
|
|
292
|
+
style.zIndex = parseInt(value);
|
|
293
|
+
break;
|
|
294
|
+
// Overflow
|
|
295
|
+
case 'overflow':
|
|
296
|
+
style.overflow = value;
|
|
297
|
+
break;
|
|
298
|
+
default:
|
|
299
|
+
// Unknown property - add warning
|
|
300
|
+
if (!property.startsWith('-webkit') && !property.startsWith('-moz')) {
|
|
301
|
+
warnings.push(`Unknown CSS property: '${property}'`);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Parse numeric value from CSS
|
|
307
|
+
*/
|
|
308
|
+
function parseNumericValue(value) {
|
|
309
|
+
return parseFloat(value.replace(/px|dp|pt|rem|em/g, '')) || 0;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Parse numeric or percentage value
|
|
313
|
+
*/
|
|
314
|
+
function parseNumericOrPercent(value) {
|
|
315
|
+
if (value.includes('%')) {
|
|
316
|
+
// RN's DimensionValue percent type is the template literal `${number}%`;
|
|
317
|
+
// a runtime-parsed CSS string can't be statically proven to match, so cast.
|
|
318
|
+
return value.trim();
|
|
319
|
+
}
|
|
320
|
+
return parseNumericValue(value);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Apply spacing shorthand (padding/margin)
|
|
324
|
+
*/
|
|
325
|
+
function applySpacingShorthand(value, style, prefix) {
|
|
326
|
+
const parts = value.split(/\s+/).map(parseNumericValue);
|
|
327
|
+
switch (parts.length) {
|
|
328
|
+
case 1:
|
|
329
|
+
style[prefix] = parts[0];
|
|
330
|
+
break;
|
|
331
|
+
case 2:
|
|
332
|
+
style[`${prefix}Vertical`] = parts[0];
|
|
333
|
+
style[`${prefix}Horizontal`] = parts[1];
|
|
334
|
+
break;
|
|
335
|
+
case 3:
|
|
336
|
+
style[`${prefix}Top`] = parts[0];
|
|
337
|
+
style[`${prefix}Horizontal`] = parts[1];
|
|
338
|
+
style[`${prefix}Bottom`] = parts[2];
|
|
339
|
+
break;
|
|
340
|
+
case 4:
|
|
341
|
+
style[`${prefix}Top`] = parts[0];
|
|
342
|
+
style[`${prefix}Right`] = parts[1];
|
|
343
|
+
style[`${prefix}Bottom`] = parts[2];
|
|
344
|
+
style[`${prefix}Left`] = parts[3];
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Parse CSS transform to React Native transform array
|
|
350
|
+
*/
|
|
351
|
+
function parseTransform(value) {
|
|
352
|
+
const transforms = [];
|
|
353
|
+
// translateX
|
|
354
|
+
const translateXMatch = value.match(/translateX\(([^)]+)\)/);
|
|
355
|
+
if (translateXMatch) {
|
|
356
|
+
transforms.push({ translateX: parseNumericValue(translateXMatch[1]) });
|
|
357
|
+
}
|
|
358
|
+
// translateY
|
|
359
|
+
const translateYMatch = value.match(/translateY\(([^)]+)\)/);
|
|
360
|
+
if (translateYMatch) {
|
|
361
|
+
transforms.push({ translateY: parseNumericValue(translateYMatch[1]) });
|
|
362
|
+
}
|
|
363
|
+
// translate(x, y)
|
|
364
|
+
const translateMatch = value.match(/translate\(([^,)]+)(?:,\s*([^)]+))?\)/);
|
|
365
|
+
if (translateMatch) {
|
|
366
|
+
transforms.push({ translateX: parseNumericValue(translateMatch[1]) });
|
|
367
|
+
if (translateMatch[2]) {
|
|
368
|
+
transforms.push({ translateY: parseNumericValue(translateMatch[2]) });
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
// scale
|
|
372
|
+
const scaleMatch = value.match(/scale\(([^)]+)\)/);
|
|
373
|
+
if (scaleMatch) {
|
|
374
|
+
transforms.push({ scale: parseFloat(scaleMatch[1]) });
|
|
375
|
+
}
|
|
376
|
+
// scaleX
|
|
377
|
+
const scaleXMatch = value.match(/scaleX\(([^)]+)\)/);
|
|
378
|
+
if (scaleXMatch) {
|
|
379
|
+
transforms.push({ scaleX: parseFloat(scaleXMatch[1]) });
|
|
380
|
+
}
|
|
381
|
+
// scaleY
|
|
382
|
+
const scaleYMatch = value.match(/scaleY\(([^)]+)\)/);
|
|
383
|
+
if (scaleYMatch) {
|
|
384
|
+
transforms.push({ scaleY: parseFloat(scaleYMatch[1]) });
|
|
385
|
+
}
|
|
386
|
+
// rotate
|
|
387
|
+
const rotateMatch = value.match(/rotate\(([^)]+)\)/);
|
|
388
|
+
if (rotateMatch) {
|
|
389
|
+
const deg = rotateMatch[1].replace('deg', '');
|
|
390
|
+
transforms.push({ rotate: `${deg}deg` });
|
|
391
|
+
}
|
|
392
|
+
return transforms;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Apply box-shadow (partial React Native support)
|
|
396
|
+
*/
|
|
397
|
+
function applyBoxShadow(value, style) {
|
|
398
|
+
// Parse: offsetX offsetY blurRadius color
|
|
399
|
+
const match = value.match(/(-?\d+)px\s+(-?\d+)px\s+(-?\d+)px(?:\s+(-?\d+)px)?\s+(.+)/);
|
|
400
|
+
if (match) {
|
|
401
|
+
const [, x, y, blur, _spread, color] = match;
|
|
402
|
+
style.shadowColor = color.trim();
|
|
403
|
+
style.shadowOffset = { width: parseInt(x), height: parseInt(y) };
|
|
404
|
+
style.shadowOpacity = 1;
|
|
405
|
+
style.shadowRadius = parseInt(blur);
|
|
406
|
+
// Android elevation
|
|
407
|
+
style.elevation = Math.max(parseInt(blur), 1);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Map CSS justify-content to React Native
|
|
412
|
+
*/
|
|
413
|
+
function mapJustifyContent(value) {
|
|
414
|
+
const map = {
|
|
415
|
+
'flex-start': 'flex-start',
|
|
416
|
+
'flex-end': 'flex-end',
|
|
417
|
+
'center': 'center',
|
|
418
|
+
'space-between': 'space-between',
|
|
419
|
+
'space-around': 'space-around',
|
|
420
|
+
'space-evenly': 'space-evenly',
|
|
421
|
+
};
|
|
422
|
+
return map[value] || 'flex-start';
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Map CSS align-items to React Native
|
|
426
|
+
*/
|
|
427
|
+
function mapAlignItems(value) {
|
|
428
|
+
const map = {
|
|
429
|
+
'flex-start': 'flex-start',
|
|
430
|
+
'flex-end': 'flex-end',
|
|
431
|
+
'center': 'center',
|
|
432
|
+
'stretch': 'stretch',
|
|
433
|
+
'baseline': 'baseline',
|
|
434
|
+
};
|
|
435
|
+
return map[value] || 'stretch';
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Validate CSS for native compatibility
|
|
439
|
+
*/
|
|
440
|
+
function validateCSSForNative(css) {
|
|
441
|
+
const warnings = [];
|
|
442
|
+
for (const prop of WEBVIEW_ONLY_PROPERTIES) {
|
|
443
|
+
if (css.includes(prop)) {
|
|
444
|
+
warnings.push(`'${prop}' is only supported in WebView mode`);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
// Check for gradients (now supported with LinearGradient component)
|
|
448
|
+
if (css.includes('linear-gradient') || css.includes('radial-gradient')) {
|
|
449
|
+
warnings.push('Gradients require LinearGradient component wrapper');
|
|
450
|
+
}
|
|
451
|
+
return warnings;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Convert gradient angle to LinearGradient start/end points
|
|
455
|
+
* CSS angle: 0deg = bottom to top, 90deg = left to right
|
|
456
|
+
* LinearGradient: start/end are {x, y} where 0,0 is top-left
|
|
457
|
+
*/
|
|
458
|
+
function angleToGradientPoints(angle) {
|
|
459
|
+
const radians = ((angle - 90) * Math.PI) / 180;
|
|
460
|
+
const startX = 0.5 - Math.cos(radians) * 0.5;
|
|
461
|
+
const startY = 0.5 + Math.sin(radians) * 0.5;
|
|
462
|
+
const endX = 0.5 + Math.cos(radians) * 0.5;
|
|
463
|
+
const endY = 0.5 - Math.sin(radians) * 0.5;
|
|
464
|
+
return {
|
|
465
|
+
start: { x: startX, y: startY },
|
|
466
|
+
end: { x: endX, y: endY },
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
// GradientStop and GradientConfig are already exported at their `export interface`
|
|
470
|
+
// declarations above; the redundant re-export was removed to avoid a conflict.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Animation utilities for React Native tap behavior transitions
|
|
3
|
+
*/
|
|
4
|
+
import { Animated } from 'react-native';
|
|
5
|
+
export type TransitionType = 'none' | 'shrink' | 'grow' | 'fade' | 'bounce' | 'slide' | 'rotate' | 'pulse';
|
|
6
|
+
/**
|
|
7
|
+
* Play a transition animation on an Animated.Value
|
|
8
|
+
*/
|
|
9
|
+
export declare function playTransition(scaleValue: Animated.Value, opacityValue: Animated.Value, type: TransitionType, duration: number): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Create animation values for a button
|
|
12
|
+
*/
|
|
13
|
+
export declare function createAnimationValues(): {
|
|
14
|
+
scale: Animated.Value;
|
|
15
|
+
opacity: Animated.Value;
|
|
16
|
+
translateX: Animated.Value;
|
|
17
|
+
rotate: Animated.Value;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Reset animation values to default
|
|
21
|
+
*/
|
|
22
|
+
export declare function resetAnimationValues(values: {
|
|
23
|
+
scale: Animated.Value;
|
|
24
|
+
opacity: Animated.Value;
|
|
25
|
+
translateX: Animated.Value;
|
|
26
|
+
rotate: Animated.Value;
|
|
27
|
+
}): void;
|
|
28
|
+
/**
|
|
29
|
+
* Get animated style from animation values
|
|
30
|
+
*/
|
|
31
|
+
export declare function getAnimatedStyle(values: {
|
|
32
|
+
scale: Animated.Value;
|
|
33
|
+
opacity: Animated.Value;
|
|
34
|
+
translateX: Animated.Value;
|
|
35
|
+
rotate: Animated.Value;
|
|
36
|
+
}): {
|
|
37
|
+
transform: {
|
|
38
|
+
scale: Animated.Value;
|
|
39
|
+
}[];
|
|
40
|
+
opacity: Animated.Value;
|
|
41
|
+
};
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Animation utilities for React Native tap behavior transitions
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.playTransition = playTransition;
|
|
7
|
+
exports.createAnimationValues = createAnimationValues;
|
|
8
|
+
exports.resetAnimationValues = resetAnimationValues;
|
|
9
|
+
exports.getAnimatedStyle = getAnimatedStyle;
|
|
10
|
+
const react_native_1 = require("react-native");
|
|
11
|
+
/**
|
|
12
|
+
* Play a transition animation on an Animated.Value
|
|
13
|
+
*/
|
|
14
|
+
async function playTransition(scaleValue, opacityValue, type, duration) {
|
|
15
|
+
if (type === 'none')
|
|
16
|
+
return;
|
|
17
|
+
return new Promise((resolve) => {
|
|
18
|
+
const animation = getTransitionAnimation(scaleValue, opacityValue, type, duration);
|
|
19
|
+
animation.start(() => resolve());
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get the appropriate animation for a transition type
|
|
24
|
+
*/
|
|
25
|
+
function getTransitionAnimation(scaleValue, opacityValue, type, duration) {
|
|
26
|
+
const halfDuration = duration / 2;
|
|
27
|
+
const quarterDuration = duration / 4;
|
|
28
|
+
switch (type) {
|
|
29
|
+
case 'shrink':
|
|
30
|
+
return react_native_1.Animated.sequence([
|
|
31
|
+
react_native_1.Animated.timing(scaleValue, {
|
|
32
|
+
toValue: 0.95,
|
|
33
|
+
duration: halfDuration,
|
|
34
|
+
easing: react_native_1.Easing.out(react_native_1.Easing.ease),
|
|
35
|
+
useNativeDriver: true,
|
|
36
|
+
}),
|
|
37
|
+
react_native_1.Animated.timing(scaleValue, {
|
|
38
|
+
toValue: 1,
|
|
39
|
+
duration: halfDuration,
|
|
40
|
+
easing: react_native_1.Easing.out(react_native_1.Easing.ease),
|
|
41
|
+
useNativeDriver: true,
|
|
42
|
+
}),
|
|
43
|
+
]);
|
|
44
|
+
case 'grow':
|
|
45
|
+
return react_native_1.Animated.sequence([
|
|
46
|
+
react_native_1.Animated.timing(scaleValue, {
|
|
47
|
+
toValue: 1.05,
|
|
48
|
+
duration: halfDuration,
|
|
49
|
+
easing: react_native_1.Easing.out(react_native_1.Easing.ease),
|
|
50
|
+
useNativeDriver: true,
|
|
51
|
+
}),
|
|
52
|
+
react_native_1.Animated.timing(scaleValue, {
|
|
53
|
+
toValue: 1,
|
|
54
|
+
duration: halfDuration,
|
|
55
|
+
easing: react_native_1.Easing.out(react_native_1.Easing.ease),
|
|
56
|
+
useNativeDriver: true,
|
|
57
|
+
}),
|
|
58
|
+
]);
|
|
59
|
+
case 'fade':
|
|
60
|
+
return react_native_1.Animated.sequence([
|
|
61
|
+
react_native_1.Animated.timing(opacityValue, {
|
|
62
|
+
toValue: 0.5,
|
|
63
|
+
duration: halfDuration,
|
|
64
|
+
easing: react_native_1.Easing.out(react_native_1.Easing.ease),
|
|
65
|
+
useNativeDriver: true,
|
|
66
|
+
}),
|
|
67
|
+
react_native_1.Animated.timing(opacityValue, {
|
|
68
|
+
toValue: 1,
|
|
69
|
+
duration: halfDuration,
|
|
70
|
+
easing: react_native_1.Easing.out(react_native_1.Easing.ease),
|
|
71
|
+
useNativeDriver: true,
|
|
72
|
+
}),
|
|
73
|
+
]);
|
|
74
|
+
case 'bounce':
|
|
75
|
+
return react_native_1.Animated.sequence([
|
|
76
|
+
react_native_1.Animated.timing(scaleValue, {
|
|
77
|
+
toValue: 0.9,
|
|
78
|
+
duration: quarterDuration,
|
|
79
|
+
easing: react_native_1.Easing.out(react_native_1.Easing.ease),
|
|
80
|
+
useNativeDriver: true,
|
|
81
|
+
}),
|
|
82
|
+
react_native_1.Animated.spring(scaleValue, {
|
|
83
|
+
toValue: 1,
|
|
84
|
+
friction: 3,
|
|
85
|
+
tension: 100,
|
|
86
|
+
useNativeDriver: true,
|
|
87
|
+
}),
|
|
88
|
+
]);
|
|
89
|
+
case 'pulse':
|
|
90
|
+
return react_native_1.Animated.sequence([
|
|
91
|
+
react_native_1.Animated.parallel([
|
|
92
|
+
react_native_1.Animated.timing(scaleValue, {
|
|
93
|
+
toValue: 1.1,
|
|
94
|
+
duration: halfDuration,
|
|
95
|
+
easing: react_native_1.Easing.out(react_native_1.Easing.ease),
|
|
96
|
+
useNativeDriver: true,
|
|
97
|
+
}),
|
|
98
|
+
react_native_1.Animated.timing(opacityValue, {
|
|
99
|
+
toValue: 0.8,
|
|
100
|
+
duration: halfDuration,
|
|
101
|
+
easing: react_native_1.Easing.out(react_native_1.Easing.ease),
|
|
102
|
+
useNativeDriver: true,
|
|
103
|
+
}),
|
|
104
|
+
]),
|
|
105
|
+
react_native_1.Animated.parallel([
|
|
106
|
+
react_native_1.Animated.timing(scaleValue, {
|
|
107
|
+
toValue: 1,
|
|
108
|
+
duration: halfDuration,
|
|
109
|
+
easing: react_native_1.Easing.out(react_native_1.Easing.ease),
|
|
110
|
+
useNativeDriver: true,
|
|
111
|
+
}),
|
|
112
|
+
react_native_1.Animated.timing(opacityValue, {
|
|
113
|
+
toValue: 1,
|
|
114
|
+
duration: halfDuration,
|
|
115
|
+
easing: react_native_1.Easing.out(react_native_1.Easing.ease),
|
|
116
|
+
useNativeDriver: true,
|
|
117
|
+
}),
|
|
118
|
+
]),
|
|
119
|
+
]);
|
|
120
|
+
case 'slide':
|
|
121
|
+
// For slide, we need a translateX value - this is a simplified version
|
|
122
|
+
return react_native_1.Animated.sequence([
|
|
123
|
+
react_native_1.Animated.timing(scaleValue, {
|
|
124
|
+
toValue: 0.98,
|
|
125
|
+
duration: quarterDuration,
|
|
126
|
+
easing: react_native_1.Easing.out(react_native_1.Easing.ease),
|
|
127
|
+
useNativeDriver: true,
|
|
128
|
+
}),
|
|
129
|
+
react_native_1.Animated.timing(scaleValue, {
|
|
130
|
+
toValue: 1.02,
|
|
131
|
+
duration: quarterDuration,
|
|
132
|
+
easing: react_native_1.Easing.inOut(react_native_1.Easing.ease),
|
|
133
|
+
useNativeDriver: true,
|
|
134
|
+
}),
|
|
135
|
+
react_native_1.Animated.timing(scaleValue, {
|
|
136
|
+
toValue: 1,
|
|
137
|
+
duration: quarterDuration,
|
|
138
|
+
easing: react_native_1.Easing.out(react_native_1.Easing.ease),
|
|
139
|
+
useNativeDriver: true,
|
|
140
|
+
}),
|
|
141
|
+
]);
|
|
142
|
+
case 'rotate':
|
|
143
|
+
// Note: Rotation requires a different animated value
|
|
144
|
+
return react_native_1.Animated.sequence([
|
|
145
|
+
react_native_1.Animated.timing(scaleValue, {
|
|
146
|
+
toValue: 0.98,
|
|
147
|
+
duration: quarterDuration,
|
|
148
|
+
easing: react_native_1.Easing.out(react_native_1.Easing.ease),
|
|
149
|
+
useNativeDriver: true,
|
|
150
|
+
}),
|
|
151
|
+
react_native_1.Animated.timing(scaleValue, {
|
|
152
|
+
toValue: 1,
|
|
153
|
+
duration: quarterDuration,
|
|
154
|
+
easing: react_native_1.Easing.out(react_native_1.Easing.ease),
|
|
155
|
+
useNativeDriver: true,
|
|
156
|
+
}),
|
|
157
|
+
]);
|
|
158
|
+
default:
|
|
159
|
+
return react_native_1.Animated.timing(scaleValue, {
|
|
160
|
+
toValue: 1,
|
|
161
|
+
duration: 0,
|
|
162
|
+
useNativeDriver: true,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Create animation values for a button
|
|
168
|
+
*/
|
|
169
|
+
function createAnimationValues() {
|
|
170
|
+
return {
|
|
171
|
+
scale: new react_native_1.Animated.Value(1),
|
|
172
|
+
opacity: new react_native_1.Animated.Value(1),
|
|
173
|
+
translateX: new react_native_1.Animated.Value(0),
|
|
174
|
+
rotate: new react_native_1.Animated.Value(0),
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Reset animation values to default
|
|
179
|
+
*/
|
|
180
|
+
function resetAnimationValues(values) {
|
|
181
|
+
values.scale.setValue(1);
|
|
182
|
+
values.opacity.setValue(1);
|
|
183
|
+
values.translateX.setValue(0);
|
|
184
|
+
values.rotate.setValue(0);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Get animated style from animation values
|
|
188
|
+
*/
|
|
189
|
+
function getAnimatedStyle(values) {
|
|
190
|
+
return {
|
|
191
|
+
transform: [{ scale: values.scale }],
|
|
192
|
+
opacity: values.opacity,
|
|
193
|
+
};
|
|
194
|
+
}
|