Show progress_bar doc example in multiple places

This commit is contained in:
Héctor Ramón Jiménez 2024-09-19 04:57:32 +02:00
parent 7b22b7e876
commit c646ff5f1f
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
2 changed files with 56 additions and 7 deletions

View file

@ -1112,11 +1112,31 @@ where
/// Creates a new [`ProgressBar`].
///
/// Progress bars visualize the progression of an extended computer operation, such as a download, file transfer, or installation.
///
/// It expects:
/// * an inclusive range of possible values, and
/// * the current value of the [`ProgressBar`].
///
/// [`ProgressBar`]: crate::ProgressBar
/// # 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::progress_bar;
///
/// struct State {
/// progress: f32,
/// }
///
/// enum Message {
/// // ...
/// }
///
/// fn view(state: &State) -> Element<'_, Message> {
/// progress_bar(0.0..=100.0, state.progress).into()
/// }
/// ```
pub fn progress_bar<'a, Theme>(
range: RangeInclusive<f32>,
value: f32,