Button restyle

This commit is contained in:
2026-08-01 17:16:58 +03:00
parent d9bd1b1b86
commit 4d6de8a02c
12 changed files with 82 additions and 63 deletions
+42 -19
View File
@@ -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()
}