summaryrefslogtreecommitdiffstats
path: root/examples/clock
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-08 01:07:11 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-08 01:07:11 +0100
commit7161cb40c7a9fbda84ee61060a109b93416b2ea0 (patch)
treef308b0db311424129680a941fc0e86e4378e760d /examples/clock
parentfe7ccd5e151d42d61e0228b540cde212da781f29 (diff)
downloadiced-7161cb40c7a9fbda84ee61060a109b93416b2ea0.tar.gz
iced-7161cb40c7a9fbda84ee61060a109b93416b2ea0.tar.bz2
iced-7161cb40c7a9fbda84ee61060a109b93416b2ea0.zip
Use `Theme::TokyoNight` for `clock` example
Diffstat (limited to 'examples/clock')
-rw-r--r--examples/clock/src/main.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/examples/clock/src/main.rs b/examples/clock/src/main.rs
index 13252526..87da0c7e 100644
--- a/examples/clock/src/main.rs
+++ b/examples/clock/src/main.rs
@@ -3,7 +3,7 @@ use iced::mouse;
use iced::widget::canvas::{stroke, Cache, Geometry, LineCap, Path, Stroke};
use iced::widget::{canvas, container};
use iced::{
- Application, Color, Command, Element, Length, Point, Rectangle, Renderer,
+ Application, Command, Element, Length, Point, Rectangle, Renderer,
Settings, Subscription, Theme, Vector,
};
@@ -80,6 +80,10 @@ impl Application for Clock {
)
})
}
+
+ fn theme(&self) -> Theme {
+ Theme::TokyoNight
+ }
}
impl<Message> canvas::Program<Message> for Clock {
@@ -89,16 +93,18 @@ impl<Message> canvas::Program<Message> for Clock {
&self,
_state: &Self::State,
renderer: &Renderer,
- _theme: &Theme,
+ theme: &Theme,
bounds: Rectangle,
_cursor: mouse::Cursor,
) -> Vec<Geometry> {
let clock = self.clock.draw(renderer, bounds.size(), |frame| {
+ let palette = theme.extended_palette();
+
let center = frame.center();
let radius = frame.width().min(frame.height()) / 2.0;
let background = Path::circle(center, radius);
- frame.fill(&background, Color::from_rgb8(0x12, 0x93, 0xD8));
+ frame.fill(&background, palette.primary.weak.color);
let short_hand =
Path::line(Point::ORIGIN, Point::new(0.0, -0.5 * radius));
@@ -111,7 +117,7 @@ impl<Message> canvas::Program<Message> for Clock {
let thin_stroke = || -> Stroke {
Stroke {
width,
- style: stroke::Style::Solid(Color::WHITE),
+ style: stroke::Style::Solid(palette.primary.weak.text),
line_cap: LineCap::Round,
..Stroke::default()
}
@@ -120,7 +126,7 @@ impl<Message> canvas::Program<Message> for Clock {
let wide_stroke = || -> Stroke {
Stroke {
width: width * 3.0,
- style: stroke::Style::Solid(Color::WHITE),
+ style: stroke::Style::Solid(palette.primary.weak.text),
line_cap: LineCap::Round,
..Stroke::default()
}