Implement Program::load to specify startup Command

This commit is contained in:
Héctor Ramón Jiménez 2024-03-16 15:53:03 +01:00
parent 5a986897d2
commit 93ae790da1
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
8 changed files with 122 additions and 77 deletions

View file

@ -11,12 +11,11 @@ static SCROLLABLE_ID: Lazy<scrollable::Id> = Lazy::new(scrollable::Id::unique);
pub fn main() -> iced::Result {
iced::application(
ScrollableDemo::new,
"Scrollable - Iced",
ScrollableDemo::update,
ScrollableDemo::view,
)
.theme(ScrollableDemo::theme)
.title("Scrollable - Iced")
.run()
}
@ -49,18 +48,15 @@ enum Message {
}
impl ScrollableDemo {
fn new() -> (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 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> {
@ -339,6 +335,12 @@ impl ScrollableDemo {
}
}
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(),