feat: show Miruro series artwork in descriptions
This commit is contained in:
+8
-63
@@ -3086,23 +3086,6 @@ impl App {
|
||||
.as_deref()
|
||||
.unwrap_or("Loading full description..."),
|
||||
};
|
||||
let mut details = if mode == PreviewMode::Description {
|
||||
inner.inner(ratatui::layout::Margin::new(1, 0))
|
||||
} else {
|
||||
let [_, image, _, mut details] = Layout::horizontal([
|
||||
Constraint::Length(1),
|
||||
Constraint::Fill(3),
|
||||
Constraint::Length(2),
|
||||
Constraint::Fill(2),
|
||||
])
|
||||
.areas(inner);
|
||||
let image_width = self.thumbnail.draw(frame, image);
|
||||
let reclaimed = image.width - image_width;
|
||||
details.x -= reclaimed;
|
||||
details.width += reclaimed;
|
||||
details.width = details.width.saturating_sub(2);
|
||||
details
|
||||
};
|
||||
let metadata = [
|
||||
Line::raw(video.title.as_str()).bold(),
|
||||
Line::default(),
|
||||
@@ -3118,6 +3101,7 @@ impl App {
|
||||
.dim(),
|
||||
];
|
||||
if mode == PreviewMode::Description {
|
||||
let details = inner.inner(ratatui::layout::Margin::new(1, 0));
|
||||
let mut content = Text::from(text);
|
||||
content.lines.splice(
|
||||
0..0,
|
||||
@@ -3142,52 +3126,13 @@ impl App {
|
||||
self.description_scroll = self.description_scroll.min(self.description_max_scroll);
|
||||
frame.render_widget(paragraph.scroll((self.description_scroll, 0)), details);
|
||||
} else {
|
||||
let metadata = Paragraph::new(Vec::from(metadata)).wrap(Wrap { trim: true });
|
||||
let height = if details.is_empty() {
|
||||
0
|
||||
} else {
|
||||
metadata
|
||||
.line_count(details.width)
|
||||
.min(details.height as usize) as u16
|
||||
};
|
||||
let mut excerpt = details;
|
||||
let gap = (excerpt.height - height).min(1);
|
||||
excerpt.y += height + gap;
|
||||
excerpt.height -= height + gap;
|
||||
details.height = height;
|
||||
frame.render_widget(metadata, details);
|
||||
let paragraph = Paragraph::new(text).wrap(Wrap { trim: false });
|
||||
let overflow = cached.is_some_and(|text| !text.is_empty())
|
||||
&& !excerpt.is_empty()
|
||||
&& paragraph.line_count(excerpt.width) > usize::from(excerpt.height);
|
||||
frame.render_widget(paragraph, excerpt);
|
||||
if overflow {
|
||||
let buffer = frame.buffer_mut();
|
||||
let y = excerpt.bottom() - 1;
|
||||
let end = (excerpt.x..excerpt.right())
|
||||
.rev()
|
||||
.find_map(|x| {
|
||||
let symbol = buffer
|
||||
.cell((x, y))
|
||||
.expect("excerpt is inside frame")
|
||||
.symbol();
|
||||
(!symbol.trim().is_empty())
|
||||
.then(|| x.saturating_add(Span::raw(symbol).width() as u16))
|
||||
})
|
||||
.unwrap_or(excerpt.x);
|
||||
let mut x = end.min(excerpt.right() - 1);
|
||||
// Do not leave half of a wide character beneath the ellipsis.
|
||||
if x > excerpt.x
|
||||
&& Span::raw(buffer.cell((x - 1, y)).unwrap().symbol()).width() > 1
|
||||
{
|
||||
x -= 1;
|
||||
}
|
||||
buffer
|
||||
.cell_mut((x, y))
|
||||
.unwrap()
|
||||
.set_symbol("…")
|
||||
.set_style(Style::new());
|
||||
}
|
||||
ui::info_preview(
|
||||
frame,
|
||||
inner,
|
||||
Some(&mut self.thumbnail),
|
||||
Vec::from(metadata),
|
||||
text,
|
||||
);
|
||||
}
|
||||
frame.render_widget(
|
||||
block.title(loading_title(
|
||||
|
||||
Reference in New Issue
Block a user