From df944f980ceec520a2a6ad1016d4b2b017680433 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Mon, 13 Jan 2025 06:06:28 -0600 Subject: [PATCH] some preliminary work on libraries --- src/core/model.rs | 3 +++ src/main.rs | 9 +++++--- src/ui/library.rs | 55 +++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 60 insertions(+), 7 deletions(-) diff --git a/src/core/model.rs b/src/core/model.rs index 9f7b401..2f38cf7 100644 --- a/src/core/model.rs +++ b/src/core/model.rs @@ -4,10 +4,13 @@ use cosmic::iced::Executor; use miette::{miette, Result}; use sqlx::{Connection, SqliteConnection}; +use super::kinds::ServiceItemKind; + #[derive(Debug)] pub struct Model { pub items: Vec, pub db: SqliteConnection, + pub kind: ServiceItemKind, } impl Model { pub fn add_item(&mut self, item: T) -> Result<()> { diff --git a/src/main.rs b/src/main.rs index 2ea0b8f..bd12812 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,6 +23,7 @@ use std::path::PathBuf; use tracing::{debug, level_filters::LevelFilter}; use tracing::{error, warn}; use tracing_subscriber::EnvFilter; +use ui::library::Library; pub mod core; pub mod lisp; @@ -87,6 +88,7 @@ struct App { current_slide: Slide, presentation_open: bool, cli_mode: bool, + library: Library, library_open: bool, library_width: f32, } @@ -172,6 +174,7 @@ impl cosmic::Application for App { current_slide, presentation_open: false, cli_mode: !input.ui, + library: Library::new(&items), library_open: true, library_width: 60.0, }; @@ -547,9 +550,9 @@ impl cosmic::Application for App { ] .spacing(3); - // let library = Container::new("library") - // .center(Length::Fill) - // .width(self.library_width); + let library = Container::new(self.library.view()) + .center(Length::Fill) + .width(self.library_width); // let drag_handle = Container::new(Space::new(1, Length::Fill)) // .style(|t| nav_bar_style(t)); // let dragger = MouseArea::new(drag_handle) diff --git a/src/ui/library.rs b/src/ui/library.rs index 949ca46..968309e 100644 --- a/src/ui/library.rs +++ b/src/ui/library.rs @@ -1,18 +1,26 @@ -use cosmic::{Element, Task}; +use cosmic::{ + iced::Length, + iced_widget::{column, text}, + widget::{button, horizontal_space, icon, row}, + Element, Task, +}; use crate::core::{ - images::Image, model::Model, presentations::Presentation, + images::Image, kinds::ServiceItemKind, model::Model, + presentations::Presentation, service_items::ServiceItemModel, songs::Song, videos::Video, }; -struct Library { +pub(crate) struct Library { song_library: Model, image_library: Model, video_library: Model