Show qr_code doc example in multiple places
This commit is contained in:
parent
c646ff5f1f
commit
1595e78b1a
2 changed files with 66 additions and 1 deletions
|
|
@ -1290,8 +1290,31 @@ where
|
||||||
|
|
||||||
/// Creates a new [`QRCode`] widget from the given [`Data`].
|
/// Creates a new [`QRCode`] widget from the given [`Data`].
|
||||||
///
|
///
|
||||||
|
/// QR codes display information in a type of two-dimensional matrix barcode.
|
||||||
|
///
|
||||||
/// [`QRCode`]: crate::QRCode
|
/// [`QRCode`]: crate::QRCode
|
||||||
/// [`Data`]: crate::qr_code::Data
|
/// [`Data`]: crate::qr_code::Data
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
/// ```no_run
|
||||||
|
/// # mod iced { pub mod widget { pub use iced_widget::*; } pub use iced_widget::Renderer; pub use iced_widget::core::*; }
|
||||||
|
/// # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>;
|
||||||
|
/// #
|
||||||
|
/// use iced::widget::qr_code;
|
||||||
|
///
|
||||||
|
/// struct State {
|
||||||
|
/// data: qr_code::Data,
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// #[derive(Debug, Clone)]
|
||||||
|
/// enum Message {
|
||||||
|
/// // ...
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// fn view(state: &State) -> Element<'_, Message> {
|
||||||
|
/// qr_code(&state.data).into()
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
#[cfg(feature = "qr_code")]
|
#[cfg(feature = "qr_code")]
|
||||||
pub fn qr_code<'a, Theme>(
|
pub fn qr_code<'a, Theme>(
|
||||||
data: &'a crate::qr_code::Data,
|
data: &'a crate::qr_code::Data,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,25 @@
|
||||||
//! Encode and display information in a QR code.
|
//! QR codes display information in a type of two-dimensional matrix barcode.
|
||||||
|
//!
|
||||||
|
//! # Example
|
||||||
|
//! ```no_run
|
||||||
|
//! # mod iced { pub mod widget { pub use iced_widget::*; } pub use iced_widget::Renderer; pub use iced_widget::core::*; }
|
||||||
|
//! # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>;
|
||||||
|
//! #
|
||||||
|
//! use iced::widget::qr_code;
|
||||||
|
//!
|
||||||
|
//! struct State {
|
||||||
|
//! data: qr_code::Data,
|
||||||
|
//! }
|
||||||
|
//!
|
||||||
|
//! #[derive(Debug, Clone)]
|
||||||
|
//! enum Message {
|
||||||
|
//! // ...
|
||||||
|
//! }
|
||||||
|
//!
|
||||||
|
//! fn view(state: &State) -> Element<'_, Message> {
|
||||||
|
//! qr_code(&state.data).into()
|
||||||
|
//! }
|
||||||
|
//! ```
|
||||||
use crate::canvas;
|
use crate::canvas;
|
||||||
use crate::core::layout;
|
use crate::core::layout;
|
||||||
use crate::core::mouse;
|
use crate::core::mouse;
|
||||||
|
|
@ -18,6 +39,27 @@ const QUIET_ZONE: usize = 2;
|
||||||
|
|
||||||
/// A type of matrix barcode consisting of squares arranged in a grid which
|
/// A type of matrix barcode consisting of squares arranged in a grid which
|
||||||
/// can be read by an imaging device, such as a camera.
|
/// can be read by an imaging device, such as a camera.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
/// ```no_run
|
||||||
|
/// # mod iced { pub mod widget { pub use iced_widget::*; } pub use iced_widget::Renderer; pub use iced_widget::core::*; }
|
||||||
|
/// # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>;
|
||||||
|
/// #
|
||||||
|
/// use iced::widget::qr_code;
|
||||||
|
///
|
||||||
|
/// struct State {
|
||||||
|
/// data: qr_code::Data,
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// #[derive(Debug, Clone)]
|
||||||
|
/// enum Message {
|
||||||
|
/// // ...
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// fn view(state: &State) -> Element<'_, Message> {
|
||||||
|
/// qr_code(&state.data).into()
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
pub struct QRCode<'a, Theme = crate::Theme>
|
pub struct QRCode<'a, Theme = crate::Theme>
|
||||||
where
|
where
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue