(&self, frame: &mut Frame, area: Rect, theme: &Theme)
| 112 | } |
| 113 | |
| 114 | pub fn render(&self, frame: &mut Frame, area: Rect, theme: &Theme) { |
| 115 | if let Some(msg) = &self.message { |
| 116 | let progress = self.animation_progress(); |
| 117 | let fade_alpha = MIN_FADE_ALPHA + (1.0 - MIN_FADE_ALPHA) * progress; |
| 118 | let border_color = match self.variant { |
| 119 | ToastVariant::Info => theme.info, |
| 120 | ToastVariant::Success => theme.success, |
| 121 | ToastVariant::Warning => theme.warning, |
| 122 | ToastVariant::Error => theme.error, |
| 123 | }; |
| 124 | let text_color = blend_colors(theme.text_muted, theme.text, progress); |
| 125 | let panel_bg = blend_colors(theme.background, theme.background_panel, fade_alpha); |
| 126 | let border_color = blend_colors(theme.background_panel, border_color, fade_alpha); |
| 127 | |
| 128 | let paragraph = Paragraph::new(msg.clone()) |
| 129 | .style(Style::default().fg(text_color).bg(panel_bg)) |
| 130 | .block( |
| 131 | Block::default() |
| 132 | .borders(Borders::LEFT | Borders::RIGHT) |
| 133 | .border_style(Style::default().fg(border_color)) |
| 134 | .style(Style::default().bg(panel_bg)), |
| 135 | ) |
| 136 | .wrap(Wrap { trim: true }); |
| 137 | frame.render_widget(paragraph, area); |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | fn animation_progress(&self) -> f32 { |
| 142 | if self.message.is_none() { |
nothing calls this directly
no test coverage detected