code cleanup

This commit is contained in:
2026-08-01 19:43:07 +03:00
parent 42d0488f23
commit 20cb50574c
21 changed files with 421 additions and 373 deletions
+28 -24
View File
@@ -15,7 +15,6 @@ use std::time::Duration;
use zstd::{Decoder, Encoder, DEFAULT_COMPRESSION_LEVEL};
const API_URL: &str = "https://learning.micialware.ru/";
/*const API_URL: &str = "http://localhost:8089/";*/
#[derive(Clone)]
pub enum SyncMessage {
@@ -70,14 +69,11 @@ impl SyncState {
.map(|_val: String| RootMessage::Sync(KeyCopied));
}
InitSync => {
return Task::perform(first_sync(), |id| {
RootMessage::Sync(IdReceived(id))
});
return Task::perform(first_sync(), |id| RootMessage::Sync(IdReceived(id)));
}
GetKey => {
return iced::clipboard::read().map(|key| {
RootMessage::Sync(IdReceived(key.unwrap_or_else(String::new)))
});
return iced::clipboard::read()
.map(|key| RootMessage::Sync(IdReceived(key.unwrap_or_else(String::new))));
}
KeyCopied => {}
IdReceived(new_id) => {
@@ -97,9 +93,7 @@ impl SyncState {
async { tokio::time::sleep(Duration::from_millis(200)).await },
|_| RootMessage::Sync(NextAnimation),
),
Task::perform(send_data(id), |_| {
RootMessage::Sync(NetworkFinished)
}),
Task::perform(send_data(id), |_| RootMessage::Sync(NetworkFinished)),
]);
return tasks;
@@ -111,9 +105,7 @@ impl SyncState {
async { tokio::time::sleep(Duration::from_millis(200)).await },
|_| RootMessage::Sync(NextAnimation),
),
Task::perform(load_data(id), |_| {
RootMessage::Sync(NetworkFinished)
}),
Task::perform(load_data(id), |_| RootMessage::Sync(NetworkFinished)),
]);
return tasks;
@@ -141,7 +133,6 @@ impl SyncState {
state.card_sets = updated_state.card_sets;
state.dictionary = updated_state.dictionary;
state.word_groups = updated_state.word_groups;
}
Disable => {}
DisableSync => {
@@ -155,9 +146,13 @@ impl SyncState {
}
pub fn view(&self) -> Element<'_, SyncMessage> {
back_overlay(row![space().width(Fill), self.sync_column(), space().width(Fill)]
.spacing(DEFAULT_SPACING)
.width(Fill).into(), Back)
back_overlay(
row![space().width(Fill), self.sync_column(), space().width(Fill)]
.spacing(DEFAULT_SPACING)
.width(Fill)
.into(),
Back,
)
}
fn sync_column(&self) -> Element<'_, SyncMessage> {
@@ -171,11 +166,16 @@ impl SyncState {
column![
text!("Ваш ключ синхронизации"),
container(
container(text!("{}", key).size(ACCENT_FONT_SIZE).font(Font::MONOSPACE)).padding(3)
container(
text!("{}", key)
.size(ACCENT_FONT_SIZE)
.font(Font::MONOSPACE)
)
.padding(3)
)
.style(rounded_box),
button("Скопировать в буфер обмена").style(jl_button)
button("Скопировать в буфер обмена")
.style(jl_button)
.on_press(CopyKey)
.width(Fill),
row![
@@ -191,18 +191,22 @@ impl SyncState {
]
} else {
column![
button("Создать сохранение").style(jl_button).on_press(InitSync),
button("Вставить ключ из буфера").style(jl_button).on_press(GetKey),
button("Создать сохранение")
.style(jl_button)
.on_press(InitSync),
button("Вставить ключ из буфера")
.style(jl_button)
.on_press(GetKey),
]
}
}
.spacing(DEFAULT_SPACING)
.align_x(Center)
.width(Length::Shrink)
.width(Length::Shrink)
.into()
}
/* fn app_updater(&self) -> Element<'_, SyncMessage> {
/* fn app_updater(&self) -> Element<'_, SyncMessage> {
column![].width(Fill).into()
}*/