Button restyle
This commit is contained in:
+3
-3
@@ -295,10 +295,10 @@ impl DictionaryState {
|
||||
container(
|
||||
row![
|
||||
iced::widget::column![
|
||||
button("Назад").on_press(Back),
|
||||
button("Назад").style(jl_button).on_press(Back),
|
||||
self.groups_panel(),
|
||||
self.words_list(),
|
||||
button("Добавить слово").on_press(DictionaryMessage::NewWord),
|
||||
button("Добавить слово").style(jl_button).on_press(DictionaryMessage::NewWord),
|
||||
]
|
||||
.spacing(5),
|
||||
self.filters()
|
||||
@@ -415,7 +415,7 @@ impl DictionaryState {
|
||||
toggler(self.reverse)
|
||||
.label("Обратный тест")
|
||||
.on_toggle(DictionaryMessage::SetReverse),
|
||||
button(text!("Тест").center().width(Length::Fill))
|
||||
button(text!("Тест").center().width(Length::Fill)).style(jl_button)
|
||||
.on_press(Test)
|
||||
.width(Length::Fill),
|
||||
]
|
||||
|
||||
@@ -105,7 +105,7 @@ impl DictionaryQuizState {
|
||||
]
|
||||
.spacing(DEFAULT_SPACING),
|
||||
row![
|
||||
button("Закончить").on_press(DictionaryQuizMessage::Back),
|
||||
button("Закончить").style(jl_button).on_press(DictionaryQuizMessage::Back),
|
||||
self.appeal_button()
|
||||
]
|
||||
.spacing(DEFAULT_SPACING),
|
||||
@@ -205,7 +205,7 @@ impl DictionaryQuizState {
|
||||
|
||||
fn appeal_button(&self) -> Element<'_, DictionaryQuizMessage> {
|
||||
if self.is_help && self.no_typing == false {
|
||||
return button("Апелляция")
|
||||
return button("Апелляция").style(jl_button)
|
||||
.on_press(DictionaryQuizMessage::Appeal)
|
||||
.into();
|
||||
}
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ impl HistoryState {
|
||||
pub fn view(&self) -> Element<'_, HistoryMessage> {
|
||||
container(
|
||||
iced::widget::column![
|
||||
button("Назад").on_press(Back),
|
||||
button("Назад").style(jl_button).on_press(Back),
|
||||
iced::widget::row![
|
||||
horizontal().width(FillPortion(1)),
|
||||
scrollable(self.history_lines().padding(DEFAULT_SPACING))
|
||||
|
||||
+1
-1
@@ -129,7 +129,7 @@ impl QuizState {
|
||||
.size(25),
|
||||
]
|
||||
.spacing(DEFAULT_SPACING),
|
||||
button("Закончить").on_press(QuizMessage::Back),
|
||||
button("Закончить").style(jl_button).on_press(QuizMessage::Back),
|
||||
]
|
||||
.spacing(DEFAULT_SPACING)
|
||||
.align_x(alignment::Horizontal::Center),
|
||||
|
||||
+3
-2
@@ -6,6 +6,7 @@ pub mod randomizer {
|
||||
use iced::Task;
|
||||
use rand::prelude::SliceRandom;
|
||||
use crate::navigation::{NavigatedPage, Page};
|
||||
use crate::styling::jl_button;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct RandomizerState {
|
||||
@@ -58,10 +59,10 @@ pub mod randomizer {
|
||||
pub fn view(&self) -> iced::Element<'_, RandomizerMessage> {
|
||||
container(
|
||||
iced::widget::column![
|
||||
button("Назад").on_press(Back),
|
||||
button("Назад").style(jl_button).on_press(Back),
|
||||
text_editor(&self.text).on_action(Edit
|
||||
).width(400).height(400).placeholder("Каждый элемент с новой строки"),
|
||||
button("Перемешать").on_press(Start),
|
||||
button("Перемешать").style(jl_button).on_press(Start),
|
||||
]
|
||||
.spacing(5),
|
||||
)
|
||||
|
||||
+42
-19
@@ -1,19 +1,19 @@
|
||||
use crate::data_provider::voice::get_voice;
|
||||
use crate::lang::{CardSet, CardStatistics, WordData, WordOpenMode};
|
||||
use crate::navigation::Page::PreviousPage;
|
||||
use crate::navigation::{KeyPressedPage, NavigatedPage, Page};
|
||||
use crate::repetitions::CardSetSettings;
|
||||
use crate::styling::*;
|
||||
use crate::{AppState, RootMessage};
|
||||
use iced::alignment::Horizontal::Center;
|
||||
use iced::keyboard::key::Physical::Code;
|
||||
use iced::widget::{button, column, container, row, rule, space, text, Column};
|
||||
use iced::{alignment, keyboard, Element, Fill, Left, Task, Theme};
|
||||
use iced::widget::text::Style;
|
||||
use iced::widget::{Column, button, column, container, row, rule, space, text, tooltip};
|
||||
use iced::{Element, Fill, Left, Task, Theme, alignment, keyboard};
|
||||
use rodio::MixerDeviceSink;
|
||||
use std::collections::HashSet;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use iced::widget::text::Style;
|
||||
use tokio::task::spawn_blocking;
|
||||
use crate::navigation::{KeyPressedPage, NavigatedPage, Page};
|
||||
use crate::navigation::Page::PreviousPage;
|
||||
use crate::styling::*;
|
||||
|
||||
pub struct RepetitionState {
|
||||
pub settings: CardSetSettings,
|
||||
@@ -39,7 +39,7 @@ impl NavigatedPage<RepetitionMessage> for RepetitionState {
|
||||
impl RepetitionState {
|
||||
pub(crate) fn new(set: CardSetSettings, state: Arc<Mutex<AppState>>) -> RepetitionState {
|
||||
let mut card_set = CardSet::new(&set, state.clone());
|
||||
let (word, stat) = card_set.next();
|
||||
let (word, stat) = card_set.next();
|
||||
let sink_handle = rodio::DeviceSinkBuilder::open_default_sink().unwrap();
|
||||
|
||||
RepetitionState {
|
||||
@@ -115,7 +115,9 @@ impl RepetitionState {
|
||||
pub fn view(&self) -> Element<'_, RepetitionMessage> {
|
||||
container(
|
||||
iced::widget::column![
|
||||
button("Назад").on_press(RepetitionMessage::Back),
|
||||
button("Назад")
|
||||
.style(jl_button)
|
||||
.on_press(RepetitionMessage::Back),
|
||||
column![
|
||||
container(self.draw_forward())
|
||||
.width(Fill)
|
||||
@@ -152,7 +154,6 @@ impl RepetitionState {
|
||||
|
||||
fn draw_forward(&self) -> Element<'_, RepetitionMessage> {
|
||||
self.draw_card_view(self.settings.forward.as_str())
|
||||
|
||||
}
|
||||
|
||||
fn draw_backward(&self) -> Element<'_, RepetitionMessage> {
|
||||
@@ -160,7 +161,6 @@ impl RepetitionState {
|
||||
return space().into();
|
||||
}
|
||||
|
||||
|
||||
self.draw_card_view(self.settings.backward.as_str())
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ impl RepetitionState {
|
||||
let mut col = Column::new();
|
||||
|
||||
for view_type in properties.split(" ") {
|
||||
col = col.push( match view_type {
|
||||
col = col.push(match view_type {
|
||||
"key" => self.draw_key(word),
|
||||
"value" => self.draw_value(word),
|
||||
"speech" => self.draw_voice(),
|
||||
@@ -185,18 +185,40 @@ impl RepetitionState {
|
||||
|
||||
fn answer_bar(&self) -> Element<'_, RepetitionMessage> {
|
||||
if !self.open {
|
||||
return text!("Нажмите Пробел для открытия карточки").style(|theme: &Theme| {Style{ color: Some(theme.palette().text.scale_alpha(0.3)) }}).into();
|
||||
return text!("Нажмите Пробел для открытия карточки")
|
||||
.style(|theme: &Theme| Style {
|
||||
color: Some(theme.palette().text.scale_alpha(0.3)),
|
||||
})
|
||||
.into();
|
||||
}
|
||||
column![
|
||||
text!("{} очков", self.current_statistic.calculated_score().round() as i32),
|
||||
text!(
|
||||
"{} очков",
|
||||
self.current_statistic.calculated_score().round() as i32
|
||||
),
|
||||
row![
|
||||
|
||||
button("Не получилось").on_press(RepetitionMessage::Answer(WordOpenMode::None)),
|
||||
button("Трудно").on_press(RepetitionMessage::Answer(WordOpenMode::Hard)),
|
||||
button("Нормально").on_press(RepetitionMessage::Answer(WordOpenMode::Ok)),
|
||||
button("Легко").on_press(RepetitionMessage::Answer(WordOpenMode::Easy)),
|
||||
tooltip(
|
||||
button("Не получилось").on_press(RepetitionMessage::Answer(WordOpenMode::None)),
|
||||
"Клавиша 1",
|
||||
tooltip::Position::Top
|
||||
),
|
||||
tooltip(
|
||||
button("Трудно").on_press(RepetitionMessage::Answer(WordOpenMode::Hard)),
|
||||
"Клавиша 2",
|
||||
tooltip::Position::Top
|
||||
),
|
||||
tooltip(
|
||||
button("Нормально").on_press(RepetitionMessage::Answer(WordOpenMode::Ok)),
|
||||
"Клавиша 3",
|
||||
tooltip::Position::Top
|
||||
),
|
||||
tooltip(
|
||||
button("Легко").on_press(RepetitionMessage::Answer(WordOpenMode::Easy)),
|
||||
"Клавиша 4",
|
||||
tooltip::Position::Top
|
||||
),
|
||||
]
|
||||
.spacing(DEFAULT_SPACING)
|
||||
.spacing(DEFAULT_SPACING / 4.0)
|
||||
]
|
||||
.align_x(Center)
|
||||
.spacing(DEFAULT_SPACING)
|
||||
@@ -212,6 +234,7 @@ impl RepetitionState {
|
||||
|
||||
fn draw_voice(&self) -> Element<'_, RepetitionMessage> {
|
||||
button("Воспроизвести")
|
||||
.style(jl_button)
|
||||
.on_press(RepetitionMessage::Play)
|
||||
.into()
|
||||
}
|
||||
|
||||
+11
-11
@@ -1,19 +1,19 @@
|
||||
use crate::data_provider::card_sets::{delete_set, update_card_set};
|
||||
use crate::data_provider::card_stats::load_stats_of_set;
|
||||
use crate::history::HistoryState;
|
||||
use crate::lang::{SetOrderMode, WordData};
|
||||
use crate::navigation::Page::{History, PreviousPage, Repetition};
|
||||
use crate::navigation::{NavigatedPage, Page};
|
||||
use crate::repetition::RepetitionState;
|
||||
use crate::styling::*;
|
||||
use crate::{AppState, RootMessage};
|
||||
use iced::widget::button::{danger, Status};
|
||||
pub use iced::widget::button::{Catalog, Style};
|
||||
use iced::widget::container::bordered_box;
|
||||
use iced::widget::{button, column, container, radio, row, scrollable, space, text, text_input, Column};
|
||||
use iced::{color, Background, Border, Center, Color, Element, Fill, Left, Length, Shadow, Task, Theme};
|
||||
use iced::{Background, Border, Center, Color, Element, Fill, Left, Length, Shadow, Task, Theme};
|
||||
use rhai::{Engine, Scope};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use crate::history::HistoryState;
|
||||
use crate::navigation::{NavigatedPage, Page};
|
||||
use crate::navigation::Page::{History, PreviousPage, Repetition};
|
||||
use crate::styling::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct RepetitionsState {
|
||||
@@ -122,11 +122,11 @@ impl RepetitionsState {
|
||||
pub fn view(&self) -> Element<'_, RepetitionsMessage> {
|
||||
container(
|
||||
iced::widget::column![
|
||||
button("Назад").on_press(RepetitionsMessage::Back),
|
||||
button("Назад").style(jl_button).on_press(RepetitionsMessage::Back),
|
||||
row![
|
||||
column![
|
||||
scrollable(self.sets_list()).height(Fill),
|
||||
button("Добавить")
|
||||
button("Добавить").style(jl_button)
|
||||
.width(Fill)
|
||||
.on_press(RepetitionsMessage::CreateSet),
|
||||
]
|
||||
@@ -150,7 +150,7 @@ impl RepetitionsState {
|
||||
|
||||
fn launch_button(&self) -> Element<'_, RepetitionsMessage> {
|
||||
if let Some(set) = self.selected_set && self.state.lock().unwrap().card_sets[set].id != 0 {
|
||||
return button(text!("▷").height(Fill).center())
|
||||
return button(text!("▷").height(Fill).center()).style(jl_button)
|
||||
.height(200)
|
||||
.on_press(RepetitionsMessage::GoToRepetition)
|
||||
.into();
|
||||
@@ -175,17 +175,17 @@ impl RepetitionsState {
|
||||
.on_input(RepetitionsMessage::SetBackward),
|
||||
text!("Фильтр"),
|
||||
text_input("", &set.filter).on_input(RepetitionsMessage::SetFilter),
|
||||
button("Проверить фильтр").on_press(RepetitionsMessage::TryFilter),
|
||||
button("Проверить фильтр").style(jl_button).on_press(RepetitionsMessage::TryFilter),
|
||||
self.count_view(&set),
|
||||
radio("Обычный режим", SetOrderMode::Default, Some(set.open_mode), RepetitionsMessage::SetOpenMode),
|
||||
self.words_words_view(&set),
|
||||
button("История").on_press(RepetitionsMessage::GoToHistory),
|
||||
button("История").style(jl_button).on_press(RepetitionsMessage::GoToHistory),
|
||||
]
|
||||
.spacing(DEFAULT_SPACING)
|
||||
)
|
||||
.height(Fill),
|
||||
row![
|
||||
button("Сохранить").on_press(RepetitionsMessage::Save),
|
||||
button("Сохранить").style(jl_button).on_press(RepetitionsMessage::Save),
|
||||
button("Удалить")
|
||||
.style(danger)
|
||||
.on_press(RepetitionsMessage::DeleteSet)
|
||||
|
||||
+2
-2
@@ -84,7 +84,7 @@ impl SelectorState {
|
||||
container(
|
||||
iced::widget::column![
|
||||
row![
|
||||
button("あ ↔ ア").on_press(SelectorMessage::Change),
|
||||
button("あ ↔ ア").on_press(SelectorMessage::Change).style(jl_button),
|
||||
button("Словарь").on_press(SelectorMessage::ToDictionary).style(button::text),
|
||||
button("Рандомайзер").on_press(SelectorMessage::ToRandomize).style(button::text),
|
||||
button("Повторение").on_press(SelectorMessage::ToRepetitions).style(button::text),
|
||||
@@ -95,7 +95,7 @@ impl SelectorState {
|
||||
toggler(self.is_writing)
|
||||
.label("Режим письма")
|
||||
.on_toggle(ChangeMode),
|
||||
button("К тесту").on_press(SelectorMessage::Goto),
|
||||
button("К тесту").on_press(SelectorMessage::Goto).style(jl_button),
|
||||
]
|
||||
.spacing(DEFAULT_SPACING),
|
||||
)
|
||||
|
||||
+2
-5
@@ -1,17 +1,13 @@
|
||||
use iced::border::Radius;
|
||||
use iced::widget::button::{primary, Status};
|
||||
use iced::widget::button::danger;
|
||||
|
||||
use iced::widget::{button, Button};
|
||||
use iced::Element;
|
||||
use iced_core::{Background, Border, Theme};
|
||||
use crate::repetitions::Style;
|
||||
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 fn jl_button(theme: &Theme, status: Status) -> Style {
|
||||
let mut style = primary(theme, status);
|
||||
style.border = Border
|
||||
@@ -22,3 +18,4 @@ pub fn jl_button(theme: &Theme, status: Status) -> Style {
|
||||
};
|
||||
style
|
||||
}
|
||||
|
||||
|
||||
+10
-12
@@ -1,20 +1,18 @@
|
||||
use crate::data_provider::settings::{delete_settings, set_setting};
|
||||
use crate::dictionary::app_data_dir;
|
||||
use crate::navigation::Page::PreviousPage;
|
||||
use crate::navigation::{NavigatedPage, Page};
|
||||
use crate::styling::*;
|
||||
use crate::sync::SyncMessage::NextAnimation;
|
||||
use crate::{fill_state, AppState, RootMessage};
|
||||
use iced::widget::button::danger;
|
||||
use iced::widget::container::rounded_box;
|
||||
use iced::widget::{button, column, container, progress_bar, row, scrollable, space, text};
|
||||
use iced::widget::{button, column, container, progress_bar, row, space, text};
|
||||
use iced::{Center, Element, Fill, Font, Left, Length, Task};
|
||||
use std::io;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::Duration;
|
||||
use iced::border::width;
|
||||
use iced::widget::operation::scroll_to;
|
||||
use zstd::{Decoder, Encoder, DEFAULT_COMPRESSION_LEVEL};
|
||||
use crate::navigation::{NavigatedPage, Page};
|
||||
use crate::navigation::Page::PreviousPage;
|
||||
use crate::styling::*;
|
||||
|
||||
const API_URL: &str = "https://learning.micialware.ru/";
|
||||
/*const API_URL: &str = "http://localhost:8089/";*/
|
||||
@@ -159,7 +157,7 @@ impl SyncState {
|
||||
pub fn view(&self) -> Element<'_, SyncMessage> {
|
||||
container(
|
||||
column![
|
||||
button("Назад").on_press(SyncMessage::Back),
|
||||
button("Назад").style(jl_button).on_press(SyncMessage::Back),
|
||||
row![space().width(Fill), self.sync_column(), space().width(Fill)]
|
||||
.spacing(DEFAULT_SPACING)
|
||||
.width(Fill)
|
||||
@@ -189,13 +187,13 @@ impl SyncState {
|
||||
)
|
||||
|
||||
.style(rounded_box),
|
||||
button("Скопировать в буфер обмена")
|
||||
button("Скопировать в буфер обмена").style(jl_button)
|
||||
.on_press(SyncMessage::CopyKey)
|
||||
.width(Fill),
|
||||
row![
|
||||
button("↑ Отправить").on_press(SyncMessage::Send),
|
||||
button("↑ Отправить").style(jl_button).on_press(SyncMessage::Send),
|
||||
space().width(Fill),
|
||||
button("↓ Скачать").on_press(SyncMessage::GetLast)
|
||||
button("↓ Скачать").style(jl_button).on_press(SyncMessage::GetLast)
|
||||
]
|
||||
.spacing(DEFAULT_SPACING),
|
||||
container(network_view).width(Fill),
|
||||
@@ -205,8 +203,8 @@ impl SyncState {
|
||||
]
|
||||
} else {
|
||||
column![
|
||||
button("Создать сохранение").on_press(SyncMessage::InitSync),
|
||||
button("Вставить ключ из буфера").on_press(SyncMessage::GetKey),
|
||||
button("Создать сохранение").style(jl_button).on_press(SyncMessage::InitSync),
|
||||
button("Вставить ключ из буфера").style(jl_button).on_press(SyncMessage::GetKey),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -93,7 +93,7 @@ impl WordState {
|
||||
}
|
||||
|
||||
let mut col = iced::widget::column![
|
||||
button("Назад").on_press(WordMessage::Back),
|
||||
button("Назад").style(jl_button).on_press(WordMessage::Back),
|
||||
text!("Ключ"),
|
||||
text_input("key", &self.word.key).on_input(WordMessage::SetKey),
|
||||
text!("Значение"),
|
||||
@@ -111,7 +111,7 @@ impl WordState {
|
||||
column![
|
||||
col.spacing(DEFAULT_SPACING).width(Fill).height(Fill),
|
||||
row![
|
||||
button("Сохранить").on_press(WordMessage::Save),
|
||||
button("Сохранить").style(jl_button).on_press(WordMessage::Save),
|
||||
button("Удалить")
|
||||
.style(danger)
|
||||
.on_press(WordMessage::Delete),
|
||||
|
||||
+2
-2
@@ -95,8 +95,8 @@ impl WritingState {
|
||||
text!("{}", self.kana).size(48),
|
||||
self.answers(),
|
||||
row![
|
||||
button(text!("{}", self.next_text)).on_press(WritingMessage::Next),
|
||||
button("Закончить").on_press(WritingMessage::Back),
|
||||
button(text!("{}", self.next_text)).style(jl_button).on_press(WritingMessage::Next),
|
||||
button("Закончить").style(jl_button).on_press(WritingMessage::Back),
|
||||
]
|
||||
.spacing(DEFAULT_SPACING)
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user