------------------------- | Polished App Demo | |-----------------------| | | | [Animated Button] | | | | Shadowed Card View | | ------------------- | | | Title | | | | Description | | | ------------------- | | | | Responsive Layout | | [Text adjusts size] | -------------------------
Why advanced UI creates polished apps in React Native - Build It to Prove It
import React from 'react'; import { View, Text, Pressable, StyleSheet, Animated, Dimensions } from 'react-native'; export default function PolishedAppDemo() { // TODO: Add animated scale value and handlers return ( <View style={styles.container}> {/* TODO: Add animated button here */} {/* TODO: Add shadowed card view here */} {/* TODO: Add responsive text here */} </View> ); } const styles = StyleSheet.create({ container: { flex: 1, padding: 20, justifyContent: 'center', alignItems: 'center', backgroundColor: '#f0f0f0' } });
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.
------------------------- | Polished App Demo | |-----------------------| | | | [Animated Button] | | | | Shadowed Card View | | ------------------- | | | Shadowed Card | | | | This card has | | | | shadow and | | | | rounded corners.| | | ------------------- | | | | Responsive Text | | Responsive Text | | adjusts size | -------------------------
Practice
Solution
Step 1: Understand the role of animations in UI
Animations provide visual feedback and smooth transitions that help users understand app behavior.Step 2: Connect animations to user engagement
Smoother and engaging animations keep users interested and make the app feel polished.Final Answer:
Animations make the app feel smoother and more engaging. -> Option DQuick Check:
Animations improve experience = B [OK]
- Thinking animations slow down the app
- Believing animations are just decoration
- Ignoring user engagement benefits
Solution
Step 1: Identify correct React Native button syntax
React Native uses <Button> with 'title' prop and 'onPress' event.Step 2: Check each option for correct props and tags
<Button title='Click me' onPress={() => alert('Hello')} /> uses correct tag and props; others use invalid tags or props.Final Answer:
<Button title='Click me' onPress={() => alert('Hello')} /> -> Option AQuick Check:
React Native Button = <Button title='Click me' onPress={() => alert('Hello')} /> [OK]
- Using lowercase <button> instead of <Button>
- Using 'text' instead of 'title' prop
- Using 'onClick' instead of 'onPress'
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
export default function App() {
return (
Welcome!
);
}
const styles = StyleSheet.create({
container: { flex: 1, justifyContent: 'center', alignItems: 'center' },
text: { fontSize: 24, color: 'blue' }
});Solution
Step 1: Analyze the container style
The container uses flex:1 to fill screen and centers content vertically and horizontally.Step 2: Analyze the text style
The text has font size 24 and blue color, so it will appear large and blue.Final Answer:
A full screen with centered blue text 'Welcome!' -> Option BQuick Check:
Centered blue text = D [OK]
- Assuming text is black by default
- Thinking styles cause errors
- Ignoring flexbox centering
import React from 'react';
import { View, Text } from 'react-native';
export default function App() {
return (
Hello
World
);
}
const styles = StyleSheet.create({
container: { flex: 1 }
});Solution
Step 1: Check imports and usage
The code uses StyleSheet.create but does not import StyleSheet from 'react-native'.Step 2: Verify JSX structure
Multiple <Text> inside <View> is allowed and <View> is properly closed.Final Answer:
Missing import of StyleSheet causes error. -> Option CQuick Check:
Missing StyleSheet import = A [OK]
- Thinking multiple <Text> tags are invalid
- Ignoring missing imports
- Assuming JSX tags are not closed
Solution
Step 1: Identify how to animate button color on press
TouchableOpacity supports animated opacity changes, giving smooth visual feedback.Step 2: Compare options for polished UI
Simple Button or instant color change lacks smooth animation; Text component lacks interaction.Final Answer:
Use TouchableOpacity with animated opacity change on press. -> Option AQuick Check:
Animated touch feedback = C [OK]
- Using Button without animation
- Changing color instantly without animation
- Using Text without interaction
Ready to prove it?
Pass the test and this pattern moves unknown
