This repository has been archived on 2024-05-04. You can view files and clone it, but cannot push or open issues or pull requests.
2022-07-12 15:54:40 +00:00
|
|
|
use druid::widget::{Button, Flex, Label};
|
|
|
|
use druid::{AppLauncher, LocalizedString, PlatformError, Widget, WidgetExt, WindowDesc};
|
|
|
|
|
|
|
|
fn main() -> Result<(), PlatformError> {
|
|
|
|
let main_window = WindowDesc::new(ui_builder);
|
|
|
|
let data = 0_u32;
|
|
|
|
AppLauncher::with_window(main_window)
|
|
|
|
.use_simple_logger()
|
|
|
|
.launch(data)
|
2022-07-12 15:42:58 +00:00
|
|
|
}
|
2022-07-12 15:54:40 +00:00
|
|
|
|
|
|
|
fn ui_builder() -> impl Widget<u32> {
|
|
|
|
// The label text will be computed dynamically based on the current locale and count
|
|
|
|
let text =
|
|
|
|
LocalizedString::new("hello-counter").with_arg("count", |data: &u32, _env| (*data).into());
|
|
|
|
let label = Label::new(text).padding(5.0).center();
|
|
|
|
let button = Button::new("increment")
|
|
|
|
.on_click(|_ctx, data, _env| *data += 1)
|
|
|
|
.padding(2.0);
|
|
|
|
|
|
|
|
Flex::column().with_child(label).with_child(button)
|
|
|
|
}
|