Display seen status of messages
This commit is contained in:
parent
6166c5e366
commit
de569211f6
2 changed files with 29 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
// TODO Remove mut in &mut Frame wherever applicable in this entire module
|
// TODO Remove mut in &mut Frame wherever applicable in this entire module
|
||||||
|
|
||||||
mod indent;
|
mod indent;
|
||||||
|
mod seen;
|
||||||
mod time;
|
mod time;
|
||||||
|
|
||||||
use crossterm::style::{ContentStyle, Stylize};
|
use crossterm::style::{ContentStyle, Stylize};
|
||||||
|
|
@ -50,6 +51,7 @@ fn style_pseudo_highlight() -> ContentStyle {
|
||||||
pub fn msg<M: Msg + ChatMsg>(highlighted: bool, indent: usize, msg: &M) -> BoxedWidget {
|
pub fn msg<M: Msg + ChatMsg>(highlighted: bool, indent: usize, msg: &M) -> BoxedWidget {
|
||||||
let (nick, content) = msg.styled();
|
let (nick, content) = msg.styled();
|
||||||
HJoin::new(vec![
|
HJoin::new(vec![
|
||||||
|
Segment::new(seen::widget(msg.seen())),
|
||||||
Segment::new(
|
Segment::new(
|
||||||
Padding::new(time::widget(Some(msg.time()), style_time(highlighted)))
|
Padding::new(time::widget(Some(msg.time()), style_time(highlighted)))
|
||||||
.stretch(true)
|
.stretch(true)
|
||||||
|
|
@ -69,6 +71,7 @@ pub fn msg<M: Msg + ChatMsg>(highlighted: bool, indent: usize, msg: &M) -> Boxed
|
||||||
|
|
||||||
pub fn msg_placeholder(highlighted: bool, indent: usize) -> BoxedWidget {
|
pub fn msg_placeholder(highlighted: bool, indent: usize) -> BoxedWidget {
|
||||||
HJoin::new(vec![
|
HJoin::new(vec![
|
||||||
|
Segment::new(seen::widget(true)),
|
||||||
Segment::new(
|
Segment::new(
|
||||||
Padding::new(time::widget(None, style_time(highlighted)))
|
Padding::new(time::widget(None, style_time(highlighted)))
|
||||||
.stretch(true)
|
.stretch(true)
|
||||||
|
|
@ -91,6 +94,7 @@ pub fn editor<M: ChatMsg>(
|
||||||
let cursor_row = editor.cursor_row(frame);
|
let cursor_row = editor.cursor_row(frame);
|
||||||
|
|
||||||
let widget = HJoin::new(vec![
|
let widget = HJoin::new(vec![
|
||||||
|
Segment::new(seen::widget(true)),
|
||||||
Segment::new(
|
Segment::new(
|
||||||
Padding::new(time::widget(None, style_editor_highlight()))
|
Padding::new(time::widget(None, style_editor_highlight()))
|
||||||
.stretch(true)
|
.stretch(true)
|
||||||
|
|
@ -112,6 +116,7 @@ pub fn pseudo<M: ChatMsg>(indent: usize, nick: &str, editor: &EditorState) -> Bo
|
||||||
let (nick, content) = M::edit(nick, &editor.text());
|
let (nick, content) = M::edit(nick, &editor.text());
|
||||||
|
|
||||||
HJoin::new(vec![
|
HJoin::new(vec![
|
||||||
|
Segment::new(seen::widget(true)),
|
||||||
Segment::new(
|
Segment::new(
|
||||||
Padding::new(time::widget(None, style_pseudo_highlight()))
|
Padding::new(time::widget(None, style_pseudo_highlight()))
|
||||||
.stretch(true)
|
.stretch(true)
|
||||||
|
|
|
||||||
24
src/ui/chat/tree/widgets/seen.rs
Normal file
24
src/ui/chat/tree/widgets/seen.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
use crossterm::style::{ContentStyle, Stylize};
|
||||||
|
|
||||||
|
use crate::ui::widgets::background::Background;
|
||||||
|
use crate::ui::widgets::empty::Empty;
|
||||||
|
use crate::ui::widgets::text::Text;
|
||||||
|
use crate::ui::widgets::BoxedWidget;
|
||||||
|
|
||||||
|
const UNSEEN: &str = "*";
|
||||||
|
const WIDTH: u16 = 1;
|
||||||
|
|
||||||
|
fn seen_style() -> ContentStyle {
|
||||||
|
ContentStyle::default().black().on_green()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn widget(seen: bool) -> BoxedWidget {
|
||||||
|
if seen {
|
||||||
|
Empty::new().width(WIDTH).into()
|
||||||
|
} else {
|
||||||
|
let style = seen_style();
|
||||||
|
Background::new(Text::new((UNSEEN, style)))
|
||||||
|
.style(style)
|
||||||
|
.into()
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue