Push full app including src folder and all project files
This commit is contained in:
139
src/components/FloatingAssistantButton.tsx
Normal file
139
src/components/FloatingAssistantButton.tsx
Normal file
@@ -0,0 +1,139 @@
|
||||
import React, { useState } from 'react';
|
||||
import {
|
||||
StyleSheet,
|
||||
TouchableOpacity,
|
||||
Animated,
|
||||
Easing,
|
||||
} from 'react-native';
|
||||
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
||||
import { colors } from '../theme/colors';
|
||||
import { ChatbotModal } from './ChatbotModal';
|
||||
|
||||
export const FloatingAssistantButton: React.FC = () => {
|
||||
const [scaleValue] = useState(new Animated.Value(1));
|
||||
const [pulseValue] = useState(new Animated.Value(1));
|
||||
const [isChatbotVisible, setIsChatbotVisible] = useState(false);
|
||||
|
||||
React.useEffect(() => {
|
||||
// Continuous pulse animation
|
||||
Animated.loop(
|
||||
Animated.sequence([
|
||||
Animated.timing(pulseValue, {
|
||||
toValue: 1.1,
|
||||
duration: 1500,
|
||||
easing: Easing.inOut(Easing.ease),
|
||||
useNativeDriver: true,
|
||||
}),
|
||||
Animated.timing(pulseValue, {
|
||||
toValue: 1,
|
||||
duration: 1500,
|
||||
easing: Easing.inOut(Easing.ease),
|
||||
useNativeDriver: true,
|
||||
}),
|
||||
])
|
||||
).start();
|
||||
}, [pulseValue]);
|
||||
|
||||
const handlePressIn = () => {
|
||||
Animated.spring(scaleValue, {
|
||||
toValue: 0.9,
|
||||
useNativeDriver: true,
|
||||
}).start();
|
||||
};
|
||||
|
||||
const handlePressOut = () => {
|
||||
Animated.spring(scaleValue, {
|
||||
toValue: 1,
|
||||
friction: 3,
|
||||
tension: 40,
|
||||
useNativeDriver: true,
|
||||
}).start();
|
||||
};
|
||||
|
||||
const handlePress = () => {
|
||||
setIsChatbotVisible(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* Pulse ring */}
|
||||
<Animated.View
|
||||
style={[
|
||||
styles.pulseRing,
|
||||
{
|
||||
transform: [{ scale: pulseValue }],
|
||||
opacity: pulseValue.interpolate({
|
||||
inputRange: [1, 1.1],
|
||||
outputRange: [0.3, 0],
|
||||
}),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
|
||||
{/* Main button */}
|
||||
<Animated.View
|
||||
style={[
|
||||
styles.buttonContainer,
|
||||
{
|
||||
transform: [{ scale: scaleValue }],
|
||||
},
|
||||
]}
|
||||
>
|
||||
<TouchableOpacity
|
||||
style={styles.button}
|
||||
onPress={handlePress}
|
||||
onPressIn={handlePressIn}
|
||||
onPressOut={handlePressOut}
|
||||
activeOpacity={0.9}
|
||||
>
|
||||
<MaterialCommunityIcons
|
||||
name="robot-excited"
|
||||
size={32}
|
||||
color={colors.background}
|
||||
/>
|
||||
</TouchableOpacity>
|
||||
</Animated.View>
|
||||
|
||||
{/* Chatbot Modal */}
|
||||
<ChatbotModal
|
||||
visible={isChatbotVisible}
|
||||
onClose={() => setIsChatbotVisible(false)}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
pulseRing: {
|
||||
position: 'absolute',
|
||||
bottom: 90,
|
||||
right: 20,
|
||||
width: 70,
|
||||
height: 70,
|
||||
borderRadius: 35,
|
||||
backgroundColor: colors.highlight,
|
||||
},
|
||||
buttonContainer: {
|
||||
position: 'absolute',
|
||||
bottom: 90,
|
||||
right: 20,
|
||||
width: 64,
|
||||
height: 64,
|
||||
borderRadius: 32,
|
||||
shadowColor: colors.highlight,
|
||||
shadowOffset: { width: 0, height: 8 },
|
||||
shadowOpacity: 0.6,
|
||||
shadowRadius: 16,
|
||||
elevation: 12,
|
||||
},
|
||||
button: {
|
||||
width: 64,
|
||||
height: 64,
|
||||
borderRadius: 32,
|
||||
backgroundColor: colors.highlight,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
borderWidth: 3,
|
||||
borderColor: colors.highlightAlt,
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user