Small changes

This commit is contained in:
2026-08-04 14:09:40 +03:00
parent 64fbfb5a32
commit a222233290
9 changed files with 89 additions and 46 deletions
+9 -5
View File
@@ -293,8 +293,7 @@ impl DictionaryState {
row![
iced::widget::column![
self.groups_panel(),
row![horizontal().width(8),
self.words_list(),],
row![horizontal().width(8), self.words_list(),],
button("Добавить слово").style(jl_button).on_press(NewWord),
]
.spacing(5),
@@ -337,8 +336,12 @@ impl DictionaryState {
}
let mut line = Row::new().width(Length::Fill).align_y(Center);
line = line
.push(checkbox(self.include_map[i]).label("").spacing(15).on_toggle(move |b| Include(i, b)));
line = line.push(
checkbox(self.include_map[i])
.label("")
.spacing(15)
.on_toggle(move |b| Include(i, b)),
);
line = line.push(
text_input("Слово", &word.key)
@@ -364,6 +367,7 @@ impl DictionaryState {
default_style
}),
);
line = line.push(
text_input("Теги", &word.tags)
.size(ACCENT_FONT_SIZE)
@@ -422,7 +426,7 @@ impl DictionaryState {
.label("Обратный тест")
.on_toggle(SetReverse),
button(text!("Тест").center().width(Length::Fill))
.style(jl_button)
.style(cta_button)
.on_press(Test)
.width(Length::Fill),
]
+8 -2
View File
@@ -24,14 +24,20 @@ use crate::navigation::{AppSettings, RootMessage, ScreenState};
use crate::quiz::*;
use crate::repetitions::CardSetSettings;
use crate::RootMessage::Keyboard;
use iced::Font;
use iced::{window, Font};
use iced::{keyboard, Subscription, Theme};
use iced_core::Size;
use iced_core::window::Position;
use rusqlite::Connection;
const USER_FONT: Font = Font::with_name("Noto Sans JP");
fn main() -> iced::Result {
iced::application(ScreenState::boot, ScreenState::update, ScreenState::view)
iced::application(ScreenState::boot, ScreenState::update, ScreenState::view).window(window::Settings{
position: Position::Centered,
min_size: Some(Size::new(700.0_f32.into(), 700.0_f32.into())),
.. Default::default()
})
.subscription(subscription)
.title("Kana learn app")
.settings(iced::Settings {
+1 -1
View File
@@ -104,7 +104,7 @@ impl QuizState {
container(
iced::widget::column![
row![
text!("{}", self.kana.to_uppercase())
text!("{}", self.kana.to_lowercase())
.size(54)
.font(USER_FONT),
text!(
+2 -2
View File
@@ -1,6 +1,6 @@
use crate::navigation::{NavigatedPage, Page};
use crate::randomizer::RandomizerMessage::{Back, Edit, Start};
use crate::styling::{back_overlay, jl_button};
use crate::styling::{back_overlay, jl_button, HALF_SPACING};
use crate::RootMessage;
use iced::widget::{button, text_editor};
use iced::Task;
@@ -72,7 +72,7 @@ impl RandomizerState {
.placeholder("Каждый элемент с новой строки"),
button("Перемешать").style(jl_button).on_press(Start),
]
.spacing(5)
.spacing(HALF_SPACING)
.into(),
Back,
)
+2 -2
View File
@@ -149,7 +149,7 @@ impl RepetitionState {
fn draw_backward(&self) -> Element<'_, RepetitionMessage> {
if !self.open {
return space().into();
return container(text!("?").size(72)).width(Fill).height(Fill).align_y(alignment::Vertical::Center).align_x(Center).into();
}
self.draw_card_view(self.settings.backward.as_str())
@@ -209,7 +209,7 @@ impl RepetitionState {
tooltip::Position::Top
),
]
.spacing(DEFAULT_SPACING / 4.0)
.spacing(QUARTER_SPACING)
]
.align_x(Center)
.spacing(DEFAULT_SPACING)
+34 -15
View File
@@ -14,6 +14,7 @@ use iced::widget::{
button, column, container, radio, row, scrollable, space, text, text_input, Column,
};
use iced::{Background, Border, Center, Color, Element, Fill, Length, Shadow, Task, Theme};
use iced_core::Padding;
use rhai::{Engine, Scope};
use std::sync::{Arc, Mutex};
@@ -138,7 +139,6 @@ impl RepetitionsState {
.spacing(DEFAULT_SPACING)
.width(Length::FillPortion(1)),
self.selected_set_view(),
self.launch_button()
]
.align_y(Center)
.spacing(DEFAULT_SPACING)
@@ -153,9 +153,8 @@ impl RepetitionsState {
if let Some(set) = self.selected_set
&& self.state.lock().unwrap().card_sets[set].id != 0
{
return button(text!("").height(Fill).center())
.style(jl_button)
.height(200)
return button(text!("Начать повторение").width(200).center())
.style(cta_button)
.on_press(RepetitionsMessage::GoToRepetition)
.into();
}
@@ -171,18 +170,30 @@ impl RepetitionsState {
return column![
scrollable(
column![
text_input("Название набора", &set.name)
.on_input(RepetitionsMessage::SetName),
text_input("Передняя сторона", &set.forward)
.on_input(RepetitionsMessage::SetForward),
text_input("Задняя сторона", &set.backward)
.on_input(RepetitionsMessage::SetBackward),
column![
text!("Название набора"),
text_input("", &set.name).on_input(RepetitionsMessage::SetName)
]
.spacing(QUARTER_SPACING),
column![
text!("Передняя сторона"),
text_input("", &set.forward).on_input(RepetitionsMessage::SetForward),
]
.spacing(QUARTER_SPACING),
column![
text!("Задняя сторона"),
text_input("", &set.backward).on_input(RepetitionsMessage::SetBackward),
]
.spacing(QUARTER_SPACING),
column![
text!("Фильтр"),
text_input("", &set.filter).on_input(RepetitionsMessage::SetFilter),
button("Проверить фильтр")
.style(jl_button)
.on_press(RepetitionsMessage::TryFilter),
self.count_view(&set),
]
.spacing(QUARTER_SPACING),
radio(
"Обычный режим",
SetOrderMode::Default,
@@ -195,6 +206,12 @@ impl RepetitionsState {
.on_press(RepetitionsMessage::GoToHistory),
]
.spacing(DEFAULT_SPACING)
.padding(Padding {
top: 0.0,
right: DEFAULT_SPACING,
bottom: 0.0,
left: 0.0,
})
)
.height(Fill),
row![
@@ -203,15 +220,17 @@ impl RepetitionsState {
.on_press(RepetitionsMessage::Save),
button("Удалить")
.style(danger)
.on_press(RepetitionsMessage::DeleteSet)
.on_press(RepetitionsMessage::DeleteSet),
space().width(Fill),
self.launch_button()
]
.spacing(DEFAULT_SPACING),
]
.spacing(DEFAULT_SPACING)
.width(Length::FillPortion(2))
.width(Length::FillPortion(3))
.into();
}
space().width(Length::FillPortion(2)).into()
space().width(Length::FillPortion(3)).into()
}
fn words_words_view(&self, set: &CardSetSettings) -> Element<'_, RepetitionsMessage> {
@@ -261,7 +280,7 @@ impl RepetitionsState {
.on_press_with(move || RepetitionsMessage::SelectSet(i.clone()))
.style(move |_x: &Theme, status: Status| Style {
background: if status == Status::Hovered {
Some(Background::Color(Color::WHITE.scale_alpha(0.1)))
Some(Background::Color(Color::WHITE.scale_alpha(0.2)))
} else {
None
},
@@ -273,7 +292,7 @@ impl RepetitionsState {
border: Border {
color: Default::default(),
width: 0.0,
radius: 8.0.into(),
radius: BUTTON_RADIUS.into(),
},
shadow: Shadow::default(),
snap: false,
+11 -6
View File
@@ -11,8 +11,10 @@ use crate::writing::WritingState;
use crate::{AppState, QuizState, RootMessage};
use iced::widget::button::{Status, Style};
use iced::widget::*;
use iced::{Element, Task, alignment};
use iced_core::{Background, Color};
use iced::{alignment, Element, Task};
use iced_core::Alignment::Center;
use iced_core::Background;
use iced_core::Color;
use std::sync::{Arc, Mutex};
pub struct SelectorState {
@@ -114,13 +116,13 @@ impl SelectorState {
.style(Self::nav_style)
]
.spacing(DEFAULT_SPACING),
self.rows_selector(),
scrollable(self.rows_selector()).horizontal(),
toggler(self.is_writing)
.label("Режим письма")
.on_toggle(ChangeMode),
button("К тесту")
.on_press(SelectorMessage::Goto)
.style(jl_button),
.style(cta_button),
]
.spacing(DEFAULT_SPACING),
)
@@ -140,8 +142,11 @@ impl SelectorState {
for v in &self.set.dictionary[i] {
chars_column = chars_column.push(
container(text!("{}", v.0.clone().to_uppercase()).size(36))
.padding(20)
container(text!("{}", v.0.clone().to_lowercase()).size(40))
.align_y(Center)
.align_x(Center)
.width(80)
.height(80)
.style(container::rounded_box),
);
}
+10 -2
View File
@@ -1,12 +1,14 @@
use crate::repetitions::Style;
use iced::border::Radius;
use iced::widget::button::{primary, Status};
use iced::widget::button::*;
use iced::widget::{button, container};
use iced::Element;
use iced_core::alignment::Horizontal::Left;
use iced_core::Length::Fill;
use iced_core::{Border, Theme};
pub const HALF_SPACING: f32 = DEFAULT_SPACING / 2.0;
pub const QUARTER_SPACING: f32 = DEFAULT_SPACING / 4.0;
pub const DEFAULT_SPACING: f32 = 16.0;
pub const ACCENT_FONT_SIZE: f32 = 22.0;
pub const BUTTON_RADIUS: f32 = 8.0;
@@ -20,6 +22,12 @@ pub fn jl_button(theme: &Theme, status: Status) -> Style {
};
style
}
pub fn cta_button(theme: &Theme, status: Status) -> Style {
let mut style = secondary(theme, status);
style.border.width = 1.0;
style.border.radius = Radius::new(BUTTON_RADIUS);
style
}
pub fn back_overlay<'a, T: Clone + 'a>(content: Element<'a, T>, back_message: T) -> Element<'a, T> {
container(
@@ -27,7 +35,7 @@ pub fn back_overlay<'a, T: Clone + 'a>(content: Element<'a, T>, back_message: T)
button("Назад").style(jl_button).on_press(back_message),
content
]
.spacing(5)
.spacing(DEFAULT_SPACING)
.align_x(Left)
.width(Fill),
)
+6 -5
View File
@@ -101,17 +101,17 @@ impl WordState {
text!("Ключ"),
text_input("key", &self.word.key).on_input(SetKey),
]
.spacing(DEFAULT_SPACING / 4.0),
.spacing(QUARTER_SPACING),
column![
text!("Значение"),
text_input("value", &self.word.value).on_input(SetValue),
]
.spacing(DEFAULT_SPACING / 4.0),
.spacing(QUARTER_SPACING),
column![
text!("Теги"),
text_input("tags", &self.word.tags).on_input(SetTags),
]
.spacing(DEFAULT_SPACING / 4.0),
.spacing(QUARTER_SPACING),
rule::horizontal(2),
scrollable(fast_add),
];
@@ -175,12 +175,13 @@ impl WordState {
.on_press(RemoveAdditional(id.clone()))
.style(danger),
]
.spacing(DEFAULT_SPACING / 4.0),
.spacing(QUARTER_SPACING),
]
.spacing(DEFAULT_SPACING / 4.0)
.spacing(QUARTER_SPACING)
.into()
}
}
#[derive(Debug, Clone)]
pub enum WordMessage {
Save,