MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / render

Method render

crates/opencode-tui/src/components/toast.rs:114–139  ·  view source on GitHub ↗
(&self, frame: &mut Frame, area: Rect, theme: &Theme)

Source from the content-addressed store, hash-verified

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() {

Callers

nothing calls this directly

Calls 4

newFunction · 0.85
animation_progressMethod · 0.80
blend_colorsFunction · 0.70
cloneMethod · 0.45

Tested by

no test coverage detected