import React, { useState } from 'react'; import { StyleSheet, Text, View, ScrollView, SafeAreaView, TouchableOpacity, Image, Switch } from 'react-native'; import { StatusBar } from 'expo-status-bar'; /** * 主屏幕组件 - 采用中文显示与注释 * 包含计数器和主题切换功能 */ export const MainScreen = () => { const [count, setCount] = useState(0); const [isDarkMode, setIsDarkMode] = useState(false); // 主题样式定义 const theme = { background: isDarkMode ? '#1C1C1E' : '#F5F7FA', card: isDarkMode ? '#2C2C2E' : '#FFFFFF', text: isDarkMode ? '#FFFFFF' : '#1C1C1E', secondaryText: isDarkMode ? '#AEAEB2' : '#3A3A3C', accent: '#007AFF', border: isDarkMode ? '#3A3A3C' : '#E5E5EA', }; return ( {/* 顶部标题栏 */} React Native 中文项目 跨平台移动端 & Web 应用 {/* 核心功能展示区 */} {/* 主题切换卡片 */} {isDarkMode ? '深色模式' : '浅色模式'} {/* 交互计数器卡片 */} 交互计数器 {count} setCount(count + 1)} > 增加 setCount(0)} > 重置 项目特点 全面支持 iOS, Android 和 Web 中文界面与详细的代码注释 响应式布局,适配多种屏幕尺寸 {/* 交互示例 */} alert('欢迎使用 React Native!')} > 点击交互示例 {/* 底部信息 */} © 2024 中文 React Native 项目 由 Trae AI 强力驱动 ); }; const styles = StyleSheet.create({ safeArea: { flex: 1, }, scrollContainer: { flexGrow: 1, }, header: { padding: 30, alignItems: 'center', justifyContent: 'center', borderBottomLeftRadius: 24, borderBottomRightRadius: 24, shadowColor: '#000', shadowOffset: { width: 0, height: 4 }, shadowOpacity: 0.1, shadowRadius: 10, elevation: 5, }, headerTitle: { fontSize: 28, fontWeight: 'bold', color: '#FFFFFF', marginBottom: 8, }, headerSubtitle: { fontSize: 16, color: 'rgba(255, 255, 255, 0.8)', }, content: { padding: 20, gap: 15, }, card: { borderRadius: 16, padding: 20, shadowColor: '#000', shadowOffset: { width: 0, height: 2 }, shadowOpacity: 0.05, shadowRadius: 8, elevation: 2, }, switchRow: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', }, cardTitle: { fontSize: 20, fontWeight: '600', marginBottom: 15, borderLeftWidth: 4, borderLeftColor: '#007AFF', paddingLeft: 10, }, counterContainer: { alignItems: 'center', paddingVertical: 10, }, counterText: { fontSize: 48, fontWeight: 'bold', marginBottom: 15, }, buttonRow: { flexDirection: 'row', gap: 15, }, smallButton: { paddingHorizontal: 20, paddingVertical: 10, borderRadius: 8, minWidth: 80, alignItems: 'center', }, smallButtonText: { color: '#FFFFFF', fontWeight: '600', }, featureItem: { flexDirection: 'row', alignItems: 'center', marginBottom: 10, }, featureDot: { fontSize: 18, marginRight: 10, }, featureText: { fontSize: 16, lineHeight: 24, }, button: { borderRadius: 12, paddingVertical: 15, alignItems: 'center', justifyContent: 'center', marginTop: 10, }, buttonText: { color: '#FFFFFF', fontSize: 18, fontWeight: '600', }, footer: { marginTop: 30, marginBottom: 20, alignItems: 'center', }, footerText: { fontSize: 14, lineHeight: 20, }, });