Skip to content

Commit 8145482

Browse files
Fixing issues with FileUploadPreview
1. Visibility of retry button was quite poor, because of white color on white background. This reload icon has been changes to contrast on white background 2. Cancel button was unaccessible because of overlapping reload icon container.
1 parent f418e0a commit 8145482

File tree

5 files changed

+54
-38
lines changed

5 files changed

+54
-38
lines changed

src/components/MessageInput/FileUploadPreview.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ const Container = styled.View`
3939
${({ theme }) => theme.messageInput.fileUploadPreview.container.css};
4040
`;
4141

42-
const DismissText = styled.Text`
43-
${({ theme }) => theme.messageInput.fileUploadPreview.dismissText.css};
44-
`;
45-
4642
const FilenameText = styled.Text`
4743
padding-left: 10px;
4844
${({ theme }) => theme.messageInput.fileUploadPreview.filenameText.css};
@@ -73,8 +69,13 @@ const FileUploadPreview = ({
7369

7470
return (
7571
<UploadProgressIndicator
76-
action={() => (retryUpload ? retryUpload(item.id) : null)}
72+
action={() => {
73+
retryUpload ? retryUpload(item.id) : null;
74+
}}
7775
active={item.state !== FileState.UPLOADED}
76+
cancel={() => {
77+
removeFile ? removeFile(item.id) : null;
78+
}}
7879
type={type}
7980
>
8081
<AttachmentContainerView>
@@ -86,12 +87,6 @@ const FileUploadPreview = ({
8687
: item.file.name}
8788
</FilenameText>
8889
</AttachmentView>
89-
<DismissText
90-
onPress={() => removeFile(item.id)}
91-
testID='remove-file-upload-preview'
92-
>
93-
X
94-
</DismissText>
9590
</AttachmentContainerView>
9691
</UploadProgressIndicator>
9792
);

src/components/MessageInput/UploadProgressIndicator.js

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { ActivityIndicator, Image, TouchableOpacity, View } from 'react-native';
2+
import { ActivityIndicator, Image, View } from 'react-native';
33
import styled from '@stream-io/styled-components';
44
import PropTypes from 'prop-types';
55

@@ -28,51 +28,71 @@ const Overlay = styled.View`
2828
${({ theme }) => theme.messageInput.uploadProgressIndicator.overlay.css};
2929
`;
3030

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 }) =>
3258
!active ? (
3359
<View testID='inactive-upload-progress-indicator'>{children}</View>
3460
) : (
35-
<TouchableOpacity
36-
onPress={action}
37-
testID='active-upload-progress-indicator'
38-
>
61+
<View testID='active-upload-progress-indicator'>
3962
{children}
4063
<Overlay />
4164
<Container>
4265
{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={{}}>
5467
<ActivityIndicator
55-
color='white'
68+
color='grey'
5669
testID='upload-progress-indicator'
5770
/>
58-
</View>
71+
</ActivityIndicatorContainer>
5972
)}
6073
{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>
6681
)}
82+
<DismissText onPress={cancel} testID='remove-file-upload-preview'>
83+
X
84+
</DismissText>
6785
</Container>
68-
</TouchableOpacity>
86+
</View>
6987
);
7088

7189
UploadProgressIndicator.propTypes = {
7290
/** Action triggered when clicked indicator */
7391
action: PropTypes.func,
74-
/** Boolean status of upload progress */
7592
active: PropTypes.bool,
93+
/** Action triggered when clicked cancel button */
94+
cancel: PropTypes.func,
95+
/** Boolean status of upload progress */
7696
/** Type of active indicator */
7797
type: PropTypes.oneOf([
7898
ProgressIndicatorTypes.IN_PROGRESS,

src/images/reload1.png

1.04 KB
Loading

src/styles/theme.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ export const defaultTheme = {
202202
attachmentContainerView: {},
203203
attachmentView: {},
204204
container: {},
205-
dismissText: {},
206205
filenameText: {},
207206
},
208207
imageUploadPreview: {
@@ -239,6 +238,7 @@ export const defaultTheme = {
239238
},
240239
uploadProgressIndicator: {
241240
container: {},
241+
dismiss: {},
242242
overlay: {},
243243
},
244244
},

types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,7 @@ export interface UploadProgressIndicatorProps extends StyledComponentProps {
11411141
active: boolean;
11421142
type: 'in_progress' | 'retry';
11431143
action?(event: GestureResponderEvent): void;
1144+
cancel?(event: GestureResponderEvent): void;
11441145
}
11451146

11461147
export interface AttachmentActionsProps extends StyledComponentProps {

0 commit comments

Comments
 (0)