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:
@ -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,13 +222,22 @@ async fn create_ui(
|
|||||||
layout[0],
|
layout[0],
|
||||||
);
|
);
|
||||||
|
|
||||||
frame.render_widget(
|
if disabled {
|
||||||
Paragraph::new(format!("{} Antworten", feedback.count_votes()))
|
frame.render_widget(
|
||||||
.white()
|
Paragraph::new("Feedback gestoppt")
|
||||||
.bold()
|
.white()
|
||||||
.alignment(Alignment::Center),
|
.alignment(Alignment::Center),
|
||||||
layout[2],
|
layout[2],
|
||||||
);
|
)
|
||||||
|
} else {
|
||||||
|
frame.render_widget(
|
||||||
|
Paragraph::new(format!("{} Antworten", feedback.count_votes()))
|
||||||
|
.white()
|
||||||
|
.bold()
|
||||||
|
.alignment(Alignment::Center),
|
||||||
|
layout[2],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
frame.render_widget(
|
frame.render_widget(
|
||||||
Paragraph::new("Beenden mit <Esc>")
|
Paragraph::new("Beenden mit <Esc>")
|
||||||
|
@ -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)]
|
||||||
|
Reference in New Issue
Block a user