apply suggesions
This commit is contained in:
parent
8e82d3cfb9
commit
98aed56e6a
3 changed files with 15 additions and 6 deletions
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
//! Application API example
|
||||
|
||||
use cosmic::app::context_drawer::{context_drawer, ContextDrawer};
|
||||
use cosmic::app::context_drawer::{self, context_drawer, ContextDrawer};
|
||||
use cosmic::app::{Core, Settings, Task};
|
||||
use cosmic::iced::widget::column;
|
||||
use cosmic::iced_core::Size;
|
||||
|
|
@ -102,16 +102,16 @@ impl cosmic::Application for App {
|
|||
}
|
||||
|
||||
fn context_drawer(&self) -> Option<ContextDrawer<Self::Message>> {
|
||||
match self.show_about {
|
||||
true => Some(context_drawer(widget::about(&self.about, Message::Open), Message::ToggleAbout)),
|
||||
false => None,
|
||||
}
|
||||
self.show_about
|
||||
.then(|| context_drawer::about(&self.about, Message::Open, Message::ToggleAbout))
|
||||
}
|
||||
|
||||
/// Handle application events here.
|
||||
fn update(&mut self, message: Self::Message) -> Task<Self::Message> {
|
||||
match message {
|
||||
Message::ToggleAbout => {
|
||||
self.core.window.show_context = !self.core.window.show_context;
|
||||
self.core.set_show_context(self.core.window.show_context);
|
||||
self.show_about = !self.show_about;
|
||||
}
|
||||
Message::Open(url) => match open::that_detached(url) {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,15 @@ pub struct ContextDrawer<'a, Message: Clone + 'static> {
|
|||
pub on_close: Message,
|
||||
}
|
||||
|
||||
#[cfg(feature = "about")]
|
||||
pub fn about<'a, Message: Clone + 'static>(
|
||||
about: &'a crate::widget::about::About,
|
||||
on_url_press: impl Fn(String) -> Message,
|
||||
on_close: Message,
|
||||
) -> ContextDrawer<'a, Message> {
|
||||
context_drawer(crate::widget::about(about, on_url_press), on_close)
|
||||
}
|
||||
|
||||
pub fn context_drawer<'a, Message: Clone + 'static>(
|
||||
content: impl Into<Element<'a, Message>>,
|
||||
on_close: Message,
|
||||
|
|
|
|||
|
|
@ -729,7 +729,7 @@ impl<App: Application> ApplicationExt for App {
|
|||
|
||||
//TODO: reduce duplication
|
||||
let context_width = core.context_width(has_nav);
|
||||
if core.window.context_is_overlay {
|
||||
if core.window.context_is_overlay && core.window.show_context {
|
||||
if let Some(context) = self.context_drawer() {
|
||||
widgets.push(
|
||||
Element::from(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue