make dialog us apply more such that it cleans up code structure
Some checks are pending
/ test (push) Waiting to run

This commit is contained in:
Chris Cochrun 2025-10-22 10:51:18 -05:00
parent 8699a08948
commit b0a33ad0f6

View file

@ -32,7 +32,7 @@ use cosmic::widget::{
}; };
use cosmic::widget::{container, text}; use cosmic::widget::{container, text};
use cosmic::widget::{icon, slider}; use cosmic::widget::{icon, slider};
use cosmic::{Application, ApplicationExt, Element, executor}; use cosmic::{Application, ApplicationExt, Apply, Element, executor};
use cosmic::{cosmic_config, theme}; use cosmic::{cosmic_config, theme};
use crisp::types::Value; use crisp::types::Value;
use lisp::parse_lisp; use lisp::parse_lisp;
@ -718,16 +718,14 @@ impl cosmic::Application for App {
.map(|item| { .map(|item| {
let title = text::title4(item.title().clone()); let title = text::title4(item.title().clone());
let subtitle = text::body(item.to_string()); let subtitle = text::body(item.to_string());
Element::from(Container::new( Element::from(
row![ row![
column![title, subtitle] column![title, subtitle]
.spacing(space_xxs), .spacing(space_xxs),
horizontal_space(), horizontal_space(),
tooltip( tooltip(
button::icon(
icon::from_name("add") icon::from_name("add")
.symbolic(true) .symbolic(true).apply(button::icon)
)
.icon_size(space_l) .icon_size(space_l)
.on_press( .on_press(
Message::AppendServiceItemKind( Message::AppendServiceItemKind(
@ -738,10 +736,8 @@ impl cosmic::Application for App {
TPosition::FollowCursor TPosition::FollowCursor
), ),
tooltip( tooltip(
button::icon(
icon::from_name("edit") icon::from_name("edit")
.symbolic(true) .symbolic(true).apply(button::icon)
)
.icon_size(space_l) .icon_size(space_l)
.on_press(Message::OpenEditorKind( .on_press(Message::OpenEditorKind(
item.clone() item.clone()
@ -750,12 +746,12 @@ impl cosmic::Application for App {
TPosition::FollowCursor TPosition::FollowCursor
), ),
] ]
.align_y(Vertical::Center), .align_y(Vertical::Center)
)) .apply(container),
)
}) })
.collect(); .collect();
let modal = Container::new( let modal = column![
column![
search_input("Amazing Grace", &self.search_query) search_input("Amazing Grace", &self.search_query)
.id(self.search_id.clone()) .id(self.search_id.clone())
.select_on_focus(true) .select_on_focus(true)
@ -763,17 +759,19 @@ impl cosmic::Application for App {
.on_submit(Message::Search), .on_submit(Message::Search),
column(items).spacing(space_xxs) column(items).spacing(space_xxs)
] ]
.spacing(space_s), .spacing(space_s)
) .apply(container)
.padding(space_xl) .padding(space_xl)
.style(nav_bar_style); .style(nav_bar_style);
let modal = Container::new(modal) let modal = mouse_area(modal)
.on_press(Message::None)
.apply(container)
.padding([space_xxl, space_xxxl * 2]) .padding([space_xxl, space_xxxl * 2])
.center_x(Length::Fill) .center_x(Length::Fill)
.align_top(Length::Fill); .align_top(Length::Fill);
let mouse_stack = stack!( let mouse_stack = stack!(
mouse_area( Space::new(Length::Fill, Length::Fill)
container(Space::new(Length::Fill, Length::Fill)) .apply(container)
.style(|_| { .style(|_| {
container::background( container::background(
cosmic::iced::Background::Color( cosmic::iced::Background::Color(
@ -782,7 +780,7 @@ impl cosmic::Application for App {
.scale_alpha(0.3), .scale_alpha(0.3),
) )
}) })
) .apply(mouse_area)
.on_press(Message::CloseSearch), .on_press(Message::CloseSearch),
modal modal
); );
@ -801,41 +799,39 @@ impl cosmic::Application for App {
), ),
); );
let settings_column = column![ let settings_column = column![
Container::new(
button::icon(
icon::from_name("dialog-close") icon::from_name("dialog-close")
.symbolic(true) .symbolic(true)
) .prefer_svg(true)
.apply(button::icon)
.class(theme::Button::Icon) .class(theme::Button::Icon)
.on_press(Message::CloseSettings) .on_press(Message::CloseSettings)
) .apply(container)
.padding(space_s) .padding(space_s)
.align_right(Length::Fill) .align_right(Length::Fill)
.align_top(60), .align_top(60),
horizontal_space().height(space_xxl), horizontal_space().height(space_xxl),
Container::new(
settings::section() settings::section()
.title("Obs Settings") .title("Obs Settings")
.add(obs_socket) .add(obs_socket)
.add(apply_button) .add(apply_button)
) .apply(container)
.center_x(Length::Fill) .center_x(Length::Fill)
.align_top(Length::Fill) .align_top(Length::Fill)
.padding([0, space_xxxl * 2]) .padding([0, space_xxxl * 2])
] ]
.height(Length::Fill); .height(Length::Fill);
let settings_container = Container::new(settings_column) let settings_container = settings_column
.apply(container)
.style(nav_bar_style) .style(nav_bar_style)
.center_x(Length::Fill) .center_x(Length::Fill)
.align_top(Length::Fill); .align_top(Length::Fill);
let modal = Container::new( let modal = mouse_area(settings_container)
mouse_area(settings_container) .on_press(Message::None)
.on_press(Message::None), .apply(container)
)
.padding([space_xxl, space_xxxl * 2]); .padding([space_xxl, space_xxxl * 2]);
let mouse_stack = stack!( let mouse_stack = stack!(
mouse_area( Space::new(Length::Fill, Length::Fill)
container(Space::new(Length::Fill, Length::Fill)) .apply(container)
.style(|_| { .style(|_| {
container::background( container::background(
cosmic::iced::Background::Color( cosmic::iced::Background::Color(
@ -844,7 +840,7 @@ impl cosmic::Application for App {
.scale_alpha(0.3), .scale_alpha(0.3),
) )
}) })
) .apply(mouse_area)
.on_press(Message::CloseSettings), .on_press(Message::CloseSettings),
modal modal
); );
@ -1239,6 +1235,7 @@ impl cosmic::Application for App {
Task::none() Task::none()
} }
Message::SearchFocus => { Message::SearchFocus => {
self.settings_open = false;
self.searching = true; self.searching = true;
cosmic::widget::text_input::focus( cosmic::widget::text_input::focus(
self.search_id.clone(), self.search_id.clone(),
@ -1500,6 +1497,7 @@ impl cosmic::Application for App {
}) })
} }
Message::OpenSettings => { Message::OpenSettings => {
self.searching = false;
self.settings_open = true; self.settings_open = true;
Task::none() Task::none()
} }