Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

375
Visualizações
Mientras se presiona un componente de botón presionable, cambio el color de fondo de un botón a un color diferente. ¿Cómo puedo agregar algún tipo de animación?

Tengo un componente de botón y cambio su color de fondo a un color diferente mientras está presionado, pero el cambio ocurre instantáneamente y me preguntaba si es posible agregar un poco de animación que haga que el cambio de color sea más suave.

El cambio de color ocurre aquí:

 { ...(variant === 'tertiary' && isPressed ? { backgroundColor: colors.primary50 } : {}) },

El componente del botón:

 const PrimaryButton: FunctionComponent<Props> = ({ title, variant = 'primary', wide = false, style, ...rest }) => { const width = wide ? '100%' : undefined; const textColor = variant === 'primary' ? colors.white : colors.primary600; return ( <Pressable style={({ pressed: isPressed }) => [ styles.button, styles[variant], { width, elevation: isPressed ? 5 : 0, }, style, { ...(variant === 'tertiary' && isPressed ? { backgroundColor: colors.primary50 } : {}) }, ]} {...rest} > <HeaderText variant="h4" style={[styles.text, { color: textColor }]}> {title} </HeaderText> </Pressable> ); }; const styles = StyleSheet.create({ button: { paddingVertical: 12, paddingHorizontal: 24, borderRadius: 100, borderWidth: 1.5, justifyContent: 'center', alignItems: 'center', alignSelf: 'center', }, primary: { backgroundColor: colors.primary600, borderColor: colors.primary600, }, secondary: { backgroundColor: colors.white, borderColor: colors.primary600, }, tertiary: { backgroundColor: 'transparent', borderColor: 'transparent', }, text: { textAlign: 'center', }, }); export default PrimaryButton;
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Puedes probar lo siguiente:

 import React, { useRef } from "react"; import { Button, Image, StyleSheet, Text, View, Animated, TouchableOpacity } from "react-native"; function App() { const color = useRef(new Animated.Value(0)).current; let newColor = color.interpolate({ inputRange: [0, 1], outputRange: ["rgba(255, 255, 255, 1)", "rgba(0, 255, 0, 1)"] }); const pressFunc = () => { Animated.timing(color, { toValue: 1, duration: 2000 }).start(); }; return ( <View style={styles.app}> <TouchableOpacity onPress={pressFunc}> <Text>Press</Text> </TouchableOpacity> <Animated.View style={[ styles.logo, { backgroundColor: newColor } ]} /> </View> ); } const styles = StyleSheet.create({ app: { marginHorizontal: "auto", maxWidth: 500, flex: 1 }, logo: { height: 100, width: 100 }, });

Espero eso ayude. conectate si no entiendes nada

about 4 years ago · Juan Pablo Isaza Relatório

0

puede usar yarn add react-native-animatable import * as Animatable from "react-native-animatable";

exportar el índice de clase predeterminado extiende el componente {

renderizar() { devolver (

 <View style={{ alignItems: "center" }}> <Animatable.View style={styles.card} animation="slideInDown" iterationCount={5} direction="alternate"> <Text style={styles.whiteText}>slideInDown Animation</Text> </Animatable.View> </View> </SafeAreaView> );

} }

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda