-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
707 additions
and
279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
use super::{App, Message}; | ||
use cosmic::widget::{button, column, row, text}; | ||
use cosmic::Element; | ||
|
||
impl App | ||
where | ||
Self: cosmic::Application, | ||
{ | ||
pub fn view_buttons(&self) -> Element<Message> { | ||
column() | ||
.max_width(800) | ||
.spacing(24) | ||
.push(text::title1("Label Buttons")) | ||
// Suggested button header | ||
.push( | ||
column() | ||
.spacing(8) | ||
.push(text::title3("Suggested Button")) | ||
.push(text("Highest level of attention, there should only be one primary button used on the page.").size(14.0)) | ||
) | ||
// Suggested button demo | ||
.push( | ||
row() | ||
.spacing(36) | ||
.push(button::suggested("Label").on_press(Message::Clicked)) | ||
.push(button::suggested("Label").on_press(Message::Clicked).leading_icon(self.leading_icon.clone())) | ||
.push(button::suggested("Label").on_press(Message::Clicked).trailing_icon(self.trailing_icon.clone())) | ||
.push(button::suggested("Label").on_press(Message::Clicked).leading_icon(self.app_icon.clone())) | ||
.push( | ||
button::suggested("Label") | ||
.on_press(Message::Clicked) | ||
.leading_icon(self.app_icon.clone()) | ||
.trailing_icon(self.trailing_icon.clone()) | ||
) | ||
) | ||
// Destructive button header | ||
.push( | ||
column() | ||
.spacing(8) | ||
.push(text::title3("Destructive Button")) | ||
.push(text("Highest level of attention, there should only be one primary button used on the page.").size(14.0)) | ||
) | ||
// Destructive button demo | ||
.push( | ||
row() | ||
.spacing(36) | ||
.push(button::destructive("Label").on_press(Message::Clicked)) | ||
.push(button::destructive("Label").on_press(Message::Clicked).leading_icon(self.leading_icon.clone())) | ||
.push(button::destructive("Label").on_press(Message::Clicked).trailing_icon(self.trailing_icon.clone())) | ||
.push(button::destructive("Label").on_press(Message::Clicked).leading_icon(self.app_icon.clone())) | ||
.push( | ||
button::destructive("Label") | ||
.on_press(Message::Clicked) | ||
.leading_icon(self.app_icon.clone()) | ||
.trailing_icon(self.trailing_icon.clone()) | ||
) | ||
) | ||
// Standard button header | ||
.push( | ||
column() | ||
.spacing(8) | ||
.push(text::title3("Standard Button")) | ||
.push( | ||
text( | ||
"Requires less attention from the user. Could be more \ | ||
than one button on the page, if necessary." | ||
) | ||
.size(14.0) | ||
) | ||
) | ||
// Standard button demo | ||
.push( | ||
row() | ||
.spacing(36) | ||
.push(button::standard("Label").on_press(Message::Clicked)) | ||
.push(button::standard("Label").on_press(Message::Clicked).leading_icon(self.leading_icon.clone())) | ||
.push(button::standard("Label").on_press(Message::Clicked).trailing_icon(self.trailing_icon.clone())) | ||
.push(button::standard("Label").on_press(Message::Clicked).leading_icon(self.app_icon.clone())) | ||
.push( | ||
button::standard("Label") | ||
.on_press(Message::Clicked) | ||
.leading_icon(self.app_icon.clone()) | ||
.trailing_icon(self.trailing_icon.clone()) | ||
) | ||
) | ||
// Text button header | ||
.push( | ||
column() | ||
.spacing(8) | ||
.push(text::title3("Text Button")) | ||
.push(text( | ||
"Lowest priority actions, especially when presenting multiple options. Because text buttons \ | ||
don’t have a visible container in their default state, they don’t distract from nearby \ | ||
content. But they are also more difficult to recognize because of that." | ||
).size(14.0)) | ||
) | ||
// Text button demo | ||
.push( | ||
row() | ||
.spacing(36) | ||
.push(button::text("Label").on_press(Message::Clicked)) | ||
.push(button::text("Label").on_press(Message::Clicked).leading_icon(self.leading_icon.clone())) | ||
.push(button::text("Label").on_press(Message::Clicked).trailing_icon(self.trailing_icon.clone())) | ||
.push(button::text("Label").on_press(Message::Clicked).leading_icon(self.app_icon.clone())) | ||
.push( | ||
button::text("Label") | ||
.on_press(Message::Clicked) | ||
.leading_icon(self.app_icon.clone()) | ||
.trailing_icon(self.trailing_icon.clone()) | ||
) | ||
) | ||
// Icon buttons | ||
.push(text::title1("Icon Buttons")) | ||
// Extra small icon buttons | ||
.push( | ||
row() | ||
.spacing(36) | ||
.push(button::icon(self.bt_icon.clone()).on_press(Message::Clicked).extra_small()) | ||
.push(button::icon(self.bt_icon.clone()).on_press(Message::Clicked).extra_small().selected(true)) | ||
.push(button::icon(self.bt_icon.clone()).on_press(Message::Clicked).extra_small().label("Label")) | ||
.push( | ||
button::icon(self.bt_icon.clone()) | ||
.on_press(Message::Clicked) | ||
.extra_small() | ||
.label("Label") | ||
.selected(true) | ||
) | ||
) | ||
// Small (default) icon buttons | ||
.push( | ||
row() | ||
.spacing(36) | ||
.push(button::icon(self.bt_icon.clone()).on_press(Message::Clicked)) | ||
.push(button::icon(self.bt_icon.clone()).on_press(Message::Clicked).selected(true)) | ||
.push(button::icon(self.bt_icon.clone()).on_press(Message::Clicked).label("Label")) | ||
.push(button::icon(self.bt_icon.clone()).on_press(Message::Clicked).label("Label").selected(true)) | ||
) | ||
// Medium icon buttons | ||
.push( | ||
row() | ||
.spacing(36) | ||
.push(button::icon(self.bt_icon.clone()).on_press(Message::Clicked).medium()) | ||
.push(button::icon(self.bt_icon.clone()).on_press(Message::Clicked).medium().selected(true)) | ||
.push(button::icon(self.bt_icon.clone()).on_press(Message::Clicked).medium().label("Label")) | ||
.push( | ||
button::icon(self.bt_icon.clone()) | ||
.on_press(Message::Clicked) | ||
.medium() | ||
.label("Label") | ||
.selected(true) | ||
) | ||
) | ||
// Large icon buttons | ||
.push( | ||
row() | ||
.spacing(36) | ||
.push(button::icon(self.bt_icon.clone()).on_press(Message::Clicked).large()) | ||
.push(button::icon(self.bt_icon.clone()).on_press(Message::Clicked).large().selected(true)) | ||
.push(button::icon(self.bt_icon.clone()).on_press(Message::Clicked).large().label("Label")) | ||
.push( | ||
button::icon(self.bt_icon.clone()) | ||
.on_press(Message::Clicked) | ||
.large() | ||
.label("Label") | ||
.selected(true) | ||
) | ||
) | ||
// Extra large icon buttons | ||
.push( | ||
row() | ||
.spacing(36) | ||
.push(button::icon(self.bt_icon.clone()).on_press(Message::Clicked).extra_large()) | ||
.push(button::icon(self.bt_icon.clone()).on_press(Message::Clicked).extra_large().selected(true)) | ||
.push(button::icon(self.bt_icon.clone()).on_press(Message::Clicked).extra_large().label("Label")) | ||
.push( | ||
button::icon(self.bt_icon.clone()) | ||
.on_press(Message::Clicked) | ||
.extra_large() | ||
.label("Label") | ||
.selected(true) | ||
) | ||
) | ||
.into() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use super::{App, Message}; | ||
use cosmic::iced_core::Length; | ||
use cosmic::widget::{container, cosmic_container, text}; | ||
use cosmic::Element; | ||
use cosmic_time::{anim, chain, id, once_cell::sync::Lazy}; | ||
|
||
static CARDS: Lazy<id::Cards> = Lazy::new(id::Cards::unique); | ||
|
||
impl App | ||
where | ||
Self: cosmic::Application, | ||
{ | ||
pub fn update_cards(&mut self) { | ||
let timeline = &mut self.timeline; | ||
let chain = if self.cards_value { | ||
chain::Cards::on(CARDS.clone(), 1.) | ||
} else { | ||
chain::Cards::off(CARDS.clone(), 1.) | ||
}; | ||
timeline.set_chain(chain); | ||
timeline.start(); | ||
} | ||
|
||
pub fn view_cards(&self) -> Element<Message> { | ||
container( | ||
cosmic_container::container(anim!( | ||
CARDS, | ||
&self.timeline, | ||
vec![ | ||
text("Card 1").size(24).width(Length::Fill).into(), | ||
text("Card 2").size(24).width(Length::Fill).into(), | ||
text("Card 3").size(24).width(Length::Fill).into(), | ||
text("Card 4").size(24).width(Length::Fill).into(), | ||
], | ||
Message::Ignore, | ||
|_, e| Message::CardsToggled(e), | ||
"Show More", | ||
"Show Less", | ||
"Clear All", | ||
None, | ||
self.cards_value, | ||
)) | ||
.layer(cosmic::cosmic_theme::Layer::Secondary) | ||
.padding(16) | ||
.style(cosmic::theme::Container::Secondary), | ||
) | ||
.width(300) | ||
.into() | ||
} | ||
} |
Oops, something went wrong.