mirror of
https://github.com/danbulant/despot
synced 2026-06-19 06:21:01 +00:00
add basic styles
This commit is contained in:
parent
2ccd472484
commit
75a3a36e9b
3 changed files with 56 additions and 39 deletions
36
Cargo.lock
generated
36
Cargo.lock
generated
|
|
@ -2372,9 +2372,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
|
|||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "0.14.30"
|
||||
version = "0.14.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9"
|
||||
checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
|
|
@ -2396,9 +2396,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "1.4.1"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05"
|
||||
checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
|
|
@ -2424,7 +2424,7 @@ dependencies = [
|
|||
"futures-util",
|
||||
"headers",
|
||||
"http 1.1.0",
|
||||
"hyper 1.4.1",
|
||||
"hyper 1.5.0",
|
||||
"hyper-rustls 0.26.0",
|
||||
"hyper-util",
|
||||
"pin-project-lite",
|
||||
|
|
@ -2443,7 +2443,7 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590"
|
|||
dependencies = [
|
||||
"futures-util",
|
||||
"http 0.2.12",
|
||||
"hyper 0.14.30",
|
||||
"hyper 0.14.31",
|
||||
"rustls 0.21.12",
|
||||
"tokio",
|
||||
"tokio-rustls 0.24.1",
|
||||
|
|
@ -2457,7 +2457,7 @@ checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c"
|
|||
dependencies = [
|
||||
"futures-util",
|
||||
"http 1.1.0",
|
||||
"hyper 1.4.1",
|
||||
"hyper 1.5.0",
|
||||
"hyper-util",
|
||||
"log",
|
||||
"rustls 0.22.4",
|
||||
|
|
@ -2476,7 +2476,7 @@ checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333"
|
|||
dependencies = [
|
||||
"futures-util",
|
||||
"http 1.1.0",
|
||||
"hyper 1.4.1",
|
||||
"hyper 1.5.0",
|
||||
"hyper-util",
|
||||
"log",
|
||||
"rustls 0.23.14",
|
||||
|
|
@ -2495,7 +2495,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0"
|
|||
dependencies = [
|
||||
"bytes",
|
||||
"http-body-util",
|
||||
"hyper 1.4.1",
|
||||
"hyper 1.5.0",
|
||||
"hyper-util",
|
||||
"native-tls",
|
||||
"tokio",
|
||||
|
|
@ -2514,7 +2514,7 @@ dependencies = [
|
|||
"futures-util",
|
||||
"http 1.1.0",
|
||||
"http-body 1.0.1",
|
||||
"hyper 1.4.1",
|
||||
"hyper 1.5.0",
|
||||
"pin-project-lite",
|
||||
"socket2",
|
||||
"tokio",
|
||||
|
|
@ -2871,7 +2871,7 @@ dependencies = [
|
|||
"futures-core",
|
||||
"futures-util",
|
||||
"http-body-util",
|
||||
"hyper 1.4.1",
|
||||
"hyper 1.5.0",
|
||||
"hyper-util",
|
||||
"librespot-core",
|
||||
"log",
|
||||
|
|
@ -2900,7 +2900,7 @@ dependencies = [
|
|||
"http 1.1.0",
|
||||
"http-body-util",
|
||||
"httparse",
|
||||
"hyper 1.4.1",
|
||||
"hyper 1.5.0",
|
||||
"hyper-proxy2",
|
||||
"hyper-rustls 0.27.3",
|
||||
"hyper-util",
|
||||
|
|
@ -4560,7 +4560,7 @@ dependencies = [
|
|||
"h2 0.3.26",
|
||||
"http 0.2.12",
|
||||
"http-body 0.4.6",
|
||||
"hyper 0.14.30",
|
||||
"hyper 0.14.31",
|
||||
"hyper-rustls 0.24.2",
|
||||
"ipnet",
|
||||
"js-sys",
|
||||
|
|
@ -4602,7 +4602,7 @@ dependencies = [
|
|||
"http 1.1.0",
|
||||
"http-body 1.0.1",
|
||||
"http-body-util",
|
||||
"hyper 1.4.1",
|
||||
"hyper 1.5.0",
|
||||
"hyper-rustls 0.27.3",
|
||||
"hyper-tls",
|
||||
"hyper-util",
|
||||
|
|
@ -4888,9 +4888,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rustls-pki-types"
|
||||
version = "1.9.0"
|
||||
version = "1.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e696e35370c65c9c541198af4543ccd580cf17fc25d8e05c5a242b202488c55"
|
||||
checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b"
|
||||
|
||||
[[package]]
|
||||
name = "rustls-webpki"
|
||||
|
|
@ -4916,9 +4916,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.17"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6"
|
||||
checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248"
|
||||
|
||||
[[package]]
|
||||
name = "rustybuzz"
|
||||
|
|
|
|||
|
|
@ -2,4 +2,9 @@ use cushy::styles::Color;
|
|||
|
||||
|
||||
pub const TEXT_SPOTIFY: Color = Color(0x1DB954FF);
|
||||
pub const BG_DEFAULT: Color = Color(0x191724FF);
|
||||
pub const BG_DEFAULT: Color = Color(0x191724FF);
|
||||
|
||||
pub const LIBRARY_BG_SELECTED_HOVER: Color = Color(0x484848FF);
|
||||
pub const LIBRARY_BG_SELECTED: Color = Color(0x2A2A2AFF);
|
||||
pub const LIBRARY_BG_HOVER: Color = Color(0x1F1F1FFF);
|
||||
pub const LIBRARY_BG: Color = Color(0x121212FF);
|
||||
|
|
@ -1,20 +1,16 @@
|
|||
use cushy::{styles::components::WidgetBackground, value::{Destination, Dynamic, IntoDynamic, IntoValue, Source, Value}, widget::{MakeWidget, WidgetList}, widgets::{grid::Orientation, Image, Stack}};
|
||||
use cushy::{value::{Destination, Dynamic, IntoDynamic, IntoValue, Source, Value}, widget::{MakeWidget, WidgetList}, widgets::{button::{ButtonBackground, ButtonHoverBackground}, grid::Orientation, Image, Stack}};
|
||||
use rspotify::model::SimplifiedPlaylist;
|
||||
use cushy::kludgine::Color;
|
||||
|
||||
use crate::widgets::{image::ImageExt, ActivePage, SelectedPage};
|
||||
use crate::{theme::{LIBRARY_BG, LIBRARY_BG_HOVER, LIBRARY_BG_SELECTED, LIBRARY_BG_SELECTED_HOVER}, widgets::{image::ImageExt, ActivePage, SelectedPage}};
|
||||
|
||||
fn playlist_entry(playlist: impl IntoValue<SimplifiedPlaylist>, selected_page: SelectedPage) -> impl MakeWidget {
|
||||
let playlist: Value<SimplifiedPlaylist> = playlist.into_value();
|
||||
let id = playlist.map(|p| p.id.clone());
|
||||
let background = selected_page.map_each(move |page| {
|
||||
match page {
|
||||
ActivePage::Playlist(p) if p.id == id => {
|
||||
Color(0xFFFFFF10)
|
||||
}
|
||||
_ => Color::CLEAR_WHITE
|
||||
}
|
||||
});
|
||||
let is_active = selected_page.map_each(move |page|
|
||||
matches!(page, ActivePage::Playlist(p) if p.id == id)
|
||||
);
|
||||
let (background, background_hover) = get_colors(is_active);
|
||||
Image::new_empty()
|
||||
.with_url(
|
||||
playlist
|
||||
|
|
@ -33,7 +29,8 @@ fn playlist_entry(playlist: impl IntoValue<SimplifiedPlaylist>, selected_page: S
|
|||
.on_click(move |_| {
|
||||
selected_page.set(ActivePage::Playlist(playlist.get()));
|
||||
})
|
||||
.with(&WidgetBackground, background)
|
||||
.with(&ButtonBackground, background)
|
||||
.with(&ButtonHoverBackground, background_hover)
|
||||
}
|
||||
|
||||
pub fn playlists_widget(playlists: impl IntoValue<Vec<SimplifiedPlaylist>>, selected_page: SelectedPage) -> impl MakeWidget {
|
||||
|
|
@ -52,14 +49,8 @@ pub fn playlists_widget(playlists: impl IntoValue<Vec<SimplifiedPlaylist>>, sele
|
|||
}
|
||||
|
||||
pub fn liked_songs_entry(selected_page: SelectedPage) -> impl MakeWidget {
|
||||
let background = selected_page.map_each(move |page| {
|
||||
match page {
|
||||
ActivePage::LikedSongs => {
|
||||
Color(0xFFFFFF10)
|
||||
}
|
||||
_ => Color::CLEAR_WHITE
|
||||
}
|
||||
});
|
||||
let is_active = selected_page.map_each(|page| matches!(page, ActivePage::LikedSongs));
|
||||
let (background, background_hover) = get_colors(is_active);
|
||||
Image::new_empty()
|
||||
.with_url(
|
||||
Dynamic::new(Some("https://misc.scdn.co/liked-songs/liked-songs-300.png".to_string()))
|
||||
|
|
@ -74,5 +65,26 @@ pub fn liked_songs_entry(selected_page: SelectedPage) -> impl MakeWidget {
|
|||
.on_click(move |_| {
|
||||
selected_page.set(ActivePage::LikedSongs);
|
||||
})
|
||||
.with(&WidgetBackground, background)
|
||||
.with(&ButtonBackground, background)
|
||||
.with(&ButtonHoverBackground, background_hover)
|
||||
}
|
||||
|
||||
/// Returns `background` and `background_hover` colors for a library entry.
|
||||
fn get_colors(is_active: impl IntoValue<bool>) -> (Value<Color>, Value<Color>) {
|
||||
let is_active= is_active.into_value();
|
||||
let background = is_active.map_each(|active| {
|
||||
if *active {
|
||||
LIBRARY_BG_SELECTED
|
||||
} else {
|
||||
LIBRARY_BG
|
||||
}
|
||||
});
|
||||
let background_hover = is_active.map_each(|active| {
|
||||
if *active {
|
||||
LIBRARY_BG_SELECTED_HOVER
|
||||
} else {
|
||||
LIBRARY_BG_HOVER
|
||||
}
|
||||
});
|
||||
(background, background_hover)
|
||||
}
|
||||
Loading…
Reference in a new issue