Use constants for the diverse sizes

This commit is contained in:
Quentin Boyer 2023-11-12 12:25:16 +01:00
parent 0d29a198b8
commit 94c5ddfae5

View file

@ -18,6 +18,13 @@ use serde::{Deserialize, Serialize};
type Element<'a> = iced::Element<'a, Message>;
const TEXT_H1: u16 = 30;
const TEXT_H2: u16 = 25;
const TEXT_EMPH1: u16 = 17;
const TEXT_EMPH2: u16 = 20;
const LIST_RULE: u16 = 5;
struct AddRecurring<F> {
on_submit: F,
}
@ -199,14 +206,14 @@ where
fn view(&self, state: &Self::State) -> iced_aw::Element<'_, Self::Event, Renderer> {
let underlay = column![
text("Recurring").size(25),
text("Recurring").size(TEXT_H2),
button(text("Add")).on_press(RecurringMessage::Add),
horizontal_rule(5),
horizontal_rule(LIST_RULE),
column(
self.items
.iter()
.map(|(name, &value)| row![
text(name).size(17),
text(name).size(TEXT_EMPH1),
text(&format!("{value}")),
horizontal_space(Length::Fill),
component(EditRecurring::new(
@ -218,11 +225,11 @@ where
.spacing(5)
.align_items(iced::Alignment::Center)
.into())
.intersperse_with(|| horizontal_rule(5).into())
.intersperse_with(|| horizontal_rule(LIST_RULE).into())
.collect()
),
horizontal_rule(5),
text(&format!("Total: {}", self.items.values().sum::<f64>())).size(20)
horizontal_rule(LIST_RULE),
text(&format!("Total: {}", self.items.values().sum::<f64>())).size(TEXT_EMPH2)
]
.max_width(500.0);
@ -326,7 +333,7 @@ impl Application for Glaurung {
fn view(&self) -> Element {
column![
text("Spendings").size(30),
text("Spendings").size(TEXT_H1),
component(Recurring {
items: &self.recurring,
on_add: Message::AddRecurring,