summaryrefslogtreecommitdiffstats
path: root/examples/qr_code/src
diff options
context:
space:
mode:
authorLibravatar Giuliano Bellini <100347457+GyulyVGC@users.noreply.github.com>2023-02-22 21:23:04 +0100
committerLibravatar GitHub <noreply@github.com>2023-02-22 21:23:04 +0100
commit4f41927155e7d4bc38497b0e298a0b23ccea6ca1 (patch)
tree70b7dbc1afdc62dfeaf42f0c62e8f4c01e407729 /examples/qr_code/src
parenta35d6d2e4d59f71309f31c87ea5150959d639185 (diff)
parent666f3cd143047e49a010f0c97eabc7136f92aa35 (diff)
downloadiced-4f41927155e7d4bc38497b0e298a0b23ccea6ca1.tar.gz
iced-4f41927155e7d4bc38497b0e298a0b23ccea6ca1.tar.bz2
iced-4f41927155e7d4bc38497b0e298a0b23ccea6ca1.zip
Merge branch 'iced-rs:master' into master
Diffstat (limited to 'examples/qr_code/src')
-rw-r--r--examples/qr_code/src/main.rs14
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);