diff options
Diffstat (limited to '')
| -rw-r--r-- | examples/qr_code/src/main.rs | 27 | 
1 files changed, 10 insertions, 17 deletions
| diff --git a/examples/qr_code/src/main.rs b/examples/qr_code/src/main.rs index 3e9ba921..6f487e4c 100644 --- a/examples/qr_code/src/main.rs +++ b/examples/qr_code/src/main.rs @@ -1,9 +1,6 @@ -use iced::qr_code::{self, QRCode}; -use iced::text_input::{self, TextInput}; -use iced::{ -    Alignment, Color, Column, Container, Element, Length, Sandbox, Settings, -    Text, -}; +use iced::widget::qr_code::{self, QRCode}; +use iced::widget::{column, container, text, text_input}; +use iced::{Alignment, Color, Element, Length, Sandbox, Settings};  pub fn main() -> iced::Result {      QRGenerator::run(Settings::default()) @@ -12,7 +9,6 @@ pub fn main() -> iced::Result {  #[derive(Default)]  struct QRGenerator {      data: String, -    input: text_input::State,      qr_code: Option<qr_code::State>,  } @@ -46,13 +42,12 @@ impl Sandbox for QRGenerator {          }      } -    fn view(&mut self) -> Element<Message> { -        let title = Text::new("QR Code Generator") +    fn view(&self) -> Element<Message> { +        let title = text("QR Code Generator")              .size(70)              .style(Color::from([0.5, 0.5, 0.5])); -        let input = TextInput::new( -            &mut self.input, +        let input = text_input(              "Type the data of your QR code here...",              &self.data,              Message::DataChanged, @@ -60,18 +55,16 @@ impl Sandbox for QRGenerator {          .size(30)          .padding(15); -        let mut content = Column::new() +        let mut content = column![title, input]              .width(Length::Units(700))              .spacing(20) -            .align_items(Alignment::Center) -            .push(title) -            .push(input); +            .align_items(Alignment::Center); -        if let Some(qr_code) = self.qr_code.as_mut() { +        if let Some(qr_code) = self.qr_code.as_ref() {              content = content.push(QRCode::new(qr_code).cell_size(10));          } -        Container::new(content) +        container(content)              .width(Length::Fill)              .height(Length::Fill)              .padding(20) | 
