|
1 | | -import React, { useState } from 'react'; |
| 1 | +import React from 'react'; |
2 | 2 | import PropTypes from 'prop-types'; |
3 | | -import { View, Text, TextProps, Dimensions, TouchableOpacity } from 'react-native'; |
4 | | -import Icon from '../Icon'; |
5 | | -import { right } from './svg'; |
6 | | -import MaskLayer from '../MaskLayer'; |
| 3 | +import { Text, TextProps } from 'react-native'; |
7 | 4 |
|
8 | | -let MainHeight = Dimensions.get('window').height; |
9 | 5 | export interface EllipsisProps extends TextProps { |
10 | 6 | children?: React.ReactNode; |
11 | 7 | placeholder?: string; |
12 | 8 | maxLen?: number; |
13 | 9 | } |
14 | 10 |
|
15 | 11 | export default function Ellipsis({ maxLen, children, placeholder, ...props }: EllipsisProps) { |
16 | | - const [modalVisible, setModalVisible] = useState(false); |
17 | | - // let content1 = Number(children.length); |
18 | | - |
19 | 12 | let content = children; |
20 | 13 | if (maxLen && content && typeof content === 'string') { |
21 | 14 | content = content.length > maxLen ? content.substr(0, maxLen) + placeholder : content; |
22 | 15 | } |
23 | | - |
24 | | - return ( |
25 | | - <> |
26 | | - <MaskLayer visible={modalVisible} onDismiss={() => setModalVisible(false)}> |
27 | | - <View |
28 | | - style={{ |
29 | | - backgroundColor: '#fff', |
30 | | - justifyContent: 'center', |
31 | | - alignItems: 'center', |
32 | | - marginTop: MainHeight * 0.2, |
33 | | - padding: 20, |
34 | | - }} |
35 | | - > |
36 | | - <Text style={{ fontSize: 17 }}>{children}</Text> |
37 | | - </View> |
38 | | - </MaskLayer> |
39 | | - |
40 | | - <TouchableOpacity |
41 | | - style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }} |
42 | | - onPress={() => setModalVisible(true)} |
43 | | - > |
44 | | - <Text {...props}>{content}</Text> |
45 | | - <Icon name="right" size={14} /> |
46 | | - </TouchableOpacity> |
47 | | - </> |
48 | | - ); |
| 16 | + return <Text {...props}>{content}</Text>; |
49 | 17 | } |
50 | 18 |
|
51 | 19 | Ellipsis.propTypes = { |
|
0 commit comments