1
- //! A simple example demonstrating how to implement a Todo app using Reducer & libui .
1
+ //! A simple example demonstrating how to implement a Todo List app using Reducer & iui .
2
2
3
3
extern crate iui;
4
4
extern crate reducer;
@@ -83,7 +83,7 @@ impl State {
83
83
}
84
84
}
85
85
86
- fn run_libui ( dispatcher : impl Dispatcher < Action > + Clone + ' static , states : Receiver < Arc < State > > ) {
86
+ fn run_iui ( dispatcher : impl Dispatcher < Action > + Clone + ' static , states : Receiver < Arc < State > > ) {
87
87
let ui = UI :: init ( ) . unwrap ( ) ;
88
88
89
89
// Layout.
@@ -128,8 +128,8 @@ fn run_libui(dispatcher: impl Dispatcher<Action> + Clone + 'static, states: Rece
128
128
let mut event_loop = ui. event_loop ( ) ;
129
129
130
130
event_loop. on_tick ( & ui, {
131
- // keep track of todos displayed as libui doesn't yet provide a way of introspecting that.
132
- let mut checkboxes : Vec < Checkbox > = vec ! [ ] ;
131
+ // keep track of todos displayed as iui doesn't yet provide a way of introspecting that.
132
+ let mut checklist : Vec < Checkbox > = vec ! [ ] ;
133
133
let mut body = body. clone ( ) ;
134
134
let mut filter = filter. clone ( ) ;
135
135
let dispatcher = dispatcher. clone ( ) ;
@@ -140,20 +140,20 @@ fn run_libui(dispatcher: impl Dispatcher<Action> + Clone + 'static, states: Rece
140
140
if let Some ( state) = states. try_iter ( ) . last ( ) {
141
141
// Add new todos
142
142
let todos = state. get_todos ( ) ;
143
- for ( i, ( _, todo) ) in todos. iter ( ) . enumerate ( ) . skip ( checkboxes . len ( ) ) {
143
+ for ( i, ( _, todo) ) in todos. iter ( ) . enumerate ( ) . skip ( checklist . len ( ) ) {
144
144
let mut checkbox = Checkbox :: new ( & ui, todo) ;
145
145
checkbox. on_toggled ( & ui, {
146
146
let mut dispatcher = dispatcher. clone ( ) ;
147
147
move |_| {
148
148
dispatcher. dispatch ( Action :: ToggleTodo ( i) ) ;
149
149
}
150
150
} ) ;
151
- checkboxes . push ( checkbox. clone ( ) ) ;
151
+ checklist . push ( checkbox. clone ( ) ) ;
152
152
body. append ( & ui, checkbox, LayoutStrategy :: Compact ) ;
153
153
}
154
154
155
- // Synchronize checkboxes with the state.
156
- for ( & ( done, _) , checkbox) in todos. iter ( ) . zip ( checkboxes . iter_mut ( ) ) {
155
+ // Synchronize checklist with the state.
156
+ for ( & ( done, _) , checkbox) in todos. iter ( ) . zip ( checklist . iter_mut ( ) ) {
157
157
checkbox. set_checked ( & ui, done) ;
158
158
match state. get_filter ( ) {
159
159
View :: Done if !done => checkbox. hide ( & ui) ,
@@ -176,7 +176,7 @@ fn run_libui(dispatcher: impl Dispatcher<Action> + Clone + 'static, states: Rece
176
176
body. append ( & ui, HorizontalSeparator :: new ( & ui) , LayoutStrategy :: Compact ) ;
177
177
178
178
// The window allows all constituent components to be displayed.
179
- let mut window = Window :: new ( & ui, "Reducer <3 libui " , 400 , 300 , WindowType :: NoMenubar ) ;
179
+ let mut window = Window :: new ( & ui, "Reducer <3 iui " , 400 , 500 , WindowType :: NoMenubar ) ;
180
180
window. set_child ( & ui, body) ;
181
181
window. show ( & ui) ;
182
182
@@ -199,7 +199,7 @@ fn main() -> Result<(), Box<dyn Error>> {
199
199
let dispatcher = store. spawn ( & mut executor) . unwrap ( ) ;
200
200
201
201
// Spin up the rendering thread
202
- executor. run ( futures:: future:: lazy ( |_| run_libui ( dispatcher, states) ) ) ;
202
+ executor. run ( futures:: future:: lazy ( |_| run_iui ( dispatcher, states) ) ) ;
203
203
204
204
Ok ( ( ) )
205
205
}
@@ -233,7 +233,7 @@ fn main() -> Result<(), Box<dyn Error>> {
233
233
}
234
234
} ) ;
235
235
236
- run_libui ( dispatcher, states) ;
236
+ run_iui ( dispatcher, states) ;
237
237
238
238
Ok ( ( ) )
239
239
}
0 commit comments