/
Lenarqa
/
reactNativeTestApp
Обзор
Документация
Войти
/
Lenarqa
/
reactNativeTestApp
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
App.js
49 строк
1 KB
Lenarqa
use styles for android and ios
21 мар 2024, 19:01
21 мар 2024, 19:01
bc1bcc2
Код
Авторство
О чём код?
import {StyleSheet, View, Text, Platform, useWindowDimensions, SafeAreaView } from "react-native"; import CustomButton from "./components/CustomButton/CustomButton"; export default function App() { return ( <SafeAreaView style={ styles.safeArea }> <View style={ styles.container }> <View style={ styles.box }> <Text style={ styles.text }>Welcome</Text> </View> <CustomButton onPress={() => alert("Hello")} title="Click Me!"/> </View> </SafeAreaView> ); } const styles = StyleSheet.create({ safeArea: { flex: 1, backgroundColor: "plum" }, container: { flex: 1, backgroundColor: "plum", marginTop: Platform.OS === "android" ? 25 : 0, alignItems: "center" }, box: { alignItems: "center", justifyContent: "center", backgroundColor: "lightblue" }, text: { ...Platform.select({ ios: { fontSize: 24, fontWeight: "600", fontStyle: "italic", }, android: { fontSize: 32, fontWeight: "200", color: "red" } }) } });