diff --git a/assets/Progress of loading hand.lottie b/assets/Progress of loading hand.zip similarity index 100% rename from assets/Progress of loading hand.lottie rename to assets/Progress of loading hand.zip diff --git a/assets/Ripple loading animation.lottie b/assets/Ripple loading animation.zip similarity index 100% rename from assets/Ripple loading animation.lottie rename to assets/Ripple loading animation.zip diff --git a/assets/dog-running.lottie b/assets/dog-running.zip similarity index 100% rename from assets/dog-running.lottie rename to assets/dog-running.zip diff --git a/metro.config.js b/metro.config.js index 9ef0040..db91346 100644 --- a/metro.config.js +++ b/metro.config.js @@ -25,7 +25,7 @@ config.transformer = { // Optimize resolver for better tree shaking and SVG support config.resolver = { ...config.resolver, - assetExts: [...config.resolver.assetExts.filter((ext) => ext !== 'svg'), 'lottie'], + assetExts: [...config.resolver.assetExts.filter((ext) => ext !== 'svg'), 'zip'], sourceExts: [...config.resolver.sourceExts, 'svg'], resolverMainFields: ['react-native', 'browser', 'main'], }; diff --git a/src/components/common/DogLoadingSpinner.tsx b/src/components/common/DogLoadingSpinner.tsx index de89a62..f65e18d 100644 --- a/src/components/common/DogLoadingSpinner.tsx +++ b/src/components/common/DogLoadingSpinner.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { View, Text, StyleSheet, Dimensions } from 'react-native'; +import React, { useEffect } from 'react'; +import { View, Text, StyleSheet, Dimensions, Platform } from 'react-native'; import LottieView from 'lottie-react-native'; import { useTheme } from '../../contexts/ThemeContext'; @@ -19,16 +19,34 @@ const LoadingSpinner: React.FC = ({ offsetY = 0, }) => { const { currentTheme } = useTheme(); + + // Android-specific Lottie configuration + useEffect(() => { + if (Platform.OS === 'android') { + // Enable merge paths for Android KitKat and above + try { + const Lottie = require('lottie-react-native'); + if (Lottie.enableMergePathsForKitKatAndAbove) { + Lottie.enableMergePathsForKitKatAndAbove(true); + } + } catch (error) { + console.warn('Failed to enable merge paths for Android:', error); + } + } + }, []); const getSizeStyles = () => { + // Ensure dimensions are whole numbers for Android compatibility + const getWholeNumber = (num: number) => Math.round(num); + switch (size) { case 'small': - return { width: 60, height: 60 }; + return { width: getWholeNumber(60), height: getWholeNumber(60) }; case 'medium': - return { width: 100, height: 100 }; + return { width: getWholeNumber(100), height: getWholeNumber(100) }; case 'large': default: - return { width: 150, height: 150 }; + return { width: getWholeNumber(150), height: getWholeNumber(150) }; } }; @@ -47,11 +65,23 @@ const LoadingSpinner: React.FC = ({ return ( { + if (__DEV__) console.log('Lottie animation finished'); + }} + onAnimationFailure={(error) => { + if (__DEV__) console.warn('Lottie animation failed:', error); + }} /> {text && ( = ({ offsetY = 0, }) => { const { currentTheme } = useTheme(); + + // Android-specific Lottie configuration + useEffect(() => { + if (Platform.OS === 'android') { + // Enable merge paths for Android KitKat and above + try { + const Lottie = require('lottie-react-native'); + if (Lottie.enableMergePathsForKitKatAndAbove) { + Lottie.enableMergePathsForKitKatAndAbove(true); + } + } catch (error) { + console.warn('Failed to enable merge paths for Android:', error); + } + } + }, []); const getSizeStyles = () => { + // Ensure dimensions are whole numbers for Android compatibility + const getWholeNumber = (num: number) => Math.round(num); + switch (size) { case 'small': - return { width: 60, height: 60 }; + return { width: getWholeNumber(60), height: getWholeNumber(60) }; case 'medium': - return { width: 100, height: 100 }; + return { width: getWholeNumber(100), height: getWholeNumber(100) }; case 'large': default: - return { width: 150, height: 150 }; + return { width: getWholeNumber(150), height: getWholeNumber(150) }; } }; @@ -47,11 +65,23 @@ const LoadingSpinner: React.FC = ({ return ( { + if (__DEV__) console.log('Lottie animation finished'); + }} + onAnimationFailure={(error) => { + if (__DEV__) console.warn('Lottie animation failed:', error); + }} /> {text && (