Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3ee35ac
Add notify-rust dependency in cargo.toml
mistermaxis Aug 1, 2025
ab8d65d
Add notify_rust.rs to examples folder
mistermaxis Aug 1, 2025
85a29f5
Copy router.rs code from router example
mistermaxis Aug 1, 2025
a5029c7
Remove unnecessary code from router example
mistermaxis Aug 1, 2025
46b8f5c
Wrap Links in Accordion component
mistermaxis Aug 1, 2025
bc1d6f9
Add code to manipulate sidebar width dinamically
mistermaxis Aug 1, 2025
a60700d
Add simple notification component
mistermaxis Aug 2, 2025
dfa4119
Add simple-async example component
mistermaxis Aug 2, 2025
bf213a7
Add minimal notification example component
mistermaxis Aug 2, 2025
e39249b
Add new actions accordion with actions component
mistermaxis Aug 2, 2025
cdc982a
Add on close message example component
mistermaxis Aug 2, 2025
199258d
Add on close with reason example component
mistermaxis Aug 2, 2025
f35d8a1
Merge branch 'main' into notify-rust-examples
mistermaxis Aug 3, 2025
69cfb4f
Add config rules for MacOS
mistermaxis Aug 3, 2025
36aba14
Update launch function to correct name
mistermaxis Aug 3, 2025
ed8eeed
Update config rules
mistermaxis Aug 3, 2025
24ff0ae
Update config rulse for Hint import
mistermaxis Aug 3, 2025
c50ee4d
Remove unnecessary .into() call
mistermaxis Aug 4, 2025
c512684
Move imports and config rules inside function components
mistermaxis Aug 4, 2025
e805955
Assign width variable to conditionally rendered element
mistermaxis Aug 4, 2025
a2080a5
Remove problematic example components
mistermaxis Aug 4, 2025
bd270ee
Merge branch 'main' into notify-rust-examples
mistermaxis Aug 4, 2025
e0bd028
Merge branch 'main' into notify-rust-examples
marc2332 Aug 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,6 @@ dioxus-radio = "0.6.0"
[profile.release]
lto = true
opt-level = 3

[dependencies]
notify-rust = "4.11.7"
181 changes: 181 additions & 0 deletions examples/notify_rust.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
#![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]

use freya::prelude::*;
use freya_router::prelude::*;
use notify_rust::Notification;

fn main() {
launch_with_params(app, "Notify Example", (550.0, 400.0));
}

fn app() -> Element {
rsx!(Router::<Route> {})
}

#[derive(Routable, Clone, PartialEq)]
#[rustfmt::skip]
pub enum Route {
#[layout(AppSidebar)]
#[route("/")]
Simple,
#[route("/simple-async")]
Minimal,
#[end_layout]
#[route("/..route")]
PageNotFound { },
}

#[allow(non_snake_case)]
fn AppSidebar() -> Element {
let PlatformInformation { viewport_size, .. } = *use_platform_information().read();
let variable_width: &str;
if viewport_size.width > 640.0 && viewport_size.width < 1024.0 {
variable_width = "40%";
} else if viewport_size.width >= 1024.0 {
variable_width = "30%";
} else {
variable_width = "50%";
}

rsx!(
NativeRouter {
Sidebar {
width: "{variable_width}",
sidebar: rsx!(
Accordion {
summary: rsx!(
AccordionSummary {
label {
"Basic Notifications"
}
}),
AccordionBody {
Link {
to: Route::Simple,
ActivableRoute {
route: Route::Simple,
exact: true,
SidebarItem {
theme: SidebarItemThemeWith {
corner_radius: Some(Cow::Borrowed("6")),
..Default::default()
},
label {
"Simple Notification"
}
}
}
}
Link {
to: Route::Minimal,
ActivableRoute {
route: Route::Minimal,
exact: true,
SidebarItem {
theme: SidebarItemThemeWith {
corner_radius: Some(Cow::Borrowed("6")),
..Default::default()
},
label {
"Minimal Notification"
}
}
}
}

}
}),
Body {
main_align: "center",
cross_align: "center",
width: "100%",
height: "100%",
Outlet::<Route> { }
}
}
}
)
}

#[allow(non_snake_case)]
#[component]
fn Simple() -> Element {
let PlatformInformation { viewport_size, .. } = *use_platform_information().read();
let variable_width: &str;

if viewport_size.width > 640.0 && viewport_size.width < 1024.0 {
variable_width = "70%";
} else if viewport_size.width >= 1024.0 {
variable_width = "60%";
} else {
variable_width = "90%";
}

fn notify() {
let _ = Notification::new()
.summary("Firefox News")
.body("This will almost look like a real firefox notification.")
.icon("firefox")
.show();
}

rsx!(
Button {
theme: ButtonThemeWith {
padding: Some(Cow::Borrowed("16 8")),
width: Some(Cow::Borrowed(variable_width)),
..Default::default()
},
onclick: |_| notify(),
label {
"Notify"
}
}
)
}

#[allow(non_snake_case)]
#[component]
fn Minimal() -> Element {
let PlatformInformation { viewport_size, .. } = *use_platform_information().read();
let variable_width: &str;

if viewport_size.width > 640.0 && viewport_size.width < 1024.0 {
variable_width = "70%";
} else if viewport_size.width >= 1024.0 {
variable_width = "60%";
} else {
variable_width = "90%";
}

fn notify_minimal() {
let _ = Notification::new().summary("minimal notification").show();
}

rsx!(
Button {
theme: ButtonThemeWith {
padding: Some(Cow::Borrowed("16 8")),
width: Some(Cow::Borrowed(variable_width)),
..Default::default()
},
onclick: |_| notify_minimal(),
label {
"Notify Minimal"
}
}
)
}

#[allow(non_snake_case)]
#[component]
fn PageNotFound() -> Element {
rsx!(
label {
"404!! 😵"
}
)
}
Loading