Replace stateful widgets with new iced_pure API
This commit is contained in:
parent
c44267b85f
commit
ff2519b1d4
142 changed files with 3631 additions and 14494 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue