feat: 1:1 For You, My Collection, Concerts, Books & Podcasts, WordsCardFullscreen and release v0.1.2
This commit is contained in:
parent
8e7ec9142f
commit
e9aa253f72
12 changed files with 4393 additions and 593 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -6325,7 +6325,7 @@ checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9"
|
|||
|
||||
[[package]]
|
||||
name = "yandex-music-rs"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"anyhow",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "yandex-music-rs"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
edition = "2021"
|
||||
description = "Native high-performance, ultra-low-RAM Yandex Music desktop client in Rust + ash Vulkan SDF + taffy + cosmic-text"
|
||||
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@
|
|||
|
||||
Готовые сборки доступны на странице [Releases](https://git.tatar/marwy/yandex-music-rs/releases):
|
||||
|
||||
- **Windows (x64)**: скачайте `yandex-music-rs-v0.1.1-windows-x86_64.exe` и запустите (переносной файл, установка не требуется).
|
||||
- **Linux (Debian / Ubuntu x64)**: скачайте `yandex-music-rs_0.1.1-1_amd64.deb` и установите:
|
||||
- **Windows (x64)**: скачайте `yandex-music-rs-v0.1.2-windows-x86_64.exe` и запустите (переносной файл, установка не требуется).
|
||||
- **Linux (Debian / Ubuntu x64)**: скачайте `yandex-music-rs_0.1.2-1_amd64.deb` и установите:
|
||||
```bash
|
||||
sudo apt install ./yandex-music-rs_0.1.1-1_amd64.deb
|
||||
sudo apt install ./yandex-music-rs_0.1.2-1_amd64.deb
|
||||
```
|
||||
- **Linux (generic x64)**: архив `yandex-music-rs-v0.1.1-linux-x86_64.tar.gz` с готовым бинарником.
|
||||
- **Linux (generic x64)**: архив `yandex-music-rs-v0.1.2-linux-x86_64.tar.gz` с готовым бинарником.
|
||||
|
||||
## Стек и возможности
|
||||
|
||||
|
|
|
|||
|
|
@ -330,6 +330,8 @@ pub fn demo_landing() -> LandingData {
|
|||
vibe_tracks,
|
||||
podcasts,
|
||||
kids_playlists,
|
||||
rich_new_releases: Vec::new(),
|
||||
vibe_pick_tabs: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
984
src/api/mod.rs
984
src/api/mod.rs
File diff suppressed because it is too large
Load diff
|
|
@ -184,6 +184,53 @@ pub struct LandingData {
|
|||
pub vibe_tracks: Vec<Track>,
|
||||
pub podcasts: Vec<AlbumSummary>,
|
||||
pub kids_playlists: Vec<PlaylistSummary>,
|
||||
#[serde(default)]
|
||||
pub rich_new_releases: Vec<NewReleaseItem>,
|
||||
#[serde(default)]
|
||||
pub vibe_pick_tabs: Vec<VibePickTab>,
|
||||
}
|
||||
|
||||
/// Rich editorial new release item from `GET /landing/skeleton/web_main` (`NEW_RELEASES`).
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct NewReleaseItem {
|
||||
pub album: AlbumSummary,
|
||||
#[serde(default)]
|
||||
pub artist_cover_uri: Option<String>,
|
||||
#[serde(default)]
|
||||
pub cover_color: Option<String>,
|
||||
#[serde(default)]
|
||||
pub release_date: Option<String>,
|
||||
}
|
||||
|
||||
/// Single My Vibe wave pick item from `WAVES` / `SETS_BY_WAVES` skeleton block.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct VibePickItem {
|
||||
pub title: String,
|
||||
pub header: String,
|
||||
pub seeds: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub color_hex: Option<String>,
|
||||
#[serde(default)]
|
||||
pub background_image_url: Option<String>,
|
||||
#[serde(default)]
|
||||
pub image_url: Option<String>,
|
||||
}
|
||||
|
||||
/// Category tab inside `More Picks` (`Ещё подборки`) from `WAVES` / `SETS_BY_WAVES`.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct VibePickTab {
|
||||
pub title: String,
|
||||
pub items: Vec<VibePickItem>,
|
||||
}
|
||||
|
||||
/// Section block on the Books & Podcasts (`non_music`) landing page.
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||
pub struct NonMusicSection {
|
||||
pub id: String,
|
||||
pub title: String,
|
||||
pub block_type: String,
|
||||
pub albums: Vec<AlbumSummary>,
|
||||
pub playlists: Vec<PlaylistSummary>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
@ -264,7 +311,7 @@ pub struct PlayTelemetryEvent {
|
|||
pub batch_id: Option<String>,
|
||||
}
|
||||
|
||||
/// Concert item returned by `GET /concerts/feed`
|
||||
/// Concert item returned by `GET /concerts/feed` or `GET /landing/skeleton/concerts`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ConcertItem {
|
||||
pub id: String,
|
||||
|
|
@ -275,6 +322,18 @@ pub struct ConcertItem {
|
|||
pub date: String,
|
||||
pub cover_uri: Option<String>,
|
||||
pub afisha_url: Option<String>,
|
||||
#[serde(default)]
|
||||
pub min_price: Option<u64>,
|
||||
#[serde(default)]
|
||||
pub currency: Option<String>,
|
||||
#[serde(default)]
|
||||
pub cashback_percent: Option<u32>,
|
||||
#[serde(default)]
|
||||
pub cashback_title: Option<String>,
|
||||
#[serde(default)]
|
||||
pub cover_color: Option<String>,
|
||||
#[serde(default)]
|
||||
pub event_kind: Option<String>,
|
||||
}
|
||||
|
||||
fn default_wheel_item_type() -> String {
|
||||
|
|
|
|||
101
src/app/state.rs
101
src/app/state.rs
|
|
@ -248,6 +248,12 @@ pub enum AppAction {
|
|||
title: String,
|
||||
seeds: Vec<String>,
|
||||
},
|
||||
StartVibeStation {
|
||||
title: String,
|
||||
seeds: Vec<String>,
|
||||
},
|
||||
RefreshConcerts,
|
||||
RefreshNonMusic,
|
||||
ApplyVibeSettings {
|
||||
mood: Option<String>,
|
||||
activity: Option<String>,
|
||||
|
|
@ -387,6 +393,7 @@ pub(crate) enum ApiEvent {
|
|||
AccountLoaded(Result<UserAccount, String>),
|
||||
LandingLoaded(LandingData),
|
||||
ConcertsLoaded(Vec<ConcertItem>),
|
||||
NonMusicLoaded(Vec<NonMusicSection>, Vec<AlbumSummary>),
|
||||
SearchHistoryLoaded(Vec<String>),
|
||||
LikedTracksLoaded(Vec<Track>),
|
||||
FavoriteFiltersLoaded(Vec<TrackFilterChip>),
|
||||
|
|
@ -474,6 +481,9 @@ pub struct AppState {
|
|||
pub account: Option<UserAccount>,
|
||||
pub landing: LandingData,
|
||||
pub concerts: Vec<ConcertItem>,
|
||||
pub concerts_loading: bool,
|
||||
pub non_music_sections: Vec<NonMusicSection>,
|
||||
pub non_music_loading: bool,
|
||||
pub liked_tracks: Vec<Track>,
|
||||
pub liked_ids: HashSet<String>,
|
||||
pub disliked_ids: HashSet<String>,
|
||||
|
|
@ -627,6 +637,9 @@ impl AppState {
|
|||
account: None,
|
||||
landing: LandingData::default(),
|
||||
concerts: Vec::new(),
|
||||
concerts_loading: false,
|
||||
non_music_sections: Vec::new(),
|
||||
non_music_loading: false,
|
||||
liked_tracks: Vec::new(),
|
||||
liked_ids: HashSet::new(),
|
||||
disliked_ids: HashSet::new(),
|
||||
|
|
@ -774,6 +787,9 @@ impl AppState {
|
|||
account,
|
||||
landing,
|
||||
concerts: Vec::new(),
|
||||
concerts_loading: false,
|
||||
non_music_sections: Vec::new(),
|
||||
non_music_loading: false,
|
||||
liked_tracks,
|
||||
liked_ids,
|
||||
disliked_ids: HashSet::new(),
|
||||
|
|
@ -1289,9 +1305,16 @@ impl AppState {
|
|||
let api = self.api.clone();
|
||||
let tx = self.tx_api.clone();
|
||||
self.runtime.spawn(async move {
|
||||
if let Ok(concerts) = api.fetch_concerts_feed().await {
|
||||
let _ = tx.send(ApiEvent::ConcertsLoaded(concerts));
|
||||
}
|
||||
let concerts = api.fetch_concerts_feed().await.unwrap_or_default();
|
||||
let _ = tx.send(ApiEvent::ConcertsLoaded(concerts));
|
||||
});
|
||||
}
|
||||
{
|
||||
let api = self.api.clone();
|
||||
let tx = self.tx_api.clone();
|
||||
self.runtime.spawn(async move {
|
||||
let (sections, albums) = api.fetch_non_music_landing().await.unwrap_or_default();
|
||||
let _ = tx.send(ApiEvent::NonMusicLoaded(sections, albums));
|
||||
});
|
||||
}
|
||||
{
|
||||
|
|
@ -1637,12 +1660,53 @@ impl AppState {
|
|||
}
|
||||
});
|
||||
}
|
||||
Route::Concerts => {
|
||||
self.detail_loading = false;
|
||||
if self.concerts.is_empty() && !self.concerts_loading {
|
||||
self.refresh_concerts();
|
||||
}
|
||||
}
|
||||
Route::Podcasts => {
|
||||
self.detail_loading = false;
|
||||
if self.non_music_sections.is_empty() && !self.non_music_loading {
|
||||
self.refresh_non_music();
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
self.detail_loading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn refresh_concerts(&mut self) {
|
||||
self.concerts_loading = true;
|
||||
let api = self.api.clone();
|
||||
let tx = self.tx_api.clone();
|
||||
self.runtime.spawn(async move {
|
||||
let concerts = api.fetch_concerts_feed().await.unwrap_or_default();
|
||||
let _ = tx.send(ApiEvent::ConcertsLoaded(concerts));
|
||||
});
|
||||
}
|
||||
|
||||
pub fn refresh_non_music(&mut self) {
|
||||
self.non_music_loading = true;
|
||||
let api = self.api.clone();
|
||||
let tx = self.tx_api.clone();
|
||||
self.runtime.spawn(async move {
|
||||
let (sections, albums) = api.fetch_non_music_landing().await.unwrap_or_default();
|
||||
let _ = tx.send(ApiEvent::NonMusicLoaded(sections, albums));
|
||||
});
|
||||
if self.api.has_token() {
|
||||
let api = self.api.clone();
|
||||
let tx = self.tx_api.clone();
|
||||
self.runtime.spawn(async move {
|
||||
if let Ok(shelf) = api.fetch_bookshelf_liked().await {
|
||||
let _ = tx.send(ApiEvent::BookshelfLoaded(shelf));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pub fn launch_oauth_login(&mut self) {
|
||||
self.show_toast(self.i18n().toast_opening_oauth());
|
||||
let tx = self.tx_api.clone();
|
||||
|
|
@ -1717,6 +1781,12 @@ impl AppState {
|
|||
self.show_toast(t.toast_welcome(&acc.display_name));
|
||||
self.account = Some(acc);
|
||||
self.ensure_words_for_current_track();
|
||||
if self.concerts.is_empty() && !self.concerts_loading {
|
||||
self.refresh_concerts();
|
||||
}
|
||||
if self.non_music_sections.is_empty() && !self.non_music_loading {
|
||||
self.refresh_non_music();
|
||||
}
|
||||
}
|
||||
ApiEvent::AccountLoaded(Err(e)) => {
|
||||
self.show_toast(if t.is_ru() {
|
||||
|
|
@ -1726,7 +1796,19 @@ impl AppState {
|
|||
});
|
||||
}
|
||||
ApiEvent::ConcertsLoaded(concerts) => {
|
||||
self.concerts = concerts;
|
||||
self.concerts_loading = false;
|
||||
if !concerts.is_empty() || self.concerts.is_empty() {
|
||||
self.concerts = concerts;
|
||||
}
|
||||
}
|
||||
ApiEvent::NonMusicLoaded(sections, albums) => {
|
||||
self.non_music_loading = false;
|
||||
if !sections.is_empty() {
|
||||
self.non_music_sections = sections;
|
||||
}
|
||||
if !albums.is_empty() {
|
||||
self.landing.podcasts = albums;
|
||||
}
|
||||
}
|
||||
ApiEvent::SearchHistoryLoaded(hist) => {
|
||||
self.config.search_history = hist;
|
||||
|
|
@ -1777,6 +1859,10 @@ impl AppState {
|
|||
self.queue_index = 0;
|
||||
}
|
||||
}
|
||||
let mut data = data;
|
||||
if data.podcasts.is_empty() && !self.landing.podcasts.is_empty() {
|
||||
data.podcasts = self.landing.podcasts.clone();
|
||||
}
|
||||
self.landing = data;
|
||||
}
|
||||
ApiEvent::LikedTracksLoaded(tracks) => {
|
||||
|
|
@ -2419,7 +2505,12 @@ impl AppState {
|
|||
}
|
||||
AppAction::ActivateWheelItem(item) => self.activate_wheel_item(item),
|
||||
AppAction::ReshuffleWheel => self.reshuffle_wheel(),
|
||||
AppAction::StartVibeBySeeds { title, seeds } => self.start_vibe_by_seeds(title, seeds),
|
||||
AppAction::StartVibeBySeeds { title, seeds }
|
||||
| AppAction::StartVibeStation { title, seeds } => {
|
||||
self.start_vibe_by_seeds(title, seeds);
|
||||
}
|
||||
AppAction::RefreshConcerts => self.refresh_concerts(),
|
||||
AppAction::RefreshNonMusic => self.refresh_non_music(),
|
||||
AppAction::ApplyVibeSettings {
|
||||
mood,
|
||||
activity,
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,3 +1,6 @@
|
|||
use std::cell::Cell;
|
||||
|
||||
use crate::api::models::{NewReleaseItem, VibePickItem, VibePickTab};
|
||||
use crate::app::state::{AppAction, AppState, CollectionTab, ForYouTab, Route};
|
||||
use crate::covers::CoverCache;
|
||||
use crate::engine::input::WidgetId;
|
||||
|
|
@ -9,7 +12,11 @@ use crate::engine::widgets::{
|
|||
};
|
||||
use crate::engine::UiContext;
|
||||
use crate::icons::Icon;
|
||||
use crate::views::overlays::ShellUiState;
|
||||
use crate::views::overlays::{EntityContextMenuState, ShellUiState};
|
||||
|
||||
thread_local! {
|
||||
static FOR_YOU_PICKS_TAB: Cell<usize> = const { Cell::new(0) };
|
||||
}
|
||||
|
||||
/// Exact Yandex Music Desktop 5.129.0 "For you and Trends" page (`vibe_wheel_foryou_spec.md` §4):
|
||||
/// - Persistent heading ("Для вас и Тренды" / "For you and Trends") + IN-PLACE switcher tabs ("Для вас" / "Тренды")
|
||||
|
|
@ -496,10 +503,15 @@ pub fn render_for_you(
|
|||
y += card_h + 26.0;
|
||||
}
|
||||
|
||||
// 5. "New Releases"
|
||||
if !app.landing.new_releases.is_empty() {
|
||||
y = render_new_releases_carousel(ctx, pal, covers, app, x, y, avail_w, "fy_rel", actions);
|
||||
// 5. "New Releases >" (1-to-1 official `NewRelease` + `NewReleaseCard` circular portrait + colored release card!)
|
||||
if !app.landing.rich_new_releases.is_empty() || !app.landing.new_releases.is_empty() {
|
||||
y = render_new_releases_carousel(
|
||||
ctx, pal, covers, app, shell, rect, x, y, avail_w, "fy_rel", actions,
|
||||
);
|
||||
}
|
||||
|
||||
// 6. Official "More Picks" / "Ещё подборки" (`Waves` / `SETS_BY_WAVES`)
|
||||
y = render_more_picks_section(ctx, pal, app, rect, x, y, avail_w, actions);
|
||||
}
|
||||
|
||||
ForYouTab::Trends => {
|
||||
|
|
@ -606,12 +618,14 @@ pub fn render_for_you(
|
|||
}
|
||||
|
||||
// 2. New Releases Carousel
|
||||
if !app.landing.new_releases.is_empty() {
|
||||
if !app.landing.rich_new_releases.is_empty() || !app.landing.new_releases.is_empty() {
|
||||
y = render_new_releases_carousel(
|
||||
ctx,
|
||||
pal,
|
||||
covers,
|
||||
app,
|
||||
shell,
|
||||
rect,
|
||||
x,
|
||||
y,
|
||||
avail_w,
|
||||
|
|
@ -678,9 +692,162 @@ pub fn render_for_you(
|
|||
}
|
||||
|
||||
y += 20.0;
|
||||
let _ = CornerRadii::ZERO;
|
||||
let total_h = y - (rect.top() - scroll_y);
|
||||
ctx.end_scroll_v(scroll_id, pal, total_h, true);
|
||||
|
||||
// Sticky Frosted Top Switcher Bar when scrolled (`scroll_y > 72.0` -> zero impact on `scroll_y == 0` parity!)
|
||||
if scroll_y > 72.0 {
|
||||
let fade_in = ((scroll_y - 72.0) / 36.0).clamp(0.0, 1.0);
|
||||
let bar_r = Rect::from_xywh(
|
||||
rect.left() - 25.0,
|
||||
rect.top() - 12.0,
|
||||
rect.width() + 50.0,
|
||||
66.0,
|
||||
);
|
||||
// Subtle atmospheric gradient glow behind the frosted sticky bar
|
||||
let glow_c = if pal.is_dark {
|
||||
Color::rgb(0x4E, 0x35, 0x62)
|
||||
} else {
|
||||
Color::rgb(0xD8, 0xD2, 0xE8)
|
||||
};
|
||||
ctx.dl().push_gradient_rect(
|
||||
bar_r,
|
||||
CornerRadii::top(12.0),
|
||||
glow_c.with_alpha((54.0 * fade_in).round() as u8),
|
||||
glow_c.with_alpha(0),
|
||||
Vec2::new(0.0, 1.0),
|
||||
);
|
||||
let glass_tint = if pal.is_dark {
|
||||
css_rgba(18, 18, 18, (186.0 * fade_in).round() as u8)
|
||||
} else {
|
||||
css_rgba(255, 255, 255, (206.0 * fade_in).round() as u8)
|
||||
};
|
||||
ctx.dl().push_backdrop_blur(
|
||||
bar_r,
|
||||
CornerRadii::top(12.0),
|
||||
2.0,
|
||||
glass_tint,
|
||||
0.0,
|
||||
Color::TRANSPARENT,
|
||||
);
|
||||
ctx.dl().push_rect(
|
||||
Rect::from_xywh(bar_r.left(), bar_r.bottom() - 1.0, bar_r.width(), 1.0),
|
||||
0.0,
|
||||
pal.border_subtle.scale_alpha(fade_in),
|
||||
);
|
||||
|
||||
let mut sx = x;
|
||||
let sy = bar_r.center_y() - 19.0;
|
||||
for (tab_kind, label) in [
|
||||
(ForYouTab::ForYou, t.for_you()),
|
||||
(ForYouTab::Trends, t.trends()),
|
||||
] {
|
||||
let active = app.for_you_tab == tab_kind;
|
||||
let tw = ctx
|
||||
.measure_text(label, TextStyle::bold(14.5, pal.text_primary), None)
|
||||
.x
|
||||
+ 32.0;
|
||||
let pr = Rect::from_xywh(sx, sy, tw.max(88.0), 38.0);
|
||||
let resp = ctx.interact(WidgetId::from_pair("fy_sticky_tab", tab_kind as u8), pr);
|
||||
if active || resp.hovered {
|
||||
ctx.dl().push_rect(
|
||||
pr,
|
||||
19.0,
|
||||
if active {
|
||||
pal.surface_hover
|
||||
} else {
|
||||
pal.surface_secondary
|
||||
},
|
||||
);
|
||||
}
|
||||
ctx.draw_text_ellipsis(
|
||||
label,
|
||||
TextStyle::bold(
|
||||
14.5,
|
||||
if active || resp.hovered {
|
||||
pal.text_bright
|
||||
} else {
|
||||
pal.text_secondary
|
||||
},
|
||||
),
|
||||
pr,
|
||||
TextAlign::Center,
|
||||
);
|
||||
if resp.hovered {
|
||||
ctx.set_cursor(CursorKind::Pointer);
|
||||
}
|
||||
if resp.clicked && !active {
|
||||
actions.push(AppAction::SetForYouTab(tab_kind));
|
||||
}
|
||||
sx = pr.right() + 8.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn rich_dark_tint(raw: Color) -> Color {
|
||||
// Rich dark-saturated card tint (~24% lightness) keeping high contrast for white album text
|
||||
let r = (raw.r as f32 / 255.0).clamp(0.0, 1.0);
|
||||
let g = (raw.g as f32 / 255.0).clamp(0.0, 1.0);
|
||||
let b = (raw.b as f32 / 255.0).clamp(0.0, 1.0);
|
||||
let max_c = r.max(g).max(b);
|
||||
let min_c = r.min(g).min(b);
|
||||
let avg = (max_c + min_c) * 0.5;
|
||||
// Slightly boost chroma then scale luminance into ~0.22..0.28 range
|
||||
let sat_r = (avg + (r - avg) * 1.25).clamp(0.0, 1.0);
|
||||
let sat_g = (avg + (g - avg) * 1.25).clamp(0.0, 1.0);
|
||||
let sat_b = (avg + (b - avg) * 1.25).clamp(0.0, 1.0);
|
||||
let luma = (0.299 * sat_r + 0.587 * sat_g + 0.114 * sat_b).max(0.01);
|
||||
let scale = (0.24 / luma).clamp(0.28, 0.95);
|
||||
Color::rgb(
|
||||
((sat_r * scale).clamp(0.08, 0.48) * 255.0).round() as u8,
|
||||
((sat_g * scale).clamp(0.08, 0.48) * 255.0).round() as u8,
|
||||
((sat_b * scale).clamp(0.08, 0.48) * 255.0).round() as u8,
|
||||
)
|
||||
}
|
||||
|
||||
fn format_release_subtitle(item: &NewReleaseItem, ru: bool) -> String {
|
||||
let is_single = item
|
||||
.album
|
||||
.content_type
|
||||
.as_deref()
|
||||
.map_or(false, |ct| ct.eq_ignore_ascii_case("single"))
|
||||
|| (item.album.track_count > 0 && item.album.track_count <= 3);
|
||||
let kind = if is_single {
|
||||
if ru { "сингл" } else { "single" }
|
||||
} else if ru {
|
||||
"альбом"
|
||||
} else {
|
||||
"album"
|
||||
};
|
||||
|
||||
if let Some(ref rd) = item.release_date {
|
||||
let date_part = rd.split('T').next().unwrap_or(rd);
|
||||
let parts: Vec<&str> = date_part.split('-').collect();
|
||||
if parts.len() >= 3 {
|
||||
if let (Ok(m), Ok(d)) = (parts[1].parse::<usize>(), parts[2].parse::<u32>()) {
|
||||
if (1..=12).contains(&m) && d > 0 {
|
||||
const MONTHS_RU: [&str; 12] = [
|
||||
"января", "февраля", "марта", "апреля", "мая", "июня", "июля", "августа",
|
||||
"сентября", "октября", "ноября", "декабря",
|
||||
];
|
||||
const MONTHS_EN: [&str; 12] = [
|
||||
"January", "February", "March", "April", "May", "June", "July", "August",
|
||||
"September", "October", "November", "December",
|
||||
];
|
||||
return if ru {
|
||||
format!("{} · {} {}", kind, d, MONTHS_RU[m - 1])
|
||||
} else {
|
||||
format!("{} · {} {}", kind, MONTHS_EN[m - 1], d)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(yr) = item.album.year {
|
||||
format!("{} · {}", kind, yr)
|
||||
} else {
|
||||
kind.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
|
|
@ -689,6 +856,8 @@ fn render_new_releases_carousel(
|
|||
pal: &YmPalette,
|
||||
covers: &mut CoverCache,
|
||||
app: &AppState,
|
||||
shell: &mut ShellUiState,
|
||||
viewport: Rect,
|
||||
x: f32,
|
||||
mut y: f32,
|
||||
avail_w: f32,
|
||||
|
|
@ -696,58 +865,589 @@ fn render_new_releases_carousel(
|
|||
actions: &mut Vec<AppAction>,
|
||||
) -> f32 {
|
||||
let t = app.i18n();
|
||||
let ru = t.is_ru();
|
||||
let items: Vec<NewReleaseItem> = if !app.landing.rich_new_releases.is_empty() {
|
||||
app.landing.rich_new_releases.clone()
|
||||
} else {
|
||||
app.landing
|
||||
.new_releases
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(|album| NewReleaseItem {
|
||||
artist_cover_uri: album.artists.first().and_then(|a| a.cover_uri.clone()),
|
||||
cover_color: None,
|
||||
release_date: None,
|
||||
album,
|
||||
})
|
||||
.collect()
|
||||
};
|
||||
if items.is_empty() {
|
||||
return y;
|
||||
}
|
||||
|
||||
let h_id = WidgetId::new(salt);
|
||||
let card_w = 286.0_f32;
|
||||
let gap = 18.0_f32;
|
||||
let portrait_d = 236.0_f32;
|
||||
let overlap = 56.0_f32;
|
||||
let bottom_h = 80.0_f32;
|
||||
let card_h = portrait_d - overlap + bottom_h; // 260.0
|
||||
let total_w = items.len() as f32 * (card_w + gap);
|
||||
|
||||
// Header row: "New Releases >" + circular `<` `>` carousel arrows on right
|
||||
let head_txt = t.new_releases();
|
||||
let head_tw = ctx
|
||||
.measure_text(head_txt, TextStyle::headline(24.0, pal.text_primary), None)
|
||||
.x;
|
||||
ctx.draw_text_ellipsis(
|
||||
t.new_releases(),
|
||||
head_txt,
|
||||
TextStyle::headline(24.0, pal.text_primary),
|
||||
Rect::from_xywh(x, y, head_tw + 4.0, 30.0),
|
||||
TextAlign::Left,
|
||||
);
|
||||
ctx.draw_icon(
|
||||
Icon::ArrowRight,
|
||||
Rect::from_center_size(Pos2::new(x + head_tw + 16.0, y + 15.0), Vec2::splat(22.0)),
|
||||
pal.text_secondary,
|
||||
);
|
||||
|
||||
let (can_left, can_right) = ctx
|
||||
.scrolls
|
||||
.get(h_id)
|
||||
.map(|s| (s.can_scroll_left(), s.can_scroll_right()))
|
||||
.unwrap_or((false, total_w > avail_w + 10.0));
|
||||
let l_btn_c = Pos2::new(x + avail_w - 54.0, y + 15.0);
|
||||
let r_btn_c = Pos2::new(x + avail_w - 16.0, y + 15.0);
|
||||
for (c, ic, enabled, is_right) in [
|
||||
(l_btn_c, Icon::ArrowLeftXxs, can_left, false),
|
||||
(r_btn_c, Icon::ArrowRightXxs, can_right, true),
|
||||
] {
|
||||
let br = Rect::from_center_size(c, Vec2::splat(32.0));
|
||||
let resp = ctx.interact(WidgetId::from_pair(salt, if is_right { "next" } else { "prev" }), br);
|
||||
let bg = if enabled && resp.hovered {
|
||||
pal.surface_hover
|
||||
} else {
|
||||
pal.surface_secondary
|
||||
};
|
||||
ctx.dl().push_circle(c, 16.0, bg);
|
||||
ctx.draw_icon(
|
||||
ic,
|
||||
Rect::from_center_size(c, Vec2::splat(18.0)),
|
||||
if enabled {
|
||||
if resp.hovered { pal.text_bright } else { pal.text_primary }
|
||||
} else {
|
||||
pal.text_disabled
|
||||
},
|
||||
);
|
||||
if enabled && resp.hovered {
|
||||
ctx.set_cursor(CursorKind::Pointer);
|
||||
}
|
||||
if enabled && resp.clicked {
|
||||
let delta = if is_right { (card_w + gap) * 2.0 } else { -(card_w + gap) * 2.0 };
|
||||
ctx.scrolls.scroll_by_x(h_id, delta);
|
||||
ctx.request_repaint();
|
||||
}
|
||||
}
|
||||
y += 42.0;
|
||||
|
||||
let row_vp = Rect::from_xywh(x, y, avail_w, card_h);
|
||||
if row_vp.bottom() >= viewport.top() - 120.0 && row_vp.top() <= viewport.bottom() + 120.0 {
|
||||
let scroll_x = ctx.begin_scroll_h(h_id, row_vp, 0.0);
|
||||
let mut cx = x - scroll_x;
|
||||
for item in &items {
|
||||
let alb = &item.album;
|
||||
let outer_r = Rect::from_xywh(cx, y, card_w, card_h);
|
||||
if outer_r.right() >= row_vp.left() - 80.0 && outer_r.left() <= row_vp.right() + 80.0 {
|
||||
// 1. Huge 236x236 circular artist portrait overlapping the bottom card by 56px
|
||||
let circle_r = Rect::from_xywh(
|
||||
cx + (card_w - portrait_d) * 0.5,
|
||||
y,
|
||||
portrait_d,
|
||||
portrait_d,
|
||||
);
|
||||
let portrait_uri = item
|
||||
.artist_cover_uri
|
||||
.as_deref()
|
||||
.or(alb.cover_uri.as_deref());
|
||||
let (portrait_dom, _) = draw_cover_art(
|
||||
ctx,
|
||||
pal,
|
||||
covers,
|
||||
circle_r,
|
||||
portrait_uri,
|
||||
&format!("nr_art_{}", alb.id),
|
||||
portrait_d * 0.5,
|
||||
true,
|
||||
false,
|
||||
);
|
||||
|
||||
// Resolve rich dark-saturated tint from `cover_color` or cover dominant color
|
||||
let raw_tint = item
|
||||
.cover_color
|
||||
.as_deref()
|
||||
.and_then(Color::from_hex_str)
|
||||
.or_else(|| {
|
||||
alb.cover_uri
|
||||
.as_deref()
|
||||
.and_then(|u| covers.get_or_fetch(u, 200))
|
||||
.map(|(_, dom, _)| dom)
|
||||
})
|
||||
.unwrap_or(portrait_dom);
|
||||
let card_tint = rich_dark_tint(raw_tint);
|
||||
|
||||
// Smooth lower gradient fade over lower 42% of circular portrait
|
||||
ctx.push_clip(circle_r, portrait_d * 0.5);
|
||||
let scrim_h = portrait_d * 0.46;
|
||||
ctx.dl().push_gradient_rect(
|
||||
Rect::from_xywh(circle_r.left(), circle_r.bottom() - scrim_h, portrait_d, scrim_h),
|
||||
0.0,
|
||||
card_tint.with_alpha(0),
|
||||
card_tint.with_alpha(232),
|
||||
Vec2::new(0.0, 1.0),
|
||||
);
|
||||
ctx.pop_clip();
|
||||
|
||||
// Bold white centered Artist Name above the card overlap
|
||||
let artist_name = alb
|
||||
.artists
|
||||
.first()
|
||||
.map(|a| a.name.as_str())
|
||||
.unwrap_or(alb.title.as_str());
|
||||
let art_lbl_r = Rect::from_xywh(
|
||||
circle_r.left() + 18.0,
|
||||
y + portrait_d - overlap - 54.0,
|
||||
portrait_d - 36.0,
|
||||
50.0,
|
||||
);
|
||||
ctx.draw_text_wrapped(
|
||||
artist_name,
|
||||
TextStyle::headline(21.0, Color::WHITE).with_line_height(24.0),
|
||||
art_lbl_r,
|
||||
Some(2),
|
||||
TextAlign::Center,
|
||||
);
|
||||
|
||||
let port_click_r = Rect::from_xywh(circle_r.left(), circle_r.top(), portrait_d, portrait_d - overlap);
|
||||
let port_resp = ctx.interact(WidgetId::from_pair(salt, format!("port_{}", alb.id)), port_click_r);
|
||||
if port_resp.hovered {
|
||||
ctx.set_cursor(CursorKind::Pointer);
|
||||
}
|
||||
|
||||
// 2. Bottom 80px colored rounded release card (`radius: 14px`)
|
||||
let card_r = Rect::from_xywh(cx, y + portrait_d - overlap, card_w, bottom_h);
|
||||
let card_resp = ctx.interact(WidgetId::from_pair(salt, format!("card_{}", alb.id)), card_r);
|
||||
let card_bg = if card_resp.hovered {
|
||||
card_tint.lerp(Color::WHITE, 0.08)
|
||||
} else {
|
||||
card_tint
|
||||
};
|
||||
ctx.dl().push_shadow(
|
||||
card_r,
|
||||
14.0,
|
||||
12.0,
|
||||
0.0,
|
||||
Vec2::new(0.0, 4.0),
|
||||
css_rgba(0, 0, 0, 72),
|
||||
);
|
||||
ctx.dl().push_rect_bordered(
|
||||
card_r,
|
||||
14.0,
|
||||
card_bg,
|
||||
1.0,
|
||||
css_rgba(255, 255, 255, 26),
|
||||
);
|
||||
|
||||
// Left 62x62 rounded (8px) album cover
|
||||
let cov_r = Rect::from_xywh(card_r.left() + 9.0, card_r.top() + 9.0, 62.0, 62.0);
|
||||
draw_cover_art(
|
||||
ctx,
|
||||
pal,
|
||||
covers,
|
||||
cov_r,
|
||||
alb.cover_uri.as_deref(),
|
||||
&format!("nr_alb_{}", alb.id),
|
||||
8.0,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
|
||||
// Right 38x38 crisp white circular Play/Pause button
|
||||
let play_c = Pos2::new(card_r.right() - 28.0, card_r.center_y());
|
||||
let play_r = Rect::from_center_size(play_c, Vec2::splat(38.0));
|
||||
let play_resp = ctx.interact(WidgetId::from_pair(salt, format!("play_{}", alb.id)), play_r);
|
||||
let play_rad = if play_resp.hovered { 20.0 } else { 19.0 };
|
||||
ctx.dl().push_circle(play_c, play_rad, Color::WHITE);
|
||||
let alb_playing = app.is_context_playing(&format!("album:{}", alb.id));
|
||||
ctx.draw_icon(
|
||||
if alb_playing {
|
||||
Icon::PauseFilledXs
|
||||
} else {
|
||||
Icon::PlayFilledXs
|
||||
},
|
||||
Rect::from_center_size(play_c, Vec2::splat(18.0)),
|
||||
Color::rgb(0x14, 0x14, 0x14),
|
||||
);
|
||||
|
||||
// Middle bold white title + muted release subtitle
|
||||
let tx_l = cov_r.right() + 12.0;
|
||||
let tx_w = (play_r.left() - tx_l - 8.0).max(40.0);
|
||||
ctx.draw_text_ellipsis(
|
||||
&alb.title,
|
||||
TextStyle::bold(14.5, Color::WHITE),
|
||||
Rect::from_xywh(tx_l, card_r.top() + 18.0, tx_w, 20.0),
|
||||
TextAlign::Left,
|
||||
);
|
||||
let sub = format_release_subtitle(item, ru);
|
||||
ctx.draw_text_ellipsis(
|
||||
&sub,
|
||||
TextStyle::medium(12.5, css_rgba(255, 255, 255, 172)),
|
||||
Rect::from_xywh(tx_l, card_r.top() + 42.0, tx_w, 18.0),
|
||||
TextAlign::Left,
|
||||
);
|
||||
|
||||
if play_resp.hovered || card_resp.hovered {
|
||||
ctx.set_cursor(CursorKind::Pointer);
|
||||
}
|
||||
if card_resp.right_clicked {
|
||||
let pos = ctx
|
||||
.input
|
||||
.pointer_pos
|
||||
.unwrap_or(Pos2::new(card_r.center_x(), card_r.bottom()));
|
||||
shell.open_entity_menu(EntityContextMenuState {
|
||||
kind: "album".into(),
|
||||
id: alb.id.clone(),
|
||||
title: alb.title.clone(),
|
||||
subtitle: sub,
|
||||
cover_uri: alb.cover_uri.clone(),
|
||||
owner_uid: None,
|
||||
is_own_playlist: false,
|
||||
tracks: Vec::new(),
|
||||
anchor: pos,
|
||||
share_url: format!("https://music.yandex.ru/album/{}", alb.id),
|
||||
});
|
||||
} else if play_resp.clicked {
|
||||
actions.push(AppAction::PlayAlbum {
|
||||
id: alb.id.clone(),
|
||||
title: alb.title.clone(),
|
||||
});
|
||||
} else if card_resp.clicked {
|
||||
actions.push(AppAction::Navigate(Route::Album {
|
||||
id: alb.id.clone(),
|
||||
title: alb.title.clone(),
|
||||
}));
|
||||
} else if port_resp.clicked {
|
||||
if let Some(first) = alb.artists.first() {
|
||||
actions.push(AppAction::Navigate(Route::Artist {
|
||||
id: first.id.clone(),
|
||||
name: first.name.clone(),
|
||||
}));
|
||||
} else {
|
||||
actions.push(AppAction::Navigate(Route::Album {
|
||||
id: alb.id.clone(),
|
||||
title: alb.title.clone(),
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
cx += card_w + gap;
|
||||
}
|
||||
ctx.end_scroll_h(h_id, pal, total_w, false);
|
||||
}
|
||||
|
||||
y + card_h + 34.0
|
||||
}
|
||||
|
||||
fn fallback_vibe_pick_tabs(ru: bool) -> Vec<VibePickTab> {
|
||||
let mk = |title: &str, header: &str, seed: &str, hex: &str| VibePickItem {
|
||||
title: title.into(),
|
||||
header: header.into(),
|
||||
seeds: vec![seed.into()],
|
||||
color_hex: Some(hex.into()),
|
||||
background_image_url: None,
|
||||
image_url: None,
|
||||
};
|
||||
if ru {
|
||||
vec![
|
||||
VibePickTab {
|
||||
title: "топ".into(),
|
||||
items: vec![
|
||||
mk("Английский", "Моя волна по языку", "language:english", "#3F68F9"),
|
||||
mk("Электроника", "Моя волна по жанру", "genre:electronics", "#8341EF"),
|
||||
mk("Бодрое", "Моя волна по настроению", "mood:energetic", "#FF5C4D"),
|
||||
mk("Для работы", "Моя волна по занятию", "activity:work", "#0D9488"),
|
||||
mk("Незнакомое", "Моя волна по характеру", "diversity:discover", "#D97706"),
|
||||
],
|
||||
},
|
||||
VibePickTab {
|
||||
title: "по языку".into(),
|
||||
items: vec![
|
||||
mk("Английский", "Моя волна по языку", "language:english", "#3F68F9"),
|
||||
mk("Русский", "Моя волна по языку", "language:russian", "#E11D48"),
|
||||
mk("Без слов", "Моя волна по языку", "language:without-words", "#0F766E"),
|
||||
],
|
||||
},
|
||||
VibePickTab {
|
||||
title: "по жанру".into(),
|
||||
items: vec![
|
||||
mk("Электроника", "Моя волна по жанру", "genre:electronics", "#7C3AED"),
|
||||
mk("Хип-хоп", "Моя волна по жанру", "genre:hiphop", "#EA580C"),
|
||||
mk("Рок", "Моя волна по жанру", "genre:rock", "#DC2626"),
|
||||
mk("Поп", "Моя волна по жанру", "genre:pop", "#DB2777"),
|
||||
],
|
||||
},
|
||||
VibePickTab {
|
||||
title: "по настроению".into(),
|
||||
items: vec![
|
||||
mk("Бодрое", "Моя волна по настроению", "mood:energetic", "#F97316"),
|
||||
mk("Спокойное", "Моя волна по настроению", "mood:calm", "#2563EB"),
|
||||
mk("Весёлое", "Моя волна по настроению", "mood:fun", "#EAB308"),
|
||||
],
|
||||
},
|
||||
VibePickTab {
|
||||
title: "по занятию".into(),
|
||||
items: vec![
|
||||
mk("Для работы", "Моя волна по занятию", "activity:work", "#0D9488"),
|
||||
mk("Тренировка", "Моя волна по занятию", "activity:workout", "#E11D48"),
|
||||
mk("В дорогу", "Моя волна по занятию", "activity:road-trip", "#4F46E5"),
|
||||
],
|
||||
},
|
||||
VibePickTab {
|
||||
title: "по характеру".into(),
|
||||
items: vec![
|
||||
mk("Незнакомое", "Моя волна по характеру", "diversity:discover", "#8B5CF6"),
|
||||
mk("Любимое", "Моя волна по характеру", "diversity:favorite", "#EC4899"),
|
||||
mk("Популярное", "Моя волна по характеру", "diversity:popular", "#059669"),
|
||||
],
|
||||
},
|
||||
]
|
||||
} else {
|
||||
vec![
|
||||
VibePickTab {
|
||||
title: "top".into(),
|
||||
items: vec![
|
||||
mk("English", "My Vibe by language", "language:english", "#3F68F9"),
|
||||
mk("Electronic", "My Vibe by genre", "genre:electronics", "#8341EF"),
|
||||
mk("Energetic", "My Vibe by mood", "mood:energetic", "#FF5C4D"),
|
||||
mk("Focus & Work", "My Vibe by activity", "activity:work", "#0D9488"),
|
||||
mk("Discover", "My Vibe by character", "diversity:discover", "#D97706"),
|
||||
],
|
||||
},
|
||||
VibePickTab {
|
||||
title: "by language".into(),
|
||||
items: vec![
|
||||
mk("English", "My Vibe by language", "language:english", "#3F68F9"),
|
||||
mk("Russian", "My Vibe by language", "language:russian", "#E11D48"),
|
||||
mk("Instrumental", "My Vibe by language", "language:without-words", "#0F766E"),
|
||||
],
|
||||
},
|
||||
VibePickTab {
|
||||
title: "by genre".into(),
|
||||
items: vec![
|
||||
mk("Electronic", "My Vibe by genre", "genre:electronics", "#7C3AED"),
|
||||
mk("Hip-Hop", "My Vibe by genre", "genre:hiphop", "#EA580C"),
|
||||
mk("Rock", "My Vibe by genre", "genre:rock", "#DC2626"),
|
||||
mk("Pop", "My Vibe by genre", "genre:pop", "#DB2777"),
|
||||
],
|
||||
},
|
||||
VibePickTab {
|
||||
title: "by mood".into(),
|
||||
items: vec![
|
||||
mk("Energetic", "My Vibe by mood", "mood:energetic", "#F97316"),
|
||||
mk("Calm", "My Vibe by mood", "mood:calm", "#2563EB"),
|
||||
mk("Upbeat", "My Vibe by mood", "mood:fun", "#EAB308"),
|
||||
],
|
||||
},
|
||||
VibePickTab {
|
||||
title: "by activity".into(),
|
||||
items: vec![
|
||||
mk("Work", "My Vibe by activity", "activity:work", "#0D9488"),
|
||||
mk("Workout", "My Vibe by activity", "activity:workout", "#E11D48"),
|
||||
mk("Road trip", "My Vibe by activity", "activity:road-trip", "#4F46E5"),
|
||||
],
|
||||
},
|
||||
VibePickTab {
|
||||
title: "by character".into(),
|
||||
items: vec![
|
||||
mk("Discover", "My Vibe by character", "diversity:discover", "#8B5CF6"),
|
||||
mk("Favorites", "My Vibe by character", "diversity:favorite", "#EC4899"),
|
||||
mk("Popular", "My Vibe by character", "diversity:popular", "#059669"),
|
||||
],
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn render_more_picks_section(
|
||||
ctx: &mut UiContext,
|
||||
pal: &YmPalette,
|
||||
app: &AppState,
|
||||
viewport: Rect,
|
||||
x: f32,
|
||||
mut y: f32,
|
||||
avail_w: f32,
|
||||
actions: &mut Vec<AppAction>,
|
||||
) -> f32 {
|
||||
let ru = app.i18n().is_ru();
|
||||
let tabs: Vec<VibePickTab> = if !app.landing.vibe_pick_tabs.is_empty() {
|
||||
app.landing.vibe_pick_tabs.clone()
|
||||
} else {
|
||||
fallback_vibe_pick_tabs(ru)
|
||||
};
|
||||
if tabs.is_empty() {
|
||||
return y;
|
||||
}
|
||||
|
||||
ctx.draw_text_ellipsis(
|
||||
if ru { "Ещё подборки" } else { "More Picks" },
|
||||
TextStyle::headline(24.0, pal.text_primary),
|
||||
Rect::from_xywh(x, y, avail_w, 30.0),
|
||||
TextAlign::Left,
|
||||
);
|
||||
y += 40.0;
|
||||
|
||||
let card_w = 164.0;
|
||||
let card_h = card_w + 54.0;
|
||||
let row_vp = Rect::from_xywh(x, y, avail_w, card_h);
|
||||
let h_id = WidgetId::new(salt);
|
||||
let scroll_x = ctx.begin_scroll_h(h_id, row_vp, 0.0);
|
||||
let active_idx = FOR_YOU_PICKS_TAB.with(|c| c.get()).min(tabs.len() - 1);
|
||||
|
||||
let releases = app.landing.new_releases.clone();
|
||||
let mut cx = x - scroll_x;
|
||||
for alb in &releases {
|
||||
let cr = Rect::from_xywh(cx, y, card_w, card_h);
|
||||
if cr.right() >= row_vp.left() - 20.0 && cr.left() <= row_vp.right() + 20.0 {
|
||||
let art = alb
|
||||
.artists
|
||||
.first()
|
||||
.map(|a| a.name.as_str())
|
||||
.unwrap_or(t.album());
|
||||
let m = media_card(
|
||||
ctx,
|
||||
pal,
|
||||
covers,
|
||||
WidgetId::from_pair(salt, &alb.id),
|
||||
cr,
|
||||
&alb.title,
|
||||
art,
|
||||
alb.cover_uri.as_deref(),
|
||||
&format!("alb_{}", alb.id),
|
||||
false,
|
||||
false,
|
||||
);
|
||||
if m.play_clicked {
|
||||
actions.push(AppAction::PlayAlbum {
|
||||
id: alb.id.clone(),
|
||||
title: alb.title.clone(),
|
||||
});
|
||||
} else if m.clicked {
|
||||
actions.push(AppAction::Navigate(Route::Album {
|
||||
id: alb.id.clone(),
|
||||
title: alb.title.clone(),
|
||||
}));
|
||||
}
|
||||
// Horizontal category filter tabs (`32px` active pill, clean secondary text inactive)
|
||||
let tabs_vp = Rect::from_xywh(x, y, avail_w, 34.0);
|
||||
let tabs_h_id = WidgetId::new("fy_picks_tabs_hscroll");
|
||||
let tabs_sx = ctx.begin_scroll_h(tabs_h_id, tabs_vp, 0.0);
|
||||
let mut tx = x - tabs_sx;
|
||||
for (idx, tab) in tabs.iter().enumerate() {
|
||||
let is_act = idx == active_idx;
|
||||
let style = TextStyle::medium(
|
||||
14.0,
|
||||
if is_act { pal.text_bright } else { pal.text_secondary },
|
||||
);
|
||||
let tw = ctx.measure_text(&tab.title, style, None).x + 24.0;
|
||||
let tr = Rect::from_xywh(tx, y, tw.max(52.0), 32.0);
|
||||
let resp = ctx.interact(WidgetId::from_pair("fy_pick_tab", idx), tr);
|
||||
if is_act {
|
||||
ctx.dl().push_rect(tr, 16.0, pal.surface_hover);
|
||||
} else if resp.hovered {
|
||||
ctx.dl().push_rect(tr, 16.0, pal.surface_secondary);
|
||||
}
|
||||
cx += card_w + 16.0;
|
||||
ctx.draw_text_ellipsis(
|
||||
&tab.title,
|
||||
TextStyle::medium(
|
||||
14.0,
|
||||
if is_act || resp.hovered {
|
||||
pal.text_bright
|
||||
} else {
|
||||
pal.text_secondary
|
||||
},
|
||||
),
|
||||
tr,
|
||||
TextAlign::Center,
|
||||
);
|
||||
if resp.hovered {
|
||||
ctx.set_cursor(CursorKind::Pointer);
|
||||
}
|
||||
if resp.clicked {
|
||||
FOR_YOU_PICKS_TAB.with(|c| c.set(idx));
|
||||
}
|
||||
tx = tr.right() + 8.0;
|
||||
}
|
||||
let total_w = (releases.len() as f32) * (card_w + 16.0);
|
||||
ctx.end_scroll_h(h_id, pal, total_w, false);
|
||||
ctx.end_scroll_h(tabs_h_id, pal, (tx + tabs_sx) - x, false);
|
||||
y += 46.0;
|
||||
|
||||
// Vibrant gradient-tinted glossy Vibe-Station cards (`260x70`, `radius: 16px`)
|
||||
const CURATED_PALETTE: &[Color] = &[
|
||||
Color::rgb(0x3F, 0x68, 0xF9),
|
||||
Color::rgb(0x83, 0x41, 0xEF),
|
||||
Color::rgb(0xE1, 0x3A, 0x52),
|
||||
Color::rgb(0x0D, 0x94, 0x88),
|
||||
Color::rgb(0xD9, 0x77, 0x06),
|
||||
Color::rgb(0xDB, 0x27, 0x77),
|
||||
];
|
||||
|
||||
let card_w = 260.0_f32;
|
||||
let card_h = 70.0_f32;
|
||||
let gap = 14.0_f32;
|
||||
let row_vp = Rect::from_xywh(x, y, avail_w, card_h);
|
||||
let items = &tabs[active_idx].items;
|
||||
if row_vp.bottom() >= viewport.top() - 120.0 && row_vp.top() <= viewport.bottom() + 120.0 {
|
||||
let h_id = WidgetId::from_pair("fy_picks_cards", active_idx);
|
||||
let sx = ctx.begin_scroll_h(h_id, row_vp, 0.0);
|
||||
let mut cx = x - sx;
|
||||
for (idx, item) in items.iter().enumerate() {
|
||||
let cr = Rect::from_xywh(cx, y, card_w, card_h);
|
||||
if cr.right() >= row_vp.left() - 60.0 && cr.left() <= row_vp.right() + 60.0 {
|
||||
let resp = ctx.interact(WidgetId::from_pair("fy_pick_card", (active_idx, idx)), cr);
|
||||
let base_c = item
|
||||
.color_hex
|
||||
.as_deref()
|
||||
.and_then(Color::from_hex_str)
|
||||
.unwrap_or(CURATED_PALETTE[idx % CURATED_PALETTE.len()]);
|
||||
let c_left = base_c.lerp(Color::BLACK, if resp.hovered { 0.14 } else { 0.24 });
|
||||
let c_right = base_c.lerp(Color::BLACK, if resp.hovered { 0.36 } else { 0.48 });
|
||||
ctx.dl()
|
||||
.push_gradient_rect(cr, 16.0, c_left, c_right, Vec2::new(1.0, 0.4));
|
||||
// Subtle glossy top sheen
|
||||
ctx.dl().push_gradient_rect(
|
||||
Rect::from_xywh(cr.left(), cr.top(), cr.width(), cr.height() * 0.48),
|
||||
CornerRadii::top(16.0),
|
||||
css_rgba(255, 255, 255, if resp.hovered { 42 } else { 28 }),
|
||||
css_rgba(255, 255, 255, 0),
|
||||
Vec2::new(0.0, 1.0),
|
||||
);
|
||||
ctx.dl().push_rect_bordered(
|
||||
cr,
|
||||
16.0,
|
||||
Color::TRANSPARENT,
|
||||
1.0,
|
||||
css_rgba(255, 255, 255, 28),
|
||||
);
|
||||
|
||||
// Eyebrow ("Моя волна по языку" / "My Vibe by language")
|
||||
if !item.header.is_empty() {
|
||||
ctx.draw_text_ellipsis(
|
||||
&item.header,
|
||||
TextStyle::medium(12.0, css_rgba(255, 255, 255, 196)),
|
||||
Rect::from_xywh(cr.left() + 14.0, cr.top() + 13.0, cr.width() - 28.0, 16.0),
|
||||
TextAlign::Center,
|
||||
);
|
||||
}
|
||||
|
||||
// Centered bold white `▶` + station title (`17px` Headline)
|
||||
let title_style = TextStyle::headline(17.0, Color::WHITE);
|
||||
let tw = ctx
|
||||
.measure_text(&item.title, title_style, None)
|
||||
.x
|
||||
.min(cr.width() - 52.0);
|
||||
let inner_w = 16.0 + 6.0 + tw;
|
||||
let tx_start = cr.center_x() - inner_w * 0.5;
|
||||
let row_y = if item.header.is_empty() {
|
||||
cr.center_y()
|
||||
} else {
|
||||
cr.top() + 45.0
|
||||
};
|
||||
ctx.draw_icon(
|
||||
Icon::PlayFilledXs,
|
||||
Rect::from_center_size(Pos2::new(tx_start + 8.0, row_y), Vec2::splat(14.0)),
|
||||
Color::WHITE,
|
||||
);
|
||||
ctx.draw_text_ellipsis(
|
||||
&item.title,
|
||||
title_style,
|
||||
Rect::from_xywh(tx_start + 22.0, row_y - 11.0, tw + 4.0, 22.0),
|
||||
TextAlign::Left,
|
||||
);
|
||||
|
||||
if resp.hovered {
|
||||
ctx.set_cursor(CursorKind::Pointer);
|
||||
}
|
||||
if resp.clicked && !item.seeds.is_empty() {
|
||||
actions.push(AppAction::StartVibeBySeeds {
|
||||
title: item.title.clone(),
|
||||
seeds: item.seeds.clone(),
|
||||
});
|
||||
}
|
||||
}
|
||||
cx += card_w + gap;
|
||||
}
|
||||
ctx.end_scroll_h(h_id, pal, items.len() as f32 * (card_w + gap), false);
|
||||
}
|
||||
|
||||
y + card_h + 26.0
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ use crate::engine::types::{
|
|||
css_rgba, Color, CornerRadii, CursorKind, Pos2, Rect, Vec2, VIBE_TEXTURE_ID,
|
||||
};
|
||||
use crate::engine::widgets::{
|
||||
draw_cover_art, secondary_pill_button, ym_menu_divider, ym_menu_frame, ym_menu_item,
|
||||
ym_menu_item_ex, ym_volume_capsule,
|
||||
draw_cover_art, ym_menu_divider, ym_menu_frame, ym_menu_item, ym_menu_item_ex,
|
||||
ym_volume_capsule,
|
||||
};
|
||||
use crate::engine::UiContext;
|
||||
use crate::icons::Icon;
|
||||
|
|
@ -1504,7 +1504,7 @@ pub fn render_my_vibe(
|
|||
|
||||
// 13. OFFICIAL 5.129.0 `WordsCardFullscreen` (`ZLayer::Modal` when `app.words_big_card_open`)
|
||||
if app.words_big_card_open {
|
||||
render_words_card_fullscreen(ctx, pal, app, ru, active_words_card.as_ref(), actions);
|
||||
render_words_card_fullscreen(ctx, pal, covers, app, ru, active_words_card.as_ref(), actions);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1664,6 +1664,7 @@ fn render_words_card_popover(
|
|||
fn render_words_card_fullscreen(
|
||||
ctx: &mut UiContext,
|
||||
pal: &YmPalette,
|
||||
covers: &mut CoverCache,
|
||||
app: &AppState,
|
||||
ru: bool,
|
||||
fallback_card: Option<&WordsCard>,
|
||||
|
|
@ -1714,31 +1715,21 @@ fn render_words_card_fullscreen(
|
|||
should_close = true;
|
||||
}
|
||||
|
||||
let col_w = (screen.width() - 96.0).clamp(300.0, 540.0);
|
||||
let modal_h = (screen.height() - 140.0).clamp(320.0, 580.0);
|
||||
let content_rect = Rect::from_center_size(screen.center(), Vec2::new(col_w + 48.0, modal_h));
|
||||
let col_x = content_rect.center_x() - col_w * 0.5;
|
||||
let mut y = content_rect.top() + 18.0;
|
||||
|
||||
// Top AI sparkle badge with soft meteor glow
|
||||
let sp_c = Pos2::new(content_rect.center_x(), y + 20.0);
|
||||
let meteor_tex = ctx.icons.get_official_meteor_glow(&mut ctx.textures);
|
||||
let badge_tl = Pos2::new(sp_c.x - 24.0, sp_c.y - 24.0);
|
||||
ctx.dl().push_image(
|
||||
Rect::from_xywh(badge_tl.x - 180.0 * 0.25, badge_tl.y - 180.0 * 0.43, 180.0, 180.0),
|
||||
meteor_tex,
|
||||
0.0,
|
||||
Color::WHITE.with_alpha(150),
|
||||
let col_w = (screen.width() - 96.0).clamp(300.0, 560.0);
|
||||
let col_x = screen.center_x() - col_w * 0.5;
|
||||
let disclaimer = if ru {
|
||||
"AI может ошибаться, проверяйте важное"
|
||||
} else {
|
||||
"AI may make mistakes, be sure to double-check important information"
|
||||
};
|
||||
let disclaimer_y = screen.bottom() - 38.0;
|
||||
let content_rect = Rect::from_min_max(
|
||||
Pos2::new(col_x - 24.0, screen.top() + 92.0),
|
||||
Pos2::new(col_x + col_w + 24.0, disclaimer_y - 12.0),
|
||||
);
|
||||
ctx.draw_icon(
|
||||
Icon::AiSparkles,
|
||||
Rect::from_center_size(sp_c, Vec2::splat(28.0)),
|
||||
pal.text_bright,
|
||||
);
|
||||
y += 64.0;
|
||||
|
||||
if app.words_big_card_loading {
|
||||
// 3 subtle animated shimmer bars while `POST /words/big-cards` loads
|
||||
// 3 subtle animated shimmer bars centered vertically while `POST /words/big-cards` loads
|
||||
let shimmer = 0.5 + 0.5 * ((ctx.input.time as f32) * 3.2).sin();
|
||||
let a = (28.0 + 36.0 * shimmer).round() as u8;
|
||||
let bar_col = if pal.is_dark {
|
||||
|
|
@ -1746,11 +1737,12 @@ fn render_words_card_fullscreen(
|
|||
} else {
|
||||
css_rgba(0, 0, 0, a)
|
||||
};
|
||||
let sy = content_rect.center_y() - 40.0;
|
||||
for (i, frac) in [0.88_f32, 1.0_f32, 0.64_f32].iter().enumerate() {
|
||||
let bw = col_w * frac;
|
||||
let br = Rect::from_xywh(
|
||||
content_rect.center_x() - bw * 0.5,
|
||||
y + i as f32 * 30.0,
|
||||
screen.center_x() - bw * 0.5,
|
||||
sy + i as f32 * 30.0,
|
||||
bw,
|
||||
18.0,
|
||||
);
|
||||
|
|
@ -1773,107 +1765,170 @@ fn render_words_card_fullscreen(
|
|||
.or_else(|| fallback_card.map(|c| c.actions.as_slice()))
|
||||
.unwrap_or(&[]);
|
||||
|
||||
let bottom_reserved = if sources.is_empty() { 104.0 } else { 154.0 };
|
||||
let text_vp_h = (content_rect.bottom() - y - bottom_reserved).max(120.0);
|
||||
let text_vp = Rect::from_xywh(col_x, y, col_w, text_vp_h);
|
||||
let text_style = TextStyle::bold(20.0, pal.text_bright).with_line_height(28.0);
|
||||
let measured = ctx.measure_text(full_text, text_style, Some(col_w));
|
||||
|
||||
let scroll_id = WidgetId::new("wcf_text_scroll");
|
||||
let scroll_y = ctx.begin_scroll_v(scroll_id, text_vp, 0.0);
|
||||
let ty = if measured.y < text_vp_h {
|
||||
text_vp.center_y() - measured.y * 0.5
|
||||
let src_count = sources.len().min(2);
|
||||
let src_block_h = if src_count > 0 {
|
||||
28.0 + src_count as f32 * 46.0 - 8.0
|
||||
} else {
|
||||
text_vp.top() - scroll_y
|
||||
0.0
|
||||
};
|
||||
ctx.draw_text_wrapped(
|
||||
full_text,
|
||||
text_style,
|
||||
Rect::from_xywh(col_x, ty, col_w, measured.y + 12.0),
|
||||
None,
|
||||
TextAlign::Center,
|
||||
);
|
||||
ctx.end_scroll_v(scroll_id, pal, measured.y + 16.0, false);
|
||||
y = text_vp.bottom() + 16.0;
|
||||
let fb_block_h = if fallback_card.is_some() { 22.0 + 32.0 } else { 0.0 };
|
||||
let max_text_h = (content_rect.height() - src_block_h - fb_block_h - 16.0).max(110.0);
|
||||
let used_text_h = measured.y.min(max_text_h);
|
||||
let total_stack_h = used_text_h + src_block_h + fb_block_h;
|
||||
let mut y = (content_rect.center_y() - total_stack_h * 0.5).max(content_rect.top());
|
||||
|
||||
// Optional source link pills
|
||||
if !sources.is_empty() {
|
||||
let mut sx = col_x;
|
||||
let max_right = col_x + col_w;
|
||||
for (idx, src) in sources.iter().take(4).enumerate() {
|
||||
let est_w = (ctx
|
||||
.measure_text(&src.title, TextStyle::medium(13.5, pal.text_primary), None)
|
||||
.x
|
||||
+ 50.0)
|
||||
.clamp(80.0, col_w);
|
||||
if sx + est_w > max_right && sx > col_x {
|
||||
break;
|
||||
}
|
||||
let (resp, r) = secondary_pill_button(
|
||||
ctx,
|
||||
pal,
|
||||
WidgetId::from_pair("wcf_src", idx),
|
||||
Pos2::new(sx, y),
|
||||
Some(Icon::LinkXxs),
|
||||
&src.title,
|
||||
34.0,
|
||||
false,
|
||||
// 1. Centered 20px bold story text (scrollable if longer than viewport, ZERO floating sparkle!)
|
||||
let text_vp = Rect::from_xywh(col_x, y, col_w, used_text_h + 6.0);
|
||||
if measured.y > max_text_h {
|
||||
let scroll_id = WidgetId::new("wcf_text_scroll");
|
||||
let scroll_y = ctx.begin_scroll_v(scroll_id, text_vp, 0.0);
|
||||
ctx.draw_text_wrapped(
|
||||
full_text,
|
||||
text_style,
|
||||
Rect::from_xywh(col_x, text_vp.top() - scroll_y, col_w, measured.y + 12.0),
|
||||
None,
|
||||
TextAlign::Center,
|
||||
);
|
||||
ctx.end_scroll_v(scroll_id, pal, measured.y + 16.0, false);
|
||||
} else {
|
||||
ctx.draw_text_wrapped(
|
||||
full_text,
|
||||
text_style,
|
||||
Rect::from_xywh(col_x, y, col_w, measured.y + 12.0),
|
||||
None,
|
||||
TextAlign::Center,
|
||||
);
|
||||
}
|
||||
y += used_text_h;
|
||||
|
||||
// 2. Centered full-width-fitted source/Alice glass pill(s) (28px below text, NEVER truncates!)
|
||||
if src_count > 0 {
|
||||
y += 28.0;
|
||||
let max_pill_w = (screen.width() - 64.0).min(520.0);
|
||||
for (idx, src) in sources.iter().take(src_count).enumerate() {
|
||||
let lbl_style = TextStyle::medium(14.0, pal.text_bright);
|
||||
let tw = ctx.measure_text(&src.title, lbl_style, None).x;
|
||||
let pill_w = (tw + 54.0).clamp(160.0, max_pill_w);
|
||||
let pill_r = Rect::from_xywh(
|
||||
screen.center_x() - pill_w * 0.5,
|
||||
y,
|
||||
pill_w,
|
||||
38.0,
|
||||
);
|
||||
let resp = ctx.interact(WidgetId::from_pair("wcf_src_pill", idx), pill_r);
|
||||
let bg = if pal.is_dark {
|
||||
css_rgba(255, 255, 255, if resp.hovered { 32 } else { 18 })
|
||||
} else if resp.hovered {
|
||||
pal.surface_hover
|
||||
} else {
|
||||
pal.surface_secondary
|
||||
};
|
||||
let border = if pal.is_dark {
|
||||
css_rgba(255, 255, 255, 28)
|
||||
} else {
|
||||
pal.border_subtle
|
||||
};
|
||||
ctx.dl().push_rect_bordered(pill_r, 19.0, bg, 1.0, border);
|
||||
|
||||
// Left 18x18 icon: favicon_url -> Alice purple ring -> LinkRounded
|
||||
let ic_center = Pos2::new(pill_r.left() + 22.0, pill_r.center_y());
|
||||
let ic_rect = Rect::from_center_size(ic_center, Vec2::splat(18.0));
|
||||
let mut drew_fav = false;
|
||||
if let Some(ref fav) = src.favicon_url {
|
||||
if let Some((tex_id, _, _)) = covers.get_or_fetch(fav, 64) {
|
||||
ctx.dl().push_image(ic_rect, tex_id, 9.0, Color::WHITE);
|
||||
drew_fav = true;
|
||||
}
|
||||
}
|
||||
if !drew_fav {
|
||||
let tl = src.title.to_lowercase();
|
||||
if tl.contains("алис") || tl.contains("alice") {
|
||||
ctx.dl()
|
||||
.push_circle(ic_center, 9.0, Color::rgb(0x18, 0x13, 0x26));
|
||||
ctx.dl().push_circle_stroke(
|
||||
ic_center,
|
||||
8.0,
|
||||
2.2,
|
||||
Color::rgb(0x8B, 0x5C, 0xF6),
|
||||
);
|
||||
ctx.dl()
|
||||
.push_circle(ic_center, 2.6, Color::rgb(0xC4, 0xB5, 0xFD));
|
||||
} else {
|
||||
ctx.draw_icon(
|
||||
Icon::LinkRounded,
|
||||
Rect::from_center_size(ic_center, Vec2::splat(16.0)),
|
||||
pal.text_bright,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ctx.draw_text_ellipsis(
|
||||
&src.title,
|
||||
lbl_style,
|
||||
Rect::from_xywh(
|
||||
pill_r.left() + 38.0,
|
||||
pill_r.top(),
|
||||
(pill_r.width() - 52.0).max(40.0),
|
||||
pill_r.height(),
|
||||
),
|
||||
TextAlign::Left,
|
||||
);
|
||||
if resp.hovered {
|
||||
ctx.set_cursor(CursorKind::Pointer);
|
||||
}
|
||||
if resp.clicked && !src.url.is_empty() {
|
||||
actions.push(AppAction::OpenUrl(src.url.clone()));
|
||||
}
|
||||
sx = r.right() + 8.0;
|
||||
y += 46.0;
|
||||
}
|
||||
y += 46.0;
|
||||
y -= 8.0;
|
||||
}
|
||||
|
||||
// Horizontal feedback bar: 👍 More similar replies | 1px divider | 👎 Not cool
|
||||
// 3. BORDERLESS TEXT-ONLY feedback buttons (22px below source pill, 28px gap, ZERO boxes!)
|
||||
if let Some(card) = fallback_card {
|
||||
y += 22.0;
|
||||
let like_lbl = if ru {
|
||||
"Больше такого"
|
||||
} else {
|
||||
"More similar replies"
|
||||
};
|
||||
let dislike_lbl = if ru { "Мимо" } else { "Not cool" };
|
||||
let btn_h = 38.0;
|
||||
let like_w = (ctx
|
||||
.measure_text(like_lbl, TextStyle::medium(14.0, pal.text_primary), None)
|
||||
.x
|
||||
+ 54.0)
|
||||
.max(120.0);
|
||||
let dislike_w = (ctx
|
||||
.measure_text(dislike_lbl, TextStyle::medium(14.0, pal.text_primary), None)
|
||||
.x
|
||||
+ 54.0)
|
||||
.max(100.0);
|
||||
let bar_w = like_w + 25.0 + dislike_w;
|
||||
let bar_x = content_rect.center_x() - bar_w * 0.5;
|
||||
let muted = if pal.is_dark {
|
||||
css_rgba(255, 255, 255, 148)
|
||||
} else {
|
||||
pal.text_secondary
|
||||
};
|
||||
let lbl_style = TextStyle::medium(14.0, muted);
|
||||
let like_tw = ctx.measure_text(like_lbl, lbl_style, None).x;
|
||||
let dislike_tw = ctx.measure_text(dislike_lbl, lbl_style, None).x;
|
||||
let like_w = 16.0 + 7.0 + like_tw + 8.0;
|
||||
let dislike_w = 16.0 + 7.0 + dislike_tw + 8.0;
|
||||
let gap = 28.0_f32;
|
||||
let total_w = like_w + gap + dislike_w;
|
||||
let start_x = screen.center_x() - total_w * 0.5;
|
||||
let btn_h = 32.0;
|
||||
|
||||
let like_r = Rect::from_xywh(bar_x, y, like_w, btn_h);
|
||||
let like_r = Rect::from_xywh(start_x, y, like_w, btn_h);
|
||||
let like_resp = ctx.interact(WidgetId::new("wcf_like"), like_r);
|
||||
ctx.dl().push_rect(
|
||||
like_r,
|
||||
19.0,
|
||||
if like_resp.hovered || card.is_liked() {
|
||||
pal.surface_hover
|
||||
} else {
|
||||
pal.surface_secondary
|
||||
},
|
||||
);
|
||||
let like_fg = if card.is_liked() || like_resp.hovered {
|
||||
pal.text_bright
|
||||
} else {
|
||||
pal.text_primary
|
||||
muted
|
||||
};
|
||||
ctx.draw_icon(
|
||||
Icon::ThumbUpXxs,
|
||||
Rect::from_center_size(Pos2::new(like_r.left() + 22.0, like_r.center_y()), Vec2::splat(18.0)),
|
||||
Rect::from_center_size(
|
||||
Pos2::new(like_r.left() + 10.0, like_r.center_y()),
|
||||
Vec2::splat(16.0),
|
||||
),
|
||||
like_fg,
|
||||
);
|
||||
ctx.draw_text_ellipsis(
|
||||
like_lbl,
|
||||
TextStyle::medium(14.0, like_fg),
|
||||
Rect::from_xywh(like_r.left() + 38.0, like_r.top(), like_r.width() - 48.0, like_r.height()),
|
||||
Rect::from_xywh(like_r.left() + 24.0, like_r.top(), like_tw + 8.0, btn_h),
|
||||
TextAlign::Left,
|
||||
);
|
||||
if like_resp.hovered {
|
||||
|
|
@ -1891,39 +1946,30 @@ fn render_words_card_fullscreen(
|
|||
});
|
||||
}
|
||||
|
||||
// 1px vertical divider
|
||||
let div_x = like_r.right() + 12.0;
|
||||
ctx.dl().push_rect(
|
||||
Rect::from_xywh(div_x, y + 7.0, 1.0, 24.0),
|
||||
0.0,
|
||||
pal.border_subtle,
|
||||
);
|
||||
|
||||
let dislike_r = Rect::from_xywh(div_x + 13.0, y, dislike_w, btn_h);
|
||||
let dislike_r = Rect::from_xywh(like_r.right() + gap, y, dislike_w, btn_h);
|
||||
let dislike_resp = ctx.interact(WidgetId::new("wcf_dislike"), dislike_r);
|
||||
ctx.dl().push_rect(
|
||||
dislike_r,
|
||||
19.0,
|
||||
if dislike_resp.hovered || card.is_disliked() {
|
||||
pal.surface_hover
|
||||
} else {
|
||||
pal.surface_secondary
|
||||
},
|
||||
);
|
||||
let dislike_fg = if card.is_disliked() || dislike_resp.hovered {
|
||||
pal.text_bright
|
||||
} else {
|
||||
pal.text_primary
|
||||
muted
|
||||
};
|
||||
ctx.draw_icon(
|
||||
Icon::ThumbDownXxs,
|
||||
Rect::from_center_size(Pos2::new(dislike_r.left() + 22.0, dislike_r.center_y()), Vec2::splat(18.0)),
|
||||
Rect::from_center_size(
|
||||
Pos2::new(dislike_r.left() + 10.0, dislike_r.center_y()),
|
||||
Vec2::splat(16.0),
|
||||
),
|
||||
dislike_fg,
|
||||
);
|
||||
ctx.draw_text_ellipsis(
|
||||
dislike_lbl,
|
||||
TextStyle::medium(14.0, dislike_fg),
|
||||
Rect::from_xywh(dislike_r.left() + 38.0, dislike_r.top(), dislike_r.width() - 48.0, dislike_r.height()),
|
||||
Rect::from_xywh(
|
||||
dislike_r.left() + 24.0,
|
||||
dislike_r.top(),
|
||||
dislike_tw + 8.0,
|
||||
btn_h,
|
||||
),
|
||||
TextAlign::Left,
|
||||
);
|
||||
if dislike_resp.hovered {
|
||||
|
|
@ -1936,24 +1982,25 @@ fn render_words_card_fullscreen(
|
|||
state: "dislike".into(),
|
||||
});
|
||||
}
|
||||
y += btn_h + 18.0;
|
||||
}
|
||||
|
||||
// Bottom AI disclaimer
|
||||
let disclaimer = if ru {
|
||||
"AI может ошибаться, проверяйте важное"
|
||||
} else {
|
||||
"AI may make mistakes, be sure to double-check important information"
|
||||
};
|
||||
ctx.draw_text_wrapped(
|
||||
disclaimer,
|
||||
TextStyle::regular(12.5, pal.text_secondary).with_line_height(17.0),
|
||||
Rect::from_xywh(col_x, y, col_w, 36.0),
|
||||
Some(2),
|
||||
TextAlign::Center,
|
||||
);
|
||||
}
|
||||
|
||||
// 4. Disclaimer pinned cleanly near the bottom (`screen.bottom() - 32.0`)
|
||||
let disc_col = if pal.is_dark {
|
||||
css_rgba(255, 255, 255, 96)
|
||||
} else {
|
||||
pal.text_secondary
|
||||
};
|
||||
ctx.draw_text_ellipsis(
|
||||
disclaimer,
|
||||
TextStyle::regular(12.0, disc_col),
|
||||
Rect::from_center_size(
|
||||
Pos2::new(screen.center_x(), screen.bottom() - 32.0),
|
||||
Vec2::new((screen.width() - 64.0).max(200.0), 22.0),
|
||||
),
|
||||
TextAlign::Center,
|
||||
);
|
||||
|
||||
if ctx.input.key_pressed(Key::Escape)
|
||||
|| ctx.input.clicked_outside_any(&[content_rect, close_r])
|
||||
{
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1863,3 +1863,384 @@ fn test_ext_16_yandex_id_popup_and_words_card_visual_parity() {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ext_17_for_you_collection_concerts_words_fullscreen() {
|
||||
use yandex_music_rs::api::models::{
|
||||
AlbumSummary, ConcertItem, NewReleaseItem, VibePickItem, VibePickTab, WordsBigCard,
|
||||
WordsCard, WordsCardSource,
|
||||
};
|
||||
use yandex_music_rs::engine::WidgetId;
|
||||
|
||||
let rt = tokio::runtime::Runtime::new().unwrap();
|
||||
let mut vk = HeadlessVulkanRenderer::new(NATIVE_W, NATIVE_H).expect("Vulkan init failed");
|
||||
let out_dir = output_dir();
|
||||
let _ = std::fs::create_dir_all(&out_dir);
|
||||
|
||||
// 1. Official `For You` scrolled down: sticky frosted header + circular NewReleases + More Picks (`for_you_new_releases_picks.png`)
|
||||
{
|
||||
let mut shell = make_base_shell(
|
||||
rt.handle().clone(),
|
||||
vk.gpu_name.clone(),
|
||||
Route::ForYou,
|
||||
ThemeMode::Dark,
|
||||
Language::En,
|
||||
0.0,
|
||||
);
|
||||
let mk_album = |id: &str, title: &str, artist: &str| AlbumSummary {
|
||||
id: id.into(),
|
||||
title: title.into(),
|
||||
year: Some(2026),
|
||||
cover_uri: None,
|
||||
artists: vec![ArtistSummary {
|
||||
id: format!("art_{id}"),
|
||||
name: artist.into(),
|
||||
cover_uri: None,
|
||||
genres: vec![],
|
||||
}],
|
||||
track_count: 12,
|
||||
genre: Some("electronic".into()),
|
||||
is_explicit: false,
|
||||
content_type: Some("album".into()),
|
||||
};
|
||||
shell.app.landing.rich_new_releases = vec![
|
||||
NewReleaseItem {
|
||||
album: mk_album("nr1", "Neon Horizon", "SALUKI"),
|
||||
artist_cover_uri: None,
|
||||
cover_color: Some("#3B4CA8".into()),
|
||||
release_date: Some("2026-11-20".into()),
|
||||
},
|
||||
NewReleaseItem {
|
||||
album: mk_album("nr2", "Velvet Pulse", "Mirele"),
|
||||
artist_cover_uri: None,
|
||||
cover_color: Some("#7B2D5F".into()),
|
||||
release_date: Some("2026-11-18".into()),
|
||||
},
|
||||
NewReleaseItem {
|
||||
album: mk_album("nr3", "Night Drive", "SLAVA MARLOW"),
|
||||
artist_cover_uri: None,
|
||||
cover_color: Some("#1E6B52".into()),
|
||||
release_date: Some("2026-11-15".into()),
|
||||
},
|
||||
NewReleaseItem {
|
||||
album: mk_album("nr4", "Solar Flare", "OG BLESS"),
|
||||
artist_cover_uri: None,
|
||||
cover_color: Some("#8F4A1E".into()),
|
||||
release_date: Some("2026-11-12".into()),
|
||||
},
|
||||
];
|
||||
shell.app.landing.vibe_pick_tabs = vec![
|
||||
VibePickTab {
|
||||
title: "Mood".into(),
|
||||
items: vec![
|
||||
VibePickItem {
|
||||
title: "Energetic".into(),
|
||||
header: "Vibe".into(),
|
||||
seeds: vec!["mood:energetic".into()],
|
||||
color_hex: Some("#D94E2A".into()),
|
||||
background_image_url: None,
|
||||
image_url: None,
|
||||
},
|
||||
VibePickItem {
|
||||
title: "Night Focus".into(),
|
||||
header: "Vibe".into(),
|
||||
seeds: vec!["mood:calm".into()],
|
||||
color_hex: Some("#2F55A4".into()),
|
||||
background_image_url: None,
|
||||
image_url: None,
|
||||
},
|
||||
VibePickItem {
|
||||
title: "Dreamy Synth".into(),
|
||||
header: "Vibe".into(),
|
||||
seeds: vec!["genre:electronic".into()],
|
||||
color_hex: Some("#7C3AED".into()),
|
||||
background_image_url: None,
|
||||
image_url: None,
|
||||
},
|
||||
],
|
||||
},
|
||||
VibePickTab {
|
||||
title: "Activity".into(),
|
||||
items: vec![VibePickItem {
|
||||
title: "Workout".into(),
|
||||
header: "Vibe".into(),
|
||||
seeds: vec!["activity:workout".into()],
|
||||
color_hex: Some("#0F766E".into()),
|
||||
background_image_url: None,
|
||||
image_url: None,
|
||||
}],
|
||||
},
|
||||
VibePickTab {
|
||||
title: "Genres".into(),
|
||||
items: vec![],
|
||||
},
|
||||
];
|
||||
|
||||
// Warm up layout so scroll content height is computed, then scroll to show New Releases + More Picks + sticky switcher
|
||||
let _ = render_single_frame(&mut vk, &mut shell, 0.0);
|
||||
let _ = render_single_frame(&mut vk, &mut shell, 0.016);
|
||||
shell
|
||||
.ui
|
||||
.scrolls
|
||||
.jump_to_y(WidgetId::new("foryou_page_scroll"), 860.0);
|
||||
let _ = render_single_frame(&mut vk, &mut shell, 0.032);
|
||||
let img = render_single_frame(&mut vk, &mut shell, 0.048);
|
||||
let _ = img.save(out_dir.join("for_you_new_releases_picks.png"));
|
||||
|
||||
// Verify colored NewRelease cards / More Picks cards rendered non-flat rich pixels in content card
|
||||
let mut colored_px = 0usize;
|
||||
for y in 110..680 {
|
||||
for x in 250..1240 {
|
||||
let [r, g, b] = img.get_pixel(x, y).0;
|
||||
let max_c = r.max(g).max(b);
|
||||
let min_c = r.min(g).min(b);
|
||||
if max_c.saturating_sub(min_c) >= 24 {
|
||||
colored_px += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
assert!(
|
||||
colored_px > 5_000,
|
||||
"[for_you_new_releases_picks] Expected colored New Releases / More Picks cards, found only {} chromatic px",
|
||||
colored_px
|
||||
);
|
||||
}
|
||||
|
||||
// 2. Official `My Collection` vertical feed (`my_collection_official.png`)
|
||||
{
|
||||
let mut shell = make_base_shell(
|
||||
rt.handle().clone(),
|
||||
vk.gpu_name.clone(),
|
||||
Route::Collection,
|
||||
ThemeMode::Dark,
|
||||
Language::En,
|
||||
0.0,
|
||||
);
|
||||
let extra_tracks = [
|
||||
("c_1", "MONTAGEM TENTA", "KYOR", 141_000),
|
||||
("c_2", "Midnight Sun", "SuperSolar", 184_000),
|
||||
("c_3", "BANG A RANG", "GSTRNM", 100_000),
|
||||
("c_4", "BOSS BITCH TEKK", "wharoxmane", 107_000),
|
||||
("c_5", "Neon Rain", "Mirele", 192_000),
|
||||
("c_6", "Skyline Pulse", "SALUKI", 168_000),
|
||||
("c_7", "Electric Horizon", "SLAVA MARLOW", 155_000),
|
||||
("c_8", "Deep Focus", "OG BLESS", 210_000),
|
||||
];
|
||||
shell.app.liked_tracks = extra_tracks
|
||||
.iter()
|
||||
.map(|(id, title, art, dur)| Track {
|
||||
id: (*id).into(),
|
||||
title: (*title).into(),
|
||||
version: None,
|
||||
artists: vec![ArtistSummary {
|
||||
id: format!("ca_{id}"),
|
||||
name: (*art).into(),
|
||||
cover_uri: None,
|
||||
genres: vec![],
|
||||
}],
|
||||
album_id: Some(format!("calb_{id}")),
|
||||
album_title: Some((*title).into()),
|
||||
duration_ms: *dur,
|
||||
cover_uri: None,
|
||||
is_explicit: false,
|
||||
has_lossless: true,
|
||||
has_lyrics: true,
|
||||
chart_position: None,
|
||||
chart_progress: None,
|
||||
preview_url: None,
|
||||
r128_i: None,
|
||||
r128_tp: None,
|
||||
derived_average_hex: None,
|
||||
derived_accent_hex: None,
|
||||
})
|
||||
.collect();
|
||||
shell.app.liked_artists = ["SALUKI", "Mirele", "KYOR", "SuperSolar", "GSTRNM", "OG BLESS"]
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, name)| ArtistSummary {
|
||||
id: format!("la_{i}"),
|
||||
name: (*name).into(),
|
||||
cover_uri: None,
|
||||
genres: vec![],
|
||||
})
|
||||
.collect();
|
||||
|
||||
let _ = render_single_frame(&mut vk, &mut shell, 0.0);
|
||||
let _ = render_single_frame(&mut vk, &mut shell, 0.016);
|
||||
let img = render_single_frame(&mut vk, &mut shell, 0.032);
|
||||
let _ = img.save(out_dir.join("my_collection_official.png"));
|
||||
|
||||
// Verify pink-magenta colored "color" word in subtitle + crimson 3D heart icon present,
|
||||
// and ZERO old yellow-bordered My Favorites hero card!
|
||||
let mut pink_subtitle_px = 0usize;
|
||||
for y in 75..125 {
|
||||
for x in 250..520 {
|
||||
let [r, g, b] = img.get_pixel(x, y).0;
|
||||
if r > 170 && b > 100 && (r as u16) > (g as u16) + 50 {
|
||||
pink_subtitle_px += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
assert!(
|
||||
pink_subtitle_px >= 15,
|
||||
"[my_collection_official] Expected magenta-colored subtitle word 'color', found {} px",
|
||||
pink_subtitle_px
|
||||
);
|
||||
}
|
||||
|
||||
// 3. Official `ConcertsPage` (`concerts_official.png`)
|
||||
{
|
||||
let mut shell = make_base_shell(
|
||||
rt.handle().clone(),
|
||||
vk.gpu_name.clone(),
|
||||
Route::Concerts,
|
||||
ThemeMode::Dark,
|
||||
Language::Ru,
|
||||
0.0,
|
||||
);
|
||||
shell.app.concerts = vec![
|
||||
ConcertItem {
|
||||
id: "con_1".into(),
|
||||
title: "SALUKI — Большой сольный концерт".into(),
|
||||
artist_name: "SALUKI".into(),
|
||||
city: "Москва".into(),
|
||||
place: "VK Stadium".into(),
|
||||
date: "14 дек, 20:00".into(),
|
||||
cover_uri: None,
|
||||
afisha_url: Some("https://afisha.yandex.ru".into()),
|
||||
min_price: Some(2500),
|
||||
currency: Some("RUB".into()),
|
||||
cashback_percent: Some(15),
|
||||
cashback_title: Some("Кешбэк 15%".into()),
|
||||
cover_color: Some("#4C2A85".into()),
|
||||
event_kind: Some("concert".into()),
|
||||
},
|
||||
ConcertItem {
|
||||
id: "con_2".into(),
|
||||
title: "Mirele — Акустический вечер".into(),
|
||||
artist_name: "Mirele".into(),
|
||||
city: "Санкт-Петербург".into(),
|
||||
place: "A2 Green Concert".into(),
|
||||
date: "21 дек, 19:30".into(),
|
||||
cover_uri: None,
|
||||
afisha_url: Some("https://afisha.yandex.ru".into()),
|
||||
min_price: Some(1900),
|
||||
currency: Some("RUB".into()),
|
||||
cashback_percent: Some(10),
|
||||
cashback_title: None,
|
||||
cover_color: Some("#1D5B79".into()),
|
||||
event_kind: Some("concert".into()),
|
||||
},
|
||||
ConcertItem {
|
||||
id: "con_3".into(),
|
||||
title: "SLAVA MARLOW — Live Tour".into(),
|
||||
artist_name: "SLAVA MARLOW".into(),
|
||||
city: "Казань".into(),
|
||||
place: "Korston Club Hotel".into(),
|
||||
date: "28 дек, 20:00".into(),
|
||||
cover_uri: None,
|
||||
afisha_url: Some("https://afisha.yandex.ru".into()),
|
||||
min_price: Some(2200),
|
||||
currency: Some("RUB".into()),
|
||||
cashback_percent: Some(20),
|
||||
cashback_title: None,
|
||||
cover_color: Some("#8C2F39".into()),
|
||||
event_kind: Some("concert".into()),
|
||||
},
|
||||
ConcertItem {
|
||||
id: "con_4".into(),
|
||||
title: "Электрофорез — Зимний сет".into(),
|
||||
artist_name: "Электрофорез".into(),
|
||||
city: "Москва".into(),
|
||||
place: "Урбан".into(),
|
||||
date: "5 янв, 20:00".into(),
|
||||
cover_uri: None,
|
||||
afisha_url: Some("https://afisha.yandex.ru".into()),
|
||||
min_price: Some(1700),
|
||||
currency: Some("RUB".into()),
|
||||
cashback_percent: Some(10),
|
||||
cashback_title: None,
|
||||
cover_color: Some("#2D4F1E".into()),
|
||||
event_kind: Some("concert".into()),
|
||||
},
|
||||
];
|
||||
|
||||
let _ = render_single_frame(&mut vk, &mut shell, 0.0);
|
||||
let _ = render_single_frame(&mut vk, &mut shell, 0.016);
|
||||
let img = render_single_frame(&mut vk, &mut shell, 0.032);
|
||||
let _ = img.save(out_dir.join("concerts_official.png"));
|
||||
|
||||
// Verify Top 3 colored poster cards + upcoming feed rendered cleanly
|
||||
let mut poster_chromatic_px = 0usize;
|
||||
for y in 160..420 {
|
||||
for x in 250..1240 {
|
||||
let [r, g, b] = img.get_pixel(x, y).0;
|
||||
if r.max(g).max(b).saturating_sub(r.min(g).min(b)) >= 20 {
|
||||
poster_chromatic_px += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
assert!(
|
||||
poster_chromatic_px > 10_000,
|
||||
"[concerts_official] Expected Top 3 concert poster cards + cashback pills, found {} chromatic px",
|
||||
poster_chromatic_px
|
||||
);
|
||||
}
|
||||
|
||||
// 4. Official `WordsCardFullscreen` (`words_fullscreen_official.png`)
|
||||
{
|
||||
let mut shell = make_base_shell(
|
||||
rt.handle().clone(),
|
||||
vk.gpu_name.clone(),
|
||||
Route::MyVibe,
|
||||
ThemeMode::Dark,
|
||||
Language::Ru,
|
||||
108.0,
|
||||
);
|
||||
shell.app.words_cards.insert(
|
||||
"t_1".into(),
|
||||
WordsCard {
|
||||
id: "wc_fs_1".into(),
|
||||
track_id: "t_1".into(),
|
||||
text: "MONTAGEM TENTA сочетает бразильский фонк и жёсткие хардстайл-кики.".into(),
|
||||
tags: vec!["FACT".into()],
|
||||
action: None,
|
||||
actions: vec![],
|
||||
big_card_ids: vec!["bc_1".into()],
|
||||
feedback_state: None,
|
||||
},
|
||||
);
|
||||
shell.app.words_big_card_open = true;
|
||||
shell.app.words_big_card_loading = false;
|
||||
shell.app.words_big_card = Some(WordsBigCard {
|
||||
id: "bc_1".into(),
|
||||
text: "MONTAGEM TENTA (Hardstyle) — взрывной кроссовер бразильского фонка и европейского хардстайла с плотным саб-басом и стремительным ритмом.".into(),
|
||||
actions: vec![WordsCardSource {
|
||||
title: "Обсудить с Алисой AI".into(),
|
||||
url: "https://alice.yandex.ru".into(),
|
||||
favicon_url: None,
|
||||
}],
|
||||
});
|
||||
|
||||
let _ = render_single_frame(&mut vk, &mut shell, 0.0);
|
||||
let _ = render_single_frame(&mut vk, &mut shell, 0.016);
|
||||
let img = render_single_frame(&mut vk, &mut shell, 0.032);
|
||||
let _ = img.save(out_dir.join("words_fullscreen_official.png"));
|
||||
|
||||
// Verify purple Alice ring (#8B5CF6) rendered inside the centered source pill
|
||||
let mut alice_purple_px = 0usize;
|
||||
for y in 360..600 {
|
||||
for x in 560..960 {
|
||||
let [r, g, b] = img.get_pixel(x, y).0;
|
||||
if b > 160 && r > 90 && (b as u16) > (g as u16) + 50 {
|
||||
alice_purple_px += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
assert!(
|
||||
alice_purple_px >= 15,
|
||||
"[words_fullscreen_official] Expected purple Alice AI icon inside source pill, found {} px",
|
||||
alice_purple_px
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue