Fix #896 Port Send Android to choo
This commit is contained in:
parent
071e283f87
commit
7a48c5201a
10 changed files with 195 additions and 206 deletions
6
android/pages/.eslintrc.yaml
Normal file
6
android/pages/.eslintrc.yaml
Normal file
|
@ -0,0 +1,6 @@
|
|||
env:
|
||||
browser: true
|
||||
|
||||
parserOptions:
|
||||
sourceType: module
|
||||
|
33
android/pages/home.js
Normal file
33
android/pages/home.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
const html = require('choo/html');
|
||||
|
||||
export default function mainPage(state, emit) {
|
||||
function uploadFile(event) {
|
||||
event.preventDefault();
|
||||
const target = event.target;
|
||||
const file = target.files[0];
|
||||
if (file.size === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
emit('pushState', '/upload');
|
||||
emit('addFiles', { files: [file] });
|
||||
emit('upload', {});
|
||||
}
|
||||
return html`<body>
|
||||
<div id="white">
|
||||
<div id="centering">
|
||||
<img src=${state.getAsset('encrypted-envelope.png')} />
|
||||
<h4>Private, Encrypted File Sharing</h4>
|
||||
<div>
|
||||
Send files through a safe, private, and encrypted link that automatically expires to ensure your stuff does not remain online forever.
|
||||
</div>
|
||||
<div id="spacer">
|
||||
</div>
|
||||
<label id="label" for="input">
|
||||
<img src=${state.getAsset('cloud-upload.png')} />
|
||||
</label>
|
||||
<input id="input" name="input" type="file" onchange=${uploadFile} />
|
||||
</div>
|
||||
</div>
|
||||
</body>`;
|
||||
}
|
47
android/pages/share.js
Normal file
47
android/pages/share.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
const html = require('choo/html');
|
||||
|
||||
export default function uploadComplete(state, emit) {
|
||||
const file = state.storage.files[state.storage.files.length - 1];
|
||||
function onclick(e) {
|
||||
e.preventDefault();
|
||||
input.select();
|
||||
document.execCommand('copy');
|
||||
input.selectionEnd = input.selectionStart;
|
||||
copyText.textContent = 'Copied!';
|
||||
setTimeout(function() {
|
||||
copyText.textContent = 'Copy link';
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
function uploadFile(event) {
|
||||
event.preventDefault();
|
||||
const target = event.target;
|
||||
const file = target.files[0];
|
||||
if (file.size === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
emit('pushState', '/upload');
|
||||
emit('addFiles', { files: [file] });
|
||||
emit('upload', {});
|
||||
}
|
||||
|
||||
const input = html`<input id="url" value=${file.url} readonly="true" />`;
|
||||
const copyText = html`<span>Copy link</span>`;
|
||||
return html`<body>
|
||||
<div id="white">
|
||||
<div class="card">
|
||||
<div>The card contents will be here.</div>
|
||||
<div>Expires after: <span class="expires-after">exp</span></div>
|
||||
${input}
|
||||
<div id="copy-link" onclick=${onclick}>
|
||||
<img id="copy-image" src=${state.getAsset('copy-link.png')} />
|
||||
${copyText}
|
||||
</div>
|
||||
<label id="label" for="input">
|
||||
<img src=${state.getAsset('cloud-upload.png')} />
|
||||
</label>
|
||||
<input id="input" name="input" type="file" onchange=${uploadFile} />
|
||||
</div>
|
||||
</body>`;
|
||||
}
|
24
android/pages/upload.js
Normal file
24
android/pages/upload.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
const html = require('choo/html');
|
||||
|
||||
export default function progressBar(state, emit) {
|
||||
let percent = 0;
|
||||
if (state.transfer && state.transfer.progress) {
|
||||
percent = Math.floor(state.transfer.progressRatio * 100);
|
||||
}
|
||||
function onclick(e) {
|
||||
e.preventDefault();
|
||||
if (state.uploading) {
|
||||
emit('cancel');
|
||||
}
|
||||
emit('pushState', '/');
|
||||
}
|
||||
return html`<body>
|
||||
<div id="white">
|
||||
<div class="card">
|
||||
<div>${percent}%</div>
|
||||
<span class="progress" style="width: ${percent}%">.</span>
|
||||
<div class="cancel" onclick=${onclick}>CANCEL</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>`;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue