This commit is contained in:
Mikhail Kilin
2026-02-13 19:52:53 +03:00
parent 6d08300daa
commit 6639dc876c
38 changed files with 961 additions and 123 deletions

View File

@@ -3,6 +3,16 @@
use crate::tdlib::{MessageInfo, ProfileInfo};
use crate::types::MessageId;
/// Vim-like input mode for chat view
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum InputMode {
/// Normal mode — navigation and commands (default)
#[default]
Normal,
/// Insert mode — text input only
Insert,
}
/// Состояния чата - взаимоисключающие режимы работы с чатом
#[derive(Debug, Clone)]
pub enum ChatState {

View File

@@ -2,7 +2,7 @@
//!
//! Handles chat list navigation and selection
use crate::app::{App, ChatState};
use crate::app::{App, ChatState, InputMode};
use crate::app::methods::search::SearchMethods;
use crate::tdlib::TdClientTrait;
@@ -84,6 +84,7 @@ impl<T: TdClientTrait> NavigationMethods<T> for App<T> {
self.last_typing_sent = None;
// Сбрасываем состояние чата в нормальный режим
self.chat_state = ChatState::Normal;
self.input_mode = InputMode::Normal;
// Очищаем данные в TdClient
self.td_client.set_current_chat_id(None);
self.td_client.clear_current_chat_messages();

View File

@@ -9,7 +9,7 @@ mod state;
pub mod methods;
pub use chat_filter::{ChatFilter, ChatFilterCriteria};
pub use chat_state::ChatState;
pub use chat_state::{ChatState, InputMode};
pub use state::AppScreen;
pub use methods::*;
@@ -60,6 +60,8 @@ pub struct App<T: TdClientTrait = TdClient> {
pub td_client: T,
/// Состояние чата - type-safe state machine (новое!)
pub chat_state: ChatState,
/// Vim-like input mode: Normal (navigation) / Insert (text input)
pub input_mode: InputMode,
// Auth state (приватные, доступ через геттеры)
phone_input: String,
code_input: String,
@@ -144,6 +146,7 @@ impl<T: TdClientTrait> App<T> {
screen: AppScreen::Loading,
td_client,
chat_state: ChatState::Normal,
input_mode: InputMode::Normal,
phone_input: String::new(),
code_input: String::new(),
password_input: String::new(),