From 9cbad0a352fcf12c5352e37bc15c0d20be6f89d7 Mon Sep 17 00:00:00 2001 From: alex-ds13 <145657253+alex-ds13@users.noreply.github.com> Date: Mon, 8 Apr 2024 19:37:37 +0100 Subject: Remove extra Download struct from dowload_progress example --- examples/download_progress/src/download.rs | 6 ------ 1 file changed, 6 deletions(-) (limited to 'examples/download_progress/src') diff --git a/examples/download_progress/src/download.rs b/examples/download_progress/src/download.rs index 3b11cb76..d6cc1e24 100644 --- a/examples/download_progress/src/download.rs +++ b/examples/download_progress/src/download.rs @@ -12,12 +12,6 @@ pub fn file( }) } -#[derive(Debug, Hash, Clone)] -pub struct Download { - id: I, - url: String, -} - async fn download(id: I, state: State) -> ((I, Progress), State) { match state { State::Ready(url) => { -- cgit From 15057a05c118dafcb8cf90d4119e66caaa6026c5 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 3 May 2024 09:11:46 +0200 Subject: Introduce `center` widget helper ... and also make `center_x` and `center_y` set `width` and `height` to `Length::Fill`, respectively. This targets the most common use case when centering things and removes a bunch of boilerplate as a result. --- examples/download_progress/src/main.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'examples/download_progress/src') diff --git a/examples/download_progress/src/main.rs b/examples/download_progress/src/main.rs index 9f4769e0..e031ac44 100644 --- a/examples/download_progress/src/main.rs +++ b/examples/download_progress/src/main.rs @@ -1,7 +1,7 @@ mod download; -use iced::widget::{button, column, container, progress_bar, text, Column}; -use iced::{Alignment, Element, Length, Subscription}; +use iced::widget::{button, center, column, progress_bar, text, Column}; +use iced::{Alignment, Element, Subscription}; pub fn main() -> iced::Result { iced::program("Download Progress - Iced", Example::update, Example::view) @@ -67,13 +67,7 @@ impl Example { .spacing(20) .align_items(Alignment::End); - container(downloads) - .width(Length::Fill) - .height(Length::Fill) - .center_x() - .center_y() - .padding(20) - .into() + center(downloads).padding(20).into() } } -- cgit