Horloges v1.0

This commit is contained in:
2026-08-30 16:23:21 +02:00
parent 3861dd7fb6
commit c5cc3e1f17
6 changed files with 769 additions and 169 deletions
+28 -8
View File
@@ -6,8 +6,23 @@ use iced::widget::{column, container, row, text};
use iced::{Element, Length, Color, Theme, Subscription};
use chrono::{DateTime, Utc};
use std::time::Duration;
use std::path::Path;
pub fn main() -> iced::Result {
// Chargement propre de l'icône avec la crate `image`
let icon = if Path::new("clock.png").exists() {
match image::open("clock.png") {
Ok(img) => {
let rgba = img.to_rgba8();
let (width, height) = rgba.dimensions();
iced::window::icon::from_rgba(rgba.into_raw(), width, height).ok()
}
Err(_) => None,
}
} else {
None
};
iced::application(
"Horloges Boursières Mondiales",
WorldClocksApp::update,
@@ -15,7 +30,8 @@ pub fn main() -> iced::Result {
)
.subscription(WorldClocksApp::subscription)
.window(iced::window::Settings {
size: iced::Size { width: 1600.0, height: 320.0 },
size: iced::Size { width: 1700.0, height: 320.0 },
icon,
..Default::default()
})
.run_with(WorldClocksApp::new)
@@ -62,15 +78,17 @@ impl WorldClocksApp {
let local_time = exchange.local_time(&self.now);
let time_str = local_time.format("%H:%M:%S").to_string();
let mut col = column![].spacing(5).align_x(iced::Alignment::Center);
// En-tête normalisé sur une hauteur fixe pour éviter tout décalage
let mut col = column![].spacing(4).align_x(iced::Alignment::Center);
if is_utc {
col = col.push(
text("UTC")
.size(14)
.size(13)
.style(|_theme: &Theme| text::Style { color: Some(Color::from_rgb(0.0, 0.8, 0.8)) })
);
col = col.push(text("").size(12));
// Espace vide invisible pour garder exactement la même hauteur que les lignes "ville + statut" des autres bourses
col = col.push(text(" ").size(11));
} else {
col = col.push(text(exchange.city.clone()).size(13));
let is_open = exchange.is_open(&self.now);
@@ -81,12 +99,12 @@ impl WorldClocksApp {
};
col = col.push(
text(status_text)
.size(12)
.size(11)
.style(move |_theme: &Theme| text::Style { color: Some(status_color) })
);
}
// Horloge analogique graphique (1.5x)
// Horloge analogique graphique
col = col.push(clock::view_clock(local_time));
// Horloge numérique
@@ -97,9 +115,11 @@ impl WorldClocksApp {
.style(move |_theme: &Theme| text::Style { color: Some(digital_color) })
);
// Conteneur strict aux dimensions fixes absolues
let boxed_clock = container(col)
.width(Length::Fixed(160.0))
.padding(8)
.width(Length::Fixed(155.0))
.height(Length::Fixed(230.0))
.padding(6)
.style(|_theme: &Theme| container::Style {
background: Some(iced::Background::Color(Color::from_rgb(0.12, 0.12, 0.15))),
border: iced::Border {