Migrate inspection popups to AsyncWidget
This commit is contained in:
parent
91d8d7ba97
commit
d7d25a8390
2 changed files with 10 additions and 14 deletions
|
|
@ -1,12 +1,12 @@
|
||||||
use crossterm::style::Stylize;
|
use crossterm::style::Stylize;
|
||||||
use euphoxide::api::{Message, NickEvent, SessionView};
|
use euphoxide::api::{Message, NickEvent, SessionView};
|
||||||
use euphoxide::conn::SessionInfo;
|
use euphoxide::conn::SessionInfo;
|
||||||
use toss::{Style, Styled};
|
use toss::widgets::{BoxedAsync, Text};
|
||||||
|
use toss::{Style, Styled, WidgetExt};
|
||||||
|
|
||||||
use crate::ui::input::{key, InputEvent, KeyBindingsList};
|
use crate::ui::input::{key, InputEvent, KeyBindingsList};
|
||||||
use crate::ui::widgets::popup::Popup;
|
use crate::ui::widgets2::Popup;
|
||||||
use crate::ui::widgets::text::Text;
|
use crate::ui::UiError;
|
||||||
use crate::ui::widgets::BoxedWidget;
|
|
||||||
|
|
||||||
macro_rules! line {
|
macro_rules! line {
|
||||||
( $text:ident, $name:expr, $val:expr ) => {
|
( $text:ident, $name:expr, $val:expr ) => {
|
||||||
|
|
@ -88,7 +88,7 @@ fn message_lines(mut text: Styled, msg: &Message) -> Styled {
|
||||||
text
|
text
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn session_widget(session: &SessionInfo) -> BoxedWidget {
|
pub fn session_widget(session: &SessionInfo) -> BoxedAsync<'static, UiError> {
|
||||||
let heading_style = Style::new().bold();
|
let heading_style = Style::new().bold();
|
||||||
|
|
||||||
let text = match session {
|
let text = match session {
|
||||||
|
|
@ -102,10 +102,10 @@ pub fn session_widget(session: &SessionInfo) -> BoxedWidget {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Popup::new(Text::new(text)).title("Inspect session").build()
|
Popup::new(Text::new(text), "Inspect session").boxed_async()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn message_widget(msg: &Message) -> BoxedWidget {
|
pub fn message_widget(msg: &Message) -> BoxedAsync<'static, UiError> {
|
||||||
let heading_style = Style::new().bold();
|
let heading_style = Style::new().bold();
|
||||||
|
|
||||||
let mut text = Styled::new("Message", heading_style).then_plain("\n");
|
let mut text = Styled::new("Message", heading_style).then_plain("\n");
|
||||||
|
|
@ -119,7 +119,7 @@ pub fn message_widget(msg: &Message) -> BoxedWidget {
|
||||||
|
|
||||||
text = session_view_lines(text, &msg.sender);
|
text = session_view_lines(text, &msg.sender);
|
||||||
|
|
||||||
Popup::new(Text::new(text)).title("Inspect message").build()
|
Popup::new(Text::new(text), "Inspect message").boxed_async()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_key_bindings(bindings: &mut KeyBindingsList) {
|
pub fn list_key_bindings(bindings: &mut KeyBindingsList) {
|
||||||
|
|
|
||||||
|
|
@ -228,12 +228,8 @@ impl EuphRoom {
|
||||||
State::Nick(editor) => layers.push(nick::widget(editor)),
|
State::Nick(editor) => layers.push(nick::widget(editor)),
|
||||||
State::Account(account) => layers.push(account.widget()),
|
State::Account(account) => layers.push(account.widget()),
|
||||||
State::Links(links) => layers.push(WidgetWrapper::new(links.widget()).boxed_async()),
|
State::Links(links) => layers.push(WidgetWrapper::new(links.widget()).boxed_async()),
|
||||||
State::InspectMessage(message) => {
|
State::InspectMessage(message) => layers.push(inspect::message_widget(message)),
|
||||||
layers.push(WidgetWrapper::new(inspect::message_widget(message)).boxed_async())
|
State::InspectSession(session) => layers.push(inspect::session_widget(session)),
|
||||||
}
|
|
||||||
State::InspectSession(session) => {
|
|
||||||
layers.push(WidgetWrapper::new(inspect::session_widget(session)).boxed_async())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for popup in &self.popups {
|
for popup in &self.popups {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue