style and macros for text input
This commit is contained in:
1 parent
5d12f3b02a
commit
b1902b35cb
3 files changed
+21
-2
No files matched your search
@@ -14,6 +14,7 @@ use log::info;
|
||||
use rhai::{Engine, Scope};
|
||||
use std::sync::Arc;
|
||||
use std::time::Instant;
|
||||
use litemap::LiteMap;
|
||||
use crate::data::Id;
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -26,6 +27,11 @@ pub struct DeckData {
|
||||
open_mode: OrderMode,
|
||||
settings: DeckSettings,
|
||||
}
|
||||
|
||||
struct DisplayStyle{
|
||||
properties: LiteMap<String, String>,
|
||||
}
|
||||
|
||||
impl DeckData {
|
||||
pub fn new(settings: &DeckSettings, open_mode: OrderMode, state: AppState) -> Self {
|
||||
let states_repo = state.card_states.read();
|
||||
|
||||
@@ -270,13 +270,13 @@ impl RepetitionState {
|
||||
fn draw_context(&self, word: &WordData) -> Element<'_, RepetitionMessage> {
|
||||
match word.additional.get(&Id(3)) {
|
||||
None => space().into(),
|
||||
Some(context) => text!("{}", context).size(24).into(),
|
||||
Some(context) => text!("{}", context).center().size(24).into(),
|
||||
}
|
||||
}
|
||||
fn draw_description(&self, word: &WordData) -> Element<'_, RepetitionMessage> {
|
||||
match word.additional.get(&Id(2)) {
|
||||
None => space().into(),
|
||||
Some(context) => text!("{}", context).size(24).into(),
|
||||
Some(context) => text!("{}", context).center().size(24).into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,12 @@ pub fn jl_button_style(theme: &Theme, status: Status) -> Style {
|
||||
};
|
||||
style
|
||||
}
|
||||
|
||||
pub fn jl_text_input_style(theme: &Theme, status: iced::widget::text_input::Status) -> iced::widget::text_input::Style {
|
||||
let mut style = iced::widget::text_input::default(theme, status);
|
||||
style.border.radius = Radius::new(BUTTON_RADIUS);
|
||||
style
|
||||
}
|
||||
pub fn cta_button(theme: &Theme, status: Status) -> Style {
|
||||
let mut style = secondary(theme, status);
|
||||
style.border.width = 1.0;
|
||||
@@ -37,6 +43,13 @@ macro_rules! jl_button {
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! jl_text_input {
|
||||
($content:expr) => {
|
||||
iced::widget::text_input($content).style($crate::styling::jl_text_input_style)
|
||||
};
|
||||
}
|
||||
|
||||
pub fn back_overlay<'a, T: Clone + 'a>(content: Element<'a, T>, back_message: T) -> Element<'a, T> {
|
||||
container(
|
||||
iced::widget::column![jl_button!("Назад").on_press(back_message), content]
|
||||
|
||||
Reference in new issue
Block a user