This commit is contained in:
Mikhail Kilin
2026-01-20 14:54:30 +03:00
parent 699f50a59c
commit 9912ac11bd
8 changed files with 232 additions and 48 deletions

View File

@@ -17,26 +17,44 @@ pub fn render(f: &mut Frame, area: Rect, app: &mut App) {
.split(area);
// Search box
let search = Paragraph::new("🔍 Search...")
let search_text = if app.is_searching {
if app.search_query.is_empty() {
"🔍 Введите для поиска...".to_string()
} else {
format!("🔍 {}", app.search_query)
}
} else {
"🔍 Ctrl+S для поиска".to_string()
};
let search_style = if app.is_searching {
Style::default().fg(Color::Yellow)
} else {
Style::default().fg(Color::DarkGray)
};
let search = Paragraph::new(search_text)
.block(Block::default().borders(Borders::ALL))
.style(Style::default().fg(Color::DarkGray));
.style(search_style);
f.render_widget(search, chat_chunks[0]);
// Chat list
let items: Vec<ListItem> = app
.chats
// Chat list (filtered if searching)
let filtered_chats = app.get_filtered_chats();
let items: Vec<ListItem> = filtered_chats
.iter()
.map(|chat| {
let is_selected = app.selected_chat_id == Some(chat.id);
let prefix = if is_selected { "" } else { " " };
let username_text = chat.username.as_ref()
.map(|u| format!(" {}", u))
.unwrap_or_default();
let unread_badge = if chat.unread_count > 0 {
format!(" ({})", chat.unread_count)
} else {
String::new()
};
let content = format!("{}{}{}", prefix, chat.title, unread_badge);
let content = format!("{}{}{}{}", prefix, chat.title, username_text, unread_badge);
let style = Style::default().fg(Color::White);
ListItem::new(content).style(style)