import React, { useRef } from 'react';
import { View, Text, Pressable, StyleSheet, Animated, Dimensions } from 'react-native';
export default function PolishedAppDemo() {
const scaleAnim = useRef(new Animated.Value(1)).current;
const screenWidth = Dimensions.get('window').width;
const onPressIn = () => {
Animated.spring(scaleAnim, {
toValue: 0.95,
useNativeDriver: true
}).start();
};
const onPressOut = () => {
Animated.spring(scaleAnim, {
toValue: 1,
friction: 3,
useNativeDriver: true
}).start();
};
const responsiveFontSize = screenWidth > 400 ? 24 : 18;
return (
<View style={styles.container}>
<Pressable onPressIn={onPressIn} onPressOut={onPressOut} accessibilityLabel="Animated button">
<Animated.View style={[styles.button, { transform: [{ scale: scaleAnim }] }]}>
<Text style={styles.buttonText}>Animated Button</Text>
</Animated.View>
</Pressable>
<View style={styles.card} accessible accessibilityRole="summary">
<Text style={styles.cardTitle}>Shadowed Card</Text>
<Text style={styles.cardDescription}>This card has shadow and rounded corners.</Text>
</View>
<Text style={[styles.responsiveText, { fontSize: responsiveFontSize }]}>Responsive Text adjusts size</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
padding: 20,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f0f0f0'
},
button: {
backgroundColor: '#4a90e2',
paddingVertical: 12,
paddingHorizontal: 24,
borderRadius: 8,
marginBottom: 30
},
buttonText: {
color: 'white',
fontWeight: '600',
fontSize: 18,
textAlign: 'center'
},
card: {
width: '80%',
backgroundColor: 'white',
borderRadius: 12,
padding: 16,
shadowColor: '#000',
shadowOffset: { width: 0, height: 4 },
shadowOpacity: 0.3,
shadowRadius: 6,
elevation: 8,
marginBottom: 30
},
cardTitle: {
fontSize: 20,
fontWeight: '700',
marginBottom: 8
},
cardDescription: {
fontSize: 16,
color: '#555'
},
responsiveText: {
color: '#333',
fontWeight: '500'
}
});This solution uses React Native's Animated API to create a button that smoothly scales down when pressed and returns to normal size when released. This subtle animation makes the button feel responsive and polished.
The card view uses shadows and rounded corners to create depth, making the UI look modern and professional. The shadow properties work on both iOS and Android (with elevation).
The responsive text adjusts its font size based on the screen width, ensuring readability on different device sizes. Flexbox layout centers and spaces the elements nicely.
Accessibility labels and roles are added for screen readers, improving usability for all users.