1
0
mirror of https://github.com/pcvolkmer/arsnova-client.git synced 2025-07-01 22:42:55 +00:00

feat: show disabled room or feedback in example

This commit is contained in:
2024-12-26 18:19:07 +01:00
parent 4ea557894a
commit 813f1a2d9c
2 changed files with 25 additions and 10 deletions

View File

@ -97,7 +97,12 @@ async fn main() -> Result<(), String> {
room_info.name, room_info.short_id, room_stats.room_user_count room_info.name, room_info.short_id, room_stats.room_user_count
); );
let l2 = create_ui(&mut terminal, &title, in_rx); let l2 = create_ui(
&mut terminal,
&title,
room_info.is_closed() || room_info.is_feedback_locked(),
in_rx,
);
let l3 = tokio::spawn(async move { let l3 = tokio::spawn(async move {
loop { loop {
@ -144,6 +149,7 @@ async fn main() -> Result<(), String> {
async fn create_ui( async fn create_ui(
terminal: &mut Terminal<CrosstermBackend<Stdout>>, terminal: &mut Terminal<CrosstermBackend<Stdout>>,
title: &str, title: &str,
disabled: bool,
mut rx: Receiver<Feedback>, mut rx: Receiver<Feedback>,
) -> Result<(), ()> { ) -> Result<(), ()> {
const ICONS: [&str; 4] = ["Super", "Gut", "Nicht so gut", "Schlecht"]; const ICONS: [&str; 4] = ["Super", "Gut", "Nicht so gut", "Schlecht"];
@ -216,6 +222,14 @@ async fn create_ui(
layout[0], layout[0],
); );
if disabled {
frame.render_widget(
Paragraph::new("Feedback gestoppt")
.white()
.alignment(Alignment::Center),
layout[2],
)
} else {
frame.render_widget( frame.render_widget(
Paragraph::new(format!("{} Antworten", feedback.count_votes())) Paragraph::new(format!("{} Antworten", feedback.count_votes()))
.white() .white()
@ -223,6 +237,7 @@ async fn create_ui(
.alignment(Alignment::Center), .alignment(Alignment::Center),
layout[2], layout[2],
); );
}
frame.render_widget( frame.render_widget(
Paragraph::new("Beenden mit <Esc>") Paragraph::new("Beenden mit <Esc>")

View File

@ -199,7 +199,7 @@ pub struct RoomInfo {
impl RoomInfo { impl RoomInfo {
/// Indicates if room is closed /// Indicates if room is closed
pub fn is_closes(&self) -> bool { pub fn is_closed(&self) -> bool {
self.closed self.closed
} }
@ -212,7 +212,7 @@ impl RoomInfo {
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct RoomInfoSettings { pub struct RoomInfoSettings {
pub feedback_locked: bool pub feedback_locked: bool,
} }
#[derive(Deserialize, Clone, Debug)] #[derive(Deserialize, Clone, Debug)]