File tree 1 file changed +5
-6
lines changed
1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change 1
1
#![ cfg( feature = "wasm" ) ]
2
2
use yew:: prelude:: * ;
3
+ use yew:: virtual_dom:: VNode ;
3
4
4
5
use cega:: wasm:: image:: * ;
5
6
use cega:: wasm:: { FileInput , FileUpload } ;
@@ -9,7 +10,7 @@ pub enum Msg {
9
10
}
10
11
11
12
pub struct App {
12
- files : Vec < FileUpload > ,
13
+ images : Vec < VNode > ,
13
14
}
14
15
15
16
impl Component for App {
@@ -18,14 +19,14 @@ impl Component for App {
18
19
19
20
fn create ( _ctx : & Context < Self > ) -> Self {
20
21
Self {
21
- files : Vec :: default ( ) ,
22
+ images : Vec :: default ( ) ,
22
23
}
23
24
}
24
25
25
26
fn update ( & mut self , _ctx : & Context < Self > , msg : Self :: Message ) -> bool {
26
27
match msg {
27
28
Msg :: Loaded ( file) => {
28
- self . files . push ( file) ;
29
+ self . images . push ( html ! { < ImageComponent file= { file } /> } ) ;
29
30
}
30
31
}
31
32
true
@@ -37,9 +38,7 @@ impl Component for App {
37
38
<h1>{ "Process your CGA/EGAs" } </h1>
38
39
<FileInput accept="image/*,.bin,.cga,.ega" onload={ ctx. link( ) . callback( Msg :: Loaded ) } />
39
40
<div id="preview-area" >
40
- { for self . files. iter( ) . map( |f|
41
- html! { <ImageComponent file={ f. clone( ) } /> }
42
- ) }
41
+ { { self . images. clone( ) } }
43
42
</div>
44
43
</div>
45
44
}
You can’t perform that action at this time.
0 commit comments