arkham/examples/stack.rs

22 lines
511 B
Rust
Raw Normal View History

2023-09-03 02:46:50 +00:00
use arkham::prelude::*;
fn main() {
let _ = App::new(root).run();
}
fn root(ctx: &mut ViewContext) {
let mut stack = ctx.vertical_stack((100, 100));
2023-09-03 02:46:50 +00:00
for _ in 0..10 {
stack.component((ctx.size().width, 1), list_item);
2023-09-03 02:46:50 +00:00
}
ctx.component((0, (100, 100)), stack);
2023-09-03 02:46:50 +00:00
}
fn list_item(ctx: &mut ViewContext) {
let size = ctx.size();
let mut hstack = ctx.horizontal_stack((ctx.size().width, 1));
hstack.insert("> ");
hstack.insert("line 1");
ctx.component(size, hstack);
2023-09-03 02:46:50 +00:00
}