You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
848 B
Rust
44 lines
848 B
Rust
pub mod backend;
|
|
pub mod layout;
|
|
pub mod view;
|
|
|
|
pub use uwui_dsl::{template, CustomComponent, NativeComponent};
|
|
|
|
use layout::Gravity;
|
|
use view::{Button, GetTemplate, NewCustom, Template, Text, VStack};
|
|
|
|
fn asdf() -> Template {
|
|
template! {
|
|
VStack(Gravity::Center) {
|
|
MyComponent(x: 420)
|
|
Button(label: "don't click me")
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Default)]
|
|
struct MyParams {
|
|
x: i32,
|
|
}
|
|
|
|
#[derive(CustomComponent)]
|
|
struct MyComponent {
|
|
params: MyParams,
|
|
}
|
|
|
|
impl<B: backend::Backend> NewCustom<B> for MyComponent {
|
|
type Params = MyParams;
|
|
|
|
fn new(params: Self::Params) -> Self {
|
|
Self { params }
|
|
}
|
|
}
|
|
|
|
impl<B: backend::Backend> GetTemplate<B> for MyComponent {
|
|
fn get_template(&self) -> Template {
|
|
template! {
|
|
Text(format!("x = {}", self.params.x))
|
|
}
|
|
}
|
|
}
|