mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 01:25:27 +00:00
reset notice banner on page update
This commit is contained in:
parent
f7b653f36a
commit
c8607e151a
4 changed files with 24 additions and 14 deletions
|
|
@ -1,24 +1,33 @@
|
|||
use adw::Banner;
|
||||
|
||||
pub trait Notice {
|
||||
fn notice() -> Self;
|
||||
fn show(&self, title: &str);
|
||||
pub struct Notice {
|
||||
pub banner: Banner,
|
||||
}
|
||||
|
||||
impl Notice for Banner {
|
||||
impl Notice {
|
||||
// Constructors
|
||||
|
||||
/// Create new `Self`
|
||||
fn notice() -> Self {
|
||||
pub fn new() -> Self {
|
||||
let banner = Banner::builder().button_label("Ok").build();
|
||||
banner.connect_button_clicked(|this| this.set_revealed(false));
|
||||
banner
|
||||
Self { banner }
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
||||
fn show(&self, title: &str) {
|
||||
self.set_title(title);
|
||||
self.set_revealed(true);
|
||||
pub fn show(&self, title: &str) {
|
||||
self.banner.set_title(title);
|
||||
self.banner.set_revealed(true);
|
||||
}
|
||||
|
||||
pub fn unset(&self) {
|
||||
self.banner.set_revealed(false);
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Notice {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue