Refactor UI components for layout management and results display
- Replaced the `renderizar` function in `layouts.rs` with a new `view` function using Iced for a more modern UI approach. - Introduced a new `view_secao_layouts` function to handle the display of saved layouts. - Updated the `resultado.rs` file to use Iced for rendering the results screen, including buttons for actions and pagination controls. - Created a new `selecionar_aba.rs` file for the selection of XLSX sheet tabs, implementing a preview feature. - Removed old rendering functions and replaced them with Iced components for better performance and maintainability. - Added design tokens in `design_tokens.json` for consistent styling across the application. - Created a mockup HTML file to visualize the UI design.
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
use crate::domain::entities::nota::Nota;
|
||||
use crate::domain::entities::{
|
||||
chave_serie::ChaveSerie,
|
||||
layout::{Layout, LayoutXlsx},
|
||||
resultado_analise::{ResultadoAnalise, ResultadoPreAnalise},
|
||||
};
|
||||
use crate::domain::errors::ResumoAvisos;
|
||||
use rusqlite::Connection;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
/// Todos os eventos/interações da UI.
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Message {
|
||||
// --- Inicialização ---
|
||||
BancoInicializado(Result<(Arc<Mutex<Connection>>, bool, Vec<Layout>), String>),
|
||||
LayoutsRecarregados(Vec<Layout>),
|
||||
|
||||
// --- Navegação ---
|
||||
IrParaImportacao,
|
||||
IrParaConfiguracaoColunas,
|
||||
IrParaLayouts,
|
||||
Voltar,
|
||||
|
||||
// --- Arquivo ---
|
||||
SelecionarArquivo,
|
||||
ArquivoSelecionado(PathBuf),
|
||||
AbaSelecionada(String),
|
||||
|
||||
// --- XLSX: abas carregadas em background ---
|
||||
AbaxlsxCarregadas {
|
||||
caminho: PathBuf,
|
||||
abas: Vec<String>,
|
||||
layout_xlsx: LayoutXlsx,
|
||||
nome_layout: String,
|
||||
},
|
||||
XlsxErroAoCarregar(String),
|
||||
|
||||
// --- Background tasks ---
|
||||
AnaliseCompleta(ResultadoPendente),
|
||||
|
||||
// --- Configuração CSV ---
|
||||
DelimitadorAlterado(char),
|
||||
EncodingAlterado(String),
|
||||
LinhaCabecalhoAlterada(usize),
|
||||
IndiceNumeroAlterado(usize),
|
||||
IndiceSerieAlterado(usize),
|
||||
IndiceValorToggle(bool),
|
||||
IndiceValorAlterado(usize),
|
||||
IndiceDataToggle(bool),
|
||||
IndiceDataAlterado(usize),
|
||||
IndiceDocTipoToggle(bool),
|
||||
IndiceDocTipoAlterado(usize),
|
||||
|
||||
// --- Configuração XLSX ---
|
||||
AbaXlsxAlterada(String),
|
||||
PosNumeroAlterada(String),
|
||||
PosSerieAlterada(String),
|
||||
PosValorToggle(bool),
|
||||
PosValorAlterada(String),
|
||||
PosDataToggle(bool),
|
||||
PosDataAlterada(String),
|
||||
PosDocTipoToggle(bool),
|
||||
PosDocTipoAlterada(String),
|
||||
|
||||
// --- Análise ---
|
||||
ExecutarImportacao,
|
||||
ReanalisarArquivo,
|
||||
ConfirmarExpansaoFaltantes,
|
||||
CancelarExpansao,
|
||||
NovaAnalise,
|
||||
|
||||
// --- Resultado ---
|
||||
PaginaFaltantesAlterada(usize),
|
||||
PaginaDuplicatasAlterada(usize),
|
||||
ItensPorPaginaAlterado(usize),
|
||||
CopiarFaltantes(ChaveSerie),
|
||||
CopiarDuplicatas(ChaveSerie),
|
||||
ExportarPdf,
|
||||
PdfExportado(Result<PathBuf, String>),
|
||||
|
||||
// --- Layouts ---
|
||||
LayoutSelecionado(i64),
|
||||
SalvarLayout,
|
||||
NomeLayoutAlterado(String),
|
||||
ExcluirLayout(i64),
|
||||
ExclusaoConfirmada(i64),
|
||||
ExportarLayoutJson(i64),
|
||||
ImportarLayoutJson,
|
||||
LayoutJsonImportado(String),
|
||||
SobrescreverLayout(Layout),
|
||||
|
||||
// --- Modal ---
|
||||
ModalTextoAlterado(String),
|
||||
ModalConfirmado,
|
||||
ModalCancelado,
|
||||
|
||||
// --- Sem operação (used as fallback) ---
|
||||
Noop,
|
||||
}
|
||||
|
||||
/// Resultado enviado pela task de análise em background para a UI.
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ResultadoPendente {
|
||||
/// Análise concluída com sucesso.
|
||||
Concluido {
|
||||
resultado: ResultadoAnalise,
|
||||
avisos: Option<ResumoAvisos>,
|
||||
notas: Option<Vec<Nota>>,
|
||||
},
|
||||
/// Pré-análise concluída mas precisa de confirmação do usuário.
|
||||
AguardandoConfirmacao {
|
||||
pre: ResultadoPreAnalise,
|
||||
series_excessivas: Vec<(ChaveSerie, u64)>,
|
||||
avisos: ResumoAvisos,
|
||||
notas: Vec<Nota>,
|
||||
},
|
||||
/// Arquivo importado não continha notas válidas.
|
||||
Vazio,
|
||||
/// Erro durante importação ou análise.
|
||||
Erro(String),
|
||||
}
|
||||
Reference in New Issue
Block a user