Visual changes
This commit is contained in:
Generated
+1
-15
@@ -765,7 +765,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "173852283a9a57a3cbe365d86e74dc428a09c50421477d5ad6fe9d9509e37737"
|
||||
dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
"fontdb 0.23.0",
|
||||
"fontdb",
|
||||
"harfrust",
|
||||
"linebender_resource_handle",
|
||||
"log",
|
||||
@@ -1200,19 +1200,6 @@ dependencies = [
|
||||
"ttf-parser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fontdb"
|
||||
version = "0.24.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2660c5e9157bf76d2db1294e4a9feba604ef610819a3b591088d0d8392a3290f"
|
||||
dependencies = [
|
||||
"fontconfig-parser",
|
||||
"log",
|
||||
"memmap2",
|
||||
"slotmap",
|
||||
"tinyvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types"
|
||||
version = "0.3.2"
|
||||
@@ -2110,7 +2097,6 @@ dependencies = [
|
||||
"chrono",
|
||||
"criterion",
|
||||
"dirs",
|
||||
"fontdb 0.24.0",
|
||||
"hex",
|
||||
"iced",
|
||||
"iced_core",
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ sha2 = "0.11.0"
|
||||
tokio = { version = "1.50.0", features = ["rt", "rt-multi-thread", "macros"] }
|
||||
hex = "0.4.3"
|
||||
zstd = "0.13.3"
|
||||
fontdb = "0.24.0"
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = "0.8.2"
|
||||
|
||||
|
||||
@@ -64,29 +64,29 @@ pub fn add_stat_list(stat: &mut Vec<CardStatistics>, connection: &Connection) {
|
||||
|
||||
let mut index = 0;
|
||||
for id in start_index..=last_index {
|
||||
stat[index].id = id as u32;
|
||||
stat[index].id = id;
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_stat(stat: &mut CardStatistics, connection: &Connection) {
|
||||
let time = Instant::now();
|
||||
let index = connection
|
||||
.query_row(
|
||||
"INSERT INTO card_stats (word_id, set_id, score, last_opened) VALUES (?1, ?2, ?3, ?4) RETURNING id",
|
||||
(
|
||||
&stat.word_id,
|
||||
&stat.set_id,
|
||||
&stat.score,
|
||||
&stat.last_open.timestamp(),
|
||||
),
|
||||
|row| row.get(0)
|
||||
)
|
||||
.unwrap_or_else(|e| {println!("{}", e); 0});
|
||||
|
||||
stat.id = index;
|
||||
println!("Added stat: {}", time.elapsed().as_millis());
|
||||
}
|
||||
// pub fn add_stat(stat: &mut CardStatistics, connection: &Connection) {
|
||||
// let time = Instant::now();
|
||||
// let index = connection
|
||||
// .query_row(
|
||||
// "INSERT INTO card_stats (word_id, set_id, score, last_opened) VALUES (?1, ?2, ?3, ?4) RETURNING id",
|
||||
// (
|
||||
// &stat.word_id,
|
||||
// &stat.set_id,
|
||||
// &stat.score,
|
||||
// &stat.last_open.timestamp(),
|
||||
// ),
|
||||
// |row| row.get(0)
|
||||
// )
|
||||
// .unwrap_or_else(|e| {println!("{}", e); 0});
|
||||
//
|
||||
// stat.id = index;
|
||||
// println!("Added stat: {}", time.elapsed().as_millis());
|
||||
// }
|
||||
|
||||
pub fn update_stat_score(stat: &CardStatistics, connection: &Connection) {
|
||||
let time = Instant::now();
|
||||
|
||||
@@ -6,17 +6,13 @@ use std::io::Write;
|
||||
use std::io::{BufRead, BufReader};
|
||||
use std::path::PathBuf;
|
||||
|
||||
const MAX_HISTORY_LENGTH: usize = 1000;
|
||||
|
||||
pub fn get_history_of_set(id: u32) -> Vec<HistoryItem> {
|
||||
let app_dir = app_data_dir();
|
||||
let head = app_dir.clone().join(format!("set_{}_history.csv", id));
|
||||
let tail = app_dir.clone().join(format!("set_{}_history_tail.csv", id));
|
||||
let mut lines = Vec::new();
|
||||
|
||||
append_lines_if_exists(tail, &mut lines);
|
||||
append_lines_if_exists(head, &mut lines);
|
||||
|
||||
lines.reverse();
|
||||
parse_history_items(lines)
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ pub fn create_db() {
|
||||
}
|
||||
}
|
||||
|
||||
fn ensure_db_schema(conn: &Connection) {}
|
||||
fn ensure_db_schema(_: &Connection) {}
|
||||
|
||||
fn create_tables(conn: &Connection) {
|
||||
make_card_set(conn).unwrap();
|
||||
|
||||
+6
-16
@@ -293,13 +293,14 @@ impl DictionaryState {
|
||||
row![
|
||||
iced::widget::column![
|
||||
self.groups_panel(),
|
||||
self.words_list(),
|
||||
row![horizontal().width(8),
|
||||
self.words_list(),],
|
||||
button("Добавить слово").style(jl_button).on_press(NewWord),
|
||||
]
|
||||
.spacing(5),
|
||||
self.filters(),
|
||||
]
|
||||
.spacing(5)
|
||||
.spacing(DEFAULT_SPACING)
|
||||
.into(),
|
||||
Back,
|
||||
)
|
||||
@@ -337,8 +338,7 @@ impl DictionaryState {
|
||||
|
||||
let mut line = Row::new().width(Length::Fill).align_y(Center);
|
||||
line = line
|
||||
.push(checkbox(self.include_map[i]).on_toggle(move |b| Include(i, b)))
|
||||
.push(space().width(10));
|
||||
.push(checkbox(self.include_map[i]).label("").spacing(15).on_toggle(move |b| Include(i, b)));
|
||||
|
||||
line = line.push(
|
||||
text_input("Слово", &word.key)
|
||||
@@ -536,7 +536,7 @@ impl DictionaryState {
|
||||
iced::widget::column![
|
||||
scrollable(row).width(Length::Fill).horizontal(),
|
||||
row![
|
||||
button("⇳").on_press(ChangeDirection),
|
||||
button("⇳").on_press(ChangeDirection).style(jl_button),
|
||||
text_input("Название группы слов", &group.name)
|
||||
.on_input(EditGroup)
|
||||
.width(250)
|
||||
@@ -544,7 +544,7 @@ impl DictionaryState {
|
||||
horizontal(),
|
||||
button("Удалить").style(danger).on_press(DeleteGroup),
|
||||
]
|
||||
.spacing(DEFAULT_SPACING)
|
||||
.spacing(DEFAULT_SPACING / 2.0)
|
||||
]
|
||||
.into()
|
||||
}
|
||||
@@ -566,13 +566,3 @@ pub fn app_data_dir() -> PathBuf {
|
||||
|
||||
dir
|
||||
}
|
||||
|
||||
// pub fn app_cache_dir() -> PathBuf {
|
||||
// let mut dir = dirs::cache_dir().unwrap();
|
||||
// dir.push("jap_learn");
|
||||
// if !dir.exists() {
|
||||
// fs::create_dir(dir.clone()).unwrap();
|
||||
// }
|
||||
//
|
||||
// dir
|
||||
// }
|
||||
|
||||
+5
-3
@@ -1,14 +1,15 @@
|
||||
use crate::data_provider::history::{get_history_of_set, HistoryItem};
|
||||
use crate::data_provider::history::{HistoryItem, get_history_of_set};
|
||||
use crate::lang::WordData;
|
||||
use crate::navigation::{NavigatedPage, Page};
|
||||
use crate::styling::*;
|
||||
use crate::{AppState, RootMessage};
|
||||
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, Mutex};
|
||||
use HistoryMessage::Back;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct HistoryState {
|
||||
@@ -82,10 +83,11 @@ impl HistoryState {
|
||||
.align_x(Center),
|
||||
iced::widget::column![
|
||||
text!("{} ➞ {}", item.before, item.after),
|
||||
text!("{}", item.timestamp.format("%d.%m %H:%M"))
|
||||
text!("{}", item.timestamp.with_timezone(&Local).format("%d.%m %H:%M"))
|
||||
]
|
||||
.spacing(5)
|
||||
.align_x(Center)
|
||||
|
||||
]
|
||||
.spacing(5),
|
||||
);
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
// #![windows_subsystem = "windows"]
|
||||
#![windows_subsystem = "windows"]
|
||||
mod data_provider;
|
||||
mod dictionary;
|
||||
mod dictionary_test;
|
||||
@@ -25,7 +25,7 @@ use crate::quiz::*;
|
||||
use crate::repetitions::CardSetSettings;
|
||||
use crate::RootMessage::Keyboard;
|
||||
use iced::Font;
|
||||
use iced::{keyboard, Program, Subscription, Theme};
|
||||
use iced::{keyboard, Subscription, Theme};
|
||||
use rusqlite::Connection;
|
||||
|
||||
const USER_FONT: Font = Font::with_name("Noto Sans JP");
|
||||
|
||||
+18
-5
@@ -9,8 +9,10 @@ use crate::styling::*;
|
||||
use crate::sync::SyncState;
|
||||
use crate::writing::WritingState;
|
||||
use crate::{AppState, QuizState, RootMessage};
|
||||
use iced::widget::button::{Status, Style};
|
||||
use iced::widget::*;
|
||||
use iced::{alignment, Element, Task};
|
||||
use iced::{Element, Task, alignment};
|
||||
use iced_core::{Background, Color};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
pub struct SelectorState {
|
||||
@@ -80,6 +82,17 @@ impl SelectorState {
|
||||
Task::none()
|
||||
}
|
||||
|
||||
fn nav_style(theme: &Theme, status: Status) -> Style {
|
||||
let mut basic = button::text(theme, status);
|
||||
basic.background = if status == Status::Hovered {
|
||||
Some(Background::Color(Color::WHITE.scale_alpha(0.1)))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
basic.border.radius = BUTTON_RADIUS.into();
|
||||
basic
|
||||
}
|
||||
|
||||
pub fn view(&self) -> Element<'_, SelectorMessage> {
|
||||
container(
|
||||
iced::widget::column![
|
||||
@@ -89,16 +102,16 @@ impl SelectorState {
|
||||
.style(jl_button),
|
||||
button("Словарь")
|
||||
.on_press(SelectorMessage::ToDictionary)
|
||||
.style(button::text),
|
||||
.style(Self::nav_style),
|
||||
button("Рандомайзер")
|
||||
.on_press(SelectorMessage::ToRandomize)
|
||||
.style(button::text),
|
||||
.style(Self::nav_style),
|
||||
button("Повторение")
|
||||
.on_press(SelectorMessage::ToRepetitions)
|
||||
.style(button::text),
|
||||
.style(Self::nav_style),
|
||||
button("Синхронизация")
|
||||
.on_press(SelectorMessage::ToSync)
|
||||
.style(button::text)
|
||||
.style(Self::nav_style)
|
||||
]
|
||||
.spacing(DEFAULT_SPACING),
|
||||
self.rows_selector(),
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ use iced_core::{Border, Theme};
|
||||
|
||||
pub const DEFAULT_SPACING: f32 = 16.0;
|
||||
pub const ACCENT_FONT_SIZE: f32 = 22.0;
|
||||
const BUTTON_RADIUS: f32 = 8.0;
|
||||
pub const BUTTON_RADIUS: f32 = 8.0;
|
||||
|
||||
pub fn jl_button(theme: &Theme, status: Status) -> Style {
|
||||
let mut style = primary(theme, status);
|
||||
|
||||
Reference in New Issue
Block a user