Make « Sélection » a phase tab beside « Défi » (#108)

Entering an Arena champ select adds the tab and shows it from anywhere; the
Challenge and Statistics stay reachable during it, and coming back shows the
hand at rest. Its end removes the tab and shows the Challenge, the hand
leaving first when « Sélection » was in front.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
nessarandClaude Opus 5.5 committed 2026-11-23 23:59:14 +01:00
1 parent 665f129da0
commit 9b02c3eab7
27 files changed
+620 -286

No files matched your search

+13 -140
View File
@@ -1,12 +1,13 @@
//! The page and its two screens: the shared state and the navigation. `display` renders the header
//! row and the alerts; `home`, `champ_select` and `statistics` render the content under them.
//! The page and its screens: the shared state. `navigation` switches between them, `display`
//! renders the header row and the alerts; `home`, `champ_select` and `statistics` render the
//! content under them.
use crate::banner_art::BannerArt;
use crate::card::Card;
use crate::card_grid::{CardGrid, CardHovered, Paging};
use crate::card_lift::Lifts;
use crate::champion_table::ChampionTable;
use crate::motion::{Deferred, Fade, FadePhase, MatchAnimation, MatchEnd};
use crate::motion::{Deferred, Fade, MatchAnimation, MatchEnd};
use crate::ring::Ring;
use crate::stage::{Entry, Leave, Taken};
use crate::worker::{LiveChampSelect, Msg, RefreshGate};
@@ -14,11 +15,9 @@ use arena_tracker_core::{
Account, ChampionSearch, ChampionSort, Format, Scope, SeasonScope, StateFilter, Statistics,
Status, SyncProgress, Tracker,
};
use gpui_kit::base::Button as BaseButton;
use gpui_kit::base::async_util::Sender;
use gpui_kit::component::input::InputState;
use gpui_kit::component::select::{SelectItem, SelectState};
use gpui_kit::component::{ActiveTheme as _, StyledExt as _};
use gpui_kit::*;
use profiling::shown;
use scrollbar::PageScrollbar;
@@ -36,6 +35,7 @@ mod home;
mod hover;
mod lifecycle;
mod links;
mod navigation;
mod playback;
mod profiling;
mod scrollbar;
@@ -102,14 +102,17 @@ impl EventEmitter<ChampSelectTransition> for Page {}
pub struct ChampionSortChosen(pub ChampionSort);
impl EventEmitter<ChampionSortChosen> for Page {}
/// The two screens the page switches between: « Défi » is the only tab of the top bar, and
/// « Statistiques » its detail page, opened from the banner.
/// The screens the page switches between: « Défi » is a tab of the top bar, « Statistiques »
/// its detail page, opened from the banner, and « Sélection » the tab of a phase, there only
/// while an Arena champ select runs.
#[derive(Clone, Copy, PartialEq, Debug)]
enum Tab {
/// « Défi », the home: the Challenge of one Season.
Challenge,
/// « Statistiques »: the analysis by Account, Season and Format.
Statistics,
/// « Sélection »: the champ select's banner, its Anvil champions and « Autres champions ».
ChampSelect,
}
/// A followed Match waiting to play: of several, the strongest plays, and the most recent of the
@@ -244,8 +247,10 @@ pub struct Page {
/// The Account and scope `home_stats` or `home_error` were computed for: the home does not
/// depend on the Format, so a change of Format keeps them.
home_computed: Option<(String, Scope)>,
/// What the banner shows, prepared when the statistics change.
/// What the home's banner shows, prepared when the statistics change.
banner: home::BannerContent,
/// What the champ select's banner shows, prepared with its cards.
champ_select_banner: home::BannerContent,
champ_select_splashes: HashMap<u32, Rc<arena_tracker_core::Splash>>,
/// The banner's ring: a cached view.
ring: Entity<Ring>,
@@ -307,135 +312,3 @@ pub struct Page {
_subscriptions: Vec<Subscription>,
_listener: Task<()>,
}
impl Page {
/// « Défi » as a button: it takes the keyboard focus, and Enter or Space activates it. It
/// stays lit on « Statistiques », the Challenge's detail page, and takes back to the
/// Challenge from there.
fn navigation(&self, cx: &mut Context<Self>) -> impl IntoElement {
let theme = cx.theme();
let (active, active_foreground) = (theme.tab_active, theme.tab_active_foreground);
div().h_flex().gap_1().flex_shrink_0().child(
BaseButton::new("tab-challenge")
.px_3()
.py_1()
.rounded_md()
.text_sm()
.font_weight(FontWeight::SEMIBOLD)
// Always bordered, so the focus ring does not shift the label.
.border_1()
.border_color(transparent_black())
.focus_visible(|style| style.border_color(active_foreground))
.text_color(active_foreground)
.bg(active)
.accessibility_label("Défi")
.debug_selector(|| "tab-challenge".into())
.child("Défi")
.on_click(
cx.listener(|this, _, window, cx| this.set_tab(Tab::Challenge, window, cx)),
),
)
}
fn set_tab(&mut self, tab: Tab, window: &mut Window, cx: &mut Context<Self>) {
// The champ select takes the window: the Statistics tab waits for its end.
if tab == Tab::Statistics && self.in_champ_select() {
return;
}
if self.tab != tab {
self.tab = tab;
// The grids leave under the veil: no card stays lifted over it.
self.lifts.clear();
if cx.reduce_motion() || !window.is_visible() {
// Nothing to see: the end state at once.
self.end_fade(window, cx);
} else {
// From where the veil is: a switch during a transition does not wait for it.
let now = cx.background_executor().now();
let veil = self.veil(cx);
self.fade = Some(if self.shown_tab == tab {
Fade::uncovering(veil, now)
} else {
Fade::covering(veil, now)
});
self.next_fade_frame(window, cx);
}
cx.notify();
}
}
/// Draws the screen of the tab chosen.
fn show_tab(&mut self, window: &mut Window, cx: &mut Context<Self>) {
if self.shown_tab == self.tab {
return;
}
self.shown_tab = self.tab;
// The home grid is no longer under the pointer.
self.release_home(cx);
// The screen arriving was not kept up to date while hidden, and is prepared only now: a
// switch undone under the veil prepares nothing.
self.refresh_table(cx);
if self.home_cards_stale {
self.prepare_home_cards(cx);
}
self.refresh_home(cx);
if self.shown_tab == Tab::Statistics {
// The home grid is not shown: its portraits are given back, and come back with the
// grid.
self.home_grid
.update(cx, |grid, cx| grid.release_images(window, cx));
// Nor is the banner: its illustration too.
self.banner_art
.update(cx, |art, cx| art.release(window, cx));
} else {
// Nor is the table: its portraits.
self.table
.update(cx, |table, cx| table.release_images(window, cx));
}
}
/// Shows the end of the transition, if one runs, at once.
fn end_fade(&mut self, window: &mut Window, cx: &mut Context<Self>) {
self.fade = None;
if self.leave.is_some() {
self.finish_exit(window, cx);
}
self.show_tab(window, cx);
self.play_waiting(window, cx);
cx.notify();
}
/// Asks for the transition's next frame, once.
fn next_fade_frame(&mut self, window: &mut Window, cx: &mut Context<Self>) {
if !self.frame_asked {
self.frame_asked = true;
cx.on_next_frame(window, |page, window, cx| page.fade_frame(window, cx));
}
}
/// One frame of the transition: the screen arriving replaces the one leaving under the full
/// veil, and no frame is asked for once the veil is lifted.
fn fade_frame(&mut self, window: &mut Window, cx: &mut Context<Self>) {
self.frame_asked = false;
let Some(fade) = &self.fade else {
return;
};
let now = cx.background_executor().now();
if fade.finished(now) {
match fade.phase() {
FadePhase::Out => {
self.show_tab(window, cx);
// The champ select that ended leaves under the full veil: the home comes
// out of it, as after a switch of tabs.
if self.leave.is_some() {
self.finish_exit(window, cx);
}
self.fade = Some(Fade::uncovering(1., now));
}
FadePhase::In => return self.end_fade(window, cx),
}
}
self.next_fade_frame(window, cx);
cx.notify();
}
}
+5 -6
View File
@@ -6,8 +6,8 @@ use gpui_kit::*;
use std::rc::Rc;
impl Page {
/// Computes the cards' order again: for when the home statistics (the champ select's during
/// a champ select) or the sort change, and for nothing else.
/// Computes the cards' order again: for when the home statistics (the champ select's Challenge
/// during a champ select) or the sort change, and for nothing else.
pub(in crate::page) fn reorder(&mut self) {
self.order = self.sorted_order();
}
@@ -73,10 +73,9 @@ impl Page {
self.reorder();
if self.in_champ_select() {
self.prepare_champ_select(cx);
} else {
self.prepare_home_cards(cx);
self.refresh_home(cx);
}
self.prepare_home_cards(cx);
self.refresh_home(cx);
cx.emit(ChampionSortChosen(sort));
cx.notify();
}
@@ -123,7 +122,7 @@ impl Page {
/// Recomputes which cards the home shows from its own filter and search, with the total
/// untouched; while the home is not shown, the next switch does.
pub(in crate::page) fn refresh_home(&mut self, cx: &mut Context<Self>) {
if self.shown_tab != Tab::Challenge || self.in_champ_select() {
if self.shown_tab != Tab::Challenge {
return;
}
if self.hold_grid {
+7 -5
View File
@@ -41,15 +41,14 @@ impl Page {
self.champ_select = champ_select;
if changed_page {
if self.in_champ_select() {
// The champ select is about the Challenge, whatever tab was open.
self.tab = Tab::Challenge;
// Nothing plays during a champ select: what waited is no longer news.
self.stop_holding();
self.end_match(cx);
// The phase decides: « Sélection » shows, whatever screen was open, at once (its
// entry's band of light is the transition).
self.tab = Tab::ChampSelect;
self.lifts.clear();
self.end_fade(window, cx);
// The home grid gives way to the champ select's sections.
self.home_grid
.update(cx, |grid, cx| grid.release_images(window, cx));
// Its entry plays once the window shows it (#63 reveals it without focus).
self.entry_waiting = true;
} else {
@@ -59,6 +58,9 @@ impl Page {
.update(cx, |grid, cx| grid.release_images(window, cx));
// An animation asked for during the champ select plays on the home.
self.playback.stats_pending = self.playback.active();
// The phase decides: « Sélection » goes, and « Défi » shows, from wherever the
// player was (under the veil the hand left for, when it left).
self.set_tab(Tab::Challenge, window, cx);
}
}
if switch {
+3 -4
View File
@@ -71,23 +71,22 @@ impl Page {
.map_or(&[][..], |s| s.rows.as_slice());
let cards =
self.champ_select_cards(rows.iter().filter(|row| ids.contains(&row.champion.id)));
// A list the client did not send dims no tick: the ring would look empty.
self.ring.update(cx, |ring, cx| ring.set_anvil(anvil, cx));
if champ_select.is_some() {
let remaining_pickable = cards.iter().filter(|card| !card.greyed());
let first = remaining_pickable.clone().next().or_else(|| cards.first());
let splash = first
.and_then(|card| self.champ_select_splashes.get(&card.id))
.cloned();
self.banner = home::BannerContent::champ_select(
self.champ_select_banner = home::BannerContent::champ_select(
self.home_season.as_ref(),
self.home_statistics(),
anvil.is_some(),
remaining_pickable.count(),
splash,
);
self.select_art(self.ring.read(cx).lit(), cx);
}
// A list the client did not send dims no tick: the ring would look empty.
self.dress_banner(cx);
self.anvil_count = cards.len().to_string().into();
let shown = (0..cards.len()).collect();
// The hand's cards are dealt once they come: the statistics load at each entry.
+12 -4
View File
@@ -1,13 +1,19 @@
use crate::card::{Card, Reason};
use crate::card_grid::CardGrid;
use crate::motion::Fade;
use crate::page::Page;
use crate::page::{Page, Tab};
use crate::stage::{self, BEFORE_VEIL, Entry, HandAt, HandMotion, Leave, Taken};
use gpui_kit::*;
use std::rc::Rc;
use std::time::Instant;
impl Page {
/// Whether « Sélection » is the screen drawn and chosen: the champ select's motion plays
/// there only.
pub(in crate::page) fn selection_shown(&self) -> bool {
self.tab == Tab::ChampSelect && self.shown_tab == Tab::ChampSelect
}
/// Whether the page is in front of the player and may animate: the window shown, not
/// behind « Paramètres », and the Windows « Show animations » setting on.
pub(in crate::page) fn may_animate(&self, window: &Window, cx: &App) -> bool {
@@ -18,7 +24,7 @@ impl Page {
/// light, the title, then the hand dealt once it has its cards. With the Windows setting off
/// the hand is simply there.
pub(in crate::page) fn start_entry(&mut self, window: &Window, cx: &mut Context<Self>) {
if !self.entry_waiting || !self.in_champ_select() {
if !self.entry_waiting || !self.in_champ_select() || !self.selection_shown() {
return;
}
if cx.reduce_motion() {
@@ -71,13 +77,15 @@ impl Page {
let grid = self.anvil_grid.read(cx);
let cards = grid.cards().len();
let leave = Leave::new(grid.cards(), hand_at, now);
// A veil already on its way (the player chose « Défi ») stays where it is meanwhile.
let veil = self.veil(cx);
self.forget_stage();
// No card stays lifted over the hand leaving.
self.lifts.clear();
self.lifted_by_keyboard = None;
self.leave = Some(leave);
let veil_from = if cards == 0 { now } else { now + BEFORE_VEIL };
self.fade = Some(Fade::covering(0., veil_from));
self.fade = Some(Fade::covering(veil, veil_from));
self.next_fade_frame(window, cx);
cx.notify();
}
@@ -97,7 +105,7 @@ impl Page {
window: &Window,
cx: &mut Context<Self>,
) {
if !self.may_animate(window, cx) {
if !self.selection_shown() || !self.may_animate(window, cx) {
return;
}
let now = cx.background_executor().now();
@@ -1,7 +1,9 @@
use super::UNKNOWN_ANVIL;
use crate::card_grid::MAX_WIDTH;
use crate::page::{
Page,
home::{StatsNotice, count_badge, notice_line},
shown,
};
use crate::theme::heading;
use gpui_kit::base::Button as BaseButton;
@@ -12,6 +14,43 @@ use gpui_kit::prelude::FluentBuilder as _;
use gpui_kit::*;
impl Page {
/// « Sélection »: the champ select's banner, its Anvil champions and « Autres champions ».
/// The column is taller than the window, and scrolls then, « Autres champions » with it (its
/// grid builds only the rows in view).
pub(in crate::page) fn champ_select_content(
&self,
window: &mut Window,
cx: &mut Context<Page>,
) -> Vec<AnyElement> {
let mut column = self.banner_column(window, cx);
if shown("anvil") {
column = column.child(self.anvil_area(window.viewport_size().width, cx));
}
// With the statistics missing there is nothing to browse: the notice stands alone.
if shown("others") && self.stats_notice().is_none() {
column = column.child(self.others_area(window.viewport_size().width, cx));
}
// One scrolling for all of it, with its scrollbar in the lane the sections leave.
vec![
div()
.relative()
.flex_1()
.min_h_0()
.w_full()
.max_w(px(MAX_WIDTH))
.mx_auto()
.child(
column
.id("champ-select")
.size_full()
.overflow_y_scroll()
.track_scroll(&self.paging.scroll),
)
.child(self.champ_select_scrollbar.clone())
.into_any_element(),
]
}
/// What stands in place of the Anvil champions row, if anything: the statistics are missing,
/// or the client gave no list (which does not make any champion without an anvil), or an
/// empty one.
+1
View File
@@ -179,6 +179,7 @@ impl Render for Page {
.children(match self.shown_tab {
Tab::Challenge => self.home_content(window, cx),
Tab::Statistics => self.statistics_content(cx),
Tab::ChampSelect => self.champ_select_content(window, cx),
})
.when(self.fade.is_some(), |screen| {
let veil = cx.theme().background.opacity(self.veil(cx));
+4 -10
View File
@@ -42,7 +42,7 @@ impl Page {
pub(in crate::page) fn official(&self) -> Option<&ProgressCheck> {
let updated = matches!((self.displayed(), &self.status.updating), (Some(v), Some(u)) if v.puuid == u.puuid);
let shown = match (self.shown_tab, &self.season) {
(Tab::Challenge, _) => self.home_season.as_deref(),
(Tab::Challenge | Tab::ChampSelect, _) => self.home_season.as_deref(),
(Tab::Statistics, SeasonScope::Season(season)) => Some(season.as_str()),
(Tab::Statistics, SeasonScope::AllSeasons) => None,
};
@@ -53,20 +53,14 @@ impl Page {
/// The tab's own statistics error: the home may have computed its own.
pub(in crate::page) fn error(&self) -> Option<&String> {
match (self.shown_tab, &self.home_scope) {
(Tab::Challenge, Some(_)) => self.home_error.as_ref(),
(Tab::Challenge | Tab::ChampSelect, Some(_)) => self.home_error.as_ref(),
_ => self.stats_error.as_ref(),
}
}
/// The Statistics tab's scope, during a champ select too: only the home's Challenge is the
/// champ select's (`prepare_statistics`).
pub(in crate::page) fn statistics_scope(&self) -> Scope {
if self.in_champ_select()
&& let Some(season) = &self.current_season
{
return Scope {
season: SeasonScope::Season(season.clone()),
format: None,
};
}
Scope {
season: self.season.clone(),
format: self.format,
+19 -38
View File
@@ -129,15 +129,14 @@ impl Page {
})
}
/// Under the status messages: the banner, then the heading with the filters and
/// search, and the cards. It holds no chart (#71): the cached charts row only belongs to the
/// Statistics tab. Everything is one centred column, as wide as the mockup's.
pub(in crate::page) fn home_content(
/// The centred column of « Défi » and « Sélection », as wide as the mockup's, with the
/// banner on top.
pub(in crate::page) fn banner_column(
&self,
window: &mut Window,
cx: &mut Context<Page>,
) -> Vec<AnyElement> {
let mut column = div()
) -> Div {
let column = div()
.v_flex()
.flex_1()
.min_h_0()
@@ -146,39 +145,21 @@ impl Page {
.mx_auto()
.gap_3();
if shown("banner") {
column = column.child(self.banner(window, cx));
}
if self.in_champ_select() {
// The champ select takes the place of the grid, its filters and its search: the
// column is taller than the window, and scrolls then, « Autres champions » with it
// (its grid builds only the rows in view).
if shown("anvil") {
column = column.child(self.anvil_area(window.viewport_size().width, cx));
}
// With the statistics missing there is nothing to browse: the notice stands alone.
if shown("others") && self.stats_notice().is_none() {
column = column.child(self.others_area(window.viewport_size().width, cx));
}
// One scrolling for all of it, with its scrollbar in the lane the sections leave.
return vec![
div()
.relative()
.flex_1()
.min_h_0()
.w_full()
.max_w(px(MAX_WIDTH))
.mx_auto()
.child(
column
.id("champ-select")
.size_full()
.overflow_y_scroll()
.track_scroll(&self.paging.scroll),
)
.child(self.champ_select_scrollbar.clone())
.into_any_element(),
];
column.child(self.banner(window, cx))
} else {
column
}
}
/// Under the status messages: the banner, then the heading with the filters and
/// search, and the cards. It holds no chart (#71): the cached charts row only belongs to the
/// Statistics tab.
pub(in crate::page) fn home_content(
&self,
window: &mut Window,
cx: &mut Context<Page>,
) -> Vec<AnyElement> {
let mut column = self.banner_column(window, cx);
if self.home_season.is_some() {
match self.stats_notice() {
None => {
+33 -13
View File
@@ -27,7 +27,7 @@ impl Page {
.previous_banner
.as_ref()
.filter(|_| landed.is_some_and(|t| t < 0.))
.unwrap_or(&self.banner);
.unwrap_or(self.shown_banner());
// The count of champions validés rolls in once the comet lands: 0 to 1.
let roll = animation
.filter(|a| a.has_comet())
@@ -114,8 +114,8 @@ impl Page {
}))
.into_any_element()
}))
// The champ select takes the window: « Statistiques » waits for its end.
.children((!self.in_champ_select()).then(|| {
// The champ select's banner is about the champ select only.
.children((self.shown_tab != Tab::ChampSelect).then(|| {
div().v_flex().mt(px(6.)).child(self.tab_link(
"statistics-link",
"Statistiques ›",
@@ -389,23 +389,43 @@ impl Page {
})
.unwrap_or_default()
.into();
if !champ_select {
self.banner = BannerContent::new(self.home_season.as_ref(), stats);
if !self.playback.active() {
self.banner_art
.update(cx, |art, cx| art.set_target(self.banner.splash.clone(), cx));
}
}
self.banner = BannerContent::new(self.home_season.as_ref(), stats);
self.champ_select_splashes = splashes;
self.ring.update(cx, |ring, cx| ring.set_ticks(ticks, cx));
self.dress_banner(cx);
}
}
impl Page {
/// What the banner drawn says: the champ select's on « Sélection », else the home's.
pub(in crate::page) fn shown_banner(&self) -> &BannerContent {
if self.shown_tab == Tab::ChampSelect {
&self.champ_select_banner
} else {
&self.banner
}
}
/// The ring and the illustration of the banner drawn. The champ select's dims the ticks
/// without an anvil and shows the card hovered; the home's dims none and shows its own
/// splash, unless the end of a Match holds it.
pub(in crate::page) fn dress_banner(&mut self, cx: &mut Context<Self>) {
let selecting = self.shown_tab == Tab::ChampSelect;
let anvil = (self.live_champ_select())
.filter(|_| selecting)
.and_then(|pick| pick.anvil_champions.as_deref());
self.ring.update(cx, |ring, cx| ring.set_anvil(anvil, cx));
if selecting {
self.select_art(self.ring.read(cx).lit(), cx);
} else if !self.playback.active() {
self.banner_art
.update(cx, |art, cx| art.set_target(self.banner.splash.clone(), cx));
}
}
/// The illustration of the champ select's banner: the card hovered's, else its own.
pub(in crate::page) fn select_art(&self, hovered: Option<u32>, cx: &mut Context<Self>) {
let splash = match hovered {
Some(id) => self.champ_select_splashes.get(&id),
None => self.banner.splash.as_ref(),
None => self.champ_select_banner.splash.as_ref(),
};
self.banner_art
.update(cx, |art, cx| art.set_target(splash.cloned(), cx));
+2 -2
View File
@@ -1,4 +1,4 @@
use super::Page;
use super::{Page, Tab};
use crate::card_grid::{CardGrid, CardHovered, PutDown};
use crate::card_lift::{Changes, Changing};
use crate::motion::MatchEnd;
@@ -150,7 +150,7 @@ impl Page {
self.release_home(cx);
}
self.ring.update(cx, |ring, cx| ring.set_lit(id, cx));
if self.in_champ_select() {
if self.shown_tab == Tab::ChampSelect {
self.select_art(id, cx);
}
}
+182
View File
@@ -0,0 +1,182 @@
//! The navigation between the screens: the tabs of the top bar, and the veil under which the
//! screen arriving replaces the one leaving. « La phase décide »: entering an Arena champ select
//! shows « Sélection », its end shows « Défi »; nothing else moves the player.
use super::{Page, Tab};
use crate::motion::{Fade, FadePhase};
use gpui_kit::base::Button as BaseButton;
use gpui_kit::component::{ActiveTheme as _, StyledExt as _};
use gpui_kit::prelude::FluentBuilder as _;
use gpui_kit::*;
impl Page {
/// The tabs as buttons: they take the keyboard focus, and Enter or Space activates them.
/// « Défi » stays lit on « Statistiques », the Challenge's detail page, and takes back to the
/// Challenge from there. « Sélection », right of it, is there only while an Arena champ
/// select runs.
pub(super) fn navigation(&self, cx: &mut Context<Self>) -> impl IntoElement {
let theme = cx.theme();
let (ring, muted, active, active_foreground, hover, hover_foreground) = (
theme.ring,
theme.tab_foreground,
theme.tab_active,
theme.tab_active_foreground,
theme.accent,
theme.accent_foreground,
);
let champ_select =
(self.in_champ_select()).then_some(("tab-champ-select", "Sélection", Tab::ChampSelect));
let tabs = [("tab-challenge", "Défi", Tab::Challenge)]
.into_iter()
.chain(champ_select);
div()
.h_flex()
.gap_1()
.flex_shrink_0()
.children(tabs.map(|(id, label, tab)| {
// « Défi » covers « Statistiques » too.
let current = (self.tab == Tab::ChampSelect) == (tab == Tab::ChampSelect);
BaseButton::new(id)
.px_3()
.py_1()
.rounded_md()
.text_sm()
.font_weight(FontWeight::SEMIBOLD)
// Always bordered, so the focus ring does not shift the label.
.border_1()
.border_color(transparent_black())
.focus_visible(|style| {
style.border_color(if current { active_foreground } else { ring })
})
.text_color(if current { active_foreground } else { muted })
.when(current, |button| button.bg(active))
.when(!current, |button| {
button.hover(|style| style.bg(hover).text_color(hover_foreground))
})
.accessibility_label(label)
.debug_selector(move || id.into())
.child(label)
.on_click(cx.listener(move |this, _, window, cx| this.set_tab(tab, window, cx)))
}))
}
pub(super) fn set_tab(&mut self, tab: Tab, window: &mut Window, cx: &mut Context<Self>) {
// « Sélection » only exists while the champ select runs.
if tab == Tab::ChampSelect && !self.in_champ_select() {
return;
}
if self.tab != tab {
self.tab = tab;
// The grids leave under the veil: no card stays lifted over it.
self.lifts.clear();
if !self.may_animate(window, cx) {
// Nothing to see: the end state at once.
self.end_fade(window, cx);
} else {
// From where the veil is: a switch during a transition does not wait for it.
let now = cx.background_executor().now();
let veil = self.veil(cx);
self.fade = Some(if self.shown_tab == tab {
Fade::uncovering(veil, now)
} else {
Fade::covering(veil, now)
});
self.next_fade_frame(window, cx);
}
cx.notify();
}
}
/// Draws the screen of the tab chosen.
fn show_tab(&mut self, window: &mut Window, cx: &mut Context<Self>) {
if self.shown_tab == self.tab {
return;
}
let left = std::mem::replace(&mut self.shown_tab, self.tab);
// The home grid is no longer under the pointer.
self.release_home(cx);
if left == Tab::ChampSelect {
// The hand is in its place when « Sélection » shows again: its deal does not play
// twice, and no card waits to go down.
self.forget_stage();
}
// The screen arriving was not kept up to date while hidden, and is prepared only now: a
// switch undone under the veil prepares nothing.
self.refresh_table(cx);
if self.home_cards_stale {
self.prepare_home_cards(cx);
}
self.refresh_home(cx);
// The ring and the illustration are the banner's on « Défi » and « Sélection ».
self.dress_banner(cx);
self.release_hidden(window, cx);
}
/// Gives back the images of the screens not shown (rule #1): they load again with their
/// screen.
fn release_hidden(&mut self, window: &mut Window, cx: &mut Context<Self>) {
let shown = self.shown_tab;
if shown != Tab::Challenge {
self.home_grid
.update(cx, |grid, cx| grid.release_images(window, cx));
}
if shown != Tab::ChampSelect {
for grid in [&self.anvil_grid, &self.others_grid] {
grid.update(cx, |grid, cx| grid.release_images(window, cx));
}
}
if shown == Tab::Statistics {
// Neither banner is shown: its illustration goes too.
self.banner_art
.update(cx, |art, cx| art.release(window, cx));
} else {
self.table
.update(cx, |table, cx| table.release_images(window, cx));
}
}
/// Shows the end of the transition, if one runs, at once.
pub(super) fn end_fade(&mut self, window: &mut Window, cx: &mut Context<Self>) {
if self.leave.is_some() {
self.finish_exit(window, cx);
}
self.fade = None;
self.show_tab(window, cx);
self.play_waiting(window, cx);
cx.notify();
}
/// Asks for the transition's next frame, once.
pub(super) fn next_fade_frame(&mut self, window: &mut Window, cx: &mut Context<Self>) {
if !self.frame_asked {
self.frame_asked = true;
cx.on_next_frame(window, |page, window, cx| page.fade_frame(window, cx));
}
}
/// One frame of the transition: the screen arriving replaces the one leaving under the full
/// veil, and no frame is asked for once the veil is lifted.
fn fade_frame(&mut self, window: &mut Window, cx: &mut Context<Self>) {
self.frame_asked = false;
let Some(fade) = &self.fade else {
return;
};
let now = cx.background_executor().now();
if fade.finished(now) {
match fade.phase() {
FadePhase::Out => {
// The champ select that ended leaves under the full veil: its end chooses
// « Défi », which comes out of it, as after a switch of tabs.
if self.leave.is_some() {
self.finish_exit(window, cx);
}
self.show_tab(window, cx);
self.fade = Some(Fade::uncovering(1., now));
}
FadePhase::In => return self.end_fade(window, cx),
}
}
self.next_fade_frame(window, cx);
cx.notify();
}
}
+3 -9
View File
@@ -1,4 +1,4 @@
use super::{MatchPlayback, Page, Tab, WaitingMatch, home};
use super::{MatchPlayback, Page, Tab, WaitingMatch};
use crate::motion::MatchAnimation;
use arena_tracker_core::FollowedMatch;
use gpui_kit::*;
@@ -12,9 +12,7 @@ impl Page {
let active = self.playback.active() || self.playback.kept_card.is_some();
self.playback = MatchPlayback::default();
if active {
self.banner_art.update(cx, |art, cx| {
art.set_target(self.banner.splash.clone(), cx);
});
self.dress_banner(cx);
self.refresh_home(cx);
}
}
@@ -31,11 +29,7 @@ impl Page {
self.end_match(cx);
}
if self.playback.waiting.waiting().is_none() {
self.playback.previous_banner = Some(if self.in_champ_select() {
home::BannerContent::new(self.home_season.as_ref(), self.home_statistics())
} else {
self.banner.clone()
});
self.playback.previous_banner = Some(self.banner.clone());
}
self.playback.stats_pending = true;
let waiting = WaitingMatch {
+1
View File
@@ -255,6 +255,7 @@ impl Page {
home_error: None,
home_computed: None,
banner: home::BannerContent::default(),
champ_select_banner: home::BannerContent::default(),
champ_select_splashes: HashMap::new(),
ring,
lit_by: None,
+20 -20
View File
@@ -1,7 +1,7 @@
use crate::card::Card;
use crate::page::{ALL_FORMATS, AccountItem, NextHome, Page, now_ms};
use crate::worker::{compute_statistics, spawn_statistics};
use arena_tracker_core::{SeasonScope, StateFilter, account_riot_id};
use arena_tracker_core::{Scope, SeasonScope, StateFilter, account_riot_id};
use gpui_kit::component::IndexPath;
use gpui_kit::*;
use std::time::Instant;
@@ -74,23 +74,27 @@ impl Page {
cx: &mut Context<Self>,
) -> Option<String> {
self.last_reload = Instant::now();
if self.in_champ_select() {
if computing {
self.stats_generation += 1;
}
// The home is the champ select's: its Challenge is the current Season's, which is
// the Statistics scope for the whole champ select.
self.home_scope = None;
self.current_season = self.tracker.current_season(now_ms()).map(|s| s.name);
self.home_season = self.current_season.clone().map(Into::into);
let puuid = self.champ_select_account()?;
return self.current_season.is_some().then_some(puuid);
}
if matches!(self.season, SeasonScope::AllSeasons)
&& !matches!(self.filter, StateFilter::All | StateFilter::NeverPlayed)
{
self.filter = StateFilter::All;
}
if self.in_champ_select() {
if computing {
self.stats_generation += 1;
}
// The home is the champ select's, on « Défi » too: its Challenge is the current
// Season's, whatever « Statistiques » analyses.
self.current_season = self.tracker.current_season(now_ms()).map(|s| s.name);
self.home_season = self.current_season.clone().map(Into::into);
let home = self.current_season.clone().map(|season| Scope {
season: SeasonScope::Season(season),
format: None,
});
self.home_scope = home.filter(|home| *home != self.statistics_scope());
let puuid = self.champ_select_account()?;
return self.current_season.is_some().then_some(puuid);
}
let previous_season = self.home_season.clone();
self.settle_home_scope();
let viewed = self.viewed().map(|a| a.puuid.clone());
@@ -197,14 +201,10 @@ impl Page {
if !self.hold_grid {
self.reorder();
}
if self.in_champ_select() {
// Neither the charts, the table nor the home grid are shown during a champ select.
self.prepare_banner(cx);
self.prepare_champ_select(cx);
cx.notify();
return;
}
self.prepare_banner(cx);
if self.in_champ_select() {
self.prepare_champ_select(cx);
}
self.prepare_home_cards(cx);
let charts = self.stats.as_ref().map(|s| &s.charts);
let in_season = self.in_season();
+1
View File
@@ -9,6 +9,7 @@ mod champ_select_fixtures;
mod champ_select_motion;
mod champ_select_others;
mod champ_select_scroll;
mod champ_select_tab;
mod grid;
mod home;
mod match_animation;
+4 -2
View File
@@ -61,8 +61,8 @@ async fn champ_select_uses_the_signed_in_accounts_challenge_and_restores_the_pin
});
cx.condition(&page, |p, _| p.stats.is_some()).await;
page.read_with(cx, |p, cx| {
// The champ select takes the home, about the signed-in Account's current Season.
assert_eq!(p.tab, Tab::Challenge);
// « Sélection » shows, about the signed-in Account's current Season.
assert_eq!(p.tab, Tab::ChampSelect);
assert_eq!(p.displayed().unwrap().puuid, "Alice");
assert_eq!(p.home_season, p.current_season.clone().map(Into::into));
assert!(p.home_season.is_some());
@@ -85,6 +85,8 @@ async fn champ_select_uses_the_signed_in_accounts_challenge_and_restores_the_pin
p.apply(Msg::ChampSelect(None), w, cx);
})
});
// The hand leaves « Sélection », then « Défi » shows.
finish_motion(&page, &mut window);
cx.condition(&page, |p, _| p.stats.is_some()).await;
page.read_with(cx, |p, cx| {
assert_eq!(p.viewed().unwrap().puuid, "Bob");
+1 -1
View File
@@ -76,7 +76,7 @@ pub(super) fn banner(
page: &Entity<Page>,
cx: &mut VisualTestContext,
) -> crate::page::home::BannerContent {
page.read_with(cx, |page, _| page.banner.clone())
page.read_with(cx, |page, _| page.shown_banner().clone())
}
pub(super) fn bold(line: &crate::page::home::Line) -> &str {
@@ -221,4 +221,5 @@ fn no_champ_select_changes_nothing(cx: &mut TestAppContext) {
});
assert!(window.debug_bounds("home-tools").is_some());
assert!(window.debug_bounds("anvil-row").is_none());
assert!(window.debug_bounds("tab-champ-select").is_none());
}
@@ -4,7 +4,7 @@ use super::champ_select_fixtures::{
joueur_tracker_with, leave, page_in_champ_select, places, read_champ_select, reasons, send,
with_bans_and_ally,
};
use super::page_fixtures::{center, draw, open_page, open_page_with_tracker, show, switch_tab};
use super::page_fixtures::{center, draw, open_page, open_page_with_tracker, show};
use crate::card::{ASPECT, Reason};
use crate::card_images::tests::TestDir;
@@ -208,7 +208,9 @@ async fn the_arena_capture_fills_the_anvil_row_in_the_homes_order(cx: &mut TestA
}
#[gpui::test]
async fn the_champ_select_takes_the_home_and_gives_it_back_as_it_was(cx: &mut TestAppContext) {
async fn the_champ_select_takes_the_window_and_gives_the_home_back_as_it_was(
cx: &mut TestAppContext,
) {
use arena_tracker_core::SeasonScope;
cx.executor().allow_parking();
let (page, mut window) = open_page_with_tracker(cx, joueur_tracker());
@@ -237,28 +239,31 @@ async fn the_champ_select_takes_the_home_and_gives_it_back_as_it_was(cx: &mut Te
cx.condition(&page, |p, _| p.stats.is_some()).await;
draw(&mut window);
page.read_with(&window, |p, _| {
// The Challenge of the signed-in Account in the current Season, whatever the
// Statistics tab shows.
assert_eq!(p.tab, Tab::Challenge);
// « Sélection », from « Statistiques »: the Challenge of the signed-in Account in the
// current Season, whatever « Statistiques » analyses.
assert_eq!(p.tab, Tab::ChampSelect);
assert_eq!(p.shown_tab, Tab::ChampSelect);
assert_eq!(p.season, SeasonScope::AllSeasons);
assert_eq!(p.viewed().unwrap().puuid, "Autre");
assert_eq!(p.displayed().unwrap().puuid, "Joueur");
assert_eq!(p.home_season.as_deref(), Some("Saison"));
assert_eq!(p.banner.season.as_ref(), "SAISON · 1 / 9 validés");
assert_eq!(p.banner.title.text.as_ref(), "Sélection des champions");
assert!(p.stats.as_ref().unwrap().challenge.is_some());
assert_eq!(
p.champ_select_banner.season.as_ref(),
"SAISON · 1 / 9 validés"
);
assert_eq!(
p.champ_select_banner.title.text.as_ref(),
"Sélection des champions"
);
assert!(p.home_statistics().unwrap().challenge.is_some());
});
// The row is there; the grid, its filters and its search are not.
// The row is there; the grid, its filters and its search are on « Défi ».
assert!(window.debug_bounds("anvil-row").is_some());
assert!(window.debug_bounds("card-233").is_some());
assert!(window.debug_bounds("home-tools").is_none());
assert!(window.debug_bounds("card-103").is_none());
// « Statistiques » is out of reach during the champ select: no link in the banner.
// Its banner is about the champ select only: no link to « Statistiques ».
assert!(window.debug_bounds("statistics-link").is_none());
assert!(window.debug_bounds("tab-statistics").is_none());
switch_tab(&page, &mut window, Tab::Statistics);
assert_eq!(page.read_with(&window, |p, _| p.tab), Tab::Challenge);
// Bans and ally picks are the champ select's.
send(&page, &mut window, &with_bans_and_ally(&[16, 233], 233));
@@ -407,13 +407,13 @@ async fn the_entry_waits_for_the_window_and_the_page_to_be_in_front(cx: &mut Tes
start_leaving(&page, cx);
assert!(!page.read_with(cx, |p, _| p.in_champ_select()));
// Behind « Paramètres »; and from « Statistiques », « Défi » first.
// Behind « Paramètres »; and from « Statistiques », « Sélection » at once.
cx.simulate_visibility_change(WindowVisibility::Visible);
switch_tab(&page, cx, Tab::Statistics);
cx.update(|window, cx| page.update(cx, |page, cx| page.hidden(window, cx)));
send(&page, cx, &frames()[0]);
assert!(!entry(cx));
assert_eq!(shown_tab(&page, cx), Tab::Challenge);
assert_eq!(shown_tab(&page, cx), Tab::ChampSelect);
cx.update(|window, cx| page.update(cx, |page, cx| page.uncovered(window, cx)));
assert!(entry(cx));
finish_motion(&page, cx);
@@ -0,0 +1,217 @@
//! « Sélection », the tab of the champ select's phase (#108): it appears and shows when an
//! Arena champ select starts, lets the player look at « Défi » and come back, and goes when the
//! champ select ends. Only entering a new phase moves the player.
use super::champ_select_fixtures::{
ANVIL_A_TO_Z, anvil_cards, below, finish_motion, frames, joueur_tracker, page_in_champ_select,
reasons, send, start_leaving, with_bans_and_ally,
};
use super::page_fixtures::{
assert_at_rest, center, draw, frame_after, open_page_with_tracker, shown_tab, start_switch,
switch_tab, veil,
};
use crate::card::Reason;
use crate::page::{Page, Tab};
use gpui_kit::{Entity, Modifiers, TestAppContext, VisualTestContext};
fn tab(page: &Entity<Page>, cx: &mut VisualTestContext) -> Tab {
page.read_with(cx, |page, _| page.tab)
}
/// Clicks the element `id`, and lets the transition it starts end.
fn click(page: &Entity<Page>, cx: &mut VisualTestContext, id: &'static str) {
let at = center(cx, id);
cx.simulate_click(at, Modifiers::none());
finish_motion(page, cx);
draw(cx);
}
fn ring_anvil(page: &Entity<Page>, cx: &mut VisualTestContext) -> Option<Vec<u32>> {
page.read_with(cx, |p, cx| p.ring.read(cx).anvil().map(<[u32]>::to_vec))
}
#[gpui::test]
async fn entering_a_champ_select_adds_the_selection_tab_and_shows_it(app: &mut TestAppContext) {
app.executor().allow_parking();
let (page, mut window) = open_page_with_tracker(app, joueur_tracker());
let cx = &mut window;
draw(cx);
assert!(cx.debug_bounds("tab-champ-select").is_none());
send(&page, cx, &frames()[0]);
app.condition(&page, |p, _| p.stats.is_some()).await;
draw(&mut window);
let cx = &mut window;
// At once, right of « Défi », with its entry: the band of light, then the hand dealt.
assert_eq!(tab(&page, cx), Tab::ChampSelect);
assert_eq!(shown_tab(&page, cx), Tab::ChampSelect);
assert!(page.read_with(cx, |p, _| p.fade.is_none() && p.entry.is_some()));
let challenge = cx.debug_bounds("tab-challenge").unwrap();
let selection = cx.debug_bounds("tab-champ-select").unwrap();
assert!(selection.origin.x > challenge.origin.x);
assert!(cx.debug_bounds("sweep").is_some());
assert!(cx.debug_bounds("anvil-row").is_some());
assert!(cx.debug_bounds("home-tools").is_none());
finish_motion(&page, cx);
assert_at_rest(cx);
}
#[gpui::test]
async fn entering_a_champ_select_from_statistics_shows_the_selection(app: &mut TestAppContext) {
app.executor().allow_parking();
let (page, mut window) = open_page_with_tracker(app, joueur_tracker());
app.condition(&page, |p, _| p.stats.is_some()).await;
switch_tab(&page, &mut window, Tab::Statistics);
send(&page, &mut window, &frames()[0]);
app.condition(&page, |p, _| p.stats.is_some()).await;
draw(&mut window);
let cx = &mut window;
assert_eq!(tab(&page, cx), Tab::ChampSelect);
assert_eq!(shown_tab(&page, cx), Tab::ChampSelect);
assert!(page.read_with(cx, |p, _| p.fade.is_none() && p.entry.is_some()));
assert!(cx.debug_bounds("back-to-challenge").is_none());
assert!(cx.debug_bounds("anvil-row").is_some());
}
// « Défi » shows the home as usual during the champ select, and « Statistiques » stays reachable
// from it; back on « Sélection », the hand is in its place, not dealt again.
#[gpui::test]
async fn the_challenge_and_the_selection_take_turns_without_dealing_again(
app: &mut TestAppContext,
) {
let (page, mut window) = page_in_champ_select(app, &frames()[0]).await;
let cx = &mut window;
let generation = page.read_with(cx, |p, _| p.stats_generation);
assert!(ring_anvil(&page, cx).is_some());
click(&page, cx, "tab-challenge");
assert_eq!(tab(&page, cx), Tab::Challenge);
assert_eq!(shown_tab(&page, cx), Tab::Challenge);
assert!(cx.debug_bounds("home-tools").is_some());
assert!(cx.debug_bounds("card-103").is_some());
assert!(cx.debug_bounds("anvil-row").is_none());
assert!(cx.debug_bounds("tab-champ-select").is_some());
// The home's banner: its count and its ring, no tick dimmed.
let title = page.read_with(cx, |p, _| p.shown_banner().title.text.clone());
assert_eq!(title.as_ref(), "1 / 9 champions validés");
assert_eq!(ring_anvil(&page, cx), None);
click(&page, cx, "statistics-link");
assert_eq!(shown_tab(&page, cx), Tab::Statistics);
assert!(cx.debug_bounds("tab-champ-select").is_some());
click(&page, cx, "tab-champ-select");
assert_eq!(tab(&page, cx), Tab::ChampSelect);
assert_eq!(shown_tab(&page, cx), Tab::ChampSelect);
assert!(cx.debug_bounds("anvil-row").is_some());
assert!(page.read_with(cx, |p, _| p.entry.is_none() && !p.entry_waiting));
for id in ANVIL_A_TO_Z {
assert_eq!(below(cx, id), None, "{id} is dealt again");
}
assert!(ring_anvil(&page, cx).is_some());
let title = page.read_with(cx, |p, _| p.shown_banner().title.text.clone());
assert_eq!(title.as_ref(), "Sélection des champions");
// Nothing was computed again for the switches.
assert_eq!(page.read_with(cx, |p, _| p.stats_generation), generation);
assert_at_rest(cx);
}
#[gpui::test]
async fn bans_and_picks_on_another_tab_do_not_bring_the_selection_back(app: &mut TestAppContext) {
let (page, mut window) = page_in_champ_select(app, &frames()[0]).await;
let cx = &mut window;
switch_tab(&page, cx, Tab::Challenge);
send(&page, cx, &with_bans_and_ally(&[16, 233], 233));
draw(cx);
assert_eq!(tab(&page, cx), Tab::Challenge);
assert_eq!(shown_tab(&page, cx), Tab::Challenge);
assert!(page.read_with(cx, |p, _| p.fade.is_none() && p.taken.is_empty()));
// The hand follows them all the same, and shows them once back, in its place.
let cards = anvil_cards(&page, cx);
assert_eq!(reasons(&cards, 233), [Reason::Banned, Reason::TakenByAlly]);
switch_tab(&page, cx, Tab::Statistics);
send(&page, cx, &with_bans_and_ally(&[16], 233));
draw(cx);
assert_eq!(shown_tab(&page, cx), Tab::Statistics);
switch_tab(&page, cx, Tab::ChampSelect);
draw(cx);
assert!(page.read_with(cx, |p, _| p.taken.is_empty()));
assert_eq!(below(cx, 233), None);
assert_at_rest(cx);
}
// The end of the champ select on « Sélection »: the hand leaves as before, then « Défi » comes
// out of the veil, and the tab is gone.
#[gpui::test]
async fn the_selection_tab_goes_after_the_hand_leaves(app: &mut TestAppContext) {
let (page, mut window) = page_in_champ_select(app, &frames()[0]).await;
let cx = &mut window;
start_leaving(&page, cx);
draw(cx);
assert!(page.read_with(cx, |p, _| p.leave.is_some()));
assert_eq!(shown_tab(&page, cx), Tab::ChampSelect);
assert!(cx.debug_bounds("anvil-row").is_some());
finish_motion(&page, cx);
assert_eq!(tab(&page, cx), Tab::Challenge);
assert_eq!(shown_tab(&page, cx), Tab::Challenge);
app.condition(&page, |p, _| p.stats.is_some()).await;
draw(&mut window);
let cx = &mut window;
assert!(cx.debug_bounds("tab-champ-select").is_none());
assert!(cx.debug_bounds("home-tools").is_some());
assert_eq!(ring_anvil(&page, cx), None);
assert_at_rest(cx);
}
// Elsewhere nothing of the champ select is drawn: it merely ends, and « Défi » shows.
#[gpui::test]
async fn the_selection_tab_goes_at_once_from_another_tab(app: &mut TestAppContext) {
let (page, mut window) = page_in_champ_select(app, &frames()[0]).await;
let cx = &mut window;
switch_tab(&page, cx, Tab::Challenge);
start_leaving(&page, cx);
draw(cx);
page.read_with(cx, |p, _| {
assert!(!p.in_champ_select());
assert!(p.leave.is_none() && p.fade.is_none());
assert_eq!((p.tab, p.shown_tab), (Tab::Challenge, Tab::Challenge));
});
assert!(cx.debug_bounds("tab-champ-select").is_none());
// From « Statistiques », « Défi » comes as after any switch.
send(&page, cx, &frames()[0]);
finish_motion(&page, cx);
switch_tab(&page, cx, Tab::Statistics);
start_leaving(&page, cx);
assert_eq!(tab(&page, cx), Tab::Challenge);
assert!(page.read_with(cx, |p, _| p.leave.is_none() && p.fade.is_some()));
finish_motion(&page, cx);
assert_eq!(shown_tab(&page, cx), Tab::Challenge);
assert!(cx.debug_bounds("tab-champ-select").is_none());
}
// The champ select ends while « Sélection » goes under the veil for « Défi »: its hand still
// leaves, and the veil holds where it is meanwhile.
#[gpui::test]
async fn an_end_during_a_switch_lets_the_hand_leave_under_the_veil_as_it_is(
app: &mut TestAppContext,
) {
let (page, mut window) = page_in_champ_select(app, &frames()[0]).await;
let cx = &mut window;
start_switch(&page, cx, Tab::Challenge);
frame_after(cx, 60);
let before = veil(&page, cx);
assert!(before > 0. && before < 1., "{before}");
start_leaving(&page, cx);
assert!(page.read_with(cx, |p, _| p.leave.is_some()));
assert_eq!(veil(&page, cx), before);
finish_motion(&page, cx);
assert_eq!(shown_tab(&page, cx), Tab::Challenge);
assert!(!page.read_with(cx, |p, _| p.in_champ_select()));
}
+12 -1
View File
@@ -170,7 +170,7 @@ async fn a_grid_that_is_not_shown_gives_its_portraits_back(cx: &mut TestAppConte
keys.len()
);
// A champ select takes the home's place with its own sections.
// A champ select shows « Sélection », with its own sections.
send(&page, &mut window, &frames()[0]);
cx.condition(&page, |p, _| p.stats.is_some()).await;
load(&mut window);
@@ -178,6 +178,17 @@ async fn a_grid_that_is_not_shown_gives_its_portraits_back(cx: &mut TestAppConte
let anvil = page.read_with(&window, |p, _| p.anvil_grid.clone());
assert_eq!(held(&anvil, &mut window), ANVIL.len());
// « Défi » during the champ select shows the home's cards, and « Sélection » gives its own
// back; going back to it, they load again.
switch_tab(&page, &mut window, Tab::Challenge);
load(&mut window);
assert_eq!(held(&home, &mut window), keys.len());
assert_eq!(held(&anvil, &mut window), 0);
switch_tab(&page, &mut window, Tab::ChampSelect);
load(&mut window);
assert_eq!(held(&home, &mut window), 0);
assert_eq!(held(&anvil, &mut window), ANVIL.len());
// And gives the Anvil row up when it ends.
leave(&page, &mut window);
assert_eq!(held(&anvil, &mut window), 0);
+6 -2
View File
@@ -1,4 +1,4 @@
use super::{Page, RELOAD_EVERY};
use super::{Page, RELOAD_EVERY, Tab};
use crate::worker::{Msg, spawn_refresh};
use gpui_kit::*;
@@ -24,7 +24,11 @@ impl Page {
if self.champ_select == champ_select {
return;
}
if champ_select.is_none() && self.in_champ_select() && self.may_animate(window, cx)
// The hand leaves where it is drawn; elsewhere the champ select merely ends.
if champ_select.is_none()
&& self.in_champ_select()
&& self.shown_tab == Tab::ChampSelect
&& self.may_animate(window, cx)
{
self.start_exit(window, cx);
} else {