Migrate to tiny macros of button

This commit is contained in:
micialware committed 2026-09-09 14:26:55 +03:00
1 parent 444352c007
commit 1ad991667b
12 files changed
+52 -45

No files matched your search

+9 -9
View File
@@ -11,7 +11,7 @@ use crate::pages::dictionary::DictionaryMessage::*;
use crate::pages::dictionary_quiz::DictionaryQuizState;
use crate::pages::import::ImportState;
use crate::pages::word::WordState;
use crate::push_error;
use crate::{jl_button, push_error};
use crate::push_error_task;
use crate::styling::*;
use chrono::{DateTime, TimeDelta, Utc};
@@ -81,7 +81,7 @@ impl NavigatedPage<DictionaryMessage> for DictionaryState {
let mut words = vec![];
let dict = &self.state.dictionary.read();
let mut query = dict.query(Arc::new(|_| true));
let query = dict.query(Arc::new(|_| true));
let handles = query.handles();
words = handles.filter(|h| self.included.contains(h)).collect();
@@ -257,7 +257,7 @@ impl NavigatedPage<DictionaryMessage> for DictionaryState {
let mut dictionary = self.state.dictionary.write();
let reload_query = handle.real() == false;
let reload_query = !handle.real();
let _ = dictionary.save(&mut handle);
if reload_query {
self.displayed_words_query.load(&dictionary);
@@ -373,7 +373,7 @@ impl DictionaryState {
key: word.key.clone().into(),
value: word.value.clone().into(),
tags: word.tags.clone().into(),
handle: word_handle.clone(),
handle: *word_handle,
};
let lazy_line = lazy(word_line_data, Self::word_line);
@@ -387,7 +387,7 @@ impl DictionaryState {
fn word_line<'a>(data: &WordLineState) -> Row<'a, DictionaryMessage> {
let mut line = Row::new().width(Fill).align_y(Center);
let handle = data.handle.clone();
let handle = data.handle;
line = line.push(
checkbox(data.is_included)
.label("")
@@ -435,7 +435,7 @@ impl DictionaryState {
return button("-")
.on_press(WordAction(data.handle))
.style(
|_x: &iced::Theme, _status: iced::widget::button::Status| Style {
|_x: &Theme, _status: button::Status| Style {
background: None,
text_color: Color::BLACK,
border: Border::default(),
@@ -590,12 +590,12 @@ impl DictionaryState {
}
let groups = self.state.word_groups.read();
let group = groups.get_static(self.selected_group.clone()).unwrap();
let group = groups.get_static(self.selected_group).unwrap();
iced::widget::column![
scrollable(row).width(Fill).horizontal(),
row![
button("⇳").on_press(ChangeDirection).style(jl_button),
jl_button!("⇳").on_press(ChangeDirection),
text_input("Название группы слов", &group.name)
.on_input(EditGroup)
.width(250)
@@ -617,7 +617,7 @@ impl DictionaryState {
}
fn add_word_button(&self) -> iced::Element<'_, DictionaryMessage> {
let button = button("Добавить слово").style(jl_button);
let button = jl_button!("Добавить слово");
if self.selected_group.real() {
return button.on_press(NewWord).into();