Skip to content

Commit

Permalink
Adds attachment button UI
Browse files Browse the repository at this point in the history
  • Loading branch information
antonis committed Dec 3, 2024
1 parent 14ac005 commit 4e13866
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
11 changes: 11 additions & 0 deletions packages/core/src/js/feedback/FeedbackFormScreen.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ const defaultStyles = StyleSheet.create({
height: 100,
textAlignVertical: 'top',
},
attachmentButton: {
backgroundColor: '#eee',
padding: 15,
borderRadius: 5,
marginBottom: 20,
alignItems: 'center',
},
attachmentText: {
color: '#333',
fontSize: 16,
},
submitButton: {
backgroundColor: '#6a1b9a',
paddingVertical: 15,
Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/js/feedback/FeedbackFormScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export class FeedbackFormScreen extends React.Component<FeedbackFormScreenProps,
closeScreen();
};

public addAttachment: () => void = () => {
Alert.alert('Info', 'Attachments are not supported yet.'); // TODO: Implement attachment support
};

/**
* Renders the feedback form screen.
*/
Expand Down Expand Up @@ -84,6 +88,10 @@ export class FeedbackFormScreen extends React.Component<FeedbackFormScreenProps,
multiline
/>

<TouchableOpacity style={styles?.attachmentButton || defaultStyles.attachmentButton} onPress={this.addAttachment}>
<Text style={styles?.attachmentText || defaultStyles.attachmentText}>{text?.attachmentButton || 'Add Screenshot'}</Text>
</TouchableOpacity>

<TouchableOpacity style={styles?.submitButton || defaultStyles.submitButton} onPress={this.handleFeedbackSubmit}>
<Text style={styles?.submitText || defaultStyles.submitText}>{text?.submitButton || 'Send Feedback'}</Text>
</TouchableOpacity>
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/js/feedback/FeedbackFormScreen.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface FeedbackFormText {
namePlaceholder?: string;
emailPlaceholder?: string;
descriptionPlaceholder?: string;
attachmentButton?: string;
submitButton?: string;
cancelButton?: string;
errorTitle?: string;
Expand All @@ -23,6 +24,8 @@ export interface FeedbackFormScreenStyles {
title?: TextStyle;
input?: TextStyle;
textArea?: ViewStyle;
attachmentButton?: ViewStyle;
attachmentText?: TextStyle;
submitButton?: ViewStyle;
submitText?: TextStyle;
cancelButton?: ViewStyle;
Expand Down
2 changes: 2 additions & 0 deletions packages/core/test/feedback/FeedbackFormScreen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const defaultProps: FeedbackFormScreenProps = {
namePlaceholder: 'Name',
emailPlaceholder: 'Email',
descriptionPlaceholder: 'Description',
attachmentButton: 'Add Attachment',
submitButton: 'Submit',
cancelButton: 'Cancel',
errorTitle: 'Error',
Expand All @@ -41,6 +42,7 @@ describe('FeedbackFormScreen', () => {
expect(getByPlaceholderText(defaultProps.text.namePlaceholder)).toBeTruthy();
expect(getByPlaceholderText(defaultProps.text.emailPlaceholder)).toBeTruthy();
expect(getByPlaceholderText(defaultProps.text.descriptionPlaceholder)).toBeTruthy();
expect(getByText(defaultProps.text.attachmentButton)).toBeTruthy();
expect(getByText(defaultProps.text.submitButton)).toBeTruthy();
expect(getByText(defaultProps.text.cancelButton)).toBeTruthy();
});
Expand Down
2 changes: 1 addition & 1 deletion samples/react-native/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const ErrorsTabNavigator = Sentry.withProfiler(
marginBottom: 10,
},
}}
text={{namePlaceholder: 'Fullname'}}
text={{namePlaceholder: 'Fullname', attachmentButton: 'Add Attachment'}}
/>
)}
</Stack.Screen>
Expand Down

0 comments on commit 4e13866

Please sign in to comment.