Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "snapdash"
version = "0.0.9"
version = "0.0.10"
edition = "2024"
authors = ["Lukáš Svoboda <opensource@schizza.cz>"]
license = "Apache-2.0"
Expand Down
29 changes: 14 additions & 15 deletions src/ui/entity_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,22 @@ fn status_line(p: Palette, connected: bool) -> Element<'static, Message> {
row![dot].spacing(8).align_y(Alignment::End).into()
}

fn pulse_border(p: Palette, pulse: f32) -> iced::Color {
/// Ring pulse color for the card border.
///
/// Normal/Low widgets rest faint and flash to accent on a state update
/// (dimmed → accent → dimmed). High-priority widgets rest on a steady
/// accent ring and *invert* the pulse — they dip to dimmed and return
/// (accent → dimmed → accent) — so the update feedback survives the
/// always-on emphasis ring.
fn pulse_border(p: Palette, pulse: f32, priority: Priority) -> iced::Color {
let t = pulse.clamp(0.0, 1.0);

let a = 0.10 + 0.55 * t;
let a = match priority {
Priority::Low | Priority::Normal => 0.15 + 0.55 * t,
Priority::High => 0.65 - 0.50 * t,
};

iced::Color {
r: p.accent.r,
g: p.accent.g,
b: p.accent.b,
a,
}
iced::Color { a, ..p.accent }
}

pub fn view(
Expand Down Expand Up @@ -127,13 +132,7 @@ pub fn view(
let disconnected_text =
components::error_message("You are disconected from Home Assistant!", p);

let ring = match priority {
Priority::High => iced::Color {
a: 0.55,
..p.accent
},
_ => pulse_border(p, state.pulse.value()),
};
let ring = pulse_border(p, state.pulse.value(), priority);

let inner = column![
title_text,
Expand Down
Loading