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