fix library buttons layout

This commit is contained in:
Chris Cochrun 2025-05-02 23:12:39 -05:00
parent 5ed7f6b837
commit ae84870ef1

View file

@ -1,8 +1,11 @@
use std::rc::Rc;
use cosmic::{ use cosmic::{
iced::{ iced::{
alignment::Vertical, clipboard::dnd::DndAction, alignment::Vertical, clipboard::dnd::DndAction,
futures::FutureExt, Background, Border, Color, Length, futures::FutureExt, Background, Border, Color, Length,
}, },
iced_core::widget::tree::State,
iced_widget::{column, row as rowm, text as textm}, iced_widget::{column, row as rowm, text as textm},
theme, theme,
widget::{ widget::{
@ -357,7 +360,7 @@ impl<'a> Library {
|(index, item)| { |(index, item)| {
let service_item = item.to_service_item(); let service_item = item.to_service_item();
let drag_item = let drag_item =
self.single_item(index, item, model); Box::new(self.single_item(index, item, &model));
let visual_item = self let visual_item = self
.single_item(index, item, model) .single_item(index, item, model)
.map(|_| Message::None); .map(|_| Message::None);
@ -384,11 +387,25 @@ impl<'a> Library {
)), )),
) )
.action(DndAction::Copy) .action(DndAction::Copy)
// .drag_icon(move |i| { .drag_icon({
// let state = let model = model.kind.clone();
// drag_item.as_widget().state(); move |i| {
// (drag_item, state, i) let state = State::None;
// }) let icon = match model {
LibraryKind::Song => icon::from_name(
"folder-music-symbolic",
)
,
LibraryKind::Video => icon::from_name("folder-videos-symbolic"),
LibraryKind::Image => icon::from_name("folder-pictures-symbolic"),
LibraryKind::Presentation => icon::from_name("x-office-presentation-symbolic"),
};
(
icon.into(),
state,
i,
)
}})
.drag_content(move || { .drag_content(move || {
service_item.to_owned() service_item.to_owned()
}) })
@ -396,10 +413,11 @@ impl<'a> Library {
}, },
) )
}) })
.spacing(2) .spacing(2)
.width(Length::Fill), .width(Length::Fill),
) )
.spacing(5); .spacing(5)
.height(Length::Fill);
let library_toolbar = rowm!( let library_toolbar = rowm!(
text_input("Search...", ""), text_input("Search...", ""),