|
1 | 1 | import React from 'react'; |
2 | | -import { ActivityIndicator, Image, TouchableOpacity, View } from 'react-native'; |
| 2 | +import { ActivityIndicator, Image, View } from 'react-native'; |
3 | 3 | import styled from '@stream-io/styled-components'; |
4 | 4 | import PropTypes from 'prop-types'; |
5 | 5 |
|
@@ -28,51 +28,71 @@ const Overlay = styled.View` |
28 | 28 | ${({ theme }) => theme.messageInput.uploadProgressIndicator.overlay.css}; |
29 | 29 | `; |
30 | 30 |
|
31 | | -const UploadProgressIndicator = ({ action, active, children, type }) => |
| 31 | +const ActivityIndicatorContainer = styled.View` |
| 32 | + align-items: center; |
| 33 | + bottom: 0; |
| 34 | + justify-content: center; |
| 35 | + left: 0; |
| 36 | + position: absolute; |
| 37 | + right: 0; |
| 38 | + top: 0; |
| 39 | +`; |
| 40 | + |
| 41 | +const DismissText = styled.Text` |
| 42 | + align-self: flex-end; |
| 43 | + margin-right: 10px; |
| 44 | + ${({ theme }) => theme.messageInput.uploadProgressIndicator.dismiss.css}; |
| 45 | +`; |
| 46 | + |
| 47 | +const RetryButtonContainer = styled.TouchableOpacity` |
| 48 | + align-items: center; |
| 49 | + bottom: 0; |
| 50 | + justify-content: center; |
| 51 | + left: 0; |
| 52 | + position: absolute; |
| 53 | + right: 0; |
| 54 | + top: 0; |
| 55 | +`; |
| 56 | + |
| 57 | +const UploadProgressIndicator = ({ action, active, cancel, children, type }) => |
32 | 58 | !active ? ( |
33 | 59 | <View testID='inactive-upload-progress-indicator'>{children}</View> |
34 | 60 | ) : ( |
35 | | - <TouchableOpacity |
36 | | - onPress={action} |
37 | | - testID='active-upload-progress-indicator' |
38 | | - > |
| 61 | + <View testID='active-upload-progress-indicator'> |
39 | 62 | {children} |
40 | 63 | <Overlay /> |
41 | 64 | <Container> |
42 | 65 | {type === ProgressIndicatorTypes.IN_PROGRESS && ( |
43 | | - <View |
44 | | - style={{ |
45 | | - alignItems: 'center', |
46 | | - bottom: 0, |
47 | | - justifyContent: 'center', |
48 | | - left: 0, |
49 | | - position: 'absolute', |
50 | | - right: 0, |
51 | | - top: 0, |
52 | | - }} |
53 | | - > |
| 66 | + <ActivityIndicatorContainer style={{}}> |
54 | 67 | <ActivityIndicator |
55 | | - color='white' |
| 68 | + color='grey' |
56 | 69 | testID='upload-progress-indicator' |
57 | 70 | /> |
58 | | - </View> |
| 71 | + </ActivityIndicatorContainer> |
59 | 72 | )} |
60 | 73 | {type === ProgressIndicatorTypes.RETRY && ( |
61 | | - <Image |
62 | | - source={iconReload} |
63 | | - style={{ height: 18, width: 18 }} |
64 | | - testID='retry-upload-progress-indicator' |
65 | | - /> |
| 74 | + <RetryButtonContainer onPress={action}> |
| 75 | + <Image |
| 76 | + source={iconReload} |
| 77 | + style={{ height: 18, width: 18 }} |
| 78 | + testID='retry-upload-progress-indicator' |
| 79 | + /> |
| 80 | + </RetryButtonContainer> |
66 | 81 | )} |
| 82 | + <DismissText onPress={cancel} testID='remove-file-upload-preview'> |
| 83 | + X |
| 84 | + </DismissText> |
67 | 85 | </Container> |
68 | | - </TouchableOpacity> |
| 86 | + </View> |
69 | 87 | ); |
70 | 88 |
|
71 | 89 | UploadProgressIndicator.propTypes = { |
72 | 90 | /** Action triggered when clicked indicator */ |
73 | 91 | action: PropTypes.func, |
74 | | - /** Boolean status of upload progress */ |
75 | 92 | active: PropTypes.bool, |
| 93 | + /** Action triggered when clicked cancel button */ |
| 94 | + cancel: PropTypes.func, |
| 95 | + /** Boolean status of upload progress */ |
76 | 96 | /** Type of active indicator */ |
77 | 97 | type: PropTypes.oneOf([ |
78 | 98 | ProgressIndicatorTypes.IN_PROGRESS, |
|
0 commit comments