@@ -40,6 +40,7 @@ export class FeedbackWidget extends React.Component<FeedbackWidgetProps, Feedbac
4040 description : '' ,
4141 filename : undefined ,
4242 attachment : undefined ,
43+ attachmentUri : undefined ,
4344 } ;
4445
4546 public constructor ( props : FeedbackWidgetProps ) {
@@ -59,6 +60,7 @@ export class FeedbackWidget extends React.Component<FeedbackWidgetProps, Feedbac
5960 description : FeedbackWidget . _savedState . description || '' ,
6061 filename : FeedbackWidget . _savedState . filename || undefined ,
6162 attachment : FeedbackWidget . _savedState . attachment || undefined ,
63+ attachmentUri : FeedbackWidget . _savedState . attachmentUri || undefined ,
6264 } ;
6365 }
6466
@@ -141,24 +143,25 @@ export class FeedbackWidget extends React.Component<FeedbackWidgetProps, Feedbac
141143 const imageUri = result . assets [ 0 ] . uri ;
142144 NATIVE . getDataFromUri ( imageUri ) . then ( ( data ) => {
143145 if ( data != null ) {
144- this . setState ( { filename, attachment : data } ) ;
146+ this . setState ( { filename, attachment : data , attachmentUri : imageUri } ) ;
145147 } else {
146148 logger . error ( 'Failed to read image data from uri:' , imageUri ) ;
147149 }
148150 } )
149- . catch ( ( error ) => {
150- logger . error ( 'Failed to read image data from uri:' , imageUri , 'error: ' , error ) ;
151- } ) ;
151+ . catch ( ( error ) => {
152+ logger . error ( 'Failed to read image data from uri:' , imageUri , 'error: ' , error ) ;
153+ } ) ;
152154 }
153155 } else {
154156 // Defaulting to the onAddScreenshot callback
155157 const { onAddScreenshot } = { ...defaultConfiguration , ...this . props } ;
156158 onAddScreenshot ( ( filename : string , attachement : Uint8Array ) => {
157- this . setState ( { filename, attachment : attachement } ) ;
159+ // TODO: Add support for image uri when using onAddScreenshot
160+ this . setState ( { filename, attachment : attachement , attachmentUri : undefined } ) ;
158161 } ) ;
159162 }
160163 } else {
161- this . setState ( { filename : undefined , attachment : undefined } ) ;
164+ this . setState ( { filename : undefined , attachment : undefined , attachmentUri : undefined } ) ;
162165 }
163166 }
164167
@@ -256,13 +259,21 @@ export class FeedbackWidget extends React.Component<FeedbackWidgetProps, Feedbac
256259 multiline
257260 />
258261 { ( config . enableScreenshot || imagePickerConfiguration . imagePicker ) && (
259- < TouchableOpacity style = { styles . screenshotButton } onPress = { this . onScreenshotButtonPress } >
260- < Text style = { styles . screenshotText } >
261- { ! this . state . filename && ! this . state . attachment
262- ? text . addScreenshotButtonLabel
263- : text . removeScreenshotButtonLabel }
264- </ Text >
265- </ TouchableOpacity >
262+ < View style = { styles . screenshotContainer } >
263+ { this . state . attachmentUri && (
264+ < Image
265+ source = { { uri : this . state . attachmentUri } }
266+ style = { styles . screenshotThumbnail }
267+ />
268+ ) }
269+ < TouchableOpacity style = { styles . screenshotButton } onPress = { this . onScreenshotButtonPress } >
270+ < Text style = { styles . screenshotText } >
271+ { ! this . state . filename && ! this . state . attachment
272+ ? text . addScreenshotButtonLabel
273+ : text . removeScreenshotButtonLabel }
274+ </ Text >
275+ </ TouchableOpacity >
276+ </ View >
266277 ) }
267278 < TouchableOpacity style = { styles . submitButton } onPress = { this . handleFeedbackSubmit } >
268279 < Text style = { styles . submitText } > { text . submitButtonLabel } </ Text >
@@ -290,6 +301,7 @@ export class FeedbackWidget extends React.Component<FeedbackWidgetProps, Feedbac
290301 description : '' ,
291302 filename : undefined ,
292303 attachment : undefined ,
304+ attachmentUri : undefined ,
293305 } ;
294306 } ;
295307}
0 commit comments