diff options
Diffstat (limited to 'examples/qr_code')
-rw-r--r-- | examples/qr_code/src/main.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/examples/qr_code/src/main.rs b/examples/qr_code/src/main.rs index 6f487e4c..d8041745 100644 --- a/examples/qr_code/src/main.rs +++ b/examples/qr_code/src/main.rs @@ -21,10 +21,7 @@ impl Sandbox for QRGenerator { type Message = Message; fn new() -> Self { - QRGenerator { - qr_code: qr_code::State::new("").ok(), - ..Self::default() - } + QRGenerator::default() } fn title(&self) -> String { @@ -36,7 +33,12 @@ impl Sandbox for QRGenerator { Message::DataChanged(mut data) => { data.truncate(100); - self.qr_code = qr_code::State::new(&data).ok(); + self.qr_code = if data.is_empty() { + None + } else { + qr_code::State::new(&data).ok() + }; + self.data = data; } } @@ -56,7 +58,7 @@ impl Sandbox for QRGenerator { .padding(15); let mut content = column![title, input] - .width(Length::Units(700)) + .width(700) .spacing(20) .align_items(Alignment::Center); |