From d3afe84223a5c300541d856db4e3caf43908927c Mon Sep 17 00:00:00 2001 From: Jannik Kolodziej Date: Mon, 3 Jun 2024 14:31:33 +0200 Subject: [PATCH] fix(ui): hide input box when phase is changed --- src/models.rs | 2 +- src/ui/voting.rs | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/models.rs b/src/models.rs index 8b99081..984d260 100644 --- a/src/models.rs +++ b/src/models.rs @@ -47,7 +47,7 @@ pub struct Player { pub user_type: UserType, } -#[derive(Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq)] pub enum GamePhase { Playing, Revealed, diff --git a/src/ui/voting.rs b/src/ui/voting.rs index 7564bde..3efc413 100644 --- a/src/ui/voting.rs +++ b/src/ui/voting.rs @@ -25,6 +25,7 @@ pub enum InputMode { pub struct VotingPage { pub input_mode: InputMode, pub input_buffer: Option, + last_phase: GamePhase } impl VotingPage { @@ -32,6 +33,7 @@ impl VotingPage { Self { input_mode: InputMode::Menu, input_buffer: None, + last_phase: GamePhase::Playing, } } @@ -363,14 +365,14 @@ impl Page for VotingPage { let vote_view = chunks[0]; let log = chunks[1]; - - if app.room.phase == GamePhase::Playing && self.input_mode == InputMode::ResetConfirm { - self.input_mode = InputMode::Menu; - } else if app.room.phase == GamePhase::Revealed && self.input_mode == InputMode::RevealConfirm { - self.input_mode = InputMode::Menu; + + if app.room.phase != self.last_phase { + if self.input_mode != InputMode::Name { + self.input_mode = InputMode::Menu; + } + self.last_phase = app.room.phase; } - self.render_own_vote(app, vote_view, frame); self.render_log(app, log, frame); self.render_votes(app, left_side, frame);