view.rs
1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use mogwai::prelude::*;
pub(super) fn upload_preview_view( tx_canvas :broadcast::Sender<Dom>
, filename :String
, size :f64
, mime_type :String
, mtime :f64 ) -> ViewBuilder<Dom> {
let post_build = move |dom: &mut Dom| {
tx_canvas.try_broadcast(dom.clone()).unwrap();
};
builder! {
<li style:display="flex">
<canvas width="75px"
height="75px"
post:build=post_build />
<ul>
<li>{format!("filename: {}", filename)}</li>
<li>{format!("size: {}", size)}</li>
<li>{format!("mime type: {}", mime_type)}</li>
<li>{format!("modification time: {}", mtime)}</li>
</ul>
</li>
}
}
pub(super) fn upload_view( tx_logic: broadcast::Sender<DomEvent>
, rx_previews: mpmc::Receiver<ListPatch<ViewBuilder<Dom>>>
) -> ViewBuilder<Dom> {
// <div class="spin"></div>
builder! {
<div class="upload">
<div>
<input type="file"
multiple="multiple"
accept="image/*"
on:change=tx_logic.sink() />
<button>"Upload"</button>
</div>
<ul patch:children=rx_previews>
</ul>
</div>
}
}