From a20c53a1bc80d34f9e454e7387fea6ef9ca844ff Mon Sep 17 00:00:00 2001 From: Adel Aloui Date: Fri, 1 Aug 2025 13:51:38 +0100 Subject: [PATCH 1/3] feat(list): add CopyError message and clipboard functionality for error handling --- src/gui/views/list.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gui/views/list.rs b/src/gui/views/list.rs index 3cd3f76..b7019c1 100644 --- a/src/gui/views/list.rs +++ b/src/gui/views/list.rs @@ -91,6 +91,7 @@ pub enum Message { ExportSelection, SelectionExported(Result), DescriptionEdit(text_editor::Action), + CopyError(String), } pub struct SummaryEntry { @@ -368,6 +369,7 @@ impl List { } Command::none() } + Message::CopyError(err) => iced::clipboard::write::(err), } } @@ -925,6 +927,13 @@ fn error_view<'a>( .center_x(); let modal_btn_row = row![ + button( + text("Copy error") + .width(Length::Fill) + .horizontal_alignment(alignment::Horizontal::Center), + ) + .width(Length::Fill) + .on_press(Message::CopyError(error.to_string())), button( text("Close") .width(Length::Fill) From 2ca3e05a8e7da5c3d62d90e6f64c44bedb3c5265 Mon Sep 17 00:00:00 2001 From: Adel Aloui Date: Fri, 1 Aug 2025 14:17:32 +0100 Subject: [PATCH 2/3] feat(list): add copy confirmation for error messages and improve clipboard handling --- src/gui/views/list.rs | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/gui/views/list.rs b/src/gui/views/list.rs index b7019c1..ed1bdf0 100644 --- a/src/gui/views/list.rs +++ b/src/gui/views/list.rs @@ -63,6 +63,7 @@ pub struct List { export_modal: bool, current_package_index: usize, is_adb_satisfied: bool, + copy_confirmation: bool, } #[derive(Debug, Clone)] @@ -92,6 +93,7 @@ pub enum Message { SelectionExported(Result), DescriptionEdit(text_editor::Action), CopyError(String), + HideCopyConfirmation, } pub struct SummaryEntry { @@ -369,7 +371,17 @@ impl List { } Command::none() } - Message::CopyError(err) => iced::clipboard::write::(err), + Message::CopyError(err) => { + self.copy_confirmation = true; + Command::batch(vec![ + iced::clipboard::write::(err), + Command::perform(Self::delay_hide_copy_confirmation(), |_| Message::HideCopyConfirmation) + ]) + } + Message::HideCopyConfirmation => { + self.copy_confirmation = false; + Command::none() + } } } @@ -638,7 +650,7 @@ impl List { } if let Some(err) = &self.error_modal { - error_view(err, content).into() + error_view(err, content, self.copy_confirmation).into() } else { container(content).height(Length::Fill).padding(10).into() } @@ -911,11 +923,16 @@ impl List { } } } + + async fn delay_hide_copy_confirmation() { + std::thread::sleep(std::time::Duration::from_secs(1)); + } } fn error_view<'a>( error: &'a str, content: Column<'a, Message, Theme, Renderer>, + copy_confirmation: bool, ) -> Modal<'a, Message, Theme, Renderer> { let title_ctn = container( row![text("Failed to perform ADB operation").size(24)].align_items(Alignment::Center), @@ -928,12 +945,13 @@ fn error_view<'a>( let modal_btn_row = row![ button( - text("Copy error") + text(if copy_confirmation { "Copied!" } else { "Copy error" }) .width(Length::Fill) .horizontal_alignment(alignment::Horizontal::Center), ) .width(Length::Fill) - .on_press(Message::CopyError(error.to_string())), + .on_press_maybe(if copy_confirmation { None } else { Some(Message::CopyError(error.to_string())) }) + .style(if copy_confirmation { style::Button::Primary } else { style::Button::default() }), button( text("Close") .width(Length::Fill) From 23ac7ae6ee48b340384c2376e8649f3cbe608677 Mon Sep 17 00:00:00 2001 From: Adel Aloui Date: Fri, 1 Aug 2025 15:40:53 +0100 Subject: [PATCH 3/3] style: fix formatting issues in list.rs to pass cargo fmt --- src/gui/views/list.rs | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/gui/views/list.rs b/src/gui/views/list.rs index ed1bdf0..74452b8 100644 --- a/src/gui/views/list.rs +++ b/src/gui/views/list.rs @@ -375,7 +375,9 @@ impl List { self.copy_confirmation = true; Command::batch(vec![ iced::clipboard::write::(err), - Command::perform(Self::delay_hide_copy_confirmation(), |_| Message::HideCopyConfirmation) + Command::perform(Self::delay_hide_copy_confirmation(), |_| { + Message::HideCopyConfirmation + }), ]) } Message::HideCopyConfirmation => { @@ -945,13 +947,25 @@ fn error_view<'a>( let modal_btn_row = row![ button( - text(if copy_confirmation { "Copied!" } else { "Copy error" }) - .width(Length::Fill) - .horizontal_alignment(alignment::Horizontal::Center), + text(if copy_confirmation { + "Copied!" + } else { + "Copy error" + }) + .width(Length::Fill) + .horizontal_alignment(alignment::Horizontal::Center), ) .width(Length::Fill) - .on_press_maybe(if copy_confirmation { None } else { Some(Message::CopyError(error.to_string())) }) - .style(if copy_confirmation { style::Button::Primary } else { style::Button::default() }), + .on_press_maybe(if copy_confirmation { + None + } else { + Some(Message::CopyError(error.to_string())) + }) + .style(if copy_confirmation { + style::Button::Primary + } else { + style::Button::default() + }), button( text("Close") .width(Length::Fill)