From 0738fc27bac154705c2e4e5f0ef43fcbca8188fa Mon Sep 17 00:00:00 2001 From: servius Date: Wed, 28 Jan 2026 02:00:16 +0530 Subject: [PATCH] feat: Use a floating box for settings --- ui-iced/src/lib.rs | 68 +++++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 25 deletions(-) diff --git a/ui-iced/src/lib.rs b/ui-iced/src/lib.rs index 5ed259d..7bcbcd0 100644 --- a/ui-iced/src/lib.rs +++ b/ui-iced/src/lib.rs @@ -4,6 +4,7 @@ mod video; mod shared_string; use iced_video::{Ready, Video, VideoHandle}; use shared_string::SharedString; +use tap::Pipe as _; use std::sync::Arc; @@ -293,9 +294,29 @@ fn update(state: &mut State, message: Message) -> Task { } fn view(state: &State) -> Element<'_, Message> { + let content = home(state); match state.screen { - Screen::Settings => settings::settings(state), - Screen::Home | _ => home(state), + Screen::Settings => { + let settings = settings::settings(state); + let settings = container(settings) + .width(Length::FillPortion(4)) + .height(Length::FillPortion(4)) + .style(container::rounded_box) + .pipe(mouse_area) + .on_press(Message::Refresh) + .pipe(|c| iced::widget::column![space::vertical(), c, space::vertical()]) + .pipe(container) + .width(Length::Fill) + .width(Length::Fill) + .align_y(Alignment::Center) + .align_x(Alignment::Center) + .padding(50) + .pipe(mouse_area) + .on_press(Message::Settings(settings::SettingsMessage::Close)); + // let content = mouse_area(content).on_press(Message::Home); + stack![content, settings].into() + } + Screen::Home | _ => content, } } @@ -310,20 +331,18 @@ fn body(state: &State) -> Element<'_, Message> { if let Some(ref video) = state.video { video::player(video) } else { - scrollable( - container( - Grid::with_children(state.cache.items_of(state.current).into_iter().map(card)) - .fluid(400) - .spacing(50), - ) + Grid::with_children(state.cache.items_of(state.current).into_iter().map(card)) + .fluid(400) + .spacing(50) + .pipe(container) .padding(50) .align_x(Alignment::Center) // .align_y(Alignment::Center) .height(Length::Fill) - .width(Length::Fill), - ) - .height(Length::Fill) - .into() + .width(Length::Fill) + .pipe(scrollable) + .height(Length::Fill) + .into() } } @@ -377,19 +396,18 @@ fn header(state: &State) -> Element<'_, Message> { } fn search(state: &State) -> Element<'_, Message> { - container( - TextInput::new("Search...", state.query.as_deref().unwrap_or_default()) - .padding(10) - .size(16) - .width(Length::Fill) - .on_input(Message::SearchQueryChanged) - .on_submit(Message::Search), - ) - .padding(10) - .width(Length::Fill) - .height(Length::Shrink) - .style(container::rounded_box) - .into() + TextInput::new("Search...", state.query.as_deref().unwrap_or_default()) + .padding(10) + .size(16) + .width(Length::Fill) + .on_input(Message::SearchQueryChanged) + .on_submit(Message::Search) + .pipe(container) + .padding(10) + .width(Length::Fill) + .height(Length::Shrink) + .style(container::rounded_box) + .into() } fn footer(state: &State) -> Element<'_, Message> {