code cleanup
This commit is contained in:
parent
b0dd7b0004
commit
2abbacf66e
9 changed files with 827 additions and 554 deletions
39
src/state.rs
Normal file
39
src/state.rs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
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),
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue