1
- import React from 'react' ;
2
- import { Text , View , StyleSheet } from 'react-native' ;
1
+ import React , { useState } from 'react' ;
2
+ import { Text , View , StyleSheet , Modal , Dimensions } from 'react-native' ;
3
3
import { Card , Button } from 'react-native-elements' ;
4
4
import { colors } from '../Theme' ;
5
5
import Supply from './Supply' ;
6
6
import moment from 'moment' ;
7
+ import HospitalDetail from './HospitalDetail' ;
8
+ const { height } = Dimensions . get ( 'window' ) ;
7
9
8
10
type PropTypes = {
9
11
item : HospitalType ;
10
- onClick : ( hospital : HospitalType ) => void ;
11
12
} ;
12
13
13
14
const styles = StyleSheet . create ( {
@@ -29,8 +30,9 @@ const styles = StyleSheet.create({
29
30
} ,
30
31
} ) ;
31
32
32
- function Hospital ( { item, onClick } : PropTypes ) {
33
+ function Hospital ( { item } : PropTypes ) {
33
34
const { supplies } = item ;
35
+ const [ visible , setVisible ] = useState ( false ) ;
34
36
return (
35
37
< Card title = { item . hospital } >
36
38
< View style = { styles . subtitleContainer } >
@@ -52,7 +54,36 @@ function Hospital({ item, onClick }: PropTypes) {
52
54
</ View >
53
55
</ View >
54
56
< View style = { { paddingHorizontal : 30 , paddingTop : 10 } } >
55
- < Button type = "outline" title = "查看详情" onPress = { ( ) => onClick ( item ) } />
57
+ < Button
58
+ type = "outline"
59
+ title = "查看详情"
60
+ onPress = { ( ) => setVisible ( true ) }
61
+ />
62
+ < Modal
63
+ animationType = "fade"
64
+ presentationStyle = "formSheet"
65
+ transparent = { false }
66
+ onDismiss = { ( ) => {
67
+ setVisible ( false ) ;
68
+ } }
69
+ onRequestClose = { ( ) => {
70
+ setVisible ( false ) ;
71
+ } }
72
+ visible = { visible } >
73
+ < View style = { { padding : 16 , justifyContent : 'space-between' } } >
74
+ < View style = { { height : height - 150 } } >
75
+ < HospitalDetail item = { item } />
76
+ </ View >
77
+ < View >
78
+ < Button
79
+ title = "关闭详情"
80
+ onPress = { ( ) => {
81
+ setVisible ( false ) ;
82
+ } }
83
+ />
84
+ </ View >
85
+ </ View >
86
+ </ Modal >
56
87
</ View >
57
88
</ Card >
58
89
) ;
0 commit comments