Skip to content

Commit

Permalink
Merge pull request SnapDrop#312 from dewanhimanshu/feature-image-preview
Browse files Browse the repository at this point in the history
file preview feature added
  • Loading branch information
RobinLinus authored Jun 4, 2021
2 parents 0ba427c + a593ef1 commit 0aa2725
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ <h2>Open Snapdrop on other devices to send files</h2>
<h3>File Received</h3>
<div class="font-subheading" id="fileName">Filename</div>
<div class="font-body2" id="fileSize"></div>
<div class='preview' style="visibility: hidden;">
<img id='img-preview' src="">
</div>
<div>
<div class="row">
<label for="autoDownload" class="grow">Ask to save each file before downloading</label>
<input type="checkbox" id="autoDownload" checked="">
Expand Down
7 changes: 7 additions & 0 deletions client/scripts/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ class ReceiveDialog extends Dialog {
$a.click()
return
}
if(file.mime.split('/')[0] === 'image'){
console.log('the file is image');
this.$el.querySelector('.preview').style.visibility = 'inherit';
this.$el.querySelector("#img-preview").src = url;
}

this.$el.querySelector('#fileName').textContent = file.name;
this.$el.querySelector('#fileSize').textContent = this._formatFileSize(file.size);
Expand All @@ -292,6 +297,8 @@ class ReceiveDialog extends Dialog {
}

hide() {
this.$el.querySelector('.preview').style.visibility = 'hidden';
this.$el.querySelector("#img-preview").src = "";
super.hide();
this._dequeueFile();
}
Expand Down
9 changes: 8 additions & 1 deletion client/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,12 @@ x-dialog x-paper {
color: var(--text-color);
background-color: var(--bg-color-secondary);
}
/* Image Preview */
#img-preview{
max-width:100%;
max-height:100%;

}


/* Styles for users who prefer dark mode at the OS level */
Expand Down Expand Up @@ -746,4 +752,5 @@ x-dialog x-paper {
body {
overflow: hidden;
}
}
}

0 comments on commit 0aa2725

Please sign in to comment.