You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
1.6 KiB
71 lines
1.6 KiB
import React, { useState } from 'react'; |
|
import { View, Text, StyleSheet, Button, Modal, TouchableOpacity, Dimensions } from 'react-native'; |
|
|
|
export const CategoryScreen = () => { |
|
const [isModalVisible, setIsModalVisible] = useState(false); |
|
|
|
const toggleModal = () => { |
|
setIsModalVisible(!isModalVisible); |
|
}; |
|
|
|
return ( |
|
<View style={styles.container}> |
|
<Button title="Category Screen" onPress={toggleModal} /> |
|
|
|
<Modal |
|
visible={isModalVisible} |
|
transparent={true} |
|
animationType="slide" |
|
onRequestClose={toggleModal} |
|
> |
|
<TouchableOpacity |
|
style={styles.modalOverlay} |
|
activeOpacity={1} |
|
onPress={toggleModal} |
|
> |
|
<View style={styles.modalContent}> |
|
<View style={styles.modalHeader}> |
|
<View style={styles.modalHandle} /> |
|
</View> |
|
{/* 这里可以添加模态框的内容 */} |
|
</View> |
|
</TouchableOpacity> |
|
</Modal> |
|
</View> |
|
); |
|
}; |
|
|
|
const styles = StyleSheet.create({ |
|
container: { |
|
flex: 1, |
|
justifyContent: 'center', |
|
alignItems: 'center', |
|
backgroundColor: '#fff', |
|
}, |
|
text: { |
|
fontSize: 20, |
|
color: '#333', |
|
}, |
|
modalOverlay: { |
|
flex: 1, |
|
backgroundColor: 'rgba(0, 0, 0, 0.5)', |
|
justifyContent: 'flex-end', |
|
}, |
|
modalContent: { |
|
height: '70%', |
|
backgroundColor: 'white', |
|
borderTopLeftRadius: 20, |
|
borderTopRightRadius: 20, |
|
padding: 20, |
|
}, |
|
modalHeader: { |
|
alignItems: 'center', |
|
paddingBottom: 10, |
|
}, |
|
modalHandle: { |
|
width: 40, |
|
height: 4, |
|
backgroundColor: '#ccc', |
|
borderRadius: 2, |
|
}, |
|
});
|