diff options
Diffstat (limited to 'examples/scrollable/src')
| -rw-r--r-- | examples/scrollable/src/main.rs | 54 | 
1 files changed, 25 insertions, 29 deletions
| diff --git a/examples/scrollable/src/main.rs b/examples/scrollable/src/main.rs index 2ad7272b..a6f3c689 100644 --- a/examples/scrollable/src/main.rs +++ b/examples/scrollable/src/main.rs @@ -1,20 +1,22 @@ -use iced::executor;  use iced::widget::scrollable::Properties;  use iced::widget::{      button, column, container, horizontal_space, progress_bar, radio, row,      scrollable, slider, text, vertical_space, Scrollable,  }; -use iced::{ -    Alignment, Application, Border, Color, Command, Element, Length, Settings, -    Theme, -}; +use iced::{Alignment, Border, Color, Command, Element, Length, Theme};  use once_cell::sync::Lazy;  static SCROLLABLE_ID: Lazy<scrollable::Id> = Lazy::new(scrollable::Id::unique);  pub fn main() -> iced::Result { -    ScrollableDemo::run(Settings::default()) +    iced::application( +        "Scrollable - Iced", +        ScrollableDemo::update, +        ScrollableDemo::view, +    ) +    .theme(ScrollableDemo::theme) +    .run()  }  struct ScrollableDemo { @@ -45,28 +47,16 @@ enum Message {      Scrolled(scrollable::Viewport),  } -impl Application for ScrollableDemo { -    type Executor = executor::Default; -    type Message = Message; -    type Theme = Theme; -    type Flags = (); - -    fn new(_flags: Self::Flags) -> (Self, Command<Message>) { -        ( -            ScrollableDemo { -                scrollable_direction: Direction::Vertical, -                scrollbar_width: 10, -                scrollbar_margin: 0, -                scroller_width: 10, -                current_scroll_offset: scrollable::RelativeOffset::START, -                alignment: scrollable::Alignment::Start, -            }, -            Command::none(), -        ) -    } - -    fn title(&self) -> String { -        String::from("Scrollable - Iced") +impl ScrollableDemo { +    fn new() -> Self { +        ScrollableDemo { +            scrollable_direction: Direction::Vertical, +            scrollbar_width: 10, +            scrollbar_margin: 0, +            scroller_width: 10, +            current_scroll_offset: scrollable::RelativeOffset::START, +            alignment: scrollable::Alignment::Start, +        }      }      fn update(&mut self, message: Message) -> Command<Message> { @@ -340,11 +330,17 @@ impl Application for ScrollableDemo {          container(content).padding(20).center_x().center_y().into()      } -    fn theme(&self) -> Self::Theme { +    fn theme(&self) -> Theme {          Theme::Dark      }  } +impl Default for ScrollableDemo { +    fn default() -> Self { +        Self::new() +    } +} +  fn progress_bar_custom_style(theme: &Theme) -> progress_bar::Appearance {      progress_bar::Appearance {          background: theme.extended_palette().background.strong.color.into(), | 
