Code cleanup
This commit is contained in:
1 parent
1ad991667b
commit
f66bf69ef5
32 files changed
+234
-899
No files matched your search
+16
-17
@@ -11,9 +11,9 @@ use crate::pages::dictionary::DictionaryMessage::*;
|
||||
use crate::pages::dictionary_quiz::DictionaryQuizState;
|
||||
use crate::pages::import::ImportState;
|
||||
use crate::pages::word::WordState;
|
||||
use crate::{jl_button, push_error};
|
||||
use crate::push_error_task;
|
||||
use crate::styling::*;
|
||||
use crate::{jl_button, push_error};
|
||||
use chrono::{DateTime, TimeDelta, Utc};
|
||||
use hashbrown::{HashMap, HashSet};
|
||||
use iced::alignment::Vertical::Center;
|
||||
@@ -434,15 +434,13 @@ impl DictionaryState {
|
||||
if !data.handle.real() {
|
||||
return button("-")
|
||||
.on_press(WordAction(data.handle))
|
||||
.style(
|
||||
|_x: &Theme, _status: button::Status| Style {
|
||||
background: None,
|
||||
text_color: Color::BLACK,
|
||||
border: Border::default(),
|
||||
shadow: Shadow::default(),
|
||||
snap: false,
|
||||
},
|
||||
)
|
||||
.style(|_x: &Theme, _status: button::Status| Style {
|
||||
background: None,
|
||||
text_color: Color::BLACK,
|
||||
border: Border::default(),
|
||||
shadow: Shadow::default(),
|
||||
snap: false,
|
||||
})
|
||||
.width(15);
|
||||
}
|
||||
|
||||
@@ -512,15 +510,16 @@ impl DictionaryState {
|
||||
let dict = &self.state.dictionary.write();
|
||||
let mut words_query = dict.full_query();
|
||||
let handles = words_query.handles().collect::<Vec<_>>();
|
||||
words_query.iter(dict).zip(handles).for_each(|(element, handle)| {
|
||||
let tags = split_with_coma(element.tags.as_str());
|
||||
tags.iter()
|
||||
.for_each(|tag| {
|
||||
words_query
|
||||
.iter(dict)
|
||||
.zip(handles)
|
||||
.for_each(|(element, handle)| {
|
||||
let tags = split_with_coma(element.tags.as_str());
|
||||
tags.iter().for_each(|tag| {
|
||||
tags_list.insert(tag.clone());
|
||||
});
|
||||
self.words_tags.push((handle, tags))
|
||||
|
||||
});
|
||||
self.words_tags.push((handle, tags))
|
||||
});
|
||||
|
||||
let current_tags = self
|
||||
.tag_map
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
use crate::app::AppState;
|
||||
use crate::data::entities::{EntityHandle, WordData};
|
||||
use crate::data::repositories::Repository;
|
||||
use crate::jl_button;
|
||||
use crate::navigation::Page::PreviousPage;
|
||||
use crate::navigation::RootMessage;
|
||||
use crate::navigation::*;
|
||||
@@ -6,15 +9,12 @@ use crate::pages::dictionary::split_with_coma;
|
||||
use crate::pages::dictionary_quiz::DictionaryQuizMessage::*;
|
||||
use crate::pages::quiz::Score;
|
||||
use crate::styling::*;
|
||||
use iced::Background::Color;
|
||||
use iced::border::Radius;
|
||||
use iced::widget::container::Style;
|
||||
use iced::widget::{Row, button, container, row, space, text, text_input};
|
||||
use iced::{Border, Element, Fill, Task, Theme, alignment};
|
||||
use iced::widget::{container, row, space, text, text_input, Row};
|
||||
use iced::Background::Color;
|
||||
use iced::{alignment, Border, Element, Fill, Task, Theme};
|
||||
use rand::prelude::SliceRandom;
|
||||
use crate::app::AppState;
|
||||
use crate::data::repositories::Repository;
|
||||
use crate::jl_button;
|
||||
|
||||
pub struct DictionaryQuizState {
|
||||
state: AppState,
|
||||
@@ -91,11 +91,8 @@ impl NavigatedPage<DictionaryQuizMessage> for DictionaryQuizState {
|
||||
.size(25),
|
||||
]
|
||||
.spacing(DEFAULT_SPACING),
|
||||
row![
|
||||
jl_button!("Закончить").on_press(Back),
|
||||
self.appeal_button()
|
||||
]
|
||||
.spacing(DEFAULT_SPACING),
|
||||
row![jl_button!("Закончить").on_press(Back), self.appeal_button()]
|
||||
.spacing(DEFAULT_SPACING),
|
||||
]
|
||||
.spacing(DEFAULT_SPACING)
|
||||
.align_x(alignment::Horizontal::Center),
|
||||
@@ -107,8 +104,13 @@ impl NavigatedPage<DictionaryQuizMessage> for DictionaryQuizState {
|
||||
}
|
||||
|
||||
impl DictionaryQuizState {
|
||||
pub fn new(words: Vec<EntityHandle<WordData>>, reverse: bool, no_typing: bool, state: AppState) -> DictionaryQuizState {
|
||||
let state = DictionaryQuizState {
|
||||
pub fn new(
|
||||
words: Vec<EntityHandle<WordData>>,
|
||||
reverse: bool,
|
||||
no_typing: bool,
|
||||
state: AppState,
|
||||
) -> DictionaryQuizState {
|
||||
Self {
|
||||
state,
|
||||
words,
|
||||
current_set: Vec::new(),
|
||||
@@ -120,9 +122,7 @@ impl DictionaryQuizState {
|
||||
reverse,
|
||||
laps: 0,
|
||||
no_typing,
|
||||
};
|
||||
|
||||
state
|
||||
}
|
||||
}
|
||||
|
||||
fn submit(&mut self) {
|
||||
|
||||
+24
-27
@@ -3,13 +3,13 @@ use crate::data::entities::{HistoryNote, WordData};
|
||||
use crate::data::repositories::Repository;
|
||||
use crate::navigation::*;
|
||||
use crate::styling::*;
|
||||
use HistoryMessage::Back;
|
||||
use chrono::Local;
|
||||
use iced::alignment::Horizontal::Center;
|
||||
use iced::widget::space::horizontal;
|
||||
use iced::widget::*;
|
||||
use iced::{Element, Fill, FillPortion, Task};
|
||||
use std::sync::Arc;
|
||||
use HistoryMessage::Back;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct HistoryState {
|
||||
@@ -37,9 +37,9 @@ impl NavigatedPage<HistoryMessage> for HistoryState {
|
||||
.width(FillPortion(5)),
|
||||
horizontal().width(FillPortion(1))
|
||||
]
|
||||
.height(Fill)
|
||||
.width(Fill)
|
||||
.into(),
|
||||
.height(Fill)
|
||||
.width(Fill)
|
||||
.into(),
|
||||
Back,
|
||||
)
|
||||
}
|
||||
@@ -50,23 +50,22 @@ impl HistoryState {
|
||||
let dict = &state.dictionary.read();
|
||||
let history_repo = &mut state.history.write();
|
||||
history_repo.init().expect("TODO: panic message");
|
||||
let id = id.clone();
|
||||
let id = id;
|
||||
let mut history = history_repo.query(Arc::new(move |h| h.deck_id == id));
|
||||
let words = history
|
||||
.iter(history_repo)
|
||||
.map(
|
||||
|item| {let handle = dict.handle_by_id(item.word_id);
|
||||
let word = dict.get_static(handle).unwrap_or(WordData {
|
||||
id: Default::default(),
|
||||
group_id: Default::default(),
|
||||
key: "Удаленное слово".to_string(),
|
||||
value: "".to_string(),
|
||||
tags: "".to_string(),
|
||||
additional: Default::default(),
|
||||
});
|
||||
(word, item.clone())
|
||||
}
|
||||
)
|
||||
.map(|item| {
|
||||
let handle = dict.handle_by_id(item.word_id);
|
||||
let word = dict.get_static(handle).unwrap_or(WordData {
|
||||
id: Default::default(),
|
||||
group_id: Default::default(),
|
||||
key: "Удаленное слово".to_string(),
|
||||
value: "".to_string(),
|
||||
tags: "".to_string(),
|
||||
additional: Default::default(),
|
||||
});
|
||||
(word, item.clone())
|
||||
})
|
||||
.collect();
|
||||
Self {
|
||||
list: words,
|
||||
@@ -77,30 +76,28 @@ impl HistoryState {
|
||||
fn history_lines(&self) -> Column<'_, HistoryMessage> {
|
||||
let mut column = Column::new();
|
||||
for (index, item) in &self.list {
|
||||
|
||||
let activity = item;
|
||||
column = column.push(
|
||||
row![
|
||||
iced::widget::column![
|
||||
text!("{}", index.key)
|
||||
.width(Fill)
|
||||
.align_x(Center),
|
||||
text!("{}", index.value)
|
||||
.width(Fill)
|
||||
.align_x(Center),
|
||||
text!("{}", index.key).width(Fill).align_x(Center),
|
||||
text!("{}", index.value).width(Fill).align_x(Center),
|
||||
]
|
||||
.align_x(Center),
|
||||
iced::widget::column![
|
||||
text!("{} ➞ {}", activity.before, activity.after),
|
||||
text!(
|
||||
"{}",
|
||||
activity.timestamp.with_timezone(&Local).format("%d.%m %H:%M")
|
||||
activity
|
||||
.timestamp
|
||||
.with_timezone(&Local)
|
||||
.format("%d.%m %H:%M")
|
||||
)
|
||||
]
|
||||
.spacing(5)
|
||||
.align_x(Center)
|
||||
]
|
||||
.spacing(5),
|
||||
.spacing(5),
|
||||
);
|
||||
column = column.push(rule::horizontal(1));
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,15 +1,15 @@
|
||||
use crate::app::AppState;
|
||||
use crate::data::entities::EntityData;
|
||||
use crate::data::entities::WordData;
|
||||
use crate::data::entities::WordGroup;
|
||||
use crate::data::repositories::{BatchedRepository, Repository};
|
||||
use crate::data_provider::import::{ImportData, ImportGroup, get_words_of_group, load_groups};
|
||||
use crate::fs::*;
|
||||
use crate::jl_button;
|
||||
use crate::navigation::{NavigatedPage, Page, RootMessage};
|
||||
use crate::notification::NotificationData::OpenFileError;
|
||||
use crate::notification::{MaybeError, NotificationData};
|
||||
use crate::pages::import::ImportMessage::*;
|
||||
use crate::push_error;
|
||||
use crate::jl_button;
|
||||
use crate::styling::*;
|
||||
use iced::widget::button::danger;
|
||||
use iced::widget::container::success;
|
||||
@@ -31,7 +31,6 @@ use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use tokio::task::spawn_blocking;
|
||||
use zip::ZipArchive;
|
||||
use crate::data::repositories::{BatchedRepository, Repository};
|
||||
|
||||
const DEFAULT_FIELDS: [&str; 6] = ["key", "value", "tags", "reading", "context", "description"];
|
||||
|
||||
@@ -436,7 +435,8 @@ impl ImportState {
|
||||
async move {
|
||||
spawn_blocking(move || {
|
||||
let temp_file_path = temp_import_path();
|
||||
let connection = Connection::open(&temp_file_path).map_err(|_| OpenFileError)?;
|
||||
let connection =
|
||||
Connection::open(&temp_file_path).map_err(|_| OpenFileError)?;
|
||||
let import_list = get_words_of_group(&connection, group.id)?;
|
||||
let mut words_list = Vec::with_capacity(import_list.len());
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,6 @@
|
||||
use crate::app::USER_FONT;
|
||||
use crate::core::kana_set::KanaSet;
|
||||
use crate::jl_button;
|
||||
use crate::navigation::Page::PreviousPage;
|
||||
use crate::navigation::{NavigatedPage, Page, RootMessage};
|
||||
use crate::pages::quiz::QuizMessage::*;
|
||||
@@ -7,7 +8,6 @@ use crate::styling::*;
|
||||
use iced::widget::*;
|
||||
use iced::{Element, Fill, Task, alignment};
|
||||
use rand::seq::SliceRandom;
|
||||
use crate::jl_button;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct QuizState {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::jl_button;
|
||||
use crate::navigation::RootMessage;
|
||||
use crate::navigation::{NavigatedPage, Page};
|
||||
use crate::pages::randomizer::RandomizerMessage::{Back, Edit, Start};
|
||||
use crate::styling::{HALF_SPACING, back_overlay};
|
||||
use crate::jl_button;
|
||||
use iced::Task;
|
||||
use iced::widget::text_editor;
|
||||
use rand::prelude::SliceRandom;
|
||||
|
||||
@@ -5,11 +5,11 @@ use crate::data::Id;
|
||||
use crate::data::entities::{CardState, WordData};
|
||||
use crate::data::repositories::Repository;
|
||||
use crate::data_provider::voice::get_voice;
|
||||
use crate::jl_button;
|
||||
use crate::navigation::Page::PreviousPage;
|
||||
use crate::navigation::{KeyPressedPage, NavigatedPage, Page, RootMessage};
|
||||
use crate::notification::{MaybeError, NotificationData};
|
||||
use crate::pages::repetitions::DeckRunData;
|
||||
use crate::jl_button;
|
||||
use crate::styling::*;
|
||||
use crate::{push_error, push_error_task};
|
||||
use iced::alignment::Horizontal::Center;
|
||||
|
||||
@@ -2,11 +2,11 @@ use crate::app::AppState;
|
||||
use crate::core::deck::DeckData;
|
||||
use crate::data::entities::{DeckSettings, EntityHandle};
|
||||
use crate::data::repositories::{BatchedRepository, Repository};
|
||||
use crate::jl_button;
|
||||
use crate::navigation::Page::PreviousPage;
|
||||
use crate::navigation::{NavigatedPage, Page, RootMessage};
|
||||
use crate::notification::MaybeError;
|
||||
use crate::pages::repetition_settings::RepetitionSettingsMessage::*;
|
||||
use crate::jl_button;
|
||||
use crate::styling::*;
|
||||
use crate::{push_error, push_error_task};
|
||||
use iced::widget::button::danger;
|
||||
@@ -123,7 +123,10 @@ impl NavigatedPage<RepetitionSettingsMessage> for RepetitionSettingsState {
|
||||
}
|
||||
let mut states = self.state.card_states.write();
|
||||
let deck_id = self.settings_handle.id;
|
||||
let mut query = states.query(Arc::new(move |state| {state.deck_id == deck_id})).handles().collect::<Vec<_>>();
|
||||
let mut query = states
|
||||
.query(Arc::new(move |state| state.deck_id == deck_id))
|
||||
.handles()
|
||||
.collect::<Vec<_>>();
|
||||
if let Err(e) = states.delete_many(query.as_mut_slice()) {
|
||||
return push_error_task!(e);
|
||||
}
|
||||
@@ -164,8 +167,7 @@ impl NavigatedPage<RepetitionSettingsMessage> for RepetitionSettingsState {
|
||||
primary
|
||||
})
|
||||
.on_input(SetFilter),
|
||||
jl_button!("Проверить фильтр")
|
||||
.on_press(TryFilter),
|
||||
jl_button!("Проверить фильтр").on_press(TryFilter),
|
||||
self.count_view(),
|
||||
]
|
||||
.spacing(QUARTER_SPACING),
|
||||
@@ -211,7 +213,7 @@ fn update_deck_stats(deck: &DeckSettings, state: &AppState) -> MaybeError {
|
||||
let deck_id = deck.id;
|
||||
let mut db_stats = states_repo
|
||||
.query_par(Arc::new(move |s| s.deck_id == deck_id))
|
||||
.iter(&states_repo)
|
||||
.iter(states_repo)
|
||||
.collect::<Vec<_>>();
|
||||
let filtered_words = DeckData::list(deck, state)
|
||||
.iter()
|
||||
|
||||
+13
-19
@@ -3,6 +3,7 @@ use crate::core::deck::DeckData;
|
||||
use crate::core::srs::{AppendMode, OrderMode};
|
||||
use crate::data::entities::{CardState, DeckSettings, EntityHandle, WordData};
|
||||
use crate::data::repositories::{BatchedRepository, Repository};
|
||||
use crate::jl_button;
|
||||
use crate::navigation::Page::{History, PreviousPage, Repetition, RepetitionSettings};
|
||||
use crate::navigation::{NavigatedPage, Page, RootMessage};
|
||||
use crate::notification::MaybeError;
|
||||
@@ -12,21 +13,20 @@ use crate::pages::repetition_settings::RepetitionSettingsState;
|
||||
use crate::pages::repetitions::RepetitionsMessage::*;
|
||||
use crate::push_error;
|
||||
use crate::push_error_task;
|
||||
use crate::jl_button;
|
||||
use crate::styling::*;
|
||||
use chrono::{Days, Local, Utc};
|
||||
use hashbrown::HashSet;
|
||||
use iced::widget::button::{danger, Status};
|
||||
pub use iced::widget::button::{Catalog, Style};
|
||||
use iced::widget::button::{Status, danger};
|
||||
use iced::widget::tooltip::Position::Top;
|
||||
use iced::widget::{
|
||||
Column, Row, button, column, container, lazy, radio, row, scrollable, space, svg, text,
|
||||
text_input, tooltip,
|
||||
button, column, container, lazy, radio, row, scrollable, space, svg, text, text_input, tooltip,
|
||||
Column, Row,
|
||||
};
|
||||
use iced::{Background, Border, Center, Color, Element, Fill, Length, Shadow, Task, Theme};
|
||||
use iced_core::Padding;
|
||||
use iced_core::border::Radius;
|
||||
use iced_core::svg::Handle;
|
||||
use iced_core::Padding;
|
||||
use std::collections::BTreeMap;
|
||||
use std::ops::Deref;
|
||||
use std::sync::Arc;
|
||||
@@ -95,7 +95,7 @@ impl NavigatedPage<RepetitionsMessage> for RepetitionsState {
|
||||
self.clear_selection();
|
||||
}
|
||||
} else {
|
||||
let _ = self.fill_deck_word_indices();
|
||||
self.fill_deck_word_indices();
|
||||
}
|
||||
}
|
||||
fn update(&mut self, message: RepetitionsMessage) -> Task<RootMessage> {
|
||||
@@ -127,7 +127,7 @@ impl NavigatedPage<RepetitionsMessage> for RepetitionsState {
|
||||
DeleteSet => {
|
||||
let index = self.selected_deck_handle.unwrap();
|
||||
self.clear_selection();
|
||||
let deck = self.decks.remove(&index);
|
||||
self.decks.remove(&index);
|
||||
|
||||
if index.real() {
|
||||
let mut repo = self.state.decks.write();
|
||||
@@ -153,7 +153,7 @@ impl NavigatedPage<RepetitionsMessage> for RepetitionsState {
|
||||
let mut repo = self.state.decks.write();
|
||||
|
||||
repo.set(handle, deck.general_settings.clone());
|
||||
let old = handle.clone();
|
||||
let old = *handle;
|
||||
if let Err(err) = repo.save(handle) {
|
||||
return push_error_task!(err);
|
||||
}
|
||||
@@ -176,7 +176,7 @@ impl NavigatedPage<RepetitionsMessage> for RepetitionsState {
|
||||
}
|
||||
TryFilter => {
|
||||
let deck = self.selected_deck().unwrap();
|
||||
let count = DeckData::list(&deck, &self.state).len();
|
||||
let count = DeckData::list(deck, &self.state).len();
|
||||
let deck = self.selected_deck_mut().unwrap();
|
||||
deck.count = Some(count);
|
||||
}
|
||||
@@ -228,9 +228,7 @@ impl NavigatedPage<RepetitionsMessage> for RepetitionsState {
|
||||
row![
|
||||
column![
|
||||
scrollable(self.decks_list()).height(Fill),
|
||||
jl_button!("Добавить")
|
||||
.width(Fill)
|
||||
.on_press(CreateSet),
|
||||
jl_button!("Добавить").width(Fill).on_press(CreateSet),
|
||||
]
|
||||
.spacing(DEFAULT_SPACING)
|
||||
.width(Length::FillPortion(1)),
|
||||
@@ -256,9 +254,7 @@ impl RepetitionsState {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_decks_from_state(
|
||||
state: &AppState,
|
||||
) -> BTreeMap<EntityHandle<DeckSettings>, DeckRunData> {
|
||||
fn get_decks_from_state(state: &AppState) -> BTreeMap<EntityHandle<DeckSettings>, DeckRunData> {
|
||||
state
|
||||
.decks
|
||||
.read()
|
||||
@@ -331,8 +327,7 @@ impl RepetitionsState {
|
||||
column![
|
||||
text!("Фильтр"),
|
||||
text_input("", &deck.filter).on_input(SetFilter),
|
||||
jl_button!("Проверить фильтр")
|
||||
.on_press(TryFilter),
|
||||
jl_button!("Проверить фильтр").on_press(TryFilter),
|
||||
self.count_view(deck),
|
||||
]
|
||||
.spacing(QUARTER_SPACING),
|
||||
@@ -519,7 +514,7 @@ impl RepetitionsState {
|
||||
fn decks_list(&self) -> Column<'_, RepetitionsMessage> {
|
||||
let mut column = Column::new();
|
||||
|
||||
for (i, (handle, deck)) in self.decks.iter().enumerate() {
|
||||
for (handle, deck) in self.decks.iter() {
|
||||
column = column.push(
|
||||
button(text!("{}", &deck.name))
|
||||
.on_press_with(move || SelectSet(*handle))
|
||||
@@ -565,7 +560,6 @@ impl RepetitionsState {
|
||||
deck: &DeckSettings,
|
||||
indices: impl Iterator<Item = EntityHandle<WordData>>,
|
||||
) -> MaybeError {
|
||||
let words = &state.dictionary;
|
||||
let stats = &mut indices
|
||||
.map(|i| CardState {
|
||||
id: 0.into(),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use crate::app::AppState;
|
||||
use crate::core::kana_set::{KanaSet, KanaType};
|
||||
use crate::jl_button;
|
||||
use crate::navigation::Page::*;
|
||||
use crate::navigation::{NavigatedPage, Page, RootMessage};
|
||||
use crate::pages::dictionary::DictionaryState;
|
||||
@@ -12,13 +13,10 @@ use crate::pages::writing::WritingState;
|
||||
use crate::styling::*;
|
||||
use iced::widget::button::{Status, Style};
|
||||
use iced::widget::*;
|
||||
use iced::{Element, Task, alignment};
|
||||
use iced::{alignment, Element, Task};
|
||||
use iced_core::Alignment::Center;
|
||||
use iced_core::Background;
|
||||
use iced_core::Color;
|
||||
use parking_lot::Mutex;
|
||||
use std::sync::Arc;
|
||||
use crate::jl_button;
|
||||
|
||||
pub struct SelectorState {
|
||||
pub set: KanaSet,
|
||||
@@ -82,8 +80,7 @@ impl NavigatedPage<SelectorMessage> for SelectorState {
|
||||
container(
|
||||
iced::widget::column![
|
||||
row![
|
||||
jl_button!("あ ↔ ア")
|
||||
.on_press(SelectorMessage::Change),
|
||||
jl_button!("あ ↔ ア").on_press(SelectorMessage::Change),
|
||||
button("Словарь")
|
||||
.on_press(SelectorMessage::ToDictionary)
|
||||
.style(Self::nav_style),
|
||||
|
||||
+7
-11
@@ -2,11 +2,11 @@ use crate::app::AppState;
|
||||
use crate::data::repositories::Repository;
|
||||
use crate::data_provider::settings::{delete_settings, set_setting};
|
||||
use crate::data_provider::web_api::*;
|
||||
use crate::jl_button;
|
||||
use crate::navigation::Page::PreviousPage;
|
||||
use crate::navigation::{NavigatedPage, Page, RootMessage};
|
||||
use crate::notification::{NotificationData, NotificationRequest};
|
||||
use crate::pages::sync::SyncMessage::*;
|
||||
use crate::jl_button;
|
||||
use crate::styling::*;
|
||||
use crate::{push_error, push_error_task};
|
||||
use iced::widget::button::danger;
|
||||
@@ -241,10 +241,8 @@ impl SyncState {
|
||||
]
|
||||
} else {
|
||||
column![
|
||||
jl_button!("Создать сохранение")
|
||||
.on_press(InitSync),
|
||||
jl_button!("Вставить ключ из буфера")
|
||||
.on_press(GetKey),
|
||||
jl_button!("Создать сохранение").on_press(InitSync),
|
||||
jl_button!("Вставить ключ из буфера").on_press(GetKey),
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -271,12 +269,10 @@ impl SyncState {
|
||||
.unwrap_or_else(|e| {
|
||||
error!("Ошибка при checkpoint WAL: {e}");
|
||||
});
|
||||
connection
|
||||
.execute("VACUUM;", [])
|
||||
.unwrap_or_else(|e| {
|
||||
error!("Ошибка при checkpoint WAL: {e}");
|
||||
0
|
||||
});
|
||||
connection.execute("VACUUM;", []).unwrap_or_else(|e| {
|
||||
error!("Ошибка при checkpoint WAL: {e}");
|
||||
0
|
||||
});
|
||||
connection
|
||||
.execute("PRAGMA optimize;", [])
|
||||
.unwrap_or_else(|e| {
|
||||
|
||||
+2
-10
@@ -1,17 +1,12 @@
|
||||
use crate::app::AppState;
|
||||
use crate::data::entities::{EntityHandle, WordData};
|
||||
use crate::data_provider::words::{delete_word, update_word};
|
||||
use crate::navigation::Page::PreviousPage;
|
||||
use crate::navigation::{NavigatedPage, Page, RootMessage};
|
||||
use crate::pages::word::WordMessage::*;
|
||||
use crate::push_error;
|
||||
use crate::push_error_task;
|
||||
use crate::styling::*;
|
||||
use iced::widget::button::danger;
|
||||
use iced::widget::{button, column, row, rule, scrollable, space, text, text_input};
|
||||
use iced::widget::{button, column, row, space, text, text_input};
|
||||
use iced::{Element, Fill, Task};
|
||||
use parking_lot::Mutex;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct WordState {
|
||||
@@ -137,10 +132,7 @@ impl NavigatedPage<WordMessage> for WordState {
|
||||
|
||||
impl WordState {
|
||||
pub fn new(handle: EntityHandle<WordData>, state: AppState) -> Self {
|
||||
Self{
|
||||
state,
|
||||
handle,
|
||||
}
|
||||
Self { state, handle }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::core::kana_set::KanaSet;
|
||||
use crate::jl_button;
|
||||
use crate::navigation::Page::PreviousPage;
|
||||
use crate::navigation::{NavigatedPage, Page, RootMessage};
|
||||
use crate::jl_button;
|
||||
use crate::styling::*;
|
||||
use iced::widget::*;
|
||||
use iced::{Element, Fill, Task, alignment};
|
||||
@@ -46,10 +46,8 @@ impl NavigatedPage<WritingMessage> for WritingState {
|
||||
text!("{}", self.kana).size(48),
|
||||
self.answers(),
|
||||
row![
|
||||
jl_button!(text!("{}", self.next_text))
|
||||
.on_press(WritingMessage::Next),
|
||||
jl_button!("Закончить")
|
||||
.on_press(WritingMessage::Back),
|
||||
jl_button!(text!("{}", self.next_text)).on_press(WritingMessage::Next),
|
||||
jl_button!("Закончить").on_press(WritingMessage::Back),
|
||||
]
|
||||
.spacing(DEFAULT_SPACING)
|
||||
]
|
||||
|
||||
Reference in new issue
Block a user