summaryrefslogtreecommitdiffstats
path: root/examples/qr_code
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-02-15 02:38:07 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-02-15 02:38:07 +0100
commitfeab96f323189ebae070a5d025531f86e436e21f (patch)
treebc15f73541151ef27e23ba1a908713b95c027d44 /examples/qr_code
parente57668d6776d4354b6d3df049aee64be0dc8eda2 (diff)
downloadiced-feab96f323189ebae070a5d025531f86e436e21f.tar.gz
iced-feab96f323189ebae070a5d025531f86e436e21f.tar.bz2
iced-feab96f323189ebae070a5d025531f86e436e21f.zip
Add `push_maybe` to `Column` and `Row`
Diffstat (limited to 'examples/qr_code')
-rw-r--r--examples/qr_code/src/main.rs16
1 files changed, 9 insertions, 7 deletions
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)