From feab96f323189ebae070a5d025531f86e436e21f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 15 Feb 2024 02:38:07 +0100 Subject: Add `push_maybe` to `Column` and `Row` --- examples/qr_code/src/main.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'examples/qr_code') diff --git a/examples/qr_code/src/main.rs b/examples/qr_code/src/main.rs index 9f75eaf6..36f79a31 100644 --- a/examples/qr_code/src/main.rs +++ b/examples/qr_code/src/main.rs @@ -1,5 +1,6 @@ -use iced::widget::qr_code::{self, QRCode}; -use iced::widget::{column, container, pick_list, row, text, text_input}; +use iced::widget::{ + column, container, pick_list, qr_code, row, text, text_input, +}; use iced::{Alignment, Element, Length, Sandbox, Settings, Theme}; pub fn main() -> iced::Result { @@ -65,15 +66,16 @@ impl Sandbox for QRGenerator { .spacing(10) .align_items(Alignment::Center); - let mut content = column![title, input, choose_theme] + let content = column![title, input, choose_theme] + .push_maybe( + self.qr_code + .as_ref() + .map(|data| qr_code(data).cell_size(10)), + ) .width(700) .spacing(20) .align_items(Alignment::Center); - if let Some(qr_code) = self.qr_code.as_ref() { - content = content.push(QRCode::new(qr_code).cell_size(10)); - } - container(content) .width(Length::Fill) .height(Length::Fill) -- cgit