Add basic methods into NavigatedPage

This commit is contained in:
2026-08-13 22:03:47 +03:00
parent d8e7cbbc36
commit 4ca7aa7044
17 changed files with 590 additions and 324 deletions
+20 -20
View File
@@ -29,23 +29,7 @@ impl NavigatedPage<RandomizerMessage> for RandomizerState {
fn navigated(&mut self) {
}
}
impl Default for RandomizerState {
fn default() -> Self {
Self::new()
}
}
impl RandomizerState {
pub fn new() -> RandomizerState {
RandomizerState {
text: Default::default(),
list: vec![],
}
}
pub fn update(&mut self, message: RandomizerMessage) -> Task<RootMessage> {
fn update(&mut self, message: RandomizerMessage) -> Task<RootMessage> {
match message {
Edit(action) => {
self.text.perform(action);
@@ -65,7 +49,7 @@ impl RandomizerState {
Task::none()
}
pub fn view(&self) -> iced::Element<'_, RandomizerMessage> {
fn view(&self) -> iced::Element<'_, RandomizerMessage> {
back_overlay(
iced::widget::column![
text_editor(&self.text)
@@ -75,9 +59,25 @@ impl RandomizerState {
.placeholder("Каждый элемент с новой строки"),
button("Перемешать").style(jl_button).on_press(Start),
]
.spacing(HALF_SPACING)
.into(),
.spacing(HALF_SPACING)
.into(),
Back,
)
}}
impl Default for RandomizerState {
fn default() -> Self {
Self::new()
}
}
impl RandomizerState {
pub fn new() -> RandomizerState {
RandomizerState {
text: Default::default(),
list: vec![],
}
}
}