From 12ce5544918a9fbadb9ac3c73cad9478d2aa5f4d Mon Sep 17 00:00:00 2001 From: Pablo Velez Vidal Date: Wed, 2 Nov 2022 17:57:57 +0100 Subject: [PATCH] initial migration of everything using reanimated --- app/screens/onboarding/footer_buttons.tsx | 31 +++++--- app/screens/onboarding/index.tsx | 90 +++++++++++------------ app/screens/onboarding/paginator.tsx | 41 ++++++----- app/screens/onboarding/slide.tsx | 84 +++++++++++---------- 4 files changed, 132 insertions(+), 114 deletions(-) diff --git a/app/screens/onboarding/footer_buttons.tsx b/app/screens/onboarding/footer_buttons.tsx index ed8b1c8c0..47e41ad58 100644 --- a/app/screens/onboarding/footer_buttons.tsx +++ b/app/screens/onboarding/footer_buttons.tsx @@ -2,8 +2,9 @@ // See LICENSE.txt for license information. import React, {useEffect} from 'react'; -import {useWindowDimensions, View} from 'react-native'; +import {Pressable, useWindowDimensions, View} from 'react-native'; import Button from 'react-native-button'; +import Animated, {useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated'; import CompassIcon from '@app/components/compass_icon'; import FormattedText from '@app/components/formatted_text'; @@ -15,7 +16,6 @@ type Props = { isLastSlide: boolean; nextSlideHandler: any; signInHandler: any; - scrollX: any; }; @@ -31,21 +31,32 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({ }, })); +const AnimatedButton = Animated.createAnimatedComponent(Pressable); + const FooterButtons = ({ theme, nextSlideHandler, signInHandler, isLastSlide, - scrollX, }: Props) => { const {width} = useWindowDimensions(); const styles = getStyleSheet(theme); - const inputRange = [-width, 0, width]; + + const scaledWidth = useSharedValue(80); + + const transform = useAnimatedStyle(() => { + return { + width: scaledWidth.value, + }; + }); useEffect(() => { - if (isLastSlide) { - console.log('is last slide'); - } + console.log('** footer buttons rerender', isLastSlide); + }, []); + + useEffect(() => { + console.log('** footer buttons rerender', isLastSlide); + scaledWidth.value = withTiming(isLastSlide ? ((width * 80) / 100) : 80, {duration: 100}); }, [isLastSlide]); let mainButtonText = ( @@ -77,13 +88,13 @@ const FooterButtons = ({ return ( - +