improv: move about to a widget
This commit is contained in:
parent
6f53b68be5
commit
48e2366662
7 changed files with 101 additions and 114 deletions
|
|
@ -3,10 +3,10 @@
|
|||
|
||||
//! Application API example
|
||||
|
||||
use cosmic::app::{about::About, Core, Settings, Task};
|
||||
use cosmic::app::{Core, Settings, Task};
|
||||
use cosmic::iced::widget::column;
|
||||
use cosmic::iced_core::Size;
|
||||
use cosmic::widget::{self, nav_bar};
|
||||
use cosmic::widget::{self, nav_bar, About};
|
||||
use cosmic::{executor, iced, ApplicationExt, Element};
|
||||
|
||||
/// Runs application with these settings
|
||||
|
|
@ -27,7 +27,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
#[derive(Clone, Debug)]
|
||||
pub enum Message {
|
||||
ToggleAbout,
|
||||
Cosmic(cosmic::app::cosmic::Message),
|
||||
Open(String),
|
||||
}
|
||||
|
||||
/// The [`App`] stores application-specific state.
|
||||
|
|
@ -100,11 +100,7 @@ impl cosmic::Application for App {
|
|||
return None;
|
||||
}
|
||||
|
||||
if let Some(abuot_view) = self.about_view() {
|
||||
Some(abuot_view.map(Message::Cosmic))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
Some(widget::about(&self.about, Message::Open))
|
||||
}
|
||||
|
||||
/// Handle application events here.
|
||||
|
|
@ -114,17 +110,14 @@ impl cosmic::Application for App {
|
|||
self.core.window.show_context = !self.core.window.show_context;
|
||||
self.core.set_show_context(self.core.window.show_context)
|
||||
}
|
||||
Message::Cosmic(message) => {
|
||||
return cosmic::command::message(cosmic::app::Message::Cosmic(message))
|
||||
}
|
||||
Message::Open(url) => match open::that_detached(url) {
|
||||
Ok(_) => (),
|
||||
Err(err) => tracing::error!("Failed to open URL: {err}"),
|
||||
},
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
|
||||
fn about(&self) -> Option<&About> {
|
||||
Some(&self.about)
|
||||
}
|
||||
|
||||
/// Creates a view after each update.
|
||||
fn view(&self) -> Element<Self::Message> {
|
||||
let centered = cosmic::widget::container(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue