Show users if room knows them

Also selects the current room in the rooms list
This commit is contained in:
Joscha 2022-02-27 00:16:36 +01:00
parent ccf6a59f39
commit f34bf63be4
7 changed files with 104 additions and 27 deletions

View file

@ -1,12 +1,17 @@
mod users;
use std::sync::Arc;
use tokio::sync::Mutex;
use tui::backend::Backend;
use tui::layout::Rect;
use tui::widgets::{Block, BorderType, Borders};
use tui::Frame;
use crate::room::Room;
use self::users::Users;
pub struct RoomInfo {
name: String,
room: Arc<Mutex<Room>>,
@ -21,11 +26,24 @@ impl RoomInfo {
&self.name
}
pub async fn render_messages<B: Backend>(&mut self, frame: &mut Frame<'_, B>, area: Rect) {
pub async fn render_main<B: Backend>(&mut self, frame: &mut Frame<'_, B>, area: Rect) {
// TODO Implement
frame.render_widget(
Block::default()
.borders(Borders::TOP)
.border_type(BorderType::Double),
Rect {
x: area.x,
y: area.y + 1,
width: area.width,
height: 1,
},
);
}
pub async fn render_users<B: Backend>(&mut self, frame: &mut Frame<'_, B>, area: Rect) {
// TODO Implement
if let Some(present) = self.room.lock().await.present() {
frame.render_widget(Users::new(present), area);
}
}
}