Make room list heading always visible

This commit is contained in:
Joscha 2022-08-19 23:26:49 +02:00
parent fc44a59a6f
commit 037bed698c

View file

@ -200,11 +200,6 @@ impl Rooms {
}
async fn render_rows(&self, list: &mut List<String>) {
let heading_style = ContentStyle::default().bold();
let amount = self.euph_rooms.len();
let heading = Styled::new("Rooms", heading_style).then_plain(format!(" ({amount})"));
list.add_unsel(Text::new(heading));
if self.euph_rooms.is_empty() {
list.add_unsel(Text::new((
"Press F1 for key bindings",
@ -230,9 +225,15 @@ impl Rooms {
}
async fn rooms_widget(&self) -> BoxedWidget {
let heading_style = ContentStyle::default().bold();
let amount = self.euph_rooms.len();
let heading =
Text::new(Styled::new("Rooms", heading_style).then_plain(format!(" ({amount})")));
let mut list = self.list.widget().focus(true);
self.render_rows(&mut list).await;
list.into()
VJoin::new(vec![Segment::new(heading), Segment::new(list).priority(0)]).into()
}
fn room_char(c: char) -> bool {