floating-calculator/src/state.rs
2026-02-27 00:16:32 +01:00

39 lines
704 B
Rust

use iced::Event;
use iced::widget::Id;
use iced_layershell::to_layer_message;
pub struct State {
pub current_message: String,
pub history: Vec<History>,
pub input_id: Id,
}
pub struct History {
pub promt: String,
pub output: String,
}
impl History {
pub fn new(promt: String, output: String) -> Self {
Self { promt, output }
}
}
impl Default for State {
fn default() -> Self {
Self {
current_message: String::new(),
history: Vec::new(),
input_id: Id::unique(),
}
}
}
#[to_layer_message]
#[derive(Debug, Clone)]
pub enum Message {
Init,
TextSubmit,
TextInput(String),
IcedEvent(Event),
}