use alloc::rc::Rc;
use slint::{SharedString, VecModel};
use spectre_api_sys::SpectreUserKey;

use crate::ui::storage::SpectreSite;

pub enum CallbackMessage {
    /// The escape key was pressed.
    Escape,
    Login(CallbackMessageLogin),
    Users(CallbackMessageUsers),
    UserEdit(CallbackMessageUserEdit),
    UserSites(CallbackMessageUserSites),
}

pub enum LoginResult {
    Failure,
    Success {
        user_key: SpectreUserKey,
        sites: Rc<VecModel<SpectreSite>>,
    },
}

pub enum CallbackMessageLogin {
    PwAccepted {
        user_index: i32,
        username: SharedString,
        password: SharedString,
    },
    LoginResult {
        username: SharedString,
        result: LoginResult,
    },
}

pub enum CallbackMessageUsers {
    EditUser { username: SharedString, new: bool },
}

pub enum CallbackMessageUserEdit {
    ComputeIdenticon { password: SharedString },
    ComputeKeyId { key: SharedString },
    ConfirmRequest,
    ConfirmProcessed,
}

pub enum CallbackMessageUserSites {
    SiteNameEdited { query: SharedString },
    SiteNameAccepted { site_list_index: i32 },
}
