import React, { useState } from 'react'; import { ScrollView, StyleSheet, View } from 'react-native'; import { Button, Card, Chip, FAB, IconButton, List, ProgressBar, Searchbar, SegmentedButtons, Snackbar, Switch, Text, TextInput, useTheme, } from 'react-native-paper'; export default function PaperDemo() { const theme = useTheme(); const [searchQuery, setSearchQuery] = useState(''); const [text, setText] = useState(''); const [switchValue, setSwitchValue] = useState(false); const [snackbarVisible, setSnackbarVisible] = useState(false); const [segmentedValue, setSegmentedValue] = useState('walk'); const [expanded, setExpanded] = useState(true); return ( {/* 标题 */} React Native Paper Material Design 组件库示例 {/* 搜索框 */} 🔍 搜索框 {/* 输入框 */} ✏️ 输入框 {/* 按钮 */} 🔘 按钮 {/* 分段按钮 */} 📊 分段按钮 {/* 开关和芯片 */} 🎛️ 开关和芯片 启用通知 {}}> 收藏 {}}> 喜欢 {}} onClose={() => {}} closeIcon="close-circle" > 可关闭 {/* 进度条 */} 📈 进度条 {/* 列表 */} 📋 列表 } expanded={expanded} onPress={() => setExpanded(!expanded)} > } /> } /> } right={(props) => } /> {/* 卡片示例 */} } right={(props) => } /> 这是一个完整的卡片示例,包含封面图片、标题、内容和操作按钮。 {/* 底部留白 */} {/* 浮动操作按钮 */} setSnackbarVisible(true)} label="添加" /> {/* 提示条 */} setSnackbarVisible(false)} duration={3000} action={{ label: '撤销', onPress: () => { // 撤销操作 }, }} > 操作成功! ); } const styles = StyleSheet.create({ container: { flex: 1, }, scrollView: { flex: 1, }, content: { padding: 16, }, title: { marginBottom: 8, fontWeight: 'bold', }, subtitle: { marginBottom: 24, opacity: 0.7, }, card: { marginBottom: 16, }, sectionTitle: { marginBottom: 12, fontWeight: '600', }, searchbar: { marginTop: 8, }, input: { marginBottom: 12, }, buttonRow: { flexDirection: 'row', gap: 8, marginBottom: 8, }, row: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16, }, chipContainer: { flexDirection: 'row', flexWrap: 'wrap', gap: 8, }, progressBar: { marginBottom: 12, }, bottomSpace: { height: 80, }, fab: { position: 'absolute', margin: 16, right: 0, bottom: 0, }, });