More styling

This commit is contained in:
2026-08-01 19:36:43 +03:00
parent 9a1d68aac1
commit 42d0488f23
13 changed files with 295 additions and 253 deletions
+29 -20
View File
@@ -1,17 +1,16 @@
pub mod randomizer {
use crate::randomizer::randomizer::RandomizerMessage::{Back, Start, Edit};
use crate::{RootMessage};
use iced::widget::{button, container, text_editor};
use crate::navigation::{NavigatedPage, Page};
use crate::randomizer::randomizer::RandomizerMessage::{Back, Edit, Start};
use crate::styling::{back_overlay, jl_button};
use crate::RootMessage;
use iced::widget::{button, text_editor};
use iced::Task;
use rand::prelude::SliceRandom;
use crate::navigation::{NavigatedPage, Page};
use crate::styling::jl_button;
#[derive(Clone, Debug)]
pub struct RandomizerState {
text: text_editor::Content,
list: Vec<String>
list: Vec<String>,
}
#[derive(Debug, Clone)]
@@ -38,15 +37,23 @@ pub mod randomizer {
impl RandomizerState {
pub fn new() -> RandomizerState {
RandomizerState { text: Default::default(), list: vec![] }
RandomizerState {
text: Default::default(),
list: vec![],
}
}
pub fn update(&mut self, message: RandomizerMessage) -> Task<RootMessage> {
match message {
Edit(action) => {
self.text.perform(action);
self.list = self.text.text().split("\n").map(|s| s.to_string()).collect();
},
self.list = self
.text
.text()
.split("\n")
.map(|s| s.to_string())
.collect();
}
Start => {
self.list.shuffle(&mut rand::rng());
self.text = text_editor::Content::with_text(self.list.join("\n").as_str());
@@ -57,17 +64,19 @@ pub mod randomizer {
}
pub fn view(&self) -> iced::Element<'_, RandomizerMessage> {
container(
iced::widget::column![
button("Назад").style(jl_button).on_press(Back),
text_editor(&self.text).on_action(Edit
).width(400).height(400).placeholder("Каждый элемент с новой строки"),
button("Перемешать").style(jl_button).on_press(Start),
]
.spacing(5),
back_overlay(
iced::widget::column![
text_editor(&self.text)
.on_action(Edit)
.width(400)
.height(400)
.placeholder("Каждый элемент с новой строки"),
button("Перемешать").style(jl_button).on_press(Start),
]
.spacing(5)
.into(),
Back,
)
.padding(10)
.into()
}
}
}