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