Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mmstick committed Sep 6, 2023
1 parent 466f80a commit e402098
Show file tree
Hide file tree
Showing 17 changed files with 707 additions and 279 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
path = iced
url = https://github.com/pop-os/iced.git
branch = master
[submodule "time"]
path = time
url = https://github.com/pop-os/cosmic-time
1 change: 1 addition & 0 deletions examples/application/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ impl cosmic::Application for App {
/// Message type specific to our [`App`].
type Message = Message;

/// The unique application ID to supply to the window manager.
const APP_ID: &'static str = "org.cosmic.AppDemo";

fn core(&self) -> &Core {
Expand Down
14 changes: 10 additions & 4 deletions examples/cosmic-sctk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ authors = []
edition = "2021"
publish = false

[dependencies]
libcosmic = { path = "../..", features = ["wayland", "tokio"] }
cosmic-time = { git = "https://github.com/pop-os/cosmic-time", branch = "icon-color", default-features = false, features = ["libcosmic", "once_cell"] }
# cosmic-time = { path = "../../../cosmic-time", default-features = false, features = ["libcosmic", "once_cell"]}
[dependencies.libcosmic]
path = "../../"
default-features = false
features = ["debug", "wayland", "tokio"]

[dependencies.cosmic-time]
git = "https://github.com/pop-os/cosmic-time"
branch = "icon-color"
default-features = false
features = ["libcosmic", "once_cell"]
6 changes: 6 additions & 0 deletions examples/design/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ tracing-subscriber = "0.3.17"
path = "../../"
default-features = false
features = ["debug", "winit", "tokio"]

[dependencies.cosmic-time]
git = "https://github.com/pop-os/cosmic-time"
branch = "icon-color"
default-features = false
features = ["libcosmic", "once_cell"]
185 changes: 185 additions & 0 deletions examples/design/src/buttons.rs
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()
}
}
50 changes: 50 additions & 0 deletions examples/design/src/cards.rs
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()
}
}
Loading

0 comments on commit e402098

Please sign in to comment.