feat: 1:1 Yandex ID account menu, official WordsCard AI replies, VibeResetButton pill, and git.tatar updater

This commit is contained in:
marwy 2026-11-27 13:43:33 +03:00
parent 682e3579ab
commit 6c30a33a9b
28 changed files with 2574 additions and 461 deletions

File diff suppressed because it is too large Load diff

View file

@ -67,6 +67,7 @@ pub struct ShellUiState {
pub entity_share_submenu_open: bool,
pub sidebar_profile_open: bool,
pub sidebar_appearance_open: bool,
pub sidebar_lang_open: bool,
pub sidebar_pin_menu: Option<(usize, Pos2)>,
pub vibe_menu_open: bool,
pub vibe_vol_open: bool,
@ -172,6 +173,7 @@ impl ShellUiState {
self.entity_share_submenu_open = false;
self.sidebar_profile_open = false;
self.sidebar_appearance_open = false;
self.sidebar_lang_open = false;
self.sidebar_pin_menu = None;
self.vibe_menu_open = false;
self.vibe_vol_open = false;

View file

@ -622,9 +622,9 @@ pub fn render_settings(
y += sc_h + 14.0;
// -------------------------------------------------------------------------
// 7. About 5.129.0 & Cache
// 7. About & Updates (`git.tatar/marwy/yandex-music-rs`) & Cache
// -------------------------------------------------------------------------
let about_h = 148.0;
let about_h = 172.0;
let about_inner = draw_settings_card(
ctx,
pal,
@ -634,9 +634,9 @@ pub fn render_settings(
{
let mut cy = about_inner.top();
let ver_str = if ru {
format!("Яндекс Музыка · Версия {}", APP_VERSION)
format!("yandex-music-rs · Версия {}", APP_VERSION)
} else {
format!("Yandex Music · Version {}", APP_VERSION)
format!("yandex-music-rs · Version {}", APP_VERSION)
};
ctx.draw_text_ellipsis(
&ver_str,
@ -645,10 +645,41 @@ pub fn render_settings(
TextAlign::Left,
);
cy += 24.0;
let repo_label = "git.tatar/marwy/yandex-music-rs";
let repo_w = ctx
.measure_text(repo_label, TextStyle::medium(13.0, pal.text_secondary), None)
.x
+ 8.0;
let repo_r = Rect::from_xywh(about_inner.left(), cy, repo_w.min(about_inner.width()), 20.0);
let repo_resp = ctx.interact(WidgetId::new("set_repo_link"), repo_r);
ctx.draw_text_ellipsis(
repo_label,
TextStyle::medium(
13.0,
if repo_resp.hovered {
pal.text_bright
} else if pal.is_dark {
pal.yellow
} else {
pal.outline_selected
},
),
repo_r,
TextAlign::Left,
);
if repo_resp.hovered {
ctx.set_cursor(CursorKind::Pointer);
}
if repo_resp.clicked {
actions.push(AppAction::OpenUrl(
"https://git.tatar/marwy/yandex-music-rs".into(),
));
}
cy += 22.0;
let cache_str = if ru {
format!("© Яндекс · Кэш обложек: {} шт.", covers.len())
format!("Кэш обложек: {} шт.", covers.len())
} else {
format!("© Yandex · Cover cache: {} items", covers.len())
format!("Cover cache: {} items", covers.len())
};
ctx.draw_text_ellipsis(
&cache_str,
@ -658,19 +689,26 @@ pub fn render_settings(
);
cy += 28.0;
let upd_label = if let Some((ref new_ver, _)) = app.available_update {
if ru {
format!("Обновить до {}", new_ver)
} else {
format!("Update to {}", new_ver)
}
} else if ru {
"Проверить обновления".to_string()
} else {
"Check for updates".to_string()
};
let (upd_resp, upd_r) = secondary_pill_button(
ctx,
pal,
WidgetId::new("set_check_updates"),
Pos2::new(about_inner.left(), cy),
None,
if ru {
"Проверить обновления"
} else {
"Check for updates"
},
&upd_label,
36.0,
false,
app.available_update.is_some(),
);
if upd_resp.clicked {
actions.push(AppAction::CheckForUpdates);

View file

@ -1,9 +1,8 @@
use crate::app::{AppAction, AppState, Route};
use crate::config::{PinnedItem, ThemeMode};
use crate::config::{Language, PinnedItem, ThemeMode};
use crate::covers::CoverCache;
use crate::engine::widgets::{
draw_cover_art, draw_plus_avatar_ring, draw_plus_badge, ym_menu_frame, ym_menu_item,
ym_menu_item_ex,
};
use crate::engine::{
css_rgba, Color, CursorKind, Pos2, Rect, TextAlign, TextStyle, UiContext, Vec2, WidgetId,
@ -589,7 +588,17 @@ pub fn render_sidebar(
}
if shell.sidebar_profile_open {
render_profile_card_popup(ctx, pal, app, shell, sidebar_rect, footer_rect, profile_hit, actions);
render_profile_card_popup(
ctx,
pal,
covers,
app,
shell,
sidebar_rect,
footer_rect,
profile_hit,
actions,
);
}
}
@ -616,11 +625,14 @@ fn is_pin_active_route(pin: &PinnedItem, app: &AppState) -> bool {
}
}
/// 100% Theme-aware Yandex ID Profile Card Popup + 3-way Appearance Submenu (`Как в системе` / `Тёмная` / `Светлая`)
/// 1-to-1 Official Yandex ID `/music` Account Popup (v2.79.0) — Dark & Light themes,
/// exact surface/text/hover tokens, centered 56px Plus-ring avatar, dynamic Appearance icon,
/// Language popover (`ru`/`en`), and 3-way Appearance popover (`Всегда светлый` / `Всегда тёмный` / `Как в системе`).
#[allow(clippy::too_many_arguments)]
fn render_profile_card_popup(
ctx: &mut UiContext,
pal: &YmPalette,
covers: &mut CoverCache,
app: &AppState,
shell: &mut ShellUiState,
sidebar_rect: Rect,
@ -630,118 +642,233 @@ fn render_profile_card_popup(
) {
let i18n = app.i18n();
let ru = i18n.is_ru();
let is_dark = pal.is_dark;
let has_plus = app.account.as_ref().map_or(false, |a| a.has_plus);
let logged_in = app.account.is_some();
// Exact Yandex ID v2.79.0 Surface & Color Tokens (`307ea1c94a69877eefe9.css`)
let card_bg = if is_dark {
Color::rgb(0x1F, 0x1F, 0x24)
} else {
Color::WHITE
};
let card_border = if is_dark {
Color::rgb(0x33, 0x33, 0x33)
} else {
Color::rgb(0xE6, 0xE6, 0xE6)
};
let popover_bg = if is_dark {
Color::rgb(0x2D, 0x2D, 0x34)
} else {
Color::WHITE
};
let popover_border = if is_dark {
css_rgba(250, 250, 255, 26)
} else {
Color::rgb(0xE6, 0xE6, 0xE6)
};
let id_text_primary = if is_dark {
Color::rgb(0xFA, 0xFA, 0xFF)
} else {
Color::rgb(0x26, 0x26, 0x33)
};
let id_text_secondary = if is_dark {
css_rgba(240, 240, 255, 118)
} else {
Color::rgb(0x85, 0x88, 0x9E)
};
let id_row_hover = if is_dark {
css_rgba(250, 250, 255, 20)
} else {
css_rgba(180, 184, 204, 36)
};
let id_separator = if is_dark {
css_rgba(250, 250, 255, 22)
} else {
css_rgba(38, 38, 51, 22)
};
let card_w = 320.0;
let header_h = if logged_in { 88.0 } else { 154.0 };
let rows_h = 50.0 // Plus row with subtitle
+ 40.0 * 4.0 // Account, Settings, Support, Language
+ 13.0 // divider
+ 40.0 // Appearance
+ if logged_in { 40.0 } else { 0.0 }; // Sign out
let card_h = 20.0 + header_h + rows_h + 20.0;
let header_h = if logged_in { 144.0 } else { 198.0 };
let group1_h = 54.0 + if logged_in { 44.0 * 4.0 } else { 44.0 * 2.0 };
let sep_h = 13.0; // 6px top + 1px line + 6px bottom
let group2_h = 44.0;
let group3_h = if logged_in { sep_h + 44.0 * 2.0 } else { 0.0 };
let card_h = header_h + group1_h + sep_h + group2_h + group3_h + 10.0;
let screen = ctx.screen_rect();
let card_x = (sidebar_rect.left() + 20.0).min((screen.right() - card_w - 12.0).max(8.0));
let card_y = (footer_rect.top() - card_h - 10.0).clamp(40.0, (screen.bottom() - card_h - 12.0).max(40.0));
let card_y =
(footer_rect.top() - card_h - 10.0).clamp(40.0, (screen.bottom() - card_h - 12.0).max(40.0));
let card_rect = Rect::from_xywh(card_x, card_y, card_w, card_h);
let mut close_popup = false;
let mut lang_row_rect = Rect::ZERO;
let mut appearance_row_rect = Rect::ZERO;
ctx.with_layer(ZLayer::Popover, |ctx| {
ctx.register_blocker(card_rect);
// Card container: exact `pal.profile_bg` (`#121212` dark / `#FFFFFF` light) + `pal.border_control`!
// Card container: exact `24px` radius, `card_bg`, `1px` `card_border`, elevation shadow
ctx.dl()
.push_shadow(card_rect, 24.0, 24.0, 0.0, Vec2::new(0.0, 6.0), pal.shadow_modal);
.push_shadow(card_rect, 24.0, 28.0, 0.0, Vec2::new(0.0, 8.0), pal.shadow_modal);
ctx.dl()
.push_rect_bordered(card_rect, 24.0, pal.profile_bg, 1.0, pal.border_control);
.push_rect_bordered(card_rect, 24.0, card_bg, 1.0, card_border);
let inner = card_rect.shrink(20.0);
let mut y = inner.top();
// 1. Top Overlay Bar (`_overlap_1v1kx_1`): 41×20 Yandex ID vector logo + 32×32 circular Close `×`
let logo_r = Rect::from_xywh(card_rect.left() + 16.0, card_rect.top() + 16.0, 41.0, 20.0);
let logo_icon = match (ru, is_dark) {
(true, true) => Icon::YandexIdLogoRuDark,
(true, false) => Icon::YandexIdLogoRuLight,
(false, true) => Icon::YandexIdLogoEnDark,
(false, false) => Icon::YandexIdLogoEnLight,
};
let logo_resp = ctx.interact(WidgetId::new("prof_yid_logo"), logo_r);
ctx.draw_icon(logo_icon, logo_r, Color::WHITE);
if logo_resp.hovered {
ctx.set_cursor(CursorKind::Pointer);
}
if logo_resp.clicked {
actions.push(AppAction::OpenUrl("https://id.yandex.ru".into()));
close_popup = true;
}
// Top row: Yandex ID badge + Close `×`
let badge_cy = y + 11.0;
ctx.dl()
.push_circle(Pos2::new(inner.left() + 11.0, badge_cy), 10.0, Color::rgb(0xFC, 0x3F, 0x1D));
ctx.draw_text_ellipsis(
if ru { "Я" } else { "Y" },
TextStyle::bold(12.0, Color::WHITE),
Rect::from_center_size(Pos2::new(inner.left() + 11.0, badge_cy), Vec2::splat(20.0)),
TextAlign::Center,
);
let id_pill = Rect::from_xywh(inner.left() + 24.0, y + 1.0, 24.0, 20.0);
ctx.dl().push_rect(id_pill, 6.0, pal.text_bright);
ctx.draw_text_ellipsis(
"ID",
TextStyle::bold(11.0, pal.profile_bg),
id_pill,
TextAlign::Center,
);
let close_r = Rect::from_xywh(inner.right() - 26.0, y - 2.0, 26.0, 26.0);
let close_r = Rect::from_xywh(card_rect.right() - 44.0, card_rect.top() + 10.0, 32.0, 32.0);
let close_resp = ctx.interact(WidgetId::new("prof_card_close"), close_r);
if close_resp.hovered {
ctx.dl().push_circle(close_r.center(), 13.0, pal.surface_hover);
ctx.dl().push_circle(close_r.center(), 16.0, id_row_hover);
ctx.set_cursor(CursorKind::Pointer);
}
ctx.draw_icon(
Icon::Close,
Rect::from_center_size(close_r.center(), Vec2::splat(16.0)),
pal.text_primary,
Rect::from_center_size(close_r.center(), Vec2::splat(18.0)),
if close_resp.hovered {
id_text_primary
} else {
id_text_secondary
},
);
if close_resp.clicked {
close_popup = true;
}
y += 32.0;
// Account info OR Guest login prompt
// 2. Header: Logged In (`cv`) vs Logged Out (`Av`)
let mut y = card_rect.top() + header_h;
if let Some(ref acc) = app.account {
let avatar_center = Pos2::new(card_rect.center_x(), card_rect.top() + 20.0 + 28.0);
if acc.has_plus {
draw_plus_avatar_ring(ctx, avatar_center, 31.0, 2.0);
ctx.dl().push_circle(avatar_center, 29.0, card_bg);
}
let av_rect = Rect::from_center_size(avatar_center, Vec2::splat(56.0));
if acc.avatar_uri.is_some() {
draw_cover_art(
ctx,
pal,
covers,
av_rect,
acc.avatar_uri.as_deref(),
"profile_popup_avatar",
28.0,
true,
false,
);
} else {
ctx.dl().push_circle(
avatar_center,
28.0,
if is_dark {
Color::rgb(0x32, 0x32, 0x3B)
} else {
Color::rgb(0xEB, 0xEC, 0xF2)
},
);
let initial = acc
.display_name
.chars()
.next()
.or_else(|| acc.login.chars().next())
.unwrap_or(if ru { 'Я' } else { 'Y' })
.to_uppercase()
.to_string();
ctx.draw_text_ellipsis(
&initial,
TextStyle::bold(22.0, id_text_primary),
av_rect,
TextAlign::Center,
);
}
let name_y = card_rect.top() + 20.0 + 56.0 + 10.0;
ctx.draw_text_ellipsis(
&acc.display_name,
TextStyle::bold(20.0, pal.text_bright),
Rect::from_xywh(inner.left(), y, inner.width(), 26.0),
TextAlign::Left,
TextStyle::bold(16.0, id_text_primary),
Rect::from_center_size(Pos2::new(card_rect.center_x(), name_y + 11.0), Vec2::new(260.0, 22.0)),
TextAlign::Center,
);
y += 26.0;
let sub_y = name_y + 22.0 + 2.0;
let contact_str = acc
.default_email
.as_deref()
.filter(|s| !s.is_empty())
.unwrap_or(&acc.login);
ctx.draw_text_ellipsis(
&format!("@{}", acc.login),
TextStyle::regular(13.0, pal.text_secondary),
Rect::from_xywh(inner.left(), y, inner.width(), 18.0),
TextAlign::Left,
contact_str,
TextStyle::regular(13.0, id_text_secondary),
Rect::from_center_size(Pos2::new(card_rect.center_x(), sub_y + 9.0), Vec2::new(260.0, 18.0)),
TextAlign::Center,
);
y += 30.0;
} else {
let hx = card_rect.left() + 16.0;
let hw = card_w - 32.0;
let mut hy = card_rect.top() + 52.0;
let title = if ru { "Войдите в аккаунт" } else { "Log in" };
ctx.draw_text_ellipsis(
i18n.log_in(),
TextStyle::bold(22.0, pal.text_bright),
Rect::from_xywh(inner.left(), y, inner.width(), 28.0),
title,
TextStyle::bold(20.0, id_text_primary),
Rect::from_xywh(hx, hy, hw, 28.0),
TextAlign::Left,
);
y += 30.0;
hy += 34.0;
let subtitle = if ru {
"Чтобы сохранить свои закладки, пароли и карты"
} else {
"To save your bookmarks, passwords, and cards"
};
ctx.draw_text_wrapped(
i18n.login_subtitle(),
TextStyle::regular(13.0, pal.text_secondary),
Rect::from_xywh(inner.left(), y, inner.width(), 34.0),
subtitle,
TextStyle::regular(13.0, id_text_secondary),
Rect::from_xywh(hx, hy, hw, 36.0),
Some(2),
TextAlign::Left,
);
y += 40.0;
hy += 52.0;
let btn_r = Rect::from_xywh(inner.left(), y, inner.width(), 42.0);
let btn_r = Rect::from_xywh(hx, hy, hw, 44.0);
let btn_resp = ctx.interact(WidgetId::new("prof_login_btn"), btn_r);
let btn_bg = if btn_resp.hovered {
pal.text_primary
let btn_bg = if is_dark {
if btn_resp.hovered {
Color::rgb(0xE8, 0xE8, 0xF2)
} else {
Color::rgb(0xFA, 0xFA, 0xFF)
}
} else if btn_resp.hovered {
Color::rgb(0x3B, 0x3B, 0x47)
} else {
pal.text_bright
Color::rgb(0x29, 0x29, 0x33)
};
ctx.dl().push_rect(btn_r, 14.0, btn_bg);
let btn_fg = if is_dark {
Color::rgb(0x1F, 0x1F, 0x24)
} else {
Color::WHITE
};
ctx.dl().push_rect(btn_r, 12.0, btn_bg);
ctx.draw_text_ellipsis(
i18n.log_in(),
TextStyle::bold(15.0, pal.profile_bg),
if ru { "Войти" } else { "Log in" },
TextStyle::bold(15.0, btn_fg),
btn_r,
TextAlign::Center,
);
@ -752,242 +879,478 @@ fn render_profile_card_popup(
actions.push(AppAction::SetLoginModalOpen(true));
close_popup = true;
}
y += 52.0;
}
// Helper for 100% theme-aware Yandex ID card rows
let draw_profile_row = |ctx: &mut UiContext,
id: &str,
y_pos: f32,
ic: Icon,
title: &str,
subtitle: Option<&str>,
has_chevron: bool,
active: bool|
// Helper for exact Yandex ID v2.79.0 menu rows (`padding: 0 8px`, `radius: 12px`, `24px` icon @ `+12px`, text @ `+48px`)
let row_x = card_rect.left() + 8.0;
let row_w = card_w - 16.0;
let draw_id_row = |ctx: &mut UiContext,
id: &str,
y_pos: f32,
row_h: f32,
ic: Icon,
ic_tint: Color,
title: &str,
subtitle: Option<&str>,
has_chevron: bool,
active: bool,
right_plus_badge: Option<&str>|
-> (bool, bool, Rect) {
let h = if subtitle.is_some() { 50.0 } else { 40.0 };
let r = Rect::from_xywh(inner.left(), y_pos, inner.width(), h);
let r = Rect::from_xywh(row_x, y_pos, row_w, row_h);
let resp = ctx.interact(WidgetId::new(id), r);
if resp.hovered || active {
ctx.dl().push_rect(r, 12.0, pal.surface_hover);
ctx.dl().push_rect(r, 12.0, id_row_hover);
}
if resp.hovered {
ctx.set_cursor(CursorKind::Pointer);
}
ctx.draw_icon(
ic,
Rect::from_center_size(Pos2::new(r.left() + 18.0, r.center_y()), Vec2::splat(20.0)),
pal.text_primary,
Rect::from_center_size(Pos2::new(r.left() + 24.0, r.center_y()), Vec2::splat(24.0)),
ic_tint,
);
let tx = r.left() + 42.0;
let tw = (r.right() - tx - if has_chevron { 28.0 } else { 8.0 }).max(40.0);
let tx = r.left() + 48.0;
let right_reserve = if right_plus_badge.is_some() {
68.0
} else if has_chevron {
32.0
} else {
12.0
};
let tw = (r.right() - tx - right_reserve).max(40.0);
if let Some(sub) = subtitle {
ctx.draw_text_ellipsis(
title,
TextStyle::medium(14.0, pal.text_primary),
Rect::from_xywh(tx, r.top() + 6.0, tw, 19.0),
TextStyle::medium(14.5, id_text_primary),
Rect::from_xywh(tx, r.top() + 8.0, tw, 20.0),
TextAlign::Left,
);
ctx.draw_text_ellipsis(
sub,
TextStyle::regular(12.0, pal.text_secondary),
Rect::from_xywh(tx, r.top() + 26.0, tw, 17.0),
TextStyle::regular(12.5, id_text_secondary),
Rect::from_xywh(tx, r.top() + 29.0, tw, 17.0),
TextAlign::Left,
);
} else {
ctx.draw_text_ellipsis(
title,
TextStyle::medium(14.0, pal.text_primary),
TextStyle::medium(14.5, id_text_primary),
Rect::from_xywh(tx, r.top(), tw, r.height()),
TextAlign::Left,
);
}
if has_chevron {
if let Some(badge_txt) = right_plus_badge {
let bw = (ctx.measure_text(badge_txt, TextStyle::bold(11.5, Color::WHITE), None).x
+ 18.0)
.max(46.0);
let br = Rect::from_xywh(r.right() - bw - 10.0, r.center_y() - 10.0, bw, 20.0);
ctx.dl().push_plus_gradient_rect(br, 10.0, 1.0);
ctx.draw_text_ellipsis(
badge_txt,
TextStyle::bold(11.5, Color::WHITE),
br,
TextAlign::Center,
);
} else if has_chevron {
ctx.draw_icon(
Icon::MenuArrowXxs,
Rect::from_center_size(Pos2::new(r.right() - 14.0, r.center_y()), Vec2::splat(20.0)),
pal.text_secondary,
Rect::from_center_size(Pos2::new(r.right() - 16.0, r.center_y()), Vec2::splat(20.0)),
id_text_secondary,
);
}
(resp.clicked, resp.hovered, r)
};
// Row 1: Yandex Plus
let plus_title = if has_plus {
if ru { "Яндекс Плюс" } else { "Yandex Plus" }
} else if ru {
"Подключить Яндекс Плюс"
} else {
"Connect Yandex Plus"
let draw_separator = |ctx: &mut UiContext, y_pos: f32| {
ctx.dl().push_rect(
Rect::from_xywh(card_rect.left() + 16.0, y_pos + 6.0, card_w - 32.0, 1.0),
0.0,
id_separator,
);
};
let plus_sub = if ru {
"Все преимущества в одной подписке"
// 3. Menu Group 1 (`r.Menu`)
// Row 1 — Plus (`54px`)
let (plus_title, plus_sub, plus_pill) = if has_plus {
(
if ru { "Плюс" } else { "Plus" },
if ru {
"Подписка активна"
} else {
"Subscription is active"
},
Some(if ru { "Плюс" } else { "Plus" }),
)
} else {
"All the fun and benefits in one subscription"
(
if ru {
"Подключить Плюс"
} else {
"Connect Yandex Plus"
},
if ru {
"Все развлечения и выгода в одной подписке"
} else {
"All the fun and benefits in one subscription"
},
None,
)
};
if draw_profile_row(ctx, "prof_plus", y, Icon::Plus, plus_title, Some(plus_sub), false, false).0 {
let (c, h, _) = draw_id_row(
ctx,
"prof_plus",
y,
54.0,
Icon::ProfilePlusXxs,
Color::WHITE, // multi-stop gradient SVG
plus_title,
Some(plus_sub),
false,
false,
plus_pill,
);
if h {
shell.sidebar_lang_open = false;
shell.sidebar_appearance_open = false;
}
if c {
actions.push(AppAction::OpenUrl("https://plus.yandex.ru".into()));
close_popup = true;
}
y += 50.0;
y += 54.0;
// Row 2: Account management (dedicated `ProfileAccountXxs`)
if draw_profile_row(
ctx,
"prof_account",
y,
Icon::ProfileAccountXxs,
i18n.account_management(),
None,
false,
false,
)
.0
{
actions.push(AppAction::OpenUrl("https://id.yandex.ru".into()));
close_popup = true;
}
y += 40.0;
// Row 3: Settings (`SettingsXxs`)
if draw_profile_row(
ctx,
"prof_settings",
y,
Icon::SettingsXxs,
i18n.settings(),
None,
false,
false,
)
.0
{
actions.push(AppAction::Navigate(Route::Settings));
close_popup = true;
}
y += 40.0;
// Row 4: Support chat (`ProfileSupportXxs`)
if draw_profile_row(
ctx,
"prof_support",
y,
Icon::ProfileSupportXxs,
i18n.support_chat(),
None,
false,
false,
)
.0
{
actions.push(AppAction::OpenUrl("https://yandex.ru/support/music/".into()));
close_popup = true;
}
y += 40.0;
// Row 5: Language (`ProfileGlobeXxs`)
if draw_profile_row(
ctx,
"prof_lang",
y,
Icon::ProfileGlobeXxs,
i18n.language_name(),
None,
false,
false,
)
.0
{
actions.push(AppAction::ToggleLanguage);
close_popup = true;
}
y += 40.0;
// Divider
ctx.dl()
.push_rect(Rect::from_xywh(inner.left(), y + 6.0, inner.width(), 1.0), 0.0, pal.border_control);
y += 13.0;
// Row 6: Appearance (`ProfileAppearanceXxs`) -> opens 3-way Appearance submenu!
let (app_clicked, app_hovered, app_rect) = draw_profile_row(
ctx,
"prof_appearance",
y,
Icon::ProfileAppearanceXxs,
i18n.appearance(),
None,
true,
shell.sidebar_appearance_open,
);
appearance_row_rect = app_rect;
if app_clicked {
shell.sidebar_appearance_open = !shell.sidebar_appearance_open;
} else if app_hovered {
shell.sidebar_appearance_open = true;
}
y += 40.0;
// Row 7: Sign out (`ProfileLogoutXxs`) when logged in
if logged_in
&& draw_profile_row(
// Row 2 — Account management (logged in)
if logged_in {
let (c, h, _) = draw_id_row(
ctx,
"prof_logout",
"prof_account",
y,
Icon::ProfileLogoutXxs,
i18n.sign_out(),
44.0,
Icon::ProfileAccountXxs,
id_text_primary,
if ru {
"Управление аккаунтом"
} else {
"Account management"
},
None,
false,
false,
)
.0
{
actions.push(AppAction::Logout);
close_popup = true;
None,
);
if h {
shell.sidebar_lang_open = false;
shell.sidebar_appearance_open = false;
}
if c {
actions.push(AppAction::OpenUrl("https://id.yandex.ru".into()));
close_popup = true;
}
y += 44.0;
// Row 3 — Settings (logged in)
let (c, h, _) = draw_id_row(
ctx,
"prof_settings",
y,
44.0,
Icon::ProfileSettingsXxs,
id_text_primary,
if ru { "Настройки" } else { "Settings" },
None,
false,
false,
None,
);
if h {
shell.sidebar_lang_open = false;
shell.sidebar_appearance_open = false;
}
if c {
actions.push(AppAction::Navigate(Route::Settings));
close_popup = true;
}
y += 44.0;
}
// Appearance Submenu (`Как в системе` / `Тёмная` / `Светлая` + active `CheckXxs`!)
let mut submenu_rect = Rect::ZERO;
// Row 4 — Support chat (paper-plane)
let (c, h, _) = draw_id_row(
ctx,
"prof_support",
y,
44.0,
Icon::ProfileSupportXxs,
id_text_primary,
if ru {
"Чат с поддержкой"
} else {
"Chat with support"
},
None,
false,
false,
None,
);
if h {
shell.sidebar_lang_open = false;
shell.sidebar_appearance_open = false;
}
if c {
actions.push(AppAction::OpenUrl(
"https://yandex.ru/support/plus/help/ru/?utm_source=music".into(),
));
close_popup = true;
}
y += 44.0;
// Row 5 — Language (opens Yandex ID Language Popover!)
let (lang_clicked, lang_hovered, lang_r) = draw_id_row(
ctx,
"prof_lang",
y,
44.0,
Icon::ProfileGlobeXxs,
id_text_primary,
if ru { "Русский" } else { "English" },
None,
true,
shell.sidebar_lang_open,
None,
);
lang_row_rect = lang_r;
if lang_clicked {
shell.sidebar_lang_open = !shell.sidebar_lang_open;
if shell.sidebar_lang_open {
shell.sidebar_appearance_open = false;
}
} else if lang_hovered {
shell.sidebar_lang_open = true;
shell.sidebar_appearance_open = false;
}
y += 44.0;
// 4. Hairline Separator 1
draw_separator(ctx, y);
y += sep_h;
// 5. Menu Group 2 (`r.Submenu`) — Appearance (dynamic icon matching current theme!)
let theme_row_icon = match app.config.theme {
ThemeMode::Light => Icon::ThemeLightXxs,
ThemeMode::Dark => Icon::ThemeDarkXxs,
ThemeMode::System => Icon::ThemeSystemXxs,
};
let (app_clicked, app_hovered, app_r) = draw_id_row(
ctx,
"prof_appearance",
y,
44.0,
theme_row_icon,
id_text_primary,
if ru { "Внешний вид" } else { "Appearance" },
None,
true,
shell.sidebar_appearance_open,
None,
);
appearance_row_rect = app_r;
if app_clicked {
shell.sidebar_appearance_open = !shell.sidebar_appearance_open;
if shell.sidebar_appearance_open {
shell.sidebar_lang_open = false;
}
} else if app_hovered {
shell.sidebar_appearance_open = true;
shell.sidebar_lang_open = false;
}
y += 44.0;
// 6. Hairline Separator 2 + Account Actions (when logged in)
if logged_in {
draw_separator(ctx, y);
y += sep_h;
// Row 7 — Add account
let (c, h, _) = draw_id_row(
ctx,
"prof_add_account",
y,
44.0,
Icon::ProfileAddAccountXxs,
id_text_primary,
if ru {
"Добавить аккаунт"
} else {
"Add account"
},
None,
false,
false,
None,
);
if h {
shell.sidebar_lang_open = false;
shell.sidebar_appearance_open = false;
}
if c {
actions.push(AppAction::SetLoginModalOpen(true));
close_popup = true;
}
y += 44.0;
// Row 8 — Sign out
let (c, h, _) = draw_id_row(
ctx,
"prof_logout",
y,
44.0,
Icon::ProfileLogoutXxs,
id_text_primary,
if ru { "Выйти" } else { "Sign out" },
None,
false,
false,
None,
);
if h {
shell.sidebar_lang_open = false;
shell.sidebar_appearance_open = false;
}
if c {
actions.push(AppAction::Logout);
close_popup = true;
}
}
// 7A. Yandex ID Language Popover (`210px`, `radius: 16px`, `40px` items: `ru Русский` / `en English`)
let mut lang_sub_rect = Rect::ZERO;
if shell.sidebar_lang_open {
let sub_w = 210.0;
let sub_h = 40.0 * 2.0 + 16.0;
let sub_x = (card_rect.right() + 8.0).min((screen.right() - sub_w - 8.0).max(8.0));
let sub_y = (lang_row_rect.top() - 8.0)
.clamp(40.0, (screen.bottom() - sub_h - 12.0).max(40.0));
lang_sub_rect = Rect::from_xywh(sub_x, sub_y, sub_w, sub_h);
ctx.register_blocker(lang_sub_rect);
ctx.dl()
.push_shadow(lang_sub_rect, 16.0, 24.0, 0.0, Vec2::new(0.0, 6.0), pal.shadow_modal);
ctx.dl()
.push_rect_bordered(lang_sub_rect, 16.0, popover_bg, 1.0, popover_border);
let sub_inner = lang_sub_rect.shrink(8.0);
let lang_opts = [
(Language::Ru, "ru", "Русский", "lang_opt_ru"),
(Language::En, "en", "English", "lang_opt_en"),
];
for (idx, (lang, code, lbl, wid)) in lang_opts.into_iter().enumerate() {
let is_cur = app.config.language == lang;
let ir = Rect::from_xywh(sub_inner.x, sub_inner.y + idx as f32 * 40.0, sub_inner.w, 40.0);
let r = ctx.interact(WidgetId::new(wid), ir);
if r.hovered {
ctx.dl().push_rect(ir, 12.0, id_row_hover);
ctx.set_cursor(CursorKind::Pointer);
}
ctx.draw_text_ellipsis(
code,
TextStyle::bold(13.0, id_text_secondary),
Rect::from_xywh(ir.left() + 12.0, ir.top(), 24.0, ir.height()),
TextAlign::Left,
);
ctx.draw_text_ellipsis(
lbl,
TextStyle::medium(14.0, id_text_primary),
Rect::from_xywh(ir.left() + 42.0, ir.top(), (ir.width() - 72.0).max(40.0), ir.height()),
TextAlign::Left,
);
if is_cur {
ctx.draw_icon(
Icon::CheckXxs,
Rect::from_center_size(Pos2::new(ir.right() - 16.0, ir.center_y()), Vec2::splat(20.0)),
id_text_primary,
);
}
if r.clicked {
actions.push(AppAction::SetLanguage(lang));
shell.sidebar_lang_open = false;
}
}
}
// 7B. Yandex ID Appearance Popover (`224px`, `radius: 16px`, `40px` items in exact official order!)
let mut app_sub_rect = Rect::ZERO;
if shell.sidebar_appearance_open {
let sub_w = 220.0;
let sub_h = 36.0 * 3.0 + 16.0;
let sub_w = 224.0;
let sub_h = 40.0 * 3.0 + 16.0;
let sub_x = (card_rect.right() + 8.0).min((screen.right() - sub_w - 8.0).max(8.0));
let sub_y = (appearance_row_rect.top() - 8.0)
.clamp(40.0, (screen.bottom() - sub_h - 12.0).max(40.0));
submenu_rect = Rect::from_xywh(sub_x, sub_y, sub_w, sub_h);
app_sub_rect = Rect::from_xywh(sub_x, sub_y, sub_w, sub_h);
ctx.register_blocker(app_sub_rect);
ctx.dl()
.push_shadow(app_sub_rect, 16.0, 24.0, 0.0, Vec2::new(0.0, 6.0), pal.shadow_modal);
ctx.dl()
.push_rect_bordered(app_sub_rect, 16.0, popover_bg, 1.0, popover_border);
let sub_inner = ym_menu_frame(ctx, pal, submenu_rect);
let sub_inner = app_sub_rect.shrink(8.0);
let theme_opts = [
(ThemeMode::System, Icon::ThemeSystemXxs, i18n.theme_system(), "theme_opt_sys"),
(ThemeMode::Dark, Icon::ThemeDarkXxs, i18n.theme_dark(), "theme_opt_dark"),
(ThemeMode::Light, Icon::ThemeLightXxs, i18n.theme_light(), "theme_opt_light"),
(
ThemeMode::Light,
Icon::ThemeLightXxs,
if ru { "Всегда светлый" } else { "Always light" },
"theme_opt_light",
),
(
ThemeMode::Dark,
Icon::ThemeDarkXxs,
if ru { "Всегда тёмный" } else { "Always dark" },
"theme_opt_dark",
),
(
ThemeMode::System,
Icon::ThemeSystemXxs,
if ru { "Как в системе" } else { "System settings" },
"theme_opt_sys",
),
];
for (idx, (mode, ic, lbl, wid)) in theme_opts.into_iter().enumerate() {
let is_cur = app.config.theme == mode;
let ir = Rect::from_xywh(sub_inner.x, sub_inner.y + idx as f32 * 36.0, sub_inner.w, 36.0);
if ym_menu_item_ex(
ctx,
pal,
WidgetId::new(wid),
ir,
let ir = Rect::from_xywh(sub_inner.x, sub_inner.y + idx as f32 * 40.0, sub_inner.w, 40.0);
let r = ctx.interact(WidgetId::new(wid), ir);
if r.hovered {
ctx.dl().push_rect(ir, 12.0, id_row_hover);
ctx.set_cursor(CursorKind::Pointer);
}
ctx.draw_icon(
ic,
Rect::from_center_size(Pos2::new(ir.left() + 20.0, ir.center_y()), Vec2::splat(20.0)),
id_text_primary,
);
ctx.draw_text_ellipsis(
lbl,
is_cur,
is_cur,
false,
false,
)
.clicked
{
TextStyle::medium(14.0, id_text_primary),
Rect::from_xywh(ir.left() + 42.0, ir.top(), (ir.width() - 72.0).max(40.0), ir.height()),
TextAlign::Left,
);
if is_cur {
ctx.draw_icon(
Icon::CheckXxs,
Rect::from_center_size(Pos2::new(ir.right() - 16.0, ir.center_y()), Vec2::splat(20.0)),
id_text_primary,
);
}
if r.clicked {
actions.push(AppAction::SetTheme(mode));
shell.sidebar_appearance_open = false;
}
}
}
// Click outside profile card + submenu + profile trigger button closes popup
// Click outside profile card + open sub-popover + profile trigger button closes everything cleanly
let mut keep_rects = vec![card_rect, profile_hit];
if !submenu_rect.is_empty() {
keep_rects.push(submenu_rect);
if !lang_sub_rect.is_empty() {
keep_rects.push(lang_sub_rect);
}
if !app_sub_rect.is_empty() {
keep_rects.push(app_sub_rect);
}
if ctx.input.clicked_outside_any(&keep_rects) {
close_popup = true;
@ -997,5 +1360,6 @@ fn render_profile_card_popup(
if close_popup {
shell.sidebar_profile_open = false;
shell.sidebar_appearance_open = false;
shell.sidebar_lang_open = false;
}
}