use std::process::ExitCode;
use smudge_core::geometry::{Color, Size};
use smudge_core::reactive::RwSignal;
use smudge_core::style::{Align, Length, px};
use smudge_core::theme::Theme;
use smudge_core::widget::panel;
use smudge_platform::{WindowOptions, run_with};
use smudge_text::TextInputExt;
use smudge_text::text_input;
const FIELD_HEIGHT: f32 = 32.0;
fn main() -> ExitCode {
let build = || {
let first = RwSignal::new(String::new());
let second = RwSignal::new(String::new());
panel()
.padding(px(24.0))
.gap(Size {
width: 0.0,
height: 16.0,
})
.align_items(Align::Start)
.background(Color::rgb(24, 26, 32))
.child(
text_input(first)
.width(Length::pct(100.0))
.height(px(FIELD_HEIGHT))
.placeholder("Focus me and compose with an input method")
.padding(px(8.0))
.border(1.0)
.border_color(Color::rgb(70, 74, 88)),
)
.child(
text_input(second)
.width(Length::pct(100.0))
.height(px(FIELD_HEIGHT))
.placeholder("Then focus me and paste")
.padding(px(8.0))
.border(1.0)
.border_color(Color::rgb(70, 74, 88)),
)
};
let result = run_with(
WindowOptions {
title: String::from("Smudge text inputs"),
size: Size {
width: 420.0,
height: 480.0,
},
clear_color: Color::rgb(16, 17, 21),
..WindowOptions::default()
},
build,
|app| app.set_theme(Theme::dark()),
);
match result {
Ok(()) => ExitCode::SUCCESS,
Err(error) => {
eprintln!("smudge: {error}");
ExitCode::FAILURE
}
}
}