43 lines
1.1 KiB
Rust
43 lines
1.1 KiB
Rust
use tuid::Data;
|
|
use tuid::*;
|
|
|
|
#[derive(Debug, Default)]
|
|
struct ExampleAppState {
|
|
pub value: i32,
|
|
}
|
|
|
|
impl Data for ExampleAppState {}
|
|
|
|
fn make_ui() -> impl Widget<ExampleAppState> {
|
|
let t1 = Text::new(Box::new(|_: &DataWrapper<ExampleAppState>| {
|
|
"Hello, Text2!".to_string()
|
|
}));
|
|
let t2 = Text::new(Box::new(|_: &DataWrapper<ExampleAppState>| {
|
|
"And hello to you, Text1!".to_string()
|
|
}));
|
|
let t3 = Text::new(Box::new(|_: &DataWrapper<ExampleAppState>| {
|
|
"Whoah- are we all saying hello in here? Hello! :D".to_string()
|
|
}));
|
|
let t4 = Text::new(Box::new(|_: &DataWrapper<ExampleAppState>| {
|
|
"Hey guys! I saw you were saying hello and wanted to see what's up! xD".to_string()
|
|
}));
|
|
|
|
let flex0 = Flex::column()
|
|
.with_child(t2)
|
|
.with_flex_spacer(1.0)
|
|
.with_child(t3);
|
|
|
|
Flex::row()
|
|
.with_child(t1)
|
|
.with_flex_spacer(1.0)
|
|
.with_child(Flex::column().with_child(t4).with_flex_spacer(1.0))
|
|
.with_flex_spacer(1.0)
|
|
.with_child(flex0)
|
|
}
|
|
|
|
fn main() {
|
|
let main_state = ExampleAppState::default();
|
|
let mut window = Window::new(main_state, make_ui());
|
|
window.run().unwrap();
|
|
}
|