This app shows the device OS, version, and screen size. Pressing the button makes the device vibrate shortly.
import React from 'react';
import { View, Text, Button, Platform, Dimensions, Vibration, StyleSheet } from 'react-native';
export default function DeviceInfoHaptics() {
const os = Platform.OS;
const version = Platform.Version;
const { width, height } = Dimensions.get('window');
const handleVibrate = () => {
Vibration.vibrate(150);
};
return (
<View style={styles.container} accessible={true} accessibilityLabel="Device info and haptics screen">
<Text style={styles.text}>OS: {os}</Text>
<Text style={styles.text}>Version: {version}</Text>
<Text style={styles.text}>Screen: {width} x {height}</Text>
<Button title="Vibrate Device" onPress={handleVibrate} accessibilityLabel="Button to vibrate device" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
padding: 20,
backgroundColor: '#f0f0f0'
},
text: {
fontSize: 18,
marginBottom: 10
}
});